diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index da5769cdc..33d462c14 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -91,8 +91,6 @@ ImageGridComponent::ImageGridComponent(Window* window) : IList @@ -166,7 +164,6 @@ void ImageGridComponent::render(const Transform4x4f& parentTrans) if(mEntriesDirty) { - buildTiles(); updateTiles(); mEntriesDirty = false; } @@ -193,7 +190,10 @@ void ImageGridComponent::render(const Transform4x4f& parentTrans) template void ImageGridComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) { - GuiComponent::applyTheme(theme, view, element, properties); + using namespace ThemeFlags; + + // Apply theme to GuiComponent but not size property, which will be applied at the end of this function + GuiComponent::applyTheme(theme, view, element, properties ^ SIZE); // Keep the theme pointer to apply it on the tiles later on mTheme = theme; @@ -262,8 +262,8 @@ void ImageGridComponent::applyTheme(const std::shared_ptr& theme, elem->get("size") * screen : GridTileComponent::getDefaultTileSize(); - // Recalculate grid dimension after theme changed - calcGridDimension(); + // Apply size property, will trigger a call to onSizeChanged() which will build the tiles + GuiComponent::applyTheme(theme, view, element, SIZE); } template @@ -288,6 +288,8 @@ void ImageGridComponent::buildTiles() { mTiles.clear(); + calcGridDimension(); + Vector2f startPosition = mTileSize / 2; Vector2f tileDistance = mTileSize + mMargin; @@ -321,9 +323,6 @@ void ImageGridComponent::buildTiles() template void ImageGridComponent::updateTiles() { - if(mTiles.empty()) - buildTiles(); - int img = getStartPosition(); for(int ti = 0; ti < mTiles.size(); ti++)