summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2009-11-16 23:17:24 +0200
committerVadim Savchuk <vsavchuk@productengine.com>2009-11-16 23:17:24 +0200
commit4b80c9978c48b6a9eaac2ed358e81cf06f3e2cb5 (patch)
treebc794297be76b309b92cb33b699cf3723a5380b1 /indra
parent19d90dc5ed5494308744c02be9afb7eb021244e0 (diff)
Fixed Stand / Stop flying buttons (EXT-2408, EXT-2467, EXT-2513).
The buttons are now attached to the movement controls floater while it's visible (EXT-984). --HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmoveview.cpp115
-rw-r--r--indra/newview/llmoveview.h35
-rw-r--r--indra/newview/llviewerwindow.cpp2
3 files changed, 89 insertions, 63 deletions
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index e3ba1b8e4a..0ee883e221 100644
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -83,6 +83,11 @@ LLFloaterMove::LLFloaterMove(const LLSD& key)
{
}
+LLFloaterMove::~LLFloaterMove()
+{
+ LLPanelStandStopFlying::getInstance()->reparent(NULL);
+}
+
// virtual
BOOL LLFloaterMove::postBuild()
{
@@ -425,42 +430,15 @@ void LLFloaterMove::showModeButtons(BOOL bShow)
return;
mModeActionsPanel->setVisible(bShow);
- if (isDocked())
- {
- return;
- }
-
- updateHeight(bShow);
-}
-
-void LLFloaterMove::updateHeight(bool show_mode_buttons)
-{
- static bool size_changed = false;
- static S32 origin_height = getRect().getHeight();
- LLRect rect = getRect();
-
- static S32 mode_panel_height = mModeActionsPanel->getRect().getHeight();
-
- S32 newHeight = getRect().getHeight();
-
- if (!show_mode_buttons && origin_height == newHeight)
- {
- newHeight -= mode_panel_height;
- size_changed = true;
- }
- else if (show_mode_buttons && origin_height > newHeight)
+ if (bShow)
+ LLPanelStandStopFlying::getInstance()->reparent(NULL);
+ else
{
- newHeight += mode_panel_height;
- size_changed = true;
+ LLPanelStandStopFlying* ssf_panel = LLPanelStandStopFlying::getInstance();
+ ssf_panel->reparent(this);
+ const LLRect& mode_actions_rect = mModeActionsPanel->getRect();
+ ssf_panel->setOrigin(mode_actions_rect.mLeft, mode_actions_rect.mBottom);
}
-
- if (!size_changed)
- return;
-
- rect.setLeftTopAndSize(rect.mLeft, rect.mTop, rect.getWidth(), newHeight);
- reshape(rect.getWidth(), rect.getHeight());
- setRect(rect);
- size_changed = false;
}
//static
@@ -504,14 +482,6 @@ void LLFloaterMove::onOpen(const LLSD& key)
//virtual
void LLFloaterMove::setDocked(bool docked, bool pop_on_undock/* = true*/)
{
- LLDockableFloater::setDocked(docked, pop_on_undock);
- bool show_mode_buttons = isDocked() || !gAgent.getFlying();
-
- if (!isMinimized())
- {
- updateHeight(show_mode_buttons);
- }
-
LLTransientDockableFloater::setDocked(docked, pop_on_undock);
}
@@ -535,7 +505,8 @@ void LLFloaterMove::setModeButtonToggleState(const EMovementMode mode)
/************************************************************************/
LLPanelStandStopFlying::LLPanelStandStopFlying() :
mStandButton(NULL),
- mStopFlyingButton(NULL)
+ mStopFlyingButton(NULL),
+ mAttached(false)
{
// make sure we have the only instance of this class
static bool b = true;
@@ -624,6 +595,45 @@ BOOL LLPanelStandStopFlying::handleToolTip(S32 x, S32 y, MASK mask)
return TRUE;
}
+void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view)
+{
+ LLPanel* parent = dynamic_cast<LLPanel*>(getParent());
+ if (!parent)
+ {
+ llwarns << "Stand/stop flying panel parent is unset" << llendl;
+ return;
+ }
+
+ if (move_view != NULL)
+ {
+ llassert(move_view != parent); // sanity check
+
+ // Save our original container.
+ if (!mOriginalParent.get())
+ mOriginalParent = parent->getHandle();
+
+ // Attach to movement controls.
+ parent->removeChild(this);
+ move_view->addChild(this);
+ // Origin must be set by movement controls.
+ mAttached = true;
+ }
+ else
+ {
+ if (!mOriginalParent.get())
+ {
+ llwarns << "Original parent of the stand / stop flying panel not found" << llendl;
+ return;
+ }
+
+ // Detach from movement controls.
+ parent->removeChild(this);
+ mOriginalParent.get()->addChild(this);
+ mAttached = false;
+ updatePosition(); // don't defer until next draw() to avoid flicker
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// Private Section
//////////////////////////////////////////////////////////////////////////
@@ -668,27 +678,14 @@ void LLPanelStandStopFlying::onStopFlyingButtonClick()
*/
void LLPanelStandStopFlying::updatePosition()
{
-
LLBottomTray* tray = LLBottomTray::getInstance();
- if (!tray) return;
+ if (!tray || mAttached) return;
LLButton* movement_btn = tray->getChild<LLButton>(BOTTOM_TRAY_BUTTON_NAME);
- //align centers of a button and a floater
+ // Align centers of the button and the panel.
S32 x = movement_btn->calcScreenRect().getCenterX() - getRect().getWidth()/2;
-
- S32 y = 0;
-
- LLFloater *move_floater = LLFloaterReg::findInstance("moveview");
- if (move_floater)
- {
- if (move_floater->isDocked())
- {
- y = move_floater->getRect().mBottom + getRect().getHeight();
- }
- }
-
- setOrigin(x, y);
+ setOrigin(x, 0);
}
diff --git a/indra/newview/llmoveview.h b/indra/newview/llmoveview.h
index cee6078ee9..2664fe6e40 100644
--- a/indra/newview/llmoveview.h
+++ b/indra/newview/llmoveview.h
@@ -46,11 +46,12 @@ class LLJoystickAgentSlide;
class LLFloaterMove
: public LLTransientDockableFloater
{
+ LOG_CLASS(LLFloaterMove);
friend class LLFloaterReg;
private:
LLFloaterMove(const LLSD& key);
- ~LLFloaterMove() {}
+ ~LLFloaterMove();
public:
/*virtual*/ BOOL postBuild();
@@ -96,7 +97,6 @@ private:
void updateButtonsWithMovementMode(const EMovementMode newMode);
void updatePosition();
void showModeButtons(BOOL bShow);
- void updateHeight(bool show_mode_buttons);
public:
@@ -126,6 +126,7 @@ private:
*/
class LLPanelStandStopFlying : public LLPanel
{
+ LOG_CLASS(LLPanelStandStopFlying);
public:
typedef enum stand_stop_flying_mode_t
{
@@ -133,6 +134,19 @@ public:
SSFM_STOP_FLYING
} EStandStopFlyingMode;
+ /**
+ * Attach or detach the panel to/from the movement controls floater.
+ *
+ * Called when the floater gets opened/closed, user sits, stands up or starts/stops flying.
+ *
+ * @param move_view The floater to attach to (not always accessible via floater registry).
+ * If NULL is passed, the panel gets reparented to its original container.
+ *
+ * @see mAttached
+ * @see mOriginalParent
+ */
+ void reparent(LLFloaterMove* move_view);
+
static LLPanelStandStopFlying* getInstance();
static void setStandStopFlyingMode(EStandStopFlyingMode mode);
static void clearStandStopFlyingMode(EStandStopFlyingMode mode);
@@ -157,6 +171,23 @@ private:
LLButton* mStandButton;
LLButton* mStopFlyingButton;
+
+ /**
+ * The original parent of the panel.
+ *
+ * Makes it possible to move (reparent) the panel to the movement controls floater and back.
+ *
+ * @see reparent()
+ */
+ LLHandle<LLPanel> mOriginalParent;
+
+ /**
+ * True if the panel is currently attached to the movement controls floater.
+ *
+ * @see reparent()
+ * @see updatePosition()
+ */
+ bool mAttached;
};
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 90a79698f6..48f0f7516f 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1566,8 +1566,6 @@ void LLViewerWindow::initWorldUI()
LLPanel* panel_ssf_container = getRootView()->getChild<LLPanel>("stand_stop_flying_container");
LLPanelStandStopFlying* panel_stand_stop_flying = LLPanelStandStopFlying::getInstance();
- panel_stand_stop_flying->setShape(panel_ssf_container->getLocalRect());
- panel_stand_stop_flying->setFollowsAll();
panel_ssf_container->addChild(panel_stand_stop_flying);
panel_ssf_container->setVisible(TRUE);