diff options
Diffstat (limited to 'indra/newview/llmoveview.cpp')
-rw-r--r-- | indra/newview/llmoveview.cpp | 229 |
1 files changed, 132 insertions, 97 deletions
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp index 2b4e35208a..0f22a50093 100644 --- a/indra/newview/llmoveview.cpp +++ b/indra/newview/llmoveview.cpp @@ -41,7 +41,8 @@ // Viewer includes #include "llagent.h" -#include "llvoavatarself.h" // to check gAgent.getAvatarObject()->isSitting() +#include "llagentcamera.h" +#include "llvoavatarself.h" // to check gAgentAvatarp->isSitting() #include "llbottomtray.h" #include "llbutton.h" #include "llfloaterreg.h" @@ -77,7 +78,6 @@ LLFloaterMove::LLFloaterMove(const LLSD& key) mTurnRightButton(NULL), mMoveUpButton(NULL), mMoveDownButton(NULL), - mStopFlyingButton(NULL), mModeActionsPanel(NULL), mCurrentMode(MM_WALK) { @@ -87,6 +87,7 @@ LLFloaterMove::LLFloaterMove(const LLSD& key) BOOL LLFloaterMove::postBuild() { setIsChrome(TRUE); + setTitleVisible(TRUE); // restore title visibility after chrome applying LLDockableFloater::postBuild(); @@ -112,8 +113,6 @@ BOOL LLFloaterMove::postBuild() mMoveDownButton->setHeldDownCallback(boost::bind(&LLFloaterMove::moveDown, this)); - mStopFlyingButton = getChild<LLButton>("stop_fly_btn"); - mModeActionsPanel = getChild<LLPanel>("panel_modes"); LLButton* btn; @@ -126,11 +125,6 @@ BOOL LLFloaterMove::postBuild() btn = getChild<LLButton>("mode_fly_btn"); btn->setCommitCallback(boost::bind(&LLFloaterMove::onFlyButtonClick, this)); - btn = getChild<LLButton>("stop_fly_btn"); - btn->setCommitCallback(boost::bind(&LLFloaterMove::onStopFlyingButtonClick, this)); - - - showFlyControls(false); initModeTooltips(); @@ -156,6 +150,34 @@ void LLFloaterMove::setEnabled(BOOL enabled) showModeButtons(enabled); } +// *NOTE: we assume that setVisible() is called on floater close. +// virtual +void LLFloaterMove::setVisible(BOOL visible) +{ + // Do nothing with Stand/Stop Flying panel in excessive calls of this method (from LLTransientFloaterMgr?). + if (getVisible() == visible) + { + LLTransientDockableFloater::setVisible(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 ) { @@ -222,6 +244,12 @@ void LLFloaterMove::setSittingMode(BOOL bSitting) else { LLPanelStandStopFlying::clearStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STAND); + + // show "Stop Flying" button if needed. EXT-871 + if (gAgent.getFlying()) + { + LLPanelStandStopFlying::setStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STOP_FLYING); + } } enableInstance(!bSitting); } @@ -270,16 +298,20 @@ void LLFloaterMove::onFlyButtonClick() { setMovementMode(MM_FLY); } -void LLFloaterMove::onStopFlyingButtonClick() -{ - setMovementMode(gAgent.getAlwaysRun() ? MM_RUN : MM_WALK); -} void LLFloaterMove::setMovementMode(const EMovementMode mode) { mCurrentMode = mode; gAgent.setFlying(MM_FLY == mode); + // attempts to set avatar flying can not set it real flying in some cases. + // For ex. when avatar fell down & is standing up. + // So, no need to continue processing FLY mode. See EXT-1079 + if (MM_FLY == mode && !gAgent.getFlying()) + { + return; + } + switch (mode) { case MM_RUN: @@ -300,7 +332,7 @@ void LLFloaterMove::setMovementMode(const EMovementMode mode) updateButtonsWithMovementMode(mode); bool bHideModeButtons = MM_FLY == mode - || (gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting()); + || (isAgentAvatarValid() && gAgentAvatarp->isSitting()); showModeButtons(!bHideModeButtons); @@ -311,16 +343,13 @@ void LLFloaterMove::updateButtonsWithMovementMode(const EMovementMode newMode) showFlyControls(MM_FLY == newMode); setModeTooltip(newMode); setModeButtonToggleState(newMode); + setModeTitle(newMode); } void LLFloaterMove::showFlyControls(bool bShow) { mMoveUpButton->setVisible(bShow); mMoveDownButton->setVisible(bShow); - - // *TODO: mantipov: mStopFlyingButton from the FloaterMove is not used now. - // It was not completly removed until functionality is reviewed by LL - mStopFlyingButton->setVisible(FALSE); } void LLFloaterMove::initModeTooltips() @@ -359,9 +388,9 @@ void LLFloaterMove::initMovementMode() } setMovementMode(initMovementMode); - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - setEnabled(!gAgent.getAvatarObject()->isSitting()); + setEnabled(!gAgentAvatarp->isSitting()); } } @@ -378,11 +407,30 @@ void LLFloaterMove::setModeTooltip(const EMovementMode mode) } } +void LLFloaterMove::setModeTitle(const EMovementMode mode) +{ + std::string title; + switch(mode) + { + case MM_WALK: + title = getString("walk_title"); + break; + case MM_RUN: + title = getString("run_title"); + break; + case MM_FLY: + title = getString("fly_title"); + break; + default: + // title should be provided for all modes + llassert(false); + break; + } + setTitle(title); +} + /** * Updates position of the floater to be center aligned with Move button. - * - * Because Tip floater created as dependent floater this method - * must be called before "showQuickTips()" to get Tip floater be positioned at the right side of the floater */ void LLFloaterMove::updatePosition() { @@ -416,43 +464,6 @@ void LLFloaterMove::showModeButtons(BOOL bShow) if (NULL == mModeActionsPanel || mModeActionsPanel->getVisible() == 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) - { - newHeight += mode_panel_height; - size_changed = true; - } - - if (!size_changed) - return; - - rect.setLeftTopAndSize(rect.mLeft, rect.mTop, rect.getWidth(), newHeight); - reshape(rect.getWidth(), rect.getHeight()); - setRect(rect); - size_changed = false; } //static @@ -480,7 +491,7 @@ void LLFloaterMove::onOpen(const LLSD& key) showModeButtons(FALSE); } - if (gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting()) + if (isAgentAvatarValid() && gAgentAvatarp->isSitting()) { setSittingMode(TRUE); showModeButtons(FALSE); @@ -496,14 +507,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); } @@ -527,7 +530,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; @@ -579,7 +583,7 @@ BOOL LLPanelStandStopFlying::postBuild() mStandButton->setVisible(FALSE); mStopFlyingButton = getChild<LLButton>("stop_fly_btn"); - mStopFlyingButton->setCommitCallback(boost::bind(&LLFloaterMove::setFlyingMode, FALSE)); + //mStopFlyingButton->setCommitCallback(boost::bind(&LLFloaterMove::setFlyingMode, FALSE)); mStopFlyingButton->setCommitCallback(boost::bind(&LLPanelStandStopFlying::onStopFlyingButtonClick, this)); mStopFlyingButton->setVisible(FALSE); @@ -590,16 +594,22 @@ BOOL LLPanelStandStopFlying::postBuild() void LLPanelStandStopFlying::setVisible(BOOL visible) { //we dont need to show the panel if these buttons are not activated - if (visible && !mStandButton->getVisible() && !mStopFlyingButton->getVisible()) visible = false; - - if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK) visible = false; + if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) visible = false; if (visible) { updatePosition(); - getParent()->sendChildToFront(this); } + // do not change parent visibility in case panel is attached into Move Floater: EXT-3632, EXT-4646 + if (!mAttached) + { + //change visibility of parent layout_panel to animate in/out. EXT-2504 + if (getParent()) getParent()->setVisible(visible); + } + + // also change own visibility to avoid displaying the panel in mouselook (broken when EXT-2504 was implemented). + // See EXT-4718. LLPanel::setVisible(visible); } @@ -616,7 +626,49 @@ BOOL LLPanelStandStopFlying::handleToolTip(S32 x, S32 y, MASK mask) LLToolTipMgr::instance().show(mStopFlyingButton->getToolTip()); } - return TRUE; + return LLPanel::handleToolTip(x, y, mask); +} + +void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view) +{ + LLPanel* parent = dynamic_cast<LLPanel*>(getParent()); + if (!parent) + { + llwarns << "Stand/stop flying panel parent is unset, already attached?: " << mAttached << ", new parent: " << (move_view == NULL ? "NULL" : "Move Floater") << 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); + // update parent with self visibility (it is changed in setVisible()). EXT-4743 + mOriginalParent.get()->setVisible(getVisible()); + + mAttached = false; + updatePosition(); // don't defer until next draw() to avoid flicker + } } ////////////////////////////////////////////////////////////////////////// @@ -630,7 +682,7 @@ LLPanelStandStopFlying* LLPanelStandStopFlying::getStandStopFlyingPanel() LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_stand_stop_flying.xml"); panel->setVisible(FALSE); - LLUI::getRootView()->addChild(panel); + //LLUI::getRootView()->addChild(panel); llinfos << "Build LLPanelStandStopFlying panel" << llendl; @@ -644,10 +696,6 @@ void LLPanelStandStopFlying::onStandButtonClick() gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); setFocus(FALSE); // EXT-482 - - BOOL fly = gAgent.getFlying(); - mStopFlyingButton->setVisible(fly); - setVisible(fly); } void LLPanelStandStopFlying::onStopFlyingButtonClick() @@ -663,27 +711,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 = tray->getRect().getHeight(); - - 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); } |