summaryrefslogtreecommitdiff
path: root/indra/llui/lltextbase.cpp
diff options
context:
space:
mode:
authorChristian Goetze (CG) <cg@lindenlab.com>2010-08-02 16:59:20 -0700
committerChristian Goetze (CG) <cg@lindenlab.com>2010-08-02 16:59:20 -0700
commit6a1fefac22b62c45542208928918e9616e85977c (patch)
treec85c576b93754ec67ac5e93884b2fd26af192325 /indra/llui/lltextbase.cpp
parentf423a69864c40f760c1c7e64a2e544fd1dba77fb (diff)
parent15247f086989a43881d79c1ee5416bb00721eb68 (diff)
Redo the same merge as in changeset "2026f824953f", but this time with feeeeling.
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r--indra/llui/lltextbase.cpp56
1 files changed, 43 insertions, 13 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index e220013274..d3b2a368a5 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -66,7 +66,10 @@ bool LLTextBase::compare_segment_end::operator()(const LLTextSegmentPtr& a, cons
{
return a->getStart() < b->getStart();
}
- return a->getEnd() < b->getEnd();
+ else
+ {
+ return a->getEnd() < b->getEnd();
+ }
}
@@ -174,7 +177,7 @@ LLTextBase::Params::Params()
LLTextBase::LLTextBase(const LLTextBase::Params &p)
: LLUICtrl(p, LLTextViewModelPtr(new LLTextViewModel)),
- mURLClickSignal(),
+ mURLClickSignal(NULL),
mMaxTextByteLength( p.max_text_length ),
mDefaultFont(p.font),
mFontShadow(p.font_shadow),
@@ -209,7 +212,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mParseHTML(p.allow_html),
mParseHighlights(p.parse_highlights),
mBGVisible(p.bg_visible),
- mScroller(NULL)
+ mScroller(NULL),
+ mStyleDirty(true)
{
if(p.allow_scroll)
{
@@ -248,9 +252,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
LLTextBase::~LLTextBase()
{
- // Menu, like any other LLUICtrl, is deleted by its parent - gMenuHolder
-
mSegments.clear();
+ delete mURLClickSignal;
}
void LLTextBase::initFromParams(const LLTextBase::Params& p)
@@ -296,13 +299,18 @@ bool LLTextBase::truncate()
return did_truncate;
}
-LLStyle::Params LLTextBase::getDefaultStyleParams()
+const LLStyle::Params& LLTextBase::getDefaultStyleParams()
{
- return LLStyle::Params()
- .color(LLUIColor(&mFgColor))
- .readonly_color(LLUIColor(&mReadOnlyFgColor))
- .font(mDefaultFont)
- .drop_shadow(mFontShadow);
+ if (mStyleDirty)
+ {
+ mDefaultStyle
+ .color(LLUIColor(&mFgColor))
+ .readonly_color(LLUIColor(&mReadOnlyFgColor))
+ .font(mDefaultFont)
+ .drop_shadow(mFontShadow);
+ mStyleDirty = false;
+ }
+ return mDefaultStyle;
}
void LLTextBase::onValueChange(S32 start, S32 end)
@@ -861,11 +869,12 @@ BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
if (cur_segment && cur_segment->handleMouseUp(x, y, mask))
{
// Did we just click on a link?
- if (cur_segment->getStyle()
+ if (mURLClickSignal
+ && cur_segment->getStyle()
&& cur_segment->getStyle()->isLink())
{
// *TODO: send URL here?
- mURLClickSignal(this, LLSD() );
+ (*mURLClickSignal)(this, LLSD() );
}
return TRUE;
}
@@ -1039,12 +1048,14 @@ void LLTextBase::draw()
void LLTextBase::setColor( const LLColor4& c )
{
mFgColor = c;
+ mStyleDirty = true;
}
//virtual
void LLTextBase::setReadOnlyColor(const LLColor4 &c)
{
mReadOnlyFgColor = c;
+ mStyleDirty = true;
}
//virtual
@@ -1488,12 +1499,22 @@ void LLTextBase::getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg
LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
{
+ if (index > getLength()) { return mSegments.end(); }
+
+ // when there are no segments, we return the end iterator, which must be checked by caller
+ if (mSegments.size() <= 1) { return mSegments.begin(); }
+
segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index));
return it;
}
LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 index) const
{
+ if (index > getLength()) { return mSegments.end(); }
+
+ // when there are no segments, we return the end iterator, which must be checked by caller
+ if (mSegments.size() <= 1) { return mSegments.begin(); }
+
LLTextBase::segment_set_t::const_iterator it = mSegments.upper_bound(new LLIndexSegment(index));
return it;
}
@@ -2330,6 +2351,15 @@ LLRect LLTextBase::getVisibleDocumentRect() const
}
}
+boost::signals2::connection LLTextBase::setURLClickedCallback(const commit_signal_t::slot_type& cb)
+{
+ if (!mURLClickSignal)
+ {
+ mURLClickSignal = new commit_signal_t();
+ }
+ return mURLClickSignal->connect(cb);
+}
+
//
// LLTextSegment
//