Move tooltip hosting from llscrolllistitem to llscrolllistcell
This commit is contained in:
@@ -187,7 +187,7 @@ LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *
|
||||
{
|
||||
std::string tool_tip = label;
|
||||
child->getAttributeString("tool_tip", tool_tip);
|
||||
item->setToolTip(tool_tip);
|
||||
item->getColumn(0)->setToolTip(tool_tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
|
||||
|
||||
LLScrollListCell::LLScrollListCell(S32 width)
|
||||
: mWidth(width)
|
||||
: mWidth(width),
|
||||
mToolTip()
|
||||
{}
|
||||
|
||||
// virtual
|
||||
@@ -159,6 +160,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
|
||||
{
|
||||
// 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
|
||||
{
|
||||
|
||||
@@ -57,10 +57,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 ! mToolTip.empty(); }
|
||||
virtual void setColor(const LLColor4&) {}
|
||||
virtual void onCommit() {};
|
||||
|
||||
@@ -69,6 +72,8 @@ public:
|
||||
|
||||
private:
|
||||
S32 mWidth;
|
||||
std::string mToolTip;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -90,6 +95,8 @@ public:
|
||||
|
||||
/*virtual*/ void setColor(const LLColor4&);
|
||||
/*virtual*/ BOOL isText() const;
|
||||
/*virtual*/ const std::string & getToolTip() const;
|
||||
/*virtual*/ BOOL needsToolTip() const;
|
||||
|
||||
S32 getTextWidth() const { return mTextWidth;}
|
||||
void setTextWidth(S32 value) { mTextWidth = value;}
|
||||
|
||||
@@ -1598,18 +1598,11 @@ BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sti
|
||||
LLScrollListItem* hit_item = hitItem(x, y);
|
||||
if (hit_item)
|
||||
{
|
||||
// If the item has a specific tool tip set by XUI use that first
|
||||
std::string tooltip=hit_item->getToolTip();
|
||||
if(!tooltip.empty())
|
||||
{
|
||||
msg=tooltip;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LLScrollListCell* hit_cell = hit_item->getColumn(column_index);
|
||||
if (!hit_cell) return FALSE;
|
||||
if (hit_cell
|
||||
&& hit_cell->isText())
|
||||
&& hit_cell->isText()
|
||||
&& hit_cell->needsToolTip())
|
||||
{
|
||||
S32 row_index = getItemIndex(hit_item);
|
||||
LLRect cell_rect = getCellRect(row_index, column_index);
|
||||
@@ -1617,7 +1610,7 @@ BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sti
|
||||
LLRect sticky_rect;
|
||||
localRectToScreen(cell_rect, sticky_rect_screen);
|
||||
|
||||
msg = hit_cell->getValue().asString();
|
||||
msg = hit_cell->getToolTip();
|
||||
}
|
||||
handled = TRUE;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,6 @@ public:
|
||||
void setUserdata( void* userdata ) { mUserdata = userdata; }
|
||||
void* getUserdata() const { return mUserdata; }
|
||||
|
||||
void setToolTip(const std::string tool_tip) { mToolTip=tool_tip; }
|
||||
std::string getToolTip() { return mToolTip; }
|
||||
|
||||
virtual LLUUID getUUID() const { return mItemValue.asUUID(); }
|
||||
LLSD getValue() const { return mItemValue; }
|
||||
|
||||
@@ -84,7 +81,6 @@ private:
|
||||
BOOL mEnabled;
|
||||
void* mUserdata;
|
||||
LLSD mItemValue;
|
||||
std::string mToolTip;
|
||||
std::vector<LLScrollListCell *> mColumns;
|
||||
LLRect mRectangle;
|
||||
};
|
||||
|
||||
@@ -476,7 +476,7 @@ void LLPanelNearByMedia::updateListItem(LLScrollListItem* item,
|
||||
{
|
||||
cell->setValue(name);
|
||||
}
|
||||
item->setToolTip(item_tooltip);
|
||||
cell->setToolTip(item_tooltip);
|
||||
|
||||
// *TODO: Make these font styles/colors configurable via XUI
|
||||
U8 font_style = LLFontGL::NORMAL;
|
||||
|
||||
Reference in New Issue
Block a user