summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2011-10-12 18:16:59 -0700
committerRichard Nelson <richard@lindenlab.com>2011-10-12 18:16:59 -0700
commit9206226a377c88d34036ebd8a3ac6d9d55bc4146 (patch)
tree7b5515350c49018773c4021c202edb619ffe2318 /indra
parent17731c50a8ad2c465654db3cf88bcc2e885e2716 (diff)
tooltips now only show labels for toolbar buttons when label is hidden or truncated
tooltips are no longer instantaneous once a tooltip is visible
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llbutton.cpp39
-rw-r--r--indra/llui/llbutton.h2
-rw-r--r--indra/llui/lltoolbar.cpp36
-rw-r--r--indra/llui/lltoolbar.h4
-rw-r--r--indra/llui/llview.cpp7
-rw-r--r--indra/llui/llview.h2
-rw-r--r--indra/newview/app_settings/settings.xml12
-rw-r--r--indra/newview/llviewermenu.cpp8
8 files changed, 78 insertions, 32 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 4f0c0d31bd..f40d99c024 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -732,16 +732,7 @@ void LLButton::draw()
}
// Unselected label assignments
- LLWString label;
-
- if( getToggleState() )
- {
- label = mSelectedLabel;
- }
- else
- {
- label = mUnselectedLabel;
- }
+ LLWString label = getCurrentLabel();
// overlay with keyboard focus border
if (hasFocus())
@@ -988,6 +979,23 @@ void LLButton::setLabelSelected( const LLStringExplicit& label )
mSelectedLabel = label;
}
+bool LLButton::labelIsTruncated() const
+{
+ return getCurrentLabel().getString().size() > mLastDrawCharsCount;
+}
+
+const LLUIString& LLButton::getCurrentLabel() const
+{
+ if( getToggleState() )
+ {
+ return mSelectedLabel;
+ }
+ else
+ {
+ return mUnselectedLabel;
+ }
+}
+
void LLButton::setImageUnselected(LLPointer<LLUIImage> image)
{
mImageUnselected = image;
@@ -999,16 +1007,7 @@ void LLButton::setImageUnselected(LLPointer<LLUIImage> image)
void LLButton::autoResize()
{
- LLUIString label;
- if(getToggleState())
- {
- label = mSelectedLabel;
- }
- else
- {
- label = mUnselectedLabel;
- }
- resize(label);
+ resize(getCurrentLabel());
}
void LLButton::resize(LLUIString label)
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index ba0345f610..7d9adcd892 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -242,6 +242,8 @@ public:
S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; }
+ bool labelIsTruncated() const;
+ const LLUIString& getCurrentLabel() const;
void setScaleImage(BOOL scale) { mScaleImage = scale; }
BOOL getScaleImage() const { return mScaleImage; }
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index a75a1552fc..fc5ec5ea26 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -193,9 +193,9 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p));
- BOOST_FOREACH(LLCommandId::Params params, p.commands)
+ BOOST_FOREACH(LLCommandId id, p.commands)
{
- addCommand(params);
+ addCommand(id);
}
mNeedsLayout = true;
@@ -688,13 +688,10 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
LLCommand* commandp = LLCommandManager::instance().getCommand(id);
if (!commandp) return NULL;
- std::string label = LLTrans::getString(commandp->labelRef());
- std::string tooltip = label + "\n" + LLTrans::getString(commandp->tooltipRef());
-
LLToolBarButton::Params button_p;
button_p.name = id.name();
- button_p.label = label;
- button_p.tool_tip = tooltip;
+ button_p.label = LLTrans::getString(commandp->labelRef());
+ button_p.tool_tip = LLTrans::getString(commandp->tooltipRef());
button_p.image_overlay = LLUI::getUIImage(commandp->icon());
button_p.overwriteFrom(mButtonParams[mButtonType]);
LLToolBarButton* button = LLUICtrlFactory::create<LLToolBarButton>(button_p);
@@ -886,3 +883,28 @@ void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent);
}
+
+const std::string LLToolBarButton::getToolTip() const
+{
+ std::string tooltip;
+ if (labelIsTruncated() || getCurrentLabel().empty())
+ {
+ return LLTrans::getString(LLCommandManager::instance().getCommand(mId)->labelRef()) + " -- " + LLView::getToolTip();
+ }
+ else
+ {
+ return LLView::getToolTip();
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 709399c59f..72fc5630bc 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -72,6 +72,10 @@ public:
void onMouseEnter(S32 x, S32 y, MASK mask);
void onMouseCaptureLost();
+ virtual const std::string getToolTip() const;
+
+
+
private:
LLCommandId mId;
S32 mMouseDownX;
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index e10c2f0d1e..55d053254c 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -708,15 +708,16 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask)
// parents provide tooltips first, which are optionally
// overridden by children, in case child is mouse_opaque
- if (!mToolTipMsg.empty())
+ std::string tooltip = getToolTip();
+ if (!tooltip.empty())
{
// allow "scrubbing" over ui by showing next tooltip immediately
// if previous one was still visible
F32 timeout = LLToolTipMgr::instance().toolTipVisible()
- ? 0.f
+ ? LLUI::sSettingGroups["config"]->getF32( "ToolTipFastDelay" )
: LLUI::sSettingGroups["config"]->getF32( "ToolTipDelay" );
LLToolTipMgr::instance().show(LLToolTip::Params()
- .message(mToolTipMsg)
+ .message(tooltip)
.sticky_rect(calcScreenRect())
.delay_time(timeout));
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index a1c46f3bf3..5e3387dc98 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -238,7 +238,7 @@ public:
ECursorType getHoverCursor() { return mHoverCursor; }
- const std::string& getToolTip() const { return mToolTipMsg.getString(); }
+ virtual const std::string getToolTip() const { return mToolTipMsg.getString(); }
void sendChildToFront(LLView* child);
void sendChildToBack(LLView* child);
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index aa2ff646a8..3298d6c627 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10905,7 +10905,17 @@
<key>Value</key>
<real>0.699999988079</real>
</map>
- <key>ToolTipFadeTime</key>
+ <key>ToolTipFastDelay</key>
+ <map>
+ <key>Comment</key>
+ <string>Seconds before displaying tooltip when mouse stops over UI element (when a tooltip is already visible)</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>F32</string>
+ <key>Value</key>
+ <real>0.1</real>
+ </map> <key>ToolTipFadeTime</key>
<map>
<key>Comment</key>
<string>Seconds over which tooltip fades away</string>
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 478af6ab7d..aee46ed5be 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -6875,6 +6875,13 @@ class LLToolsEnableSaveToObjectInventory : public view_listener_t
}
};
+class LLToggleHowTo : public view_listener_t
+{
+ bool handleEvent(const LLSD& userdata)
+ {
+ return true;
+ }
+};
class LLViewEnableMouselook : public view_listener_t
{
@@ -8039,6 +8046,7 @@ void initialize_menus()
// Help menu
// most items use the ShowFloater method
+ view_listener_t::addMenu(new LLToggleHowTo(), "Help.ToggleHowTo");
// Advanced menu
view_listener_t::addMenu(new LLAdvancedToggleConsole(), "Advanced.ToggleConsole");