summaryrefslogtreecommitdiff
path: root/indra/llui/llmenubutton.cpp
diff options
context:
space:
mode:
authorPaul Guslisty <pguslisty@productengine.com>2010-10-07 13:46:50 +0300
committerPaul Guslisty <pguslisty@productengine.com>2010-10-07 13:46:50 +0300
commit6589c200199e1fe0d0bf5f610d990ae197108981 (patch)
tree2b041ce2366bbe8345598a61ec90852a8a1ac768 /indra/llui/llmenubutton.cpp
parent7d9ec365cc815fad03c31bfaf9acf5d871c2e11b (diff)
STORM-263 FIXED Cog button in lower-left of sidebar panel does not close popup menu on second click
- In all places of sidebar panel where gear menu button is used changed type of gear menu buttons from LLButton to LLMenuButton - Added setMenuPosition and setMenu to the LLMenuButton interface as public methods - In all sidebar panels where LLButton was replaced with LLMenuButton the algorithm of replacing is simple and the same for all sidebar panels. In general the algorithm is: 1. set gearMenu to the menuButton using LLMenuButton::setMenu 2. set mouse down callback for the menuButton 3. in callback for mouse down set the menu position where it should be shown using LLMenuButton::setMenuPosition
Diffstat (limited to 'indra/llui/llmenubutton.cpp')
-rw-r--r--indra/llui/llmenubutton.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp
index 3df05f4d3f..0930eb95dd 100644
--- a/indra/llui/llmenubutton.cpp
+++ b/indra/llui/llmenubutton.cpp
@@ -57,6 +57,8 @@ LLMenuButton::LLMenuButton(const LLMenuButton::Params& p)
llwarns << "Error loading menu_button menu" << llendl;
}
}
+
+ setMenuPosition();
}
void LLMenuButton::toggleMenu()
@@ -70,12 +72,34 @@ void LLMenuButton::toggleMenu()
}
else
{
- LLRect rect = getRect();
- //mMenu->needsArrange(); //so it recalculates the visible elements
- LLMenuGL::showPopup(getParent(), mMenu, rect.mLeft, rect.mBottom);
+ //mMenu->needsArrange(); //so it recalculates the visible elements
+ LLMenuGL::showPopup(getParent(), mMenu, mX, mY);
}
}
+void LLMenuButton::setMenuPosition(EMenuPosition position /*ON_BOTTOM_LEFT*/)
+{
+ if (!mMenu)
+ return;
+
+ LLRect rect = getRect();
+
+ switch (position)
+ {
+ case ON_TOP_LEFT:
+ {
+ mX = rect.mLeft;
+ mY = rect.mTop + mMenu->getRect().getHeight();
+ break;
+ }
+ case ON_BOTTOM_LEFT:
+ {
+ mX = rect.mLeft;
+ mY = rect.mBottom;
+ break;
+ }
+ }
+}
void LLMenuButton::hideMenu()
{
@@ -109,6 +133,8 @@ BOOL LLMenuButton::handleMouseDown(S32 x, S32 y, MASK mask)
setFocus(TRUE);
}
+ LLUICtrl::handleMouseDown(x, y, mask);
+
toggleMenu();
if (getSoundFlags() & MOUSE_DOWN)