summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Pasetto <rick@lindenlab.com>2009-11-11 15:08:00 -0800
committerRick Pasetto <rick@lindenlab.com>2009-11-11 15:08:00 -0800
commitd023672e597770671720f8b68f7799b662f82175 (patch)
tree3c645a16baaa3c1259bb86cf84dba1876a1beee1
parent8ec85a68acee6b600320b10eea2b9aa11e434e83 (diff)
Add ToolTip functionality to LLScrollListCell
This change enables a user to set a custom tool tip on a particular scroll list cell by calling setToolTip(). Then, this tool tip is used. If this is not done, the existing tooltip functionality is left alone. Reviewed by Richard
-rw-r--r--indra/llui/llscrolllistcell.cpp21
-rw-r--r--indra/llui/llscrolllistcell.h9
-rw-r--r--indra/llui/llscrolllistctrl.cpp2
3 files changed, 27 insertions, 5 deletions
diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp
index a7c268758a..9f169ac777 100644
--- a/indra/llui/llscrolllistcell.cpp
+++ b/indra/llui/llscrolllistcell.cpp
@@ -71,7 +71,7 @@ LLScrollListCell* LLScrollListCell::create(const LLScrollListCell::Params& cell_
LLScrollListCell::LLScrollListCell(const LLScrollListCell::Params& p)
-: mWidth(p.width)
+: mWidth(p.width), mToolTip(p.tool_tip)
{}
// virtual
@@ -204,13 +204,28 @@ BOOL LLScrollListText::isText() const
return TRUE;
}
+// virtual
+const std::string &LLScrollListText::getToolTip() const
+{
+ // If base class has a tooltip, return that
+ if (! LLScrollListCell::getToolTip().empty())
+ return LLScrollListCell::getToolTip();
+
+ // ...otherwise, return the value itself as the tooltip
+ return mText.getString();
+}
+
+// virtual
BOOL LLScrollListText::needsToolTip() const
{
- // show tooltips for truncated text
+ // If base class has a tooltip, return that
+ if (LLScrollListCell::needsToolTip())
+ return LLScrollListCell::needsToolTip();
+
+ // ...otherwise, show tooltips for truncated text
return mFont->getWidth(mText.getString()) > getWidth();
}
-
//virtual
BOOL LLScrollListText::getVisible() const
{
diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h
index 758623f121..cff8434b32 100644
--- a/indra/llui/llscrolllistcell.h
+++ b/indra/llui/llscrolllistcell.h
@@ -66,6 +66,7 @@ public:
Optional<void*> userdata;
Optional<LLSD> value;
+ Optional<std::string> tool_tip;
Optional<const LLFontGL*> font;
Optional<LLColor4> font_color;
@@ -80,6 +81,7 @@ public:
enabled("enabled", true),
visible("visible", true),
value("value"),
+ tool_tip("tool_tip", ""),
font("font", LLFontGL::getFontSansSerifSmall()),
font_color("font_color", LLColor4::black),
color("color", LLColor4::white),
@@ -87,6 +89,7 @@ public:
{
addSynonym(column, "name");
addSynonym(font_color, "font-color");
+ addSynonym(tool_tip, "tooltip");
}
};
@@ -101,11 +104,13 @@ public:
virtual S32 getHeight() const { return 0; }
virtual const LLSD getValue() const;
virtual void setValue(const LLSD& value) { }
+ virtual const std::string &getToolTip() const { return mToolTip; }
+ virtual void setToolTip(const std::string &str) { mToolTip = str; }
virtual BOOL getVisible() const { return TRUE; }
virtual void setWidth(S32 width) { mWidth = width; }
virtual void highlightText(S32 offset, S32 num_chars) {}
virtual BOOL isText() const { return FALSE; }
- virtual BOOL needsToolTip() const { return FALSE; }
+ virtual BOOL needsToolTip() const { return ! mToolTip.empty(); }
virtual void setColor(const LLColor4&) {}
virtual void onCommit() {};
@@ -114,6 +119,7 @@ public:
private:
S32 mWidth;
+ std::string mToolTip;
};
class LLScrollListSpacer : public LLScrollListCell
@@ -143,6 +149,7 @@ public:
/*virtual*/ void setColor(const LLColor4&);
/*virtual*/ BOOL isText() const;
+ /*virtual*/ const std::string & getToolTip() const;
/*virtual*/ BOOL needsToolTip() const;
void setText(const LLStringExplicit& text);
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 1c2c02e1cc..a53a30b501 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -1565,7 +1565,7 @@ BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, MASK mask)
// display tooltip exactly over original cell, in same font
LLToolTipMgr::instance().show(LLToolTip::Params()
- .message(hit_cell->getValue().asString())
+ .message(hit_cell->getToolTip())
.font(LLFontGL::getFontSansSerifSmall())
.pos(LLCoordGL(sticky_rect.mLeft - 5, sticky_rect.mTop + 6))
.delay_time(0.2f)