From 869c8d1882bfb5a37b5157fc8fa38726b4fccd08 Mon Sep 17 00:00:00 2001 From: Zi Ree Date: Fri, 29 Dec 2023 20:32:28 +0100 Subject: [PATCH] Add label / caption color support to texture picker, fix label width setting and remember to also add the required parameters to the skin --- indra/newview/lltexturectrl.cpp | 27 ++++++++++++++----- indra/newview/lltexturectrl.h | 13 +++++++++ .../default/xui/en/widgets/texture_picker.xml | 3 +++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index c26b4c7c53..4142ad6927 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -1759,6 +1759,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) mDefaultImageAssetID(p.default_image_id), mDefaultImageName(p.default_image_name), mFallbackImage(p.fallback_image), + mTextEnabledColor(p.text_enabled_color), // Add label/caption colors + mTextDisabledColor(p.text_disabled_color), // Add label/caption colors // Mask texture if desired mIsMasked(FALSE) { @@ -1774,7 +1776,10 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) LLTextBox::Params params(p.caption_text); params.name(p.label); - params.rect(LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 )); + // Fix label width + // params.rect(LLRect( 0, BTN_HEIGHT_SMALL, getRect().getWidth(), 0 )); + params.rect(LLRect( 0, BTN_HEIGHT_SMALL, p.label_width == -1 ? getRect().getWidth() : p.label_width, 0 )); + // params.initial_value(p.label()); params.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM); mCaption = LLUICtrlFactory::create (params); @@ -1812,6 +1817,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p) addChild(mBorder); mLoadingPlaceholderString = LLTrans::getString("texture_loading"); + + updateLabelColor(); // Add label/caption colors } LLTextureCtrl::~LLTextureCtrl() @@ -1896,7 +1903,10 @@ void LLTextureCtrl::setEnabled( BOOL enabled ) closeDependentFloater(); } - mCaption->setEnabled( enabled ); + // Add label/caption colors + // mCaption->setEnabled( enabled ); + mCaption->setEnabled(enabled && isInEnabledChain()); + // // Texture preview mode //LLView::setEnabled( enabled ); @@ -2421,6 +2431,8 @@ void LLTextureCtrl::draw() } } + mCaption->setEnabled(getEnabled() && isInEnabledChain()); // Add label/caption colors + LLUICtrl::draw(); } @@ -2527,7 +2539,10 @@ LLSD LLTextureCtrl::getValue() const return LLSD(getImageAssetID()); } - - - - +// Add label/caption colors +void LLTextureCtrl::updateLabelColor() +{ + mCaption->setColor(mTextEnabledColor.get()); + mCaption->setReadOnlyColor(mTextDisabledColor.get()); +} +// diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h index 146949d3f7..3b4e61f11f 100644 --- a/indra/newview/lltexturectrl.h +++ b/indra/newview/lltexturectrl.h @@ -115,6 +115,9 @@ public: Optional border; Optional show_caption; // leave some room underneath the image for the caption + Optional text_enabled_color; // Add label/caption colors + Optional text_disabled_color; // Add label/caption colors + Params() : image_id("image"), default_image_id("default_image_id"), @@ -127,6 +130,8 @@ public: fallback_image("fallback_image"), multiselect_text("multiselect_text"), show_caption("show_caption", true), // leave some room underneath the image for the caption + text_enabled_color("text_enabled_color"), // Add label/caption colors + text_disabled_color("text_disabled_color"), // Add label/caption colors caption_text("caption_text"), border("border") {} @@ -243,10 +248,15 @@ public: // Mask texture if desired void setIsMasked(BOOL masked) { mIsMasked = masked; } + void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); } // Add label/caption colors + void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor(); } // Add label/caption colors + private: BOOL allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type, std::string& tooltip_msg); BOOL doDrop(LLInventoryItem* item); + void updateLabelColor(); // Add label/caption colors + private: drag_n_drop_callback mDragCallback; drag_n_drop_callback mDropCallback; @@ -286,6 +296,9 @@ private: // Mask texture if desired BOOL mIsMasked; + + LLUIColor mTextEnabledColor; // Add label/caption colors + LLUIColor mTextDisabledColor; // Add label/caption colors }; ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/skins/default/xui/en/widgets/texture_picker.xml b/indra/newview/skins/default/xui/en/widgets/texture_picker.xml index 1511116ba6..eea5f54fe5 100644 --- a/indra/newview/skins/default/xui/en/widgets/texture_picker.xml +++ b/indra/newview/skins/default/xui/en/widgets/texture_picker.xml @@ -1,8 +1,11 @@ +