diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 39 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 2 | ||||
-rw-r--r-- | indra/llui/lltoolbar.cpp | 46 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 4 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 7 | ||||
-rw-r--r-- | indra/llui/llview.h | 2 |
6 files changed, 64 insertions, 36 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 21eeed1d27..e67e18872c 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -194,9 +194,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; @@ -452,17 +452,17 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) { // We hit passed the end of the list so put the insertion point at the end if (orientation == LLLayoutStack::HORIZONTAL) - { + { mDragx = button_rect.mRight + mPadRight; mDragy = button_rect.mTop + mPadTop; - } - else - { + } + else + { mDragx = button_rect.mLeft - mPadLeft; mDragy = button_rect.mBottom - mPadBottom; } } - + // Update the "girth" of the caret, i.e. the width or height (depending of orientation) if (orientation == LLLayoutStack::HORIZONTAL) { @@ -723,13 +723,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); @@ -925,3 +922,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 7f8ae4f839..8d38bc0234 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); |