diff options
author | Mike Antipov <mantipov@productengine.com> | 2010-05-14 17:15:28 +0300 |
---|---|---|
committer | Mike Antipov <mantipov@productengine.com> | 2010-05-14 17:15:28 +0300 |
commit | 4b9b5c1d38a234d4127c2c38df5f6f1f902190b2 (patch) | |
tree | 6c820e14886ba807d97b46a82abd49d4a7fe4c64 /indra/newview/llbottomtray.cpp | |
parent | 5088d01be115f4f9ded71da2313ee08af01f6616 (diff) |
EXT-7104 WIP added 4 buttons to bottom tray, added "Show button" menu support.
* Added 4 buttons with tooltips:
** Build - Shows/hides Build Tools
** Search - Shows/hides Search
** Map - Shows/hides World Map
** Mini-Map - Shows/hides Mini-Map
* Made their width and minimal width the same as "Move" and "View" buttons (increased default total width of the bottom tray to make Layout Stack initialize its panels with default values from xml)
* Added appropriate menu items in context menu to Show these buttons in the bottom tray (with functionality)
* Set on click actions for this buttons. ("Build" temporary made disabled because default toggle registration is not enough for this floater.)
Dev Notes:
* Improved LLBottomTray::initResizeStateContainers to fill mObjectDefaultWidthMap using mStateProcessedObjectMap & mButtonsProcessOrder container
* Improved LLBottomTray::canButtonBeShown to process variable number of buttons that can be hidden on resize
QA Notes:
Resize behavior with new buttons can already be tested.
Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/381/
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llbottomtray.cpp')
-rw-r--r-- | indra/newview/llbottomtray.cpp | 106 |
1 files changed, 83 insertions, 23 deletions
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 226d5593c9..7f528c88b2 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -479,6 +479,10 @@ BOOL LLBottomTray::postBuild() initResizeStateContainers(); + setButtonsControlsAndListeners(); + + initButtonsVisibility(); + // update wells visibility: showWellButton(RS_IM_WELL, !LLIMWellWindow::getInstance()->isWindowEmpty()); showWellButton(RS_NOTIFICATION_WELL, !LLNotificationWellWindow::getInstance()->isWindowEmpty()); @@ -1091,52 +1095,108 @@ void LLBottomTray::processExtendButton(EResizeState processed_object_type, S32& bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const { + // 0. Check if passed button was previously hidden on resize bool can_be_shown = mResizeState & processed_object_type; if (can_be_shown) { - static MASK MOVEMENT_PREVIOUS_BUTTONS_MASK = RS_BUTTON_GESTURES; - static MASK CAMERA_PREVIOUS_BUTTONS_MASK = RS_BUTTON_GESTURES | RS_BUTTON_MOVEMENT; - static MASK SNAPSHOT_PREVIOUS_BUTTONS_MASK = RS_BUTTON_GESTURES | RS_BUTTON_MOVEMENT | RS_BUTTON_CAMERA; + // Yes, it was. Lets now check that all buttons before it (that can be hidden on resize) + // are already shown + + // process buttons in direct order (from left to right) + resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin(); + const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end(); - switch(processed_object_type) + // 1. Find and accumulate all buttons types before one passed into the method. + MASK buttons_before_mask = RS_NORESIZE; + for (; it != it_end; ++it) { - case RS_BUTTON_GESTURES: // Gestures should be shown first - break; - case RS_BUTTON_MOVEMENT: // Move only if gesture is shown - can_be_shown = !(MOVEMENT_PREVIOUS_BUTTONS_MASK & mResizeState); - break; - case RS_BUTTON_CAMERA: - can_be_shown = !(CAMERA_PREVIOUS_BUTTONS_MASK & mResizeState); - break; - case RS_BUTTON_SNAPSHOT: - can_be_shown = !(SNAPSHOT_PREVIOUS_BUTTONS_MASK & mResizeState); - break; - default: // nothing to do here - break; + const EResizeState button_type = *it; + if (button_type == processed_object_type) break; + + buttons_before_mask |= button_type; } + + // 2. Check if some previous buttons are still hidden on resize + can_be_shown = !(buttons_before_mask & mResizeState); } return can_be_shown; } void LLBottomTray::initResizeStateContainers() { + // *TODO: get rid of mGesturePanel, mMovementPanel, mCamPanel, mSnapshotPanel instance members // init map with objects should be processed for each type mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_GESTURES, mGesturePanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_MOVEMENT, mMovementPanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_CAMERA, mCamPanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_SNAPSHOT, mSnapshotPanel)); - - // init default widths - mObjectDefaultWidthMap[RS_BUTTON_GESTURES] = mGesturePanel->getRect().getWidth(); - mObjectDefaultWidthMap[RS_BUTTON_MOVEMENT] = mMovementPanel->getRect().getWidth(); - mObjectDefaultWidthMap[RS_BUTTON_CAMERA] = mCamPanel->getRect().getWidth(); - mObjectDefaultWidthMap[RS_BUTTON_SPEAK] = mSpeakPanel->getRect().getWidth(); + mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_BUILD, getChild<LLPanel>("build_btn_panel"))); + mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_SEARCH, getChild<LLPanel>("search_btn_panel"))); + mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_WORLD_MAP, getChild<LLPanel>("world_map_btn_panel"))); + mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_MINI_MAP, getChild<LLPanel>("mini_map_btn_panel"))); // init an order of processed buttons mButtonsProcessOrder.push_back(RS_BUTTON_GESTURES); mButtonsProcessOrder.push_back(RS_BUTTON_MOVEMENT); mButtonsProcessOrder.push_back(RS_BUTTON_CAMERA); mButtonsProcessOrder.push_back(RS_BUTTON_SNAPSHOT); + mButtonsProcessOrder.push_back(RS_BUTTON_BUILD); + mButtonsProcessOrder.push_back(RS_BUTTON_SEARCH); + mButtonsProcessOrder.push_back(RS_BUTTON_WORLD_MAP); + mButtonsProcessOrder.push_back(RS_BUTTON_MINI_MAP); + + // init default widths + + // process buttons that can be hidden on resize... + resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin(); + const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end(); + + for (; it != it_end; ++it) + { + const EResizeState button_type = *it; + // is there an appropriate object? + if (0 == mStateProcessedObjectMap.count(button_type)) continue; + + // set default width for it. + mObjectDefaultWidthMap[button_type] = mStateProcessedObjectMap[button_type]->getRect().getWidth(); + } + + // ... and add Speak button because it also can be shrunk. + mObjectDefaultWidthMap[RS_BUTTON_SPEAK] = mSpeakPanel->getRect().getWidth(); + +} + +void LLBottomTray::initButtonsVisibility() +{ + // *TODO: move control settings of other buttons here + setTrayButtonVisibleIfPossible(RS_BUTTON_BUILD, gSavedSettings.getBOOL("ShowBuildButton")); + setTrayButtonVisibleIfPossible(RS_BUTTON_SEARCH, gSavedSettings.getBOOL("ShowSearchButton")); + setTrayButtonVisibleIfPossible(RS_BUTTON_WORLD_MAP, gSavedSettings.getBOOL("ShowWorldMapButton")); + setTrayButtonVisibleIfPossible(RS_BUTTON_MINI_MAP, gSavedSettings.getBOOL("ShowMiniMapButton")); +} + +void LLBottomTray::setButtonsControlsAndListeners() +{ + // *TODO: move control settings of other buttons here + gSavedSettings.declareBOOL("ShowBuildButton", TRUE, "Shows/Hides Build button in the bottom tray. (Declared in code)"); + gSavedSettings.declareBOOL("ShowSearchButton", TRUE, "Shows/Hides Search button in the bottom tray. (Declared in code)"); + gSavedSettings.declareBOOL("ShowWorldMapButton", TRUE, "Shows/Hides Map button in the bottom tray. (Declared in code)"); + gSavedSettings.declareBOOL("ShowMiniMapButton", TRUE, "Shows/Hides Mini-Map button in the bottom tray. (Declared in code)"); + + + gSavedSettings.getControl("ShowBuildButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_BUILD, _2)); + gSavedSettings.getControl("ShowSearchButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_SEARCH, _2)); + gSavedSettings.getControl("ShowWorldMapButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_WORLD_MAP, _2)); + gSavedSettings.getControl("ShowMiniMapButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_MINI_MAP, _2)); +} + +bool LLBottomTray::toggleShowButton(LLBottomTray::EResizeState button_type, const LLSD& new_visibility) +{ + if (LLBottomTray::instanceExists()) + { + LLBottomTray::getInstance()->setTrayButtonVisibleIfPossible(button_type, new_visibility.asBoolean()); + } + return true; } void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible) |