From 4b80c9978c48b6a9eaac2ed358e81cf06f3e2cb5 Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Mon, 16 Nov 2009 23:17:24 +0200 Subject: 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 --- indra/newview/llmoveview.cpp | 115 +++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 59 deletions(-) (limited to 'indra/newview/llmoveview.cpp') 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(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(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); } -- cgit v1.2.3 From 40041fc2af7d711f8b0adfc2a6b6fdb07c708c37 Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Wed, 18 Nov 2009 18:03:48 +0200 Subject: Fixed normal priority bug EXT-2606 (Stand/Stop Flying btn disappear if movement floater looses focus). --HG-- branch : product-engine --- indra/newview/llmoveview.cpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'indra/newview/llmoveview.cpp') diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index 0ee883e221..93db337053 100644 --- a/indra/newview/llmoveview.cpp +++ b/indra/newview/llmoveview.cpp @@ -83,11 +83,6 @@ LLFloaterMove::LLFloaterMove(const LLSD& key) { } -LLFloaterMove::~LLFloaterMove() -{ - LLPanelStandStopFlying::getInstance()->reparent(NULL); -} - // virtual BOOL LLFloaterMove::postBuild() { @@ -161,6 +156,31 @@ void LLFloaterMove::setEnabled(BOOL enabled) showModeButtons(enabled); } +// *NOTE: we assume that setVisible() is called on floater close. +// virtual +void LLFloaterMove::setVisible(BOOL visible) +{ + // Ignore excessive calls of this method (from LLTransientFloaterMgr?). + if (getVisible() == visible) + return; + + if (visible) + { + // Attach the Stand/Stop Flying panel. + 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); + } + else + { + // Detach the Stand/Stop Flying panel. + LLPanelStandStopFlying::getInstance()->reparent(NULL); + } + + LLTransientDockableFloater::setVisible(visible); +} + // static F32 LLFloaterMove::getYawRate( F32 time ) { @@ -429,16 +449,6 @@ void LLFloaterMove::showModeButtons(BOOL bShow) if (NULL == mModeActionsPanel || mModeActionsPanel->getVisible() == bShow) return; mModeActionsPanel->setVisible(bShow); - - if (bShow) - LLPanelStandStopFlying::getInstance()->reparent(NULL); - else - { - 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); - } } //static -- cgit v1.2.3