From 06ff001d49a38563e134cf4c708aa28e69b5ec08 Mon Sep 17 00:00:00 2001
From: Ansariel Hiller <Ansariel@users.noreply.github.com>
Date: Wed, 16 Oct 2024 21:10:23 +0200
Subject: Apply changes from 55f2103adc36db0d3f068a31a144e15465226e13 to
 LLFolderViewItem::drawFavoriteIcon (#2867)

---
 indra/llui/llfolderviewitem.cpp | 24 ++++++++++++++----------
 indra/llui/llfolderviewitem.h   |  4 +++-
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index eff276d8c6..5592bb4b5c 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -62,6 +62,8 @@ LLUIColor LLFolderViewItem::sFavoriteColor;
 S32 LLFolderViewItem::sTopPad = 0;
 LLUIImagePtr LLFolderViewItem::sFolderArrowImg;
 LLUIImagePtr LLFolderViewItem::sSelectionImg;
+LLUIImagePtr LLFolderViewItem::sFavoriteImg;
+LLUIImagePtr LLFolderViewItem::sFavoriteContentImg;
 LLFontGL* LLFolderViewItem::sSuffixFont = nullptr;
 
 // only integers can be initialized in header
@@ -104,6 +106,8 @@ void LLFolderViewItem::initClass()
     sTopPad = default_params.item_top_pad;
     sFolderArrowImg = default_params.folder_arrow_image;
     sSelectionImg = default_params.selection_image;
+    sFavoriteImg = default_params.favorite_image;
+    sFavoriteContentImg = default_params.favorite_content_image;
     sSuffixFont = getLabelFontForStyle(LLFontGL::NORMAL);
 
     sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE);
@@ -124,6 +128,8 @@ void LLFolderViewItem::cleanupClass()
     sFonts.clear();
     sFolderArrowImg = nullptr;
     sSelectionImg = nullptr;
+    sFavoriteImg = nullptr;
+    sFavoriteContentImg = nullptr;
     sSuffixFont = nullptr;
 }
 
@@ -787,29 +793,29 @@ void LLFolderViewItem::drawOpenFolderArrow()
     }
 }
 
-void LLFolderViewItem::drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color)
+void LLFolderViewItem::drawFavoriteIcon()
 {
     static LLUICachedControl<bool> draw_star("InventoryFavoritesUseStar", true);
     static LLUICachedControl<bool> draw_hollow_star("InventoryFavoritesUseHollowStar", true);
 
-    LLUIImage* favorite_image = NULL;
+    LLUIImage* favorite_image = nullptr;
     if (draw_star && mIsFavorite)
     {
-        favorite_image = default_params.favorite_image;
+        favorite_image = sFavoriteImg;
     }
     else if (draw_hollow_star && mHasFavorites && !isOpen())
     {
-        favorite_image = default_params.favorite_content_image;
+        favorite_image = sFavoriteContentImg;
     }
 
     if (favorite_image)
     {
-        const S32 PAD = 3;
-        const S32 image_size = 14;
+        constexpr S32 PAD = 3;
+        constexpr S32 image_size = 14;
 
         gl_draw_scaled_image(
             getRect().getWidth() - image_size - PAD, getRect().getHeight() - mItemHeight + PAD,
-            image_size, image_size, favorite_image->getImage(), fg_color);
+            image_size, image_size, favorite_image->getImage(), sFgColor);
     }
 }
 
@@ -961,8 +967,6 @@ void LLFolderViewItem::draw()
     const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false);
     const bool filled = show_context || (getRoot() ? getRoot()->getParentPanel()->hasFocus() : false); // If we have keyboard focus, draw selection filled
 
-    const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
-
     const LLFontGL* font = getLabelFont();
     S32 line_height = font->getLineHeight();
 
@@ -972,7 +976,7 @@ void LLFolderViewItem::draw()
     {
         drawOpenFolderArrow();
     }
-    drawFavoriteIcon(default_params, sFgColor);
+    drawFavoriteIcon();
 
     drawHighlight(show_context, filled, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
 
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index 61bdeef188..32b15e32e2 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -306,7 +306,7 @@ public:
     //  virtual void handleDropped();
     virtual void draw();
     void drawOpenFolderArrow();
-    void drawFavoriteIcon(const Params& default_params, const LLUIColor& fg_color);
+    void drawFavoriteIcon();
     void drawHighlight(bool showContent, bool hasKeyboardFocus, const LLUIColor& selectColor, const LLUIColor& flashColor, const LLUIColor& outlineColor, const LLUIColor& mouseOverColor);
     void drawLabel(const LLFontGL* font, const F32 x, const F32 y, const LLColor4& color, F32 &right_x);
     virtual bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
@@ -320,6 +320,8 @@ private:
     static S32 sTopPad;
     static LLUIImagePtr sFolderArrowImg;
     static LLUIImagePtr sSelectionImg;
+    static LLUIImagePtr sFavoriteImg;
+    static LLUIImagePtr sFavoriteContentImg;
     static LLFontGL* sSuffixFont;
 
     LLFontVertexBuffer mLabelFontBuffer;
-- 
cgit v1.2.3