Add label / caption color support to texture picker, fix label width setting and remember to also add the required parameters to the skin

master
Zi Ree 2023-12-29 20:32:28 +01:00
parent d75ba744a8
commit 869c8d1882
3 changed files with 37 additions and 6 deletions

View File

@ -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), // <FS:Zi> Add label/caption colors
mTextDisabledColor(p.text_disabled_color), // <FS:Zi> Add label/caption colors
// <FS:Ansariel> 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 ));
// <FS:Zi> 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 ));
// <//FS:Zi>
params.initial_value(p.label());
params.follows.flags(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_BOTTOM);
mCaption = LLUICtrlFactory::create<LLTextBox> (params);
@ -1812,6 +1817,8 @@ LLTextureCtrl::LLTextureCtrl(const LLTextureCtrl::Params& p)
addChild(mBorder);
mLoadingPlaceholderString = LLTrans::getString("texture_loading");
updateLabelColor(); // <FS:Zi> Add label/caption colors
}
LLTextureCtrl::~LLTextureCtrl()
@ -1896,7 +1903,10 @@ void LLTextureCtrl::setEnabled( BOOL enabled )
closeDependentFloater();
}
mCaption->setEnabled( enabled );
// <FS:Zi> Add label/caption colors
// mCaption->setEnabled( enabled );
mCaption->setEnabled(enabled && isInEnabledChain());
// </FS:Zi>
// <FS:Ansariel> Texture preview mode
//LLView::setEnabled( enabled );
@ -2421,6 +2431,8 @@ void LLTextureCtrl::draw()
}
}
mCaption->setEnabled(getEnabled() && isInEnabledChain()); // <FS:Zi> Add label/caption colors
LLUICtrl::draw();
}
@ -2527,7 +2539,10 @@ LLSD LLTextureCtrl::getValue() const
return LLSD(getImageAssetID());
}
// <FS:Zi> Add label/caption colors
void LLTextureCtrl::updateLabelColor()
{
mCaption->setColor(mTextEnabledColor.get());
mCaption->setReadOnlyColor(mTextDisabledColor.get());
}
// </FS:Zi>

View File

@ -115,6 +115,9 @@ public:
Optional<LLViewBorder::Params> border;
Optional<bool> show_caption; // <FS:Zi> leave some room underneath the image for the caption
Optional<LLUIColor> text_enabled_color; // <FS:Zi> Add label/caption colors
Optional<LLUIColor> text_disabled_color; // <FS:Zi> 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), // <FS:Zi> leave some room underneath the image for the caption
text_enabled_color("text_enabled_color"), // <FS:Zi> Add label/caption colors
text_disabled_color("text_disabled_color"), // <FS:Zi> Add label/caption colors
caption_text("caption_text"),
border("border")
{}
@ -243,10 +248,15 @@ public:
// <FS:Ansariel> Mask texture if desired
void setIsMasked(BOOL masked) { mIsMasked = masked; }
void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); } // <FS:Zi> Add label/caption colors
void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor(); } // <FS:Zi> Add label/caption colors
private:
BOOL allowDrop(LLInventoryItem* item, EDragAndDropType cargo_type, std::string& tooltip_msg);
BOOL doDrop(LLInventoryItem* item);
void updateLabelColor(); // <FS:Zi> Add label/caption colors
private:
drag_n_drop_callback mDragCallback;
drag_n_drop_callback mDropCallback;
@ -286,6 +296,9 @@ private:
// <FS:Ansariel> Mask texture if desired
BOOL mIsMasked;
LLUIColor mTextEnabledColor; // <FS:Zi> Add label/caption colors
LLUIColor mTextDisabledColor; // <FS:Zi> Add label/caption colors
};
//////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!-- <FS:Zi> Add label/caption colors (text_enabled_color/text_disabled_color) -->
<texture_picker border_color="DefaultHighlightLight"
name="texture picker"
mouse_opaque="true"
follows="left|top"
text_enabled_color="LabelTextColor"
text_disabled_color="LabelDisabledColor"
>
<multiselect_text font="SansSerifSmall"/>
<caption_text halign="center"