Add label / caption color support to color swatches

master
Zi Ree 2023-12-29 20:28:05 +01:00
parent fdeddfcdf2
commit 8776d50ef4
2 changed files with 32 additions and 1 deletions

View File

@ -52,6 +52,8 @@ LLColorSwatchCtrl::Params::Params()
border_color("border_color"),
label_width("label_width", -1),
label_height("label_height", -1),
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")
{
@ -66,6 +68,8 @@ LLColorSwatchCtrl::LLColorSwatchCtrl(const Params& p)
mOnCancelCallback(p.cancel_callback()),
mOnSelectCallback(p.select_callback()),
mBorderColor(p.border_color()),
mTextEnabledColor(p.text_enabled_color), // <FS:Zi> Add label/caption colors
mTextDisabledColor(p.text_disabled_color), // <FS:Zi> Add label/caption colors
mLabelWidth(p.label_width),
mLabelHeight(p.label_height)
{
@ -95,6 +99,8 @@ LLColorSwatchCtrl::LLColorSwatchCtrl(const Params& p)
params.rect(border_rect);
mBorder = LLUICtrlFactory::create<LLViewBorder> (params);
addChild(mBorder);
updateLabelColor(); // <FS:Zi> Add label/caption colors
}
LLColorSwatchCtrl::~LLColorSwatchCtrl ()
@ -250,12 +256,18 @@ void LLColorSwatchCtrl::draw()
}
}
mCaption->setEnabled(getEnabled() && isInEnabledChain()); // <FS:Zi> Add label/caption colors
LLUICtrl::draw();
}
void LLColorSwatchCtrl::setEnabled( BOOL enabled )
{
mCaption->setEnabled( enabled );
// <FS:Zi> Add label/caption colors
// mCaption->setEnabled( enabled );
mCaption->setEnabled(enabled && isInEnabledChain());
// </FS:Zi>
LLView::setEnabled( enabled );
if (!enabled)
@ -374,3 +386,10 @@ void LLColorSwatchCtrl::showPicker(BOOL take_focus)
}
}
// <FS:Zi> Add label/caption colors
void LLColorSwatchCtrl::updateLabelColor()
{
mCaption->setColor(mTextEnabledColor.get());
mCaption->setReadOnlyColor(mTextDisabledColor.get());
}
// </FS:Zi>

View File

@ -62,6 +62,10 @@ public:
Optional<LLTextBox::Params> caption_text;
Optional<LLViewBorder::Params> border;
Optional<LLUIColor> text_enabled_color; // <FS:Zi> Add label/caption colors
Optional<LLUIColor> text_disabled_color; // <FS:Zi> Add label/caption colors
Params();
};
@ -100,7 +104,12 @@ public:
static void onColorChanged ( void* data, EColorPickOp pick_op = COLOR_CHANGE );
void closeFloaterColorPicker();
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
protected:
void updateLabelColor(); // <FS:Zi> Add label/caption colors
bool mValid;
LLColor4 mColor;
LLUIColor mBorderColor;
@ -116,6 +125,9 @@ protected:
LLPointer<LLUIImage> mAlphaGradientImage;
LLPointer<LLUIImage> mFallbackImage;
LLUIColor mTextEnabledColor; // <FS:Zi> Add label/caption colors
LLUIColor mTextDisabledColor; // <FS:Zi> Add label/caption colors
};
#endif // LL_LLBUTTON_H