summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llspinctrl.cpp16
-rw-r--r--indra/llui/llspinctrl.h5
-rw-r--r--indra/llui/llstyle.h4
-rw-r--r--indra/llui/lltextbase.cpp49
-rw-r--r--indra/llui/lltextbase.h19
-rw-r--r--indra/llui/lltexteditor.cpp8
-rw-r--r--indra/llui/llui.cpp18
-rw-r--r--indra/llui/lluicolortable.h2
-rw-r--r--indra/llui/lluiimage.cpp4
9 files changed, 61 insertions, 64 deletions
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 20a1ab7af3..28f3788817 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -270,13 +270,19 @@ void LLSpinCtrl::clear()
mbHasBeenSet = FALSE;
}
-
+void LLSpinCtrl::updateLabelColor()
+{
+ if( mLabelBox )
+ {
+ mLabelBox->setColor( getEnabled() ? mTextEnabledColor.get() : mTextDisabledColor.get() );
+ }
+}
void LLSpinCtrl::updateEditor()
{
LLLocale locale(LLLocale::USER_LOCALE);
- // Don't display very small negative values as -0.000
+ // Don't display very small negative valu es as -0.000
F32 displayed_value = clamp_precision((F32)getValue().asReal(), mPrecision);
// if( S32( displayed_value * pow( 10, mPrecision ) ) == 0 )
@@ -339,10 +345,7 @@ void LLSpinCtrl::setEnabled(BOOL b)
{
LLView::setEnabled( b );
mEditor->setEnabled( b );
- if( mLabelBox )
- {
- mLabelBox->setColor( b ? mTextEnabledColor.get() : mTextDisabledColor.get() );
- }
+ updateLabelColor();
}
@@ -390,6 +393,7 @@ void LLSpinCtrl::setLabel(const LLStringExplicit& label)
{
llwarns << "Attempting to set label on LLSpinCtrl constructed without one " << getName() << llendl;
}
+ updateLabelColor();
}
void LLSpinCtrl::setAllowEdit(BOOL allow_edit)
diff --git a/indra/llui/llspinctrl.h b/indra/llui/llspinctrl.h
index 0e610b7741..00d6f86f83 100644
--- a/indra/llui/llspinctrl.h
+++ b/indra/llui/llspinctrl.h
@@ -81,8 +81,8 @@ public:
virtual void setPrecision(S32 precision);
void setLabel(const LLStringExplicit& label);
- void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; }
- void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; }
+ void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); }
+ void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor();}
void setAllowEdit(BOOL allow_edit);
virtual void onTabInto();
@@ -103,6 +103,7 @@ public:
void onDownBtn(const LLSD& data);
private:
+ void updateLabelColor();
void updateEditor();
void reportInvalidData();
diff --git a/indra/llui/llstyle.h b/indra/llui/llstyle.h
index ee9ca730e9..2067e8e8be 100644
--- a/indra/llui/llstyle.h
+++ b/indra/llui/llstyle.h
@@ -59,11 +59,12 @@ public:
void setColor(const LLColor4 &color) { mColor = color; }
const LLColor4& getReadOnlyColor() const { return mReadOnlyColor; }
+ void setReadOnlyColor(const LLColor4& color) { mReadOnlyColor = color; }
BOOL isVisible() const;
void setVisible(BOOL is_visible);
- LLFontGL::ShadowType getShadowType() { return mDropShadow; }
+ LLFontGL::ShadowType getShadowType() const { return mDropShadow; }
void setFont(const LLFontGL* font);
const LLFontGL* getFont() const;
@@ -116,5 +117,6 @@ private:
};
typedef LLPointer<LLStyle> LLStyleSP;
+typedef LLPointer<const LLStyle> LLStyleConstSP;
#endif // LL_LLSTYLE_H
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 17aecaf32f..885a830c9f 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -291,9 +291,13 @@ bool LLTextBase::truncate()
return did_truncate;
}
-LLStyle::Params LLTextBase::getDefaultStyle()
+LLStyle::Params LLTextBase::getDefaultStyleParams()
{
- return LLStyle::Params().color(mFgColor.get()).readonly_color(mReadOnlyFgColor.get()).font(mDefaultFont).drop_shadow(mFontShadow);
+ return LLStyle::Params()
+ .color(LLUIColor(&mFgColor))
+ .readonly_color(LLUIColor(&mReadOnlyFgColor))
+ .font(mDefaultFont)
+ .drop_shadow(mFontShadow);
}
void LLTextBase::onValueChange(S32 start, S32 end)
@@ -619,7 +623,7 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
else
{
// create default editable segment to hold new text
- default_segment = new LLNormalTextSegment( new LLStyle(getDefaultStyle()), pos, pos + insert_len, *this);
+ default_segment = new LLNormalTextSegment( LLStyleConstSP(new LLStyle(getDefaultStyleParams())), pos, pos + insert_len, *this);
}
// shift remaining segments to right
@@ -743,7 +747,7 @@ void LLTextBase::createDefaultSegment()
// ensures that there is always at least one segment
if (mSegments.empty())
{
- LLTextSegmentPtr default_segment = new LLNormalTextSegment( new LLStyle(getDefaultStyle()), 0, getLength() + 1, *this);
+ LLTextSegmentPtr default_segment = new LLNormalTextSegment( LLStyleConstSP(new LLStyle(getDefaultStyleParams())), 0, getLength() + 1, *this);
mSegments.insert(default_segment);
default_segment->linkToDocument(this);
}
@@ -1510,16 +1514,7 @@ std::string LLTextBase::getText() const
void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params)
{
LLStyle::Params style_params(input_params);
- style_params.fillFrom(getDefaultStyle());
-
- if (!style_params.font.isProvided())
- {
- style_params.font = mDefaultFont;
- }
- if (!style_params.drop_shadow.isProvided())
- {
- style_params.drop_shadow = mFontShadow;
- }
+ style_params.fillFrom(getDefaultStyleParams());
S32 part = (S32)LLTextParser::WHOLE;
if(mParseHTML)
@@ -1536,13 +1531,7 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
LLStyle::Params link_params = style_params;
link_params.color = match.getColor();
link_params.readonly_color = match.getColor();
- // apply font name from requested style_params
- std::string font_name = LLFontGL::nameFromFont(style_params.font());
- std::string font_size = LLFontGL::sizeFromFont(style_params.font());
- link_params.font.name(font_name);
- link_params.font.size(font_size);
link_params.font.style("UNDERLINE");
-
link_params.link_href = match.getUrl();
// output the text before the Url
@@ -1611,9 +1600,9 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
}
}
-void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepend_newline, S32 highlight_part, const LLStyle::Params& stylep)
+void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepend_newline, S32 highlight_part, const LLStyle::Params& style_params)
{
- if (new_text.empty()) return;
+ if (new_text.empty()) return;
// Save old state
S32 selection_start = mSelectionStart;
@@ -1631,7 +1620,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepen
if (mParseHighlights && highlight)
{
- LLStyle::Params highlight_params = stylep;
+ LLStyle::Params highlight_params(style_params);
LLSD pieces = highlight->parsePartialLineHighlights(new_text, highlight_params.color(), (LLTextParser::EHighlightPosition)highlight_part);
for (S32 i = 0; i < pieces.size(); i++)
@@ -1651,7 +1640,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepen
wide_text = utf8str_to_wstring(pieces[i]["text"].asString());
}
S32 cur_length = getLength();
- LLTextSegmentPtr segmentp = new LLNormalTextSegment(new LLStyle(highlight_params), cur_length, cur_length + wide_text.size(), *this);
+ LLTextSegmentPtr segmentp = new LLNormalTextSegment(LLStyleConstSP(new LLStyle(highlight_params)), cur_length, cur_length + wide_text.size(), *this);
segment_vec_t segments;
segments.push_back(segmentp);
insertStringNoUndo(cur_length, wide_text, &segments);
@@ -1675,7 +1664,7 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepen
segment_vec_t segments;
S32 segment_start = old_length;
S32 segment_end = old_length + wide_text.size();
- segments.push_back(new LLNormalTextSegment(new LLStyle(stylep), segment_start, segment_end, *this ));
+ segments.push_back(new LLNormalTextSegment(LLStyleConstSP(new LLStyle(style_params)), segment_start, segment_end, *this ));
insertStringNoUndo(getLength(), wide_text, &segments);
}
@@ -1719,7 +1708,7 @@ void LLTextBase::replaceUrlLabel(const std::string &url,
for (it = mSegments.begin(); it != mSegments.end(); ++it)
{
LLTextSegment *seg = *it;
- const LLStyleSP style = seg->getStyle();
+ LLStyleConstSP style = seg->getStyle();
// update segment start/end length in case we replaced text earlier
S32 seg_length = seg->getEnd() - seg->getStart();
@@ -2212,9 +2201,9 @@ bool LLTextSegment::canEdit() const { return false; }
void LLTextSegment::unlinkFromDocument(LLTextBase*) {}
void LLTextSegment::linkToDocument(LLTextBase*) {}
const LLColor4& LLTextSegment::getColor() const { return LLColor4::white; }
-void LLTextSegment::setColor(const LLColor4 &color) {}
-const LLStyleSP LLTextSegment::getStyle() const {static LLStyleSP sp(new LLStyle()); return sp; }
-void LLTextSegment::setStyle(const LLStyleSP &style) {}
+//void LLTextSegment::setColor(const LLColor4 &color) {}
+LLStyleConstSP LLTextSegment::getStyle() const {static LLStyleConstSP sp(new LLStyle()); return sp; }
+void LLTextSegment::setStyle(LLStyleConstSP &style) {}
void LLTextSegment::setToken( LLKeywordToken* token ) {}
LLKeywordToken* LLTextSegment::getToken() const { return NULL; }
void LLTextSegment::setToolTip( const std::string &msg ) {}
@@ -2239,7 +2228,7 @@ BOOL LLTextSegment::hasMouseCapture() { return FALSE; }
// LLNormalTextSegment
//
-LLNormalTextSegment::LLNormalTextSegment( const LLStyleSP& style, S32 start, S32 end, LLTextBase& editor )
+LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP& style, S32 start, S32 end, LLTextBase& editor )
: LLTextSegment(start, end),
mStyle( style ),
mToken(NULL),
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 038b9eaa62..5526667166 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -184,7 +184,6 @@ public:
bool scrolledToEnd();
const LLFontGL* getDefaultFont() const { return mDefaultFont; }
- LLStyle::Params getDefaultStyle();
public:
// Fired when a URL link is clicked
@@ -281,7 +280,8 @@ protected:
void createDefaultSegment();
virtual void updateSegments();
void insertSegment(LLTextSegmentPtr segment_to_insert);
-
+ LLStyle::Params getDefaultStyleParams();
+
// manage lines
S32 getLineStart( S32 line ) const;
S32 getLineEnd( S32 line ) const;
@@ -388,9 +388,9 @@ public:
virtual void linkToDocument(class LLTextBase* editor);
virtual const LLColor4& getColor() const;
- virtual void setColor(const LLColor4 &color);
- virtual const LLStyleSP getStyle() const;
- virtual void setStyle(const LLStyleSP &style);
+ //virtual void setColor(const LLColor4 &color);
+ virtual LLStyleConstSP getStyle() const;
+ virtual void setStyle(LLStyleConstSP &style);
virtual void setToken( LLKeywordToken* token );
virtual LLKeywordToken* getToken() const;
virtual void setToolTip(const std::string& tooltip);
@@ -426,7 +426,7 @@ protected:
class LLNormalTextSegment : public LLTextSegment
{
public:
- LLNormalTextSegment( const LLStyleSP& style, S32 start, S32 end, LLTextBase& editor );
+ LLNormalTextSegment( LLStyleConstSP& style, S32 start, S32 end, LLTextBase& editor );
LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible = TRUE);
~LLNormalTextSegment();
@@ -436,9 +436,8 @@ public:
/*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect);
/*virtual*/ bool canEdit() const { return true; }
/*virtual*/ const LLColor4& getColor() const { return mStyle->getColor(); }
- /*virtual*/ void setColor(const LLColor4 &color) { mStyle->setColor(color); }
- /*virtual*/ const LLStyleSP getStyle() const { return mStyle; }
- /*virtual*/ void setStyle(const LLStyleSP &style) { mStyle = style; }
+ /*virtual*/ LLStyleConstSP getStyle() const { return mStyle; }
+ /*virtual*/ void setStyle(LLStyleConstSP &style) { mStyle = style; }
/*virtual*/ void setToken( LLKeywordToken* token ) { mToken = token; }
/*virtual*/ LLKeywordToken* getToken() const { return mToken; }
/*virtual*/ BOOL getToolTip( std::string& msg ) const;
@@ -456,7 +455,7 @@ protected:
protected:
class LLTextBase& mEditor;
- LLStyleSP mStyle;
+ LLStyleConstSP mStyle;
S32 mFontHeight;
LLKeywordToken* mToken;
std::string mTooltip;
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index f2c3879a6c..93ce7a4bea 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -2390,7 +2390,7 @@ void LLTextEditor::replaceUrlLabel(const std::string &url,
for (it = mSegments.begin(); it != mSegments.end(); ++it)
{
LLTextSegment *seg = *it;
- const LLStyleSP style = seg->getStyle();
+ LLStyleConstSP style = seg->getStyle();
// update segment start/end length in case we replaced text earlier
S32 seg_length = seg->getEnd() - seg->getStart();
@@ -2559,13 +2559,15 @@ void LLTextEditor::updateLinkSegments()
// if the link's label (what the user can edit) is a valid Url,
// then update the link's HREF to be the same as the label text.
// This lets users edit Urls in-place.
- LLStyleSP style = static_cast<LLStyleSP>(segment->getStyle());
+ LLStyleConstSP style = segment->getStyle();
+ LLStyle* new_style = new LLStyle(*style);
LLWString url_label = wtext.substr(segment->getStart(), segment->getEnd()-segment->getStart());
if (LLUrlRegistry::instance().hasUrl(url_label))
{
std::string new_url = wstring_to_utf8str(url_label);
LLStringUtil::trim(new_url);
- style->setLinkHREF(new_url);
+ new_style->setLinkHREF(new_url);
+ segment->setStyle(LLStyleConstSP(new_style));
}
}
}
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index d0ed3b6fca..76f07373b4 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -1911,10 +1911,10 @@ namespace LLInitParam
void TypedParam<LLUIColor>::setBlockFromValue()
{
LLColor4 color = mData.mValue.get();
- red = color.mV[VRED];
- green = color.mV[VGREEN];
- blue = color.mV[VBLUE];
- alpha = color.mV[VALPHA];
+ red.set(color.mV[VRED], false);
+ green.set(color.mV[VGREEN], false);
+ blue.set(color.mV[VBLUE], false);
+ alpha.set(color.mV[VALPHA], false);
control.set("", false);
}
@@ -1965,9 +1965,9 @@ namespace LLInitParam
{
if (mData.mValue)
{
- name = LLFontGL::nameFromFont(mData.mValue);
- size = LLFontGL::sizeFromFont(mData.mValue);
- style = LLFontGL::getStringFromStyle(mData.mValue->getFontDesc().getStyle());
+ name.set(LLFontGL::nameFromFont(mData.mValue), false);
+ size.set(LLFontGL::sizeFromFont(mData.mValue), false);
+ style.set(LLFontGL::getStringFromStyle(mData.mValue->getFontDesc().getStyle()), false);
}
}
@@ -2073,8 +2073,8 @@ namespace LLInitParam
void TypedParam<LLCoordGL>::setBlockFromValue()
{
- x = mData.mValue.mX;
- y = mData.mValue.mY;
+ x.set(mData.mValue.mX, false);
+ y.set(mData.mValue.mY, false);
}
diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h
index 59be0c4f9a..c87695f456 100644
--- a/indra/llui/lluicolortable.h
+++ b/indra/llui/lluicolortable.h
@@ -94,7 +94,7 @@ private:
bool loadFromFilename(const std::string& filename);
// consider using sorted vector, can be much faster
- typedef std::map<std::string, LLColor4> string_color_map_t;
+ typedef std::map<std::string, LLUIColor> string_color_map_t;
void clearTable(string_color_map_t& table);
void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table);
diff --git a/indra/llui/lluiimage.cpp b/indra/llui/lluiimage.cpp
index 966d919dc7..8cd6460b66 100644
--- a/indra/llui/lluiimage.cpp
+++ b/indra/llui/lluiimage.cpp
@@ -182,11 +182,11 @@ namespace LLInitParam
{
if (mData.mValue == NULL)
{
- name = "none";
+ name.set("none", false);
}
else
{
- name = mData.mValue->getName();
+ name.set(mData.mValue->getName(), false);
}
}