From 3eafbeaac57c952b674fb134124354036c9bb967 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Tue, 10 Nov 2009 15:02:42 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Initial refactoring of functionality: - Re-Fixed bug with visibility of chiclet panel of the min size - updated bottomtray xml to make buttons identical to each other - Imroved logic while resizing of bottom tray (changing width of chiclet & nearby panels, hide/show buttons) --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 419 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 392 insertions(+), 27 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index a17ba79078..d0fdf24403 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -50,6 +50,8 @@ LLBottomTray::LLBottomTray(const LLSD&) mSpeakBtn(NULL), mNearbyChatBar(NULL), mToolbarStack(NULL) +, mMovementButton(NULL) +// Add more members { mFactoryMap["chat_bar"] = LLCallbackMap(LLBottomTray::createNearbyChatBar, NULL); @@ -253,12 +255,28 @@ void LLBottomTray::showSnapshotButton(BOOL visible) mSnapshotPanel->setVisible(visible); } +typedef enum e_resize_status_type +{ + RS_NORESIZE = 0x0000 + , RS_CHICLET_PANEL = 0x0001 + , RS_CHATBAR_INPUT = 0x0002 + , RS_BUTTON_SNAPSHOT = 0x0004 + , RS_BUTTON_CAMERA = 0x0008 + , RS_BUTTON_MOVEMENT = 0x0010 + , RS_BUTTON_GESTURES = 0x0020 + , RS_BUTTON_SPEAK = 0x0040 + , RS_RESIZABLE_BUTTONS = /*RS_BUTTON_SNAPSHOT | */RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES +}EResizeState; + + + namespace { - const std::string& PANEL_CHICLET_NAME = "chiclet_list_panel"; - const std::string& PANEL_CHATBAR_NAME = "chat_bar"; - const std::string& PANEL_MOVEMENT_NAME = "movement_panel"; - const std::string& PANEL_CAMERA_NAME = "cam_panel"; + const std::string& PANEL_CHICLET_NAME = "chiclet_list_panel"; + const std::string& PANEL_CHATBAR_NAME = "chat_bar"; + const std::string& PANEL_MOVEMENT_NAME = "movement_panel"; + const std::string& PANEL_CAMERA_NAME = "cam_panel"; + const std::string& PANEL_GESTURE_NAME = "gesture_panel"; } BOOL LLBottomTray::postBuild() @@ -284,63 +302,133 @@ BOOL LLBottomTray::postBuild() return TRUE; } +void LLBottomTray::log(LLView* panel, const std::string& descr) +{ + if (NULL == panel) return; + LLView* layout = panel->getParent(); + llwarns << descr << ": " + << "panel: " << panel->getName() + << ", rect: " << panel->getRect() + + + << "layout: " << layout->getName() + << ", rect: " << layout->getRect() + << llendl + ; +} + void LLBottomTray::verifyChildControlsSizes() { LLRect rect = mChicletPanel->getRect(); if (rect.getWidth() < mChicletPanel->getMinWidth()) { + llwarns << "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ: chiclet panel less then min" << llendl; mChicletPanel->reshape(mChicletPanel->getMinWidth(), rect.getHeight()); } rect = mNearbyChatBar->getRect(); if (rect.getWidth() < mNearbyChatBar->getMinWidth()) { + llwarns << "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW: near chat panel less then min" << llendl; mNearbyChatBar->reshape(mNearbyChatBar->getMinWidth(), rect.getHeight()); } - else if (rect.getWidth() > mNearbyChatBar->getMaxWidth()) + else + if (rect.getWidth() > mNearbyChatBar->getMaxWidth()) { rect.setLeftTopAndSize(rect.mLeft, rect.mTop, mNearbyChatBar->getMaxWidth(), rect.getHeight()); mNearbyChatBar->reshape(mNearbyChatBar->getMaxWidth(), rect.getHeight()); mNearbyChatBar->setRect(rect); } } - +#define __FEATURE_EXT_991 void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { + static S32 depth = 0; +if (0 == depth) lldebugs << "" << llendl; + + lldebugs << "Reshaping: depth: " << ++depth + << ", width: " << width + << ", height: " << height + << ", called_from_parent" << called_from_parent + << ", cur width: " << getRect().getWidth() + << ", cur height: " << getRect().getHeight() + << llendl; + + if (mNearbyChatBar) log(mNearbyChatBar, "before"); + if (mChicletPanel) log(mChicletPanel, "before"); if (mChicletPanel && mToolbarStack && mNearbyChatBar) { -#ifdef __FEATURE_EXT_991__ +// S32 delta_width = width - getRect().getWidth(); BOOL shrink = width < getRect().getWidth(); +#ifdef __FEATURE_EXT_991__ const S32 MIN_RENDERED_CHARS = 3; #endif - verifyChildControlsSizes(); - updateResizeState(width, height); + + + verifyChildControlsSizes(); + updateResizeState(width, height); + if (RS_NORESIZE == mResizeState && !called_from_parent) + { + // this can be in case nearby + lldebugs << "width was not changed & !called_from_parent" << llendl; + + } + + + + + if (RS_NORESIZE != mResizeState) + { + +// mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, mResizeState & RS_CHICLET_PANEL); + mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); + +// mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, mResizeState & RS_CHATBAR_INPUT); + +/* + mToolbarStack->updatePanelAutoResize(PANEL_GESTURE_NAME, mResizeState & RS_BUTTON_GESTURES); + mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, mResizeState & RS_BUTTON_CAMERA); + mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, mResizeState & RS_BUTTON_MOVEMENT); +*/ + + bool show_button = !shrink; + if (width != getRect().getWidth() && show_button) + { + if (mResizeState & RS_BUTTON_SNAPSHOT) showSnapshotButton(show_button); + if (mResizeState & RS_BUTTON_CAMERA) showCameraButton(show_button); + if (mResizeState & RS_BUTTON_MOVEMENT) showMoveButton(show_button); + if (mResizeState & RS_BUTTON_GESTURES) showGestureButton(show_button); + } switch (mResizeState) { - case STATE_CHICLET_PANEL: + case RS_CHICLET_PANEL: +/* mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, FALSE); mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); +*/ break; - case STATE_CHATBAR_INPUT: + case RS_CHATBAR_INPUT: +/* mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, TRUE); mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, FALSE); mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); +*/ break; #ifdef __FEATURE_EXT_991__ - case STATE_BUTTONS: - mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, TRUE); + case RS_RESIZABLE_BUTTONS: +// mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, TRUE); mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, TRUE); mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, FALSE); @@ -352,6 +440,8 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) if (mSnapshotPanel->getVisible()) { showSnapshotButton(FALSE); +// mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); +// mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); } if (mCamPanel->getVisible() && mCamButton->getLastDrawCharsCount() < MIN_RENDERED_CHARS) @@ -368,6 +458,12 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) else { showMoveButton(TRUE); + S32 button_delta = delta_width / 4; + + LLRect panel_rect = mMovementPanel->getRect(); +// panel_rect.mRight += button_delta; + mMovementPanel->reshape(panel_rect.getWidth() + button_delta, panel_rect.getHeight()/*, FALSE*/); + mMovementPanel->draw(); if (mMovementButton->getLastDrawCharsCount() >= MIN_RENDERED_CHARS) @@ -378,6 +474,7 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { showMoveButton(FALSE); } + mMovementPanel->reshape(panel_rect.getWidth() , panel_rect.getHeight()/*, FALSE*/); } break; #endif @@ -385,58 +482,326 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) default: break; } + } + else + { + lldebugs << "Nothing changed" << llendl; + } + } LLPanel::reshape(width, height, called_from_parent); + + // *TODO: проверить ширину nearby после ресайза на предмет выхода за максимальный предел + +// if (mMovementButton) log(mMovementButton, "after"); + if (mNearbyChatBar) log(mNearbyChatBar, "after"); + if (mChicletPanel) log(mChicletPanel, "after"); + + if (mToolbarStack) + { +/* + mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); + mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); +*/ + } + --depth; } void LLBottomTray::updateResizeState(S32 width, S32 height) { - mResizeState = STATE_BUTTONS; + mResizeState = RS_NORESIZE; + static MASK prev_resize_state = mResizeState; + MASK compensative_view_item_mask = RS_CHATBAR_INPUT; + LLPanel* compansative_view = mNearbyChatBar; + S32 compensative_delta_width = 0; - const S32 chiclet_panel_width = mChicletPanel->getRect().getWidth(); + S32 delta_width = width - getRect().getWidth(); +// if (delta_width == 0) return; + + const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); + lldebugs << "chatbar_panel_width: " << chatbar_panel_width + << llendl; + + bool still_should_be_processed = true; // bottom tray is narrowed if (width < getRect().getWidth()) { if (chiclet_panel_width > chiclet_panel_min_width) { - mResizeState = STATE_CHICLET_PANEL; + // we have some space to decrease chiclet panel + S32 panel_delta_min = chiclet_panel_width - chiclet_panel_min_width; + mResizeState |= RS_CHICLET_PANEL; + + S32 delta_panel = llmin(-delta_width, panel_delta_min); + + lldebugs << "delta_width: " << delta_width + << ", panel_delta_min: " << panel_delta_min + << ", delta_panel: " << delta_panel + << llendl; + + // is chiclet panel width enough to process resizing? + delta_width += panel_delta_min; + + still_should_be_processed = delta_width < 0; + + mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - delta_panel, mChicletPanel->getParent()->getRect().getHeight()); + log(mChicletPanel, "after processing panel decreasing via chiclet panel"); + + lldebugs << "RS_CHICLET_PANEL" + << ", delta_width: " << delta_width + << llendl; } - else if (chatbar_panel_width > chatbar_panel_min_width) + + if (still_should_be_processed && chatbar_panel_width > chatbar_panel_min_width) { - mResizeState = STATE_CHATBAR_INPUT; + // we have some space to decrease chatbar panel + S32 panel_delta_min = chatbar_panel_width - chatbar_panel_min_width; + mResizeState |= RS_CHATBAR_INPUT; + + S32 delta_panel = llmin(-delta_width, panel_delta_min); + + // is chatbar panel width enough to process resizing? + delta_width += panel_delta_min; + + + still_should_be_processed = delta_width < 0; + + mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mNearbyChatBar->getRect().getHeight()); + + lldebugs << "RS_CHATBAR_INPUT" + << ", delta_panel: " << delta_panel + << ", delta_width: " << delta_width + << llendl; + + log(mChicletPanel, "after nearby was processed"); + } - else + if (still_should_be_processed) { - mResizeState = STATE_BUTTONS; + mResizeState |= compensative_view_item_mask; + + if (mSnapshotPanel->getVisible()) + { + mResizeState |= RS_BUTTON_SNAPSHOT; + delta_width += mSnapshotPanel->getRect().getWidth(); + compensative_delta_width += mSnapshotPanel->getRect().getWidth(); + lldebugs << "RS_BUTTON_SNAPSHOT" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + showSnapshotButton(false); + } + + if (delta_width < 0 && mCamPanel->getVisible()) + { + mResizeState |= RS_BUTTON_CAMERA; + delta_width += mCamPanel->getRect().getWidth(); + compensative_delta_width += mCamPanel->getRect().getWidth(); + lldebugs << "RS_BUTTON_CAMERA" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + showCameraButton(false); + } + + if (delta_width < 0 && mMovementPanel->getVisible()) + { + mResizeState |= RS_BUTTON_MOVEMENT; + delta_width += mMovementPanel->getRect().getWidth(); + compensative_delta_width += mMovementPanel->getRect().getWidth(); + lldebugs << "RS_BUTTON_MOVEMENT" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + showMoveButton(false); + } + + if (delta_width < 0 && mGesturePanel->getVisible()) + { + mResizeState |= RS_BUTTON_GESTURES; + delta_width += mGesturePanel->getRect().getWidth(); + compensative_delta_width += mGesturePanel->getRect().getWidth(); + lldebugs << "RS_BUTTON_GESTURES" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + showGestureButton(false); + } + + if (delta_width < 0) + { + llwarns << "WARNING: there is no enough room for bottom tray, resizing still should be processed" << llendl; + } + + if (compensative_delta_width != 0) + { + if (compansative_view) log(compansative_view, "before applying compensative width: "); + compansative_view->reshape(compansative_view->getRect().getWidth() + compensative_delta_width, compansative_view->getRect().getHeight() ); + if (compansative_view) log(compansative_view, "after applying compensative width: "); + lldebugs << compensative_delta_width << llendl; + + } + +/* + switch (mResizeState) + { + case: + } +*/ + +// mResizeState = RS_RESIZABLE_BUTTONS; } } // bottom tray is widen else { +// const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); +// const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); +// // const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); + S32 available_width_chat = chatbar_panel_width - chatbar_panel_min_width; + S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; + S32 available_width = delta_width + available_width_chat + available_width_chiclet; + + if (available_width > 0 && processShowButton(mGesturePanel, &available_width)) + { + mResizeState |= RS_BUTTON_GESTURES | compensative_view_item_mask; + delta_width -= mGesturePanel->getRect().getWidth(); + compensative_delta_width -= mGesturePanel->getRect().getWidth(); + lldebugs << "RS_BUTTON_GESTURES" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + } + + if (available_width > 0 && processShowButton(mMovementPanel, &available_width)) + { + mResizeState |= RS_BUTTON_MOVEMENT | compensative_view_item_mask; + delta_width -= mMovementPanel->getRect().getWidth(); + compensative_delta_width -= mMovementPanel->getRect().getWidth(); + + lldebugs << "RS_BUTTON_MOVEMENT" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + } + + if (available_width > 0 && processShowButton(mCamPanel, &available_width)) + { + mResizeState |= RS_BUTTON_CAMERA | compensative_view_item_mask; + delta_width -= mCamPanel->getRect().getWidth(); + compensative_delta_width -= mCamPanel->getRect().getWidth(); + + lldebugs << "RS_BUTTON_CAMERA " + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + } + + if (available_width > 0 && processShowButton(mSnapshotPanel, &available_width)) + { + mResizeState |= RS_BUTTON_SNAPSHOT | compensative_view_item_mask; + delta_width -= mSnapshotPanel->getRect().getWidth(); + compensative_delta_width -= mSnapshotPanel->getRect().getWidth(); + + lldebugs << "RS_BUTTON_SNAPSHOT" + << ", compensative_delta_width: " << compensative_delta_width + << ", delta_width: " << delta_width + << llendl; + } + + if (compensative_delta_width != 0) + { + S32 required_to_process_width = -compensative_delta_width; + S32 total_delta_width = width - getRect().getWidth(); + + // 1. use delta width of resizing + required_to_process_width -= total_delta_width; + + // 2. use delta width of chatbar + + + S32 chatbar_compensative_delta_width = required_to_process_width; + if (available_width_chat < chatbar_compensative_delta_width) + { + chatbar_compensative_delta_width = available_width_chat; + } + + log(compansative_view, "increase width: before applying compensative width: "); + compansative_view->reshape(compansative_view->getRect().getWidth() - chatbar_compensative_delta_width, compansative_view->getRect().getHeight() ); + if (compansative_view) log(compansative_view, "after applying compensative width: "); + lldebugs << chatbar_compensative_delta_width << llendl; + + // 3. use delta width of chiclet panel + required_to_process_width -= chatbar_compensative_delta_width; + + mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); + log(mChicletPanel, "after applying compensative width for chiclets: "); + lldebugs << required_to_process_width << llendl; + + } + + #ifdef __FEATURE_EXT_991__ - if (!mMovementPanel->getVisible()) + //S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, BOOL end_on_word_boundary) const + static S32 DEFAULT_BUTTON_WIDTH = 80; + if (!mMovementPanel->getVisible() || mMovementPanel->getRect().getWidth() < DEFAULT_BUTTON_WIDTH) { - mResizeState = STATE_BUTTONS; + mResizeState = RS_RESIZABLE_BUTTONS; } else #endif - if (chatbar_panel_width < chatbar_panel_max_width) + if (delta_width > 0 && chatbar_panel_width < chatbar_panel_max_width) { - mResizeState = STATE_CHATBAR_INPUT; + mResizeState |= RS_CHATBAR_INPUT; + // how many space can nearby chat take? + S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); + S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_; + S32 delta_panel = llmin(delta_width, delta_panel_max); + delta_width -= delta_panel_max; + mNearbyChatBar->reshape(chatbar_panel_width_ + delta_panel, mNearbyChatBar->getRect().getHeight()); } - else + + if (delta_width > 0) { - mResizeState = STATE_CHICLET_PANEL; + mResizeState |= RS_CHICLET_PANEL; } } + prev_resize_state = mResizeState; + lldebugs << "New resize state: " << mResizeState << llendl; +} - // TODO: finish implementation +bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width) +{ + bool can_be_shown = canButtonBeShown(panel); + if (can_be_shown) + { + //validate if we have enough room to show this button + const S32 required_width = panel->getRect().getWidth(); + can_be_shown = *available_width >= required_width; + if (can_be_shown) + { + *available_width -= required_width; + } + + } + return can_be_shown; +} + +bool LLBottomTray::canButtonBeShown(LLPanel* panel) const +{ + bool can_be_shown = !panel->getVisible(); + if (can_be_shown) + { + // *TODO: mantipov: synchronize with situation when button was hidden via context menu; + } + return can_be_shown; } +//EOF -- cgit v1.3 From 729df1aa330a50fa4f4b887e46c32a94a01880d7 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Tue, 10 Nov 2009 16:13:20 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Initial refactoring of functionality: - cleaning - Imroved logic while resizing of bottom tray --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 155 ++++++----------------------------------- 1 file changed, 23 insertions(+), 132 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index d0fdf24403..b74b1d900b 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -344,12 +344,12 @@ void LLBottomTray::verifyChildControlsSizes() void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { static S32 depth = 0; -if (0 == depth) lldebugs << "" << llendl; +if (0 == depth) lldebugs << "****************************************" << llendl; lldebugs << "Reshaping: depth: " << ++depth << ", width: " << width << ", height: " << height - << ", called_from_parent" << called_from_parent + << ", called_from_parent: " << called_from_parent << ", cur width: " << getRect().getWidth() << ", cur height: " << getRect().getHeight() << llendl; @@ -361,9 +361,6 @@ if (0 == depth) lldebugs << "" << llendl; { // S32 delta_width = width - getRect().getWidth(); BOOL shrink = width < getRect().getWidth(); -#ifdef __FEATURE_EXT_991__ - const S32 MIN_RENDERED_CHARS = 3; -#endif @@ -376,9 +373,6 @@ if (0 == depth) lldebugs << "" << llendl; } - - - if (RS_NORESIZE != mResizeState) { @@ -387,11 +381,6 @@ if (0 == depth) lldebugs << "" << llendl; // mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, mResizeState & RS_CHATBAR_INPUT); -/* - mToolbarStack->updatePanelAutoResize(PANEL_GESTURE_NAME, mResizeState & RS_BUTTON_GESTURES); - mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, mResizeState & RS_BUTTON_CAMERA); - mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, mResizeState & RS_BUTTON_MOVEMENT); -*/ bool show_button = !shrink; if (width != getRect().getWidth() && show_button) @@ -402,109 +391,16 @@ if (0 == depth) lldebugs << "" << llendl; if (mResizeState & RS_BUTTON_GESTURES) showGestureButton(show_button); } - switch (mResizeState) - { - case RS_CHICLET_PANEL: -/* - mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); - - mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); -*/ - - break; - case RS_CHATBAR_INPUT: -/* - mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, TRUE); - - mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); - -*/ - break; - -#ifdef __FEATURE_EXT_991__ - - case RS_RESIZABLE_BUTTONS: -// mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, TRUE); - mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, TRUE); - - mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, FALSE); - - if (shrink) - { - - if (mSnapshotPanel->getVisible()) - { - showSnapshotButton(FALSE); -// mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); -// mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); - } - - if (mCamPanel->getVisible() && mCamButton->getLastDrawCharsCount() < MIN_RENDERED_CHARS) - { - showCameraButton(FALSE); - } - - if (mMovementPanel->getVisible() && mMovementButton->getLastDrawCharsCount() < MIN_RENDERED_CHARS) - { - showMoveButton(FALSE); - } - - } - else - { - showMoveButton(TRUE); - S32 button_delta = delta_width / 4; - - LLRect panel_rect = mMovementPanel->getRect(); -// panel_rect.mRight += button_delta; - mMovementPanel->reshape(panel_rect.getWidth() + button_delta, panel_rect.getHeight()/*, FALSE*/); - - mMovementPanel->draw(); - - if (mMovementButton->getLastDrawCharsCount() >= MIN_RENDERED_CHARS) - { - showMoveButton(TRUE); - } - else - { - showMoveButton(FALSE); - } - mMovementPanel->reshape(panel_rect.getWidth() , panel_rect.getHeight()/*, FALSE*/); - } - break; -#endif - - default: - break; - } } - else - { - lldebugs << "Nothing changed" << llendl; - } - } LLPanel::reshape(width, height, called_from_parent); // *TODO: проверить ширину nearby после ресайза на предмет выхода за максимальный предел -// if (mMovementButton) log(mMovementButton, "after"); if (mNearbyChatBar) log(mNearbyChatBar, "after"); if (mChicletPanel) log(mChicletPanel, "after"); - if (mToolbarStack) - { -/* - mToolbarStack->updatePanelAutoResize(PANEL_CAMERA_NAME, FALSE); - mToolbarStack->updatePanelAutoResize(PANEL_MOVEMENT_NAME, FALSE); -*/ - } --depth; } @@ -527,6 +423,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); lldebugs << "chatbar_panel_width: " << chatbar_panel_width + << ", chatbar_panel_min_width: " << chatbar_panel_min_width + << ", chatbar_panel_max_width: " << chatbar_panel_max_width + << ", chiclet_panel_width: " << chiclet_panel_width + << ", chiclet_panel_min_width: " << chiclet_panel_min_width << llendl; bool still_should_be_processed = true; @@ -591,7 +491,11 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_SNAPSHOT; delta_width += mSnapshotPanel->getRect().getWidth(); - compensative_delta_width += mSnapshotPanel->getRect().getWidth(); + + if (delta_width > 0) + { + compensative_delta_width += delta_width; + } lldebugs << "RS_BUTTON_SNAPSHOT" << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width @@ -603,7 +507,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_CAMERA; delta_width += mCamPanel->getRect().getWidth(); - compensative_delta_width += mCamPanel->getRect().getWidth(); + if (delta_width > 0) + { + compensative_delta_width += delta_width; + } lldebugs << "RS_BUTTON_CAMERA" << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width @@ -615,7 +522,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_MOVEMENT; delta_width += mMovementPanel->getRect().getWidth(); - compensative_delta_width += mMovementPanel->getRect().getWidth(); + if (delta_width > 0) + { + compensative_delta_width += delta_width; + } lldebugs << "RS_BUTTON_MOVEMENT" << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width @@ -627,7 +537,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_GESTURES; delta_width += mGesturePanel->getRect().getWidth(); - compensative_delta_width += mGesturePanel->getRect().getWidth(); + if (delta_width > 0) + { + compensative_delta_width += delta_width; + } lldebugs << "RS_BUTTON_GESTURES" << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width @@ -648,23 +561,11 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) lldebugs << compensative_delta_width << llendl; } - -/* - switch (mResizeState) - { - case: - } -*/ - -// mResizeState = RS_RESIZABLE_BUTTONS; } } // bottom tray is widen else { -// const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); -// const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); -// // const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); S32 available_width_chat = chatbar_panel_width - chatbar_panel_min_width; S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; S32 available_width = delta_width + available_width_chat + available_width_chiclet; @@ -747,16 +648,6 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) } - -#ifdef __FEATURE_EXT_991__ - //S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, BOOL end_on_word_boundary) const - static S32 DEFAULT_BUTTON_WIDTH = 80; - if (!mMovementPanel->getVisible() || mMovementPanel->getRect().getWidth() < DEFAULT_BUTTON_WIDTH) - { - mResizeState = RS_RESIZABLE_BUTTONS; - } - else -#endif if (delta_width > 0 && chatbar_panel_width < chatbar_panel_max_width) { mResizeState |= RS_CHATBAR_INPUT; -- cgit v1.3 From eb05116e2b3339648a1458fd3be5c502583053ea Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Tue, 10 Nov 2009 18:07:19 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) - update min width for chiclet panel - move showing of hidden buttons to place where resize strategy is determined --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 45 ++++++++-------------- .../skins/default/xui/en/panel_bottomtray.xml | 6 ++- 2 files changed, 20 insertions(+), 31 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index b74b1d900b..c33d667e0b 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -320,21 +320,26 @@ void LLBottomTray::log(LLView* panel, const std::string& descr) void LLBottomTray::verifyChildControlsSizes() { LLRect rect = mChicletPanel->getRect(); + /* if (rect.getWidth() < mChicletPanel->getMinWidth()) { llwarns << "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ: chiclet panel less then min" << llendl; mChicletPanel->reshape(mChicletPanel->getMinWidth(), rect.getHeight()); } - +*/ rect = mNearbyChatBar->getRect(); +/* if (rect.getWidth() < mNearbyChatBar->getMinWidth()) { llwarns << "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW: near chat panel less then min" << llendl; mNearbyChatBar->reshape(mNearbyChatBar->getMinWidth(), rect.getHeight()); } else +*/ if (rect.getWidth() > mNearbyChatBar->getMaxWidth()) { + llerrs << "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW: near chat panel more then max width" << llendl; + rect.setLeftTopAndSize(rect.mLeft, rect.mTop, mNearbyChatBar->getMaxWidth(), rect.getHeight()); mNearbyChatBar->reshape(mNearbyChatBar->getMaxWidth(), rect.getHeight()); mNearbyChatBar->setRect(rect); @@ -346,11 +351,12 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) static S32 depth = 0; if (0 == depth) lldebugs << "****************************************" << llendl; + S32 prev_width = getRect().getWidth(); lldebugs << "Reshaping: depth: " << ++depth << ", width: " << width << ", height: " << height << ", called_from_parent: " << called_from_parent - << ", cur width: " << getRect().getWidth() + << ", cur width: " << prev_width << ", cur height: " << getRect().getHeight() << llendl; @@ -359,19 +365,8 @@ if (0 == depth) lldebugs << "****************************************" << llendl if (mChicletPanel && mToolbarStack && mNearbyChatBar) { -// S32 delta_width = width - getRect().getWidth(); - BOOL shrink = width < getRect().getWidth(); - - - verifyChildControlsSizes(); - updateResizeState(width, height); - if (RS_NORESIZE == mResizeState && !called_from_parent) - { - // this can be in case nearby - lldebugs << "width was not changed & !called_from_parent" << llendl; - - } + updateResizeState(width, prev_width); if (RS_NORESIZE != mResizeState) { @@ -380,23 +375,11 @@ if (0 == depth) lldebugs << "****************************************" << llendl mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); // mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, mResizeState & RS_CHATBAR_INPUT); - - - bool show_button = !shrink; - if (width != getRect().getWidth() && show_button) - { - if (mResizeState & RS_BUTTON_SNAPSHOT) showSnapshotButton(show_button); - if (mResizeState & RS_BUTTON_CAMERA) showCameraButton(show_button); - if (mResizeState & RS_BUTTON_MOVEMENT) showMoveButton(show_button); - if (mResizeState & RS_BUTTON_GESTURES) showGestureButton(show_button); - } - } } LLPanel::reshape(width, height, called_from_parent); - // *TODO: проверить ширину nearby после ресайза на предмет выхода за максимальный предел if (mNearbyChatBar) log(mNearbyChatBar, "after"); if (mChicletPanel) log(mChicletPanel, "after"); @@ -412,7 +395,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) LLPanel* compansative_view = mNearbyChatBar; S32 compensative_delta_width = 0; - S32 delta_width = width - getRect().getWidth(); + S32 delta_width = width - height; // if (delta_width == 0) return; const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); @@ -431,7 +414,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) bool still_should_be_processed = true; // bottom tray is narrowed - if (width < getRect().getWidth()) + if (width < height) { if (chiclet_panel_width > chiclet_panel_min_width) { @@ -579,6 +562,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width << llendl; + showGestureButton(true); } if (available_width > 0 && processShowButton(mMovementPanel, &available_width)) @@ -591,6 +575,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width << llendl; + showMoveButton(true); } if (available_width > 0 && processShowButton(mCamPanel, &available_width)) @@ -603,6 +588,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width << llendl; + showCameraButton(true); } if (available_width > 0 && processShowButton(mSnapshotPanel, &available_width)) @@ -615,12 +601,13 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) << ", compensative_delta_width: " << compensative_delta_width << ", delta_width: " << delta_width << llendl; + showSnapshotButton(true); } if (compensative_delta_width != 0) { S32 required_to_process_width = -compensative_delta_width; - S32 total_delta_width = width - getRect().getWidth(); + S32 total_delta_width = width - height; // 1. use delta width of resizing required_to_process_width -= total_delta_width; diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index 1c1065bc11..a945010d3e 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -224,16 +224,18 @@ bg_alpha_color="green" top="0" name="chiclet_list_panel" width="189" - min_width="189" + min_width="180" user_resize="false" auto_resize="true"> + Date: Tue, 10 Nov 2009 17:12:07 -0800 Subject: EXT-2338 Move button tooltips to strings the viewer translation tool can parse. Also moved mSpeakBtn from llnearbychatbar to llbottomtray, because the bottom tray is its parent. --- indra/newview/llbottomtray.cpp | 36 ++++++++++++++++++++++ indra/newview/llbottomtray.h | 7 ++++- indra/newview/llnearbychatbar.cpp | 30 ------------------ indra/newview/llnearbychatbar.h | 10 ------ indra/newview/llspeakbutton.cpp | 10 ++++++ indra/newview/llspeakbutton.h | 5 +++ .../skins/default/xui/en/panel_bottomtray.xml | 6 ++-- 7 files changed, 60 insertions(+), 44 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 832694873f..9ea8b53d3d 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -40,6 +40,7 @@ #include "llimfloater.h" // for LLIMFloater #include "lllayoutstack.h" #include "llnearbychatbar.h" +#include "llspeakbutton.h" #include "llsplitbutton.h" #include "llsyswellwindow.h" #include "llfloatercamera.h" @@ -181,6 +182,28 @@ void LLBottomTray::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& } } +// virtual +void LLBottomTray::onChange(EStatusType status, const std::string &channelURI, bool proximal) +{ + // Time it takes to connect to voice channel might be pretty long, + // so don't expect user login or STATUS_VOICE_ENABLED to be followed by STATUS_JOINED. + BOOL enable = FALSE; + + switch (status) + { + // Do not add STATUS_VOICE_ENABLED because voice chat is + // inactive until STATUS_JOINED + case STATUS_JOINED: + enable = TRUE; + break; + default: + enable = FALSE; + break; + } + + mSpeakBtn->setEnabled(enable); +} + //virtual void LLBottomTray::onFocusLost() { @@ -275,6 +298,19 @@ BOOL LLBottomTray::postBuild() mSnapshotPanel = getChild("snapshot_panel"); setRightMouseDownCallback(boost::bind(&LLBottomTray::showBottomTrayContextMenu,this, _2, _3,_4)); + mSpeakBtn = getChild("talk"); + + // Speak button should be initially disabled because + // it takes some time between logging in to world and connecting to voice channel. + mSpeakBtn->setEnabled(FALSE); + + // Localization tool doesn't understand custom buttons like + mSpeakBtn->setSpeakToolTip( getString("SpeakBtnToolTip") ); + mSpeakBtn->setShowToolTip( getString("VoiceControlBtnToolTip") ); + + // Registering Chat Bar to receive Voice client status change notifications. + gVoiceClient->addObserver(this); + if (mChicletPanel && mToolbarStack && mNearbyChatBar) { verifyChildControlsSizes(); diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 02588a1975..3f6d0756de 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -33,7 +33,7 @@ #ifndef LL_LLBOTTOMPANEL_H #define LL_LLBOTTOMPANEL_H -#include +#include "llmenugl.h" #include "llpanel.h" #include "llimview.h" @@ -51,6 +51,7 @@ class LLBottomTray : public LLSingleton , public LLPanel , public LLIMSessionObserver + , public LLVoiceClientStatusObserver { friend class LLSingleton; public: @@ -74,6 +75,10 @@ public: virtual void onFocusLost(); virtual void setVisible(BOOL visible); + // Implements LLVoiceClientStatusObserver::onChange() to enable the speak + // button when voice is available + /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal); + void showBottomTrayContextMenu(S32 x, S32 y, MASK mask); void showGestureButton(BOOL visible); diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index d54545971b..dfeade2e4d 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -36,7 +36,6 @@ #include "lltrans.h" #include "llnearbychatbar.h" -#include "llspeakbutton.h" #include "llbottomtray.h" #include "llagent.h" #include "llgesturemgr.h" @@ -234,14 +233,6 @@ BOOL LLNearbyChatBar::postBuild() mOutputMonitor = getChild("chat_zone_indicator"); mOutputMonitor->setVisible(FALSE); - mSpeakBtn = getParent()->getChild("talk"); - - // Speak button should be initially disabled because - // it takes some time between logging in to world and connecting to voice channel. - mSpeakBtn->setEnabled(FALSE); - - // Registering Chat Bar to receive Voice client status change notifications. - gVoiceClient->addObserver(this); return TRUE; } @@ -730,27 +721,6 @@ public: } }; -void LLNearbyChatBar::onChange(EStatusType status, const std::string &channelURI, bool proximal) -{ - // Time it takes to connect to voice channel might be pretty long, - // so don't expect user login or STATUS_VOICE_ENABLED to be followed by STATUS_JOINED. - BOOL enable = FALSE; - - switch (status) - { - // Do not add STATUS_VOICE_ENABLED because voice chat is - // inactive until STATUS_JOINED - case STATUS_JOINED: - enable = TRUE; - break; - default: - enable = FALSE; - break; - } - - mSpeakBtn->setEnabled(enable); -} - // Creating the object registers with the dispatcher. LLChatHandler gChatHandler; diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h index 56ee706a97..224118e088 100644 --- a/indra/newview/llnearbychatbar.h +++ b/indra/newview/llnearbychatbar.h @@ -42,9 +42,6 @@ #include "llspeakers.h" -class LLSpeakButton; - - class LLGestureComboBox : public LLComboBox , public LLGestureManagerObserver @@ -76,7 +73,6 @@ protected: class LLNearbyChatBar : public LLPanel -, public LLVoiceClientStatusObserver { public: // constructor for inline chat-bars (e.g. hosted in chat history window) @@ -105,11 +101,6 @@ public: S32 getMinWidth() const; S32 getMaxWidth() const; - /** - * Implements LLVoiceClientStatusObserver::onChange() - */ - /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal); - protected: static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); static void onChatBoxKeystroke(LLLineEditor* caller, void* userdata); @@ -127,7 +118,6 @@ protected: static S32 sLastSpecialChatChannel; LLLineEditor* mChatBox; - LLSpeakButton* mSpeakBtn; LLOutputMonitorCtrl* mOutputMonitor; LLLocalSpeakerMgr* mSpeakerMgr; }; diff --git a/indra/newview/llspeakbutton.cpp b/indra/newview/llspeakbutton.cpp index 57ea018f25..51d53b2674 100644 --- a/indra/newview/llspeakbutton.cpp +++ b/indra/newview/llspeakbutton.cpp @@ -133,6 +133,16 @@ LLSpeakButton::~LLSpeakButton() LLTransientFloaterMgr::getInstance()->removeControlView(mShowBtn); } +void LLSpeakButton::setSpeakToolTip(const std::string& msg) +{ + mSpeakBtn->setToolTip(msg); +} + +void LLSpeakButton::setShowToolTip(const std::string& msg) +{ + mShowBtn->setToolTip(msg); +} + void LLSpeakButton::onMouseDown_SpeakBtn() { bool down = true; diff --git a/indra/newview/llspeakbutton.h b/indra/newview/llspeakbutton.h index e213c562dd..02c8ab3890 100644 --- a/indra/newview/llspeakbutton.h +++ b/indra/newview/llspeakbutton.h @@ -62,6 +62,11 @@ public: /*virtual*/ ~LLSpeakButton(); /*virtual*/ void draw(); + // *HACK: Need to put tooltips in a translatable location, + // the panel that contains this button. + void setSpeakToolTip(const std::string& msg); + void setShowToolTip(const std::string& msg); + protected: friend class LLUICtrlFactory; LLSpeakButton(const Params& p); diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index 3fbc8e1afd..e96d3a152f 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -13,6 +13,8 @@ chrome="true" border_visible="false" width="1000"> + Turns microphone on/off + Shows/hides voice control panel + width="100" /> Date: Wed, 11 Nov 2009 13:13:34 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) - refactored logic increasing of width - fixed bug with incorrect work in some cases --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 71 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 33 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index c33d667e0b..908fe15be6 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -393,10 +393,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) static MASK prev_resize_state = mResizeState; MASK compensative_view_item_mask = RS_CHATBAR_INPUT; LLPanel* compansative_view = mNearbyChatBar; - S32 compensative_delta_width = 0; S32 delta_width = width - height; // if (delta_width == 0) return; + bool shrink = width < height; const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); @@ -414,8 +414,9 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) bool still_should_be_processed = true; // bottom tray is narrowed - if (width < height) + if (shrink) { + S32 compensative_delta_width = 0; if (chiclet_panel_width > chiclet_panel_min_width) { // we have some space to decrease chiclet panel @@ -549,17 +550,17 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) // bottom tray is widen else { - S32 available_width_chat = chatbar_panel_width - chatbar_panel_min_width; + S32 chatbar_available_shrink_width = chatbar_panel_width - chatbar_panel_min_width; S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; - S32 available_width = delta_width + available_width_chat + available_width_chiclet; - + S32 available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet; + S32 buttons_required_width = 0; //How many room will take shown buttons if (available_width > 0 && processShowButton(mGesturePanel, &available_width)) { mResizeState |= RS_BUTTON_GESTURES | compensative_view_item_mask; delta_width -= mGesturePanel->getRect().getWidth(); - compensative_delta_width -= mGesturePanel->getRect().getWidth(); + buttons_required_width += mGesturePanel->getRect().getWidth(); lldebugs << "RS_BUTTON_GESTURES" - << ", compensative_delta_width: " << compensative_delta_width + << ", buttons_required_width: " << buttons_required_width << ", delta_width: " << delta_width << llendl; showGestureButton(true); @@ -569,10 +570,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_MOVEMENT | compensative_view_item_mask; delta_width -= mMovementPanel->getRect().getWidth(); - compensative_delta_width -= mMovementPanel->getRect().getWidth(); + buttons_required_width += mMovementPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_MOVEMENT" - << ", compensative_delta_width: " << compensative_delta_width + << ", buttons_required_width: " << buttons_required_width << ", delta_width: " << delta_width << llendl; showMoveButton(true); @@ -582,10 +583,10 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_CAMERA | compensative_view_item_mask; delta_width -= mCamPanel->getRect().getWidth(); - compensative_delta_width -= mCamPanel->getRect().getWidth(); + buttons_required_width += mCamPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_CAMERA " - << ", compensative_delta_width: " << compensative_delta_width + << ", buttons_required_width: " << buttons_required_width << ", delta_width: " << delta_width << llendl; showCameraButton(true); @@ -595,51 +596,55 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) { mResizeState |= RS_BUTTON_SNAPSHOT | compensative_view_item_mask; delta_width -= mSnapshotPanel->getRect().getWidth(); - compensative_delta_width -= mSnapshotPanel->getRect().getWidth(); + buttons_required_width += mSnapshotPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_SNAPSHOT" - << ", compensative_delta_width: " << compensative_delta_width + << ", buttons_required_width: " << buttons_required_width << ", delta_width: " << delta_width << llendl; showSnapshotButton(true); } - if (compensative_delta_width != 0) + S32 total_delta_width = width - height; + + // if we have to show some buttons but whidth increasing is not enough... + if (buttons_required_width > 0 && total_delta_width < buttons_required_width) { - S32 required_to_process_width = -compensative_delta_width; - S32 total_delta_width = width - height; + // ... let's shrink nearby chat & chiclet panels + S32 required_to_process_width = buttons_required_width; // 1. use delta width of resizing required_to_process_width -= total_delta_width; - // 2. use delta width of chatbar - - - S32 chatbar_compensative_delta_width = required_to_process_width; - if (available_width_chat < chatbar_compensative_delta_width) + // 2. use delta width available via decreasing of nearby chat panel + S32 chatbar_shrink_width = required_to_process_width; + if (chatbar_available_shrink_width < chatbar_shrink_width) { - chatbar_compensative_delta_width = available_width_chat; + chatbar_shrink_width = chatbar_available_shrink_width; } log(compansative_view, "increase width: before applying compensative width: "); - compansative_view->reshape(compansative_view->getRect().getWidth() - chatbar_compensative_delta_width, compansative_view->getRect().getHeight() ); + compansative_view->reshape(compansative_view->getRect().getWidth() - chatbar_shrink_width, compansative_view->getRect().getHeight() ); if (compansative_view) log(compansative_view, "after applying compensative width: "); - lldebugs << chatbar_compensative_delta_width << llendl; + lldebugs << chatbar_shrink_width << llendl; - // 3. use delta width of chiclet panel - required_to_process_width -= chatbar_compensative_delta_width; + // 3. use delta width available via decreasing of chiclet panel + required_to_process_width -= chatbar_shrink_width; - mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); - log(mChicletPanel, "after applying compensative width for chiclets: "); - lldebugs << required_to_process_width << llendl; + if (required_to_process_width > 0) + { + mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); + log(mChicletPanel, "after applying compensative width for chiclets: "); + lldebugs << required_to_process_width << llendl; + } } - - if (delta_width > 0 && chatbar_panel_width < chatbar_panel_max_width) +// TODO: mantipov: probably need delta_width -= buttons_required_width & remove calculating from the buttons processing + // how many space can nearby chat take? + S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); + if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) { mResizeState |= RS_CHATBAR_INPUT; - // how many space can nearby chat take? - S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_; S32 delta_panel = llmin(delta_width, delta_panel_max); delta_width -= delta_panel_max; -- cgit v1.3 From 9ab02a68bbb735f89d4c633697a7917ca2fa3839 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 11 Nov 2009 13:53:04 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Code refactored: - move calculating of buttons_required_width inside processShowButton(); - remove changing of delta_width out of processing each button while increasing width --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 61 +++++++++++++++--------------------------- indra/newview/llbottomtray.h | 4 +-- 2 files changed, 23 insertions(+), 42 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 908fe15be6..0ebf9947e3 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -348,15 +348,14 @@ void LLBottomTray::verifyChildControlsSizes() #define __FEATURE_EXT_991 void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { - static S32 depth = 0; -if (0 == depth) lldebugs << "****************************************" << llendl; + lldebugs << "****************************************" << llendl; - S32 prev_width = getRect().getWidth(); - lldebugs << "Reshaping: depth: " << ++depth + S32 current_width = getRect().getWidth(); + lldebugs << "Reshaping: " << ", width: " << width << ", height: " << height << ", called_from_parent: " << called_from_parent - << ", cur width: " << prev_width + << ", cur width: " << current_width << ", cur height: " << getRect().getHeight() << llendl; @@ -365,17 +364,9 @@ if (0 == depth) lldebugs << "****************************************" << llendl if (mChicletPanel && mToolbarStack && mNearbyChatBar) { - verifyChildControlsSizes(); - updateResizeState(width, prev_width); - - if (RS_NORESIZE != mResizeState) - { - -// mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, mResizeState & RS_CHICLET_PANEL); mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); - -// mToolbarStack->updatePanelAutoResize(PANEL_CHATBAR_NAME, mResizeState & RS_CHATBAR_INPUT); - } + verifyChildControlsSizes(); + updateResizeState(width, current_width); } LLPanel::reshape(width, height, called_from_parent); @@ -383,20 +374,18 @@ if (0 == depth) lldebugs << "****************************************" << llendl if (mNearbyChatBar) log(mNearbyChatBar, "after"); if (mChicletPanel) log(mChicletPanel, "after"); - - --depth; } -void LLBottomTray::updateResizeState(S32 width, S32 height) +void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) { mResizeState = RS_NORESIZE; static MASK prev_resize_state = mResizeState; MASK compensative_view_item_mask = RS_CHATBAR_INPUT; LLPanel* compansative_view = mNearbyChatBar; - S32 delta_width = width - height; + S32 delta_width = new_width - cur_width; // if (delta_width == 0) return; - bool shrink = width < height; + bool shrink = new_width < cur_width; const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); @@ -554,58 +543,46 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; S32 available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet; S32 buttons_required_width = 0; //How many room will take shown buttons - if (available_width > 0 && processShowButton(mGesturePanel, &available_width)) + if (available_width > 0 && processShowButton(mGesturePanel, &available_width, &buttons_required_width)) { mResizeState |= RS_BUTTON_GESTURES | compensative_view_item_mask; - delta_width -= mGesturePanel->getRect().getWidth(); - buttons_required_width += mGesturePanel->getRect().getWidth(); lldebugs << "RS_BUTTON_GESTURES" << ", buttons_required_width: " << buttons_required_width - << ", delta_width: " << delta_width << llendl; showGestureButton(true); } - if (available_width > 0 && processShowButton(mMovementPanel, &available_width)) + if (available_width > 0 && processShowButton(mMovementPanel, &available_width, &buttons_required_width)) { mResizeState |= RS_BUTTON_MOVEMENT | compensative_view_item_mask; - delta_width -= mMovementPanel->getRect().getWidth(); - buttons_required_width += mMovementPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_MOVEMENT" << ", buttons_required_width: " << buttons_required_width - << ", delta_width: " << delta_width << llendl; showMoveButton(true); } - if (available_width > 0 && processShowButton(mCamPanel, &available_width)) + if (available_width > 0 && processShowButton(mCamPanel, &available_width, &buttons_required_width)) { mResizeState |= RS_BUTTON_CAMERA | compensative_view_item_mask; - delta_width -= mCamPanel->getRect().getWidth(); - buttons_required_width += mCamPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_CAMERA " << ", buttons_required_width: " << buttons_required_width - << ", delta_width: " << delta_width << llendl; showCameraButton(true); } - if (available_width > 0 && processShowButton(mSnapshotPanel, &available_width)) + if (available_width > 0 && processShowButton(mSnapshotPanel, &available_width, &buttons_required_width)) { mResizeState |= RS_BUTTON_SNAPSHOT | compensative_view_item_mask; - delta_width -= mSnapshotPanel->getRect().getWidth(); - buttons_required_width += mSnapshotPanel->getRect().getWidth(); lldebugs << "RS_BUTTON_SNAPSHOT" << ", buttons_required_width: " << buttons_required_width - << ", delta_width: " << delta_width << llendl; showSnapshotButton(true); } - S32 total_delta_width = width - height; + S32 total_delta_width = new_width - cur_width; // if we have to show some buttons but whidth increasing is not enough... if (buttons_required_width > 0 && total_delta_width < buttons_required_width) @@ -639,8 +616,11 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) } } -// TODO: mantipov: probably need delta_width -= buttons_required_width & remove calculating from the buttons processing - // how many space can nearby chat take? + + // shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels + delta_width -= buttons_required_width; + + // how many space can nearby chatbar take? S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) { @@ -661,7 +641,7 @@ void LLBottomTray::updateResizeState(S32 width, S32 height) lldebugs << "New resize state: " << mResizeState << llendl; } -bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width) +bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width, S32* buttons_required_width) { bool can_be_shown = canButtonBeShown(panel); if (can_be_shown) @@ -672,6 +652,7 @@ bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width) if (can_be_shown) { *available_width -= required_width; + *buttons_required_width += required_width; } } diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 4a763e6c7c..509f8b1e41 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -84,10 +84,10 @@ public: private: - void updateResizeState(S32 width, S32 height); + void updateResizeState(S32 new_width, S32 cur_width); void verifyChildControlsSizes(); void log(LLView* panel, const std::string& descr); - bool processShowButton(LLPanel* panel, S32* available_width); + bool processShowButton(LLPanel* panel, S32* available_width, S32* buttons_required_width); bool canButtonBeShown(LLPanel* panel) const; MASK mResizeState; -- cgit v1.3 From 3862e9721906d2bbdf61cfcc4d6970a24ce7e6e0 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 11 Nov 2009 16:17:29 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Code refactored: - processShowButton() now gets type of buttons should be shown instead of object - removed unnecessary code --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 98 ++++++++++++++++++++---------------------- indra/newview/llbottomtray.h | 18 +++++++- 2 files changed, 63 insertions(+), 53 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 0ebf9947e3..08b1847887 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -75,6 +75,8 @@ LLBottomTray::LLBottomTray(const LLSD&) //destroyed LLBottomTray requires some subsystems that are long gone LLUI::getRootView()->addChild(this); + initStateProcessedObjectMap(); + // Necessary for focus movement among child controls setFocusRoot(TRUE); } @@ -255,21 +257,6 @@ void LLBottomTray::showSnapshotButton(BOOL visible) mSnapshotPanel->setVisible(visible); } -typedef enum e_resize_status_type -{ - RS_NORESIZE = 0x0000 - , RS_CHICLET_PANEL = 0x0001 - , RS_CHATBAR_INPUT = 0x0002 - , RS_BUTTON_SNAPSHOT = 0x0004 - , RS_BUTTON_CAMERA = 0x0008 - , RS_BUTTON_MOVEMENT = 0x0010 - , RS_BUTTON_GESTURES = 0x0020 - , RS_BUTTON_SPEAK = 0x0040 - , RS_RESIZABLE_BUTTONS = /*RS_BUTTON_SNAPSHOT | */RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES -}EResizeState; - - - namespace { const std::string& PANEL_CHICLET_NAME = "chiclet_list_panel"; @@ -306,7 +293,7 @@ void LLBottomTray::log(LLView* panel, const std::string& descr) { if (NULL == panel) return; LLView* layout = panel->getParent(); - llwarns << descr << ": " + lldebugs << descr << ": " << "panel: " << panel->getName() << ", rect: " << panel->getRect() @@ -379,7 +366,6 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) { mResizeState = RS_NORESIZE; - static MASK prev_resize_state = mResizeState; MASK compensative_view_item_mask = RS_CHATBAR_INPUT; LLPanel* compansative_view = mNearbyChatBar; @@ -543,43 +529,28 @@ void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; S32 available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet; S32 buttons_required_width = 0; //How many room will take shown buttons - if (available_width > 0 && processShowButton(mGesturePanel, &available_width, &buttons_required_width)) + if (available_width > 0) { - mResizeState |= RS_BUTTON_GESTURES | compensative_view_item_mask; - lldebugs << "RS_BUTTON_GESTURES" - << ", buttons_required_width: " << buttons_required_width - << llendl; - showGestureButton(true); + lldebugs << "Trying to process: RS_BUTTON_GESTURES" << llendl; + processShowButton(RS_BUTTON_GESTURES, &available_width, &buttons_required_width); } - if (available_width > 0 && processShowButton(mMovementPanel, &available_width, &buttons_required_width)) + if (available_width > 0) { - mResizeState |= RS_BUTTON_MOVEMENT | compensative_view_item_mask; - - lldebugs << "RS_BUTTON_MOVEMENT" - << ", buttons_required_width: " << buttons_required_width - << llendl; - showMoveButton(true); + lldebugs << "Trying to process: RS_BUTTON_MOVEMENT" << llendl; + processShowButton(RS_BUTTON_MOVEMENT, &available_width, &buttons_required_width); } - if (available_width > 0 && processShowButton(mCamPanel, &available_width, &buttons_required_width)) + if (available_width > 0) { - mResizeState |= RS_BUTTON_CAMERA | compensative_view_item_mask; - - lldebugs << "RS_BUTTON_CAMERA " - << ", buttons_required_width: " << buttons_required_width - << llendl; - showCameraButton(true); + lldebugs << "Trying to process: RS_BUTTON_CAMERA" << llendl; + processShowButton(RS_BUTTON_CAMERA, &available_width, &buttons_required_width); } - if (available_width > 0 && processShowButton(mSnapshotPanel, &available_width, &buttons_required_width)) + if (available_width > 0) { - mResizeState |= RS_BUTTON_SNAPSHOT | compensative_view_item_mask; - - lldebugs << "RS_BUTTON_SNAPSHOT" - << ", buttons_required_width: " << buttons_required_width - << llendl; - showSnapshotButton(true); + lldebugs << "Trying to process: RS_BUTTON_SNAPSHOT" << llendl; + processShowButton(RS_BUTTON_SNAPSHOT, &available_width, &buttons_required_width); } S32 total_delta_width = new_width - cur_width; @@ -587,6 +558,8 @@ void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) // if we have to show some buttons but whidth increasing is not enough... if (buttons_required_width > 0 && total_delta_width < buttons_required_width) { + mResizeState |= compensative_view_item_mask; + // ... let's shrink nearby chat & chiclet panels S32 required_to_process_width = buttons_required_width; @@ -630,19 +603,19 @@ void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) delta_width -= delta_panel_max; mNearbyChatBar->reshape(chatbar_panel_width_ + delta_panel, mNearbyChatBar->getRect().getHeight()); } - - if (delta_width > 0) - { - mResizeState |= RS_CHICLET_PANEL; - } } - prev_resize_state = mResizeState; lldebugs << "New resize state: " << mResizeState << llendl; } -bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width, S32* buttons_required_width) +bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width) { + LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to process for state: " << shown_object_type << llendl; + return false; + } bool can_be_shown = canButtonBeShown(panel); if (can_be_shown) { @@ -653,8 +626,21 @@ bool LLBottomTray::processShowButton(LLPanel* panel, S32* available_width, S32* { *available_width -= required_width; *buttons_required_width += required_width; - } + switch (shown_object_type) + { + case RS_BUTTON_GESTURES: showGestureButton(true); break; + case RS_BUTTON_MOVEMENT: showMoveButton(true); break; + case RS_BUTTON_CAMERA: showCameraButton(true); break; + case RS_BUTTON_SNAPSHOT: showSnapshotButton(true); break; + default: + llwarns << "Unexpected type of button to be shown: " << shown_object_type << llendl; + } + + lldebugs << "processing object type: " << shown_object_type + << ", buttons_required_width: " << buttons_required_width + << llendl; + } } return can_be_shown; } @@ -668,4 +654,12 @@ bool LLBottomTray::canButtonBeShown(LLPanel* panel) const } return can_be_shown; } + +void LLBottomTray::initStateProcessedObjectMap() +{ + 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)); +} //EOF diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 509f8b1e41..c2eeef239c 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -83,15 +83,31 @@ public: void showSnapshotButton(BOOL visible); private: + typedef enum e_resize_status_type + { + RS_NORESIZE = 0x0000 + , RS_CHICLET_PANEL = 0x0001 + , RS_CHATBAR_INPUT = 0x0002 + , RS_BUTTON_SNAPSHOT = 0x0004 + , RS_BUTTON_CAMERA = 0x0008 + , RS_BUTTON_MOVEMENT = 0x0010 + , RS_BUTTON_GESTURES = 0x0020 + , RS_BUTTON_SPEAK = 0x0040 + , RS_RESIZABLE_BUTTONS = /*RS_BUTTON_SNAPSHOT | */RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES + }EResizeState; void updateResizeState(S32 new_width, S32 cur_width); void verifyChildControlsSizes(); void log(LLView* panel, const std::string& descr); - bool processShowButton(LLPanel* panel, S32* available_width, S32* buttons_required_width); + bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); bool canButtonBeShown(LLPanel* panel) const; + void initStateProcessedObjectMap(); MASK mResizeState; + typedef std::map state_object_map_t; + state_object_map_t mStateProcessedObjectMap; + protected: LLBottomTray(const LLSD& key = LLSD()); -- cgit v1.3 From 454c02102c71e39fc0d844a1ae8bd70873de01a1 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Wed, 11 Nov 2009 16:42:18 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Code refactored: - moved code to process width increasing into separate method --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 140 +++++++++++++++++++++++------------------ indra/newview/llbottomtray.h | 2 + 2 files changed, 80 insertions(+), 62 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 08b1847887..9ff6c05acc 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -525,87 +525,103 @@ void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) // bottom tray is widen else { - S32 chatbar_available_shrink_width = chatbar_panel_width - chatbar_panel_min_width; - S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; - S32 available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet; - S32 buttons_required_width = 0; //How many room will take shown buttons - if (available_width > 0) - { - lldebugs << "Trying to process: RS_BUTTON_GESTURES" << llendl; - processShowButton(RS_BUTTON_GESTURES, &available_width, &buttons_required_width); - } + processWidthIncreased(delta_width); + } - if (available_width > 0) - { - lldebugs << "Trying to process: RS_BUTTON_MOVEMENT" << llendl; - processShowButton(RS_BUTTON_MOVEMENT, &available_width, &buttons_required_width); - } + lldebugs << "New resize state: " << mResizeState << llendl; +} - if (available_width > 0) - { - lldebugs << "Trying to process: RS_BUTTON_CAMERA" << llendl; - processShowButton(RS_BUTTON_CAMERA, &available_width, &buttons_required_width); - } +void LLBottomTray::processWidthDecreased(S32 delta_width) +{ - if (available_width > 0) - { - lldebugs << "Trying to process: RS_BUTTON_SNAPSHOT" << llendl; - processShowButton(RS_BUTTON_SNAPSHOT, &available_width, &buttons_required_width); - } +} - S32 total_delta_width = new_width - cur_width; +void LLBottomTray::processWidthIncreased(S32 delta_width) +{ + const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); + const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); - // if we have to show some buttons but whidth increasing is not enough... - if (buttons_required_width > 0 && total_delta_width < buttons_required_width) - { - mResizeState |= compensative_view_item_mask; + const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); + const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); + const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); - // ... let's shrink nearby chat & chiclet panels - S32 required_to_process_width = buttons_required_width; + const S32 chatbar_available_shrink_width = chatbar_panel_width - chatbar_panel_min_width; + const S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; - // 1. use delta width of resizing - required_to_process_width -= total_delta_width; + // how many room we have to show hidden buttons + S32 available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet; + S32 buttons_required_width = 0; //How many room will take shown buttons - // 2. use delta width available via decreasing of nearby chat panel - S32 chatbar_shrink_width = required_to_process_width; - if (chatbar_available_shrink_width < chatbar_shrink_width) - { - chatbar_shrink_width = chatbar_available_shrink_width; - } + if (available_width > 0) + { + lldebugs << "Trying to process: RS_BUTTON_GESTURES" << llendl; + processShowButton(RS_BUTTON_GESTURES, &available_width, &buttons_required_width); + } - log(compansative_view, "increase width: before applying compensative width: "); - compansative_view->reshape(compansative_view->getRect().getWidth() - chatbar_shrink_width, compansative_view->getRect().getHeight() ); - if (compansative_view) log(compansative_view, "after applying compensative width: "); - lldebugs << chatbar_shrink_width << llendl; + if (available_width > 0) + { + lldebugs << "Trying to process: RS_BUTTON_MOVEMENT" << llendl; + processShowButton(RS_BUTTON_MOVEMENT, &available_width, &buttons_required_width); + } - // 3. use delta width available via decreasing of chiclet panel - required_to_process_width -= chatbar_shrink_width; + if (available_width > 0) + { + lldebugs << "Trying to process: RS_BUTTON_CAMERA" << llendl; + processShowButton(RS_BUTTON_CAMERA, &available_width, &buttons_required_width); + } - if (required_to_process_width > 0) - { - mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); - log(mChicletPanel, "after applying compensative width for chiclets: "); - lldebugs << required_to_process_width << llendl; - } + if (available_width > 0) + { + lldebugs << "Trying to process: RS_BUTTON_SNAPSHOT" << llendl; + processShowButton(RS_BUTTON_SNAPSHOT, &available_width, &buttons_required_width); + } + // if we have to show some buttons but whidth increasing is not enough... + if (buttons_required_width > 0 && delta_width < buttons_required_width) + { + // ... let's shrink nearby chat & chiclet panels + S32 required_to_process_width = buttons_required_width; + + // 1. use delta width of resizing + required_to_process_width -= delta_width; + + // 2. use width available via decreasing of nearby chat panel + S32 chatbar_shrink_width = required_to_process_width; + if (chatbar_available_shrink_width < chatbar_shrink_width) + { + chatbar_shrink_width = chatbar_available_shrink_width; } - // shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels - delta_width -= buttons_required_width; + log(mNearbyChatBar, "increase width: before applying compensative width: "); + mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - chatbar_shrink_width, mNearbyChatBar->getRect().getHeight() ); + if (mNearbyChatBar) log(mNearbyChatBar, "after applying compensative width: "); + lldebugs << chatbar_shrink_width << llendl; + + // 3. use width available via decreasing of chiclet panel + required_to_process_width -= chatbar_shrink_width; - // how many space can nearby chatbar take? - S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); - if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) + if (required_to_process_width > 0) { - mResizeState |= RS_CHATBAR_INPUT; - S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_; - S32 delta_panel = llmin(delta_width, delta_panel_max); - delta_width -= delta_panel_max; - mNearbyChatBar->reshape(chatbar_panel_width_ + delta_panel, mNearbyChatBar->getRect().getHeight()); + mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); + log(mChicletPanel, "after applying compensative width for chiclets: "); + lldebugs << required_to_process_width << llendl; } + } - lldebugs << "New resize state: " << mResizeState << llendl; + // shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels + delta_width -= buttons_required_width; + + // how many space can nearby chatbar take? + S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); + if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) + { + mResizeState |= RS_CHATBAR_INPUT; + S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_; + S32 delta_panel = llmin(delta_width, delta_panel_max); + delta_width -= delta_panel_max; + mNearbyChatBar->reshape(chatbar_panel_width_ + delta_panel, mNearbyChatBar->getRect().getHeight()); + } } bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width) diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index c2eeef239c..6509fea63d 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -98,6 +98,8 @@ private: void updateResizeState(S32 new_width, S32 cur_width); void verifyChildControlsSizes(); + void processWidthDecreased(S32 delta_width); + void processWidthIncreased(S32 delta_width); void log(LLView* panel, const std::string& descr); bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); bool canButtonBeShown(LLPanel* panel) const; -- cgit v1.3 From fcb99c30407d6ccbae17ea4c3d17a65037ca6a5c Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 12 Nov 2009 17:43:23 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Code refuctored: - moved code to process Borrom Bar shrinking into separate method - unified code to process a hiding of the Bottom Tray's buttons Code is ready to process shrink after min width is reached & be synchronized with user hidden buttons --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 264 ++++++++++++++++++++--------------------- indra/newview/llbottomtray.h | 2 + 2 files changed, 128 insertions(+), 138 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 204d7d23fa..291f645ea2 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -238,22 +238,22 @@ void LLBottomTray::showBottomTrayContextMenu(S32 x, S32 y, MASK mask) void LLBottomTray::showGestureButton(BOOL visible) { - mGesturePanel->setVisible(visible); + showTrayButton(RS_BUTTON_GESTURES, visible); } void LLBottomTray::showMoveButton(BOOL visible) { - mMovementPanel->setVisible(visible); + showTrayButton(RS_BUTTON_MOVEMENT, visible); } void LLBottomTray::showCameraButton(BOOL visible) { - mCamPanel->setVisible(visible); + showTrayButton(RS_BUTTON_CAMERA, visible); } void LLBottomTray::showSnapshotButton(BOOL visible) { - mSnapshotPanel->setVisible(visible); + showTrayButton(RS_BUTTON_SNAPSHOT, visible); } namespace @@ -365,8 +365,6 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) { mResizeState = RS_NORESIZE; - MASK compensative_view_item_mask = RS_CHATBAR_INPUT; - LLPanel* compansative_view = mNearbyChatBar; S32 delta_width = new_width - cur_width; // if (delta_width == 0) return; @@ -386,153 +384,113 @@ void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) << ", chiclet_panel_min_width: " << chiclet_panel_min_width << llendl; - bool still_should_be_processed = true; // bottom tray is narrowed if (shrink) { - S32 compensative_delta_width = 0; - if (chiclet_panel_width > chiclet_panel_min_width) - { - // we have some space to decrease chiclet panel - S32 panel_delta_min = chiclet_panel_width - chiclet_panel_min_width; - mResizeState |= RS_CHICLET_PANEL; - - S32 delta_panel = llmin(-delta_width, panel_delta_min); + processWidthDecreased(delta_width); + } + // bottom tray is widen + else + { + processWidthIncreased(delta_width); + } - lldebugs << "delta_width: " << delta_width - << ", panel_delta_min: " << panel_delta_min - << ", delta_panel: " << delta_panel - << llendl; + lldebugs << "New resize state: " << mResizeState << llendl; +} - // is chiclet panel width enough to process resizing? - delta_width += panel_delta_min; +void LLBottomTray::processWidthDecreased(S32 delta_width) +{ + bool still_should_be_processed = true; - still_should_be_processed = delta_width < 0; + const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); + const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); - mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - delta_panel, mChicletPanel->getParent()->getRect().getHeight()); - log(mChicletPanel, "after processing panel decreasing via chiclet panel"); + if (chiclet_panel_width > chiclet_panel_min_width) + { + // we have some space to decrease chiclet panel + S32 panel_delta_min = chiclet_panel_width - chiclet_panel_min_width; + mResizeState |= RS_CHICLET_PANEL; - lldebugs << "RS_CHICLET_PANEL" - << ", delta_width: " << delta_width - << llendl; - } - - if (still_should_be_processed && chatbar_panel_width > chatbar_panel_min_width) - { - // we have some space to decrease chatbar panel - S32 panel_delta_min = chatbar_panel_width - chatbar_panel_min_width; - mResizeState |= RS_CHATBAR_INPUT; + S32 delta_panel = llmin(-delta_width, panel_delta_min); - S32 delta_panel = llmin(-delta_width, panel_delta_min); + lldebugs << "delta_width: " << delta_width + << ", panel_delta_min: " << panel_delta_min + << ", delta_panel: " << delta_panel + << llendl; - // is chatbar panel width enough to process resizing? - delta_width += panel_delta_min; - + // is chiclet panel width enough to process resizing? + delta_width += panel_delta_min; - still_should_be_processed = delta_width < 0; + still_should_be_processed = delta_width < 0; - mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mNearbyChatBar->getRect().getHeight()); + mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - delta_panel, mChicletPanel->getParent()->getRect().getHeight()); + log(mChicletPanel, "after processing panel decreasing via chiclet panel"); - lldebugs << "RS_CHATBAR_INPUT" - << ", delta_panel: " << delta_panel - << ", delta_width: " << delta_width - << llendl; + lldebugs << "RS_CHICLET_PANEL" + << ", delta_width: " << delta_width + << llendl; + } - log(mChicletPanel, "after nearby was processed"); + const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); + const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); + if (still_should_be_processed && chatbar_panel_width > chatbar_panel_min_width) + { + // we have some space to decrease chatbar panel + S32 panel_delta_min = chatbar_panel_width - chatbar_panel_min_width; + mResizeState |= RS_CHATBAR_INPUT; - } - if (still_should_be_processed) - { - mResizeState |= compensative_view_item_mask; + S32 delta_panel = llmin(-delta_width, panel_delta_min); - if (mSnapshotPanel->getVisible()) - { - mResizeState |= RS_BUTTON_SNAPSHOT; - delta_width += mSnapshotPanel->getRect().getWidth(); - - if (delta_width > 0) - { - compensative_delta_width += delta_width; - } - lldebugs << "RS_BUTTON_SNAPSHOT" - << ", compensative_delta_width: " << compensative_delta_width - << ", delta_width: " << delta_width - << llendl; - showSnapshotButton(false); - } + // is chatbar panel width enough to process resizing? + delta_width += panel_delta_min; - if (delta_width < 0 && mCamPanel->getVisible()) - { - mResizeState |= RS_BUTTON_CAMERA; - delta_width += mCamPanel->getRect().getWidth(); - if (delta_width > 0) - { - compensative_delta_width += delta_width; - } - lldebugs << "RS_BUTTON_CAMERA" - << ", compensative_delta_width: " << compensative_delta_width - << ", delta_width: " << delta_width - << llendl; - showCameraButton(false); - } - if (delta_width < 0 && mMovementPanel->getVisible()) - { - mResizeState |= RS_BUTTON_MOVEMENT; - delta_width += mMovementPanel->getRect().getWidth(); - if (delta_width > 0) - { - compensative_delta_width += delta_width; - } - lldebugs << "RS_BUTTON_MOVEMENT" - << ", compensative_delta_width: " << compensative_delta_width - << ", delta_width: " << delta_width - << llendl; - showMoveButton(false); - } + still_should_be_processed = delta_width < 0; - if (delta_width < 0 && mGesturePanel->getVisible()) - { - mResizeState |= RS_BUTTON_GESTURES; - delta_width += mGesturePanel->getRect().getWidth(); - if (delta_width > 0) - { - compensative_delta_width += delta_width; - } - lldebugs << "RS_BUTTON_GESTURES" - << ", compensative_delta_width: " << compensative_delta_width - << ", delta_width: " << delta_width - << llendl; - showGestureButton(false); - } + mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mNearbyChatBar->getRect().getHeight()); - if (delta_width < 0) - { - llwarns << "WARNING: there is no enough room for bottom tray, resizing still should be processed" << llendl; - } + lldebugs << "RS_CHATBAR_INPUT" + << ", delta_panel: " << delta_panel + << ", delta_width: " << delta_width + << llendl; - if (compensative_delta_width != 0) - { - if (compansative_view) log(compansative_view, "before applying compensative width: "); - compansative_view->reshape(compansative_view->getRect().getWidth() + compensative_delta_width, compansative_view->getRect().getHeight() ); - if (compansative_view) log(compansative_view, "after applying compensative width: "); - lldebugs << compensative_delta_width << llendl; + log(mChicletPanel, "after nearby was processed"); - } - } } - // bottom tray is widen - else + + S32 buttons_freed_width = 0; + if (still_should_be_processed) { - processWidthIncreased(delta_width); - } + processHideButton(RS_BUTTON_SNAPSHOT, &delta_width, &buttons_freed_width); - lldebugs << "New resize state: " << mResizeState << llendl; -} + if (delta_width < 0) + { + processHideButton(RS_BUTTON_CAMERA, &delta_width, &buttons_freed_width); + } -void LLBottomTray::processWidthDecreased(S32 delta_width) -{ + if (delta_width < 0) + { + processHideButton(RS_BUTTON_MOVEMENT, &delta_width, &buttons_freed_width); + } + if (delta_width < 0) + { + processHideButton(RS_BUTTON_GESTURES, &delta_width, &buttons_freed_width); + } + + if (delta_width < 0) + { + llwarns << "WARNING: there is no enough room for bottom tray, resizing still should be processed" << llendl; + } + + if (buttons_freed_width > 0) + { + log(mNearbyChatBar, "before applying compensative width"); + mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() + buttons_freed_width, mNearbyChatBar->getRect().getHeight() ); + log(mNearbyChatBar, "after applying compensative width"); + lldebugs << buttons_freed_width << llendl; + } + } } void LLBottomTray::processWidthIncreased(S32 delta_width) @@ -591,9 +549,9 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) chatbar_shrink_width = chatbar_available_shrink_width; } - log(mNearbyChatBar, "increase width: before applying compensative width: "); + log(mNearbyChatBar, "increase width: before applying compensative width"); mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - chatbar_shrink_width, mNearbyChatBar->getRect().getHeight() ); - if (mNearbyChatBar) log(mNearbyChatBar, "after applying compensative width: "); + if (mNearbyChatBar) log(mNearbyChatBar, "after applying compensative width"); lldebugs << chatbar_shrink_width << llendl; // 3. use width available via decreasing of chiclet panel @@ -642,24 +600,42 @@ bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* availa *available_width -= required_width; *buttons_required_width += required_width; - switch (shown_object_type) - { - case RS_BUTTON_GESTURES: showGestureButton(true); break; - case RS_BUTTON_MOVEMENT: showMoveButton(true); break; - case RS_BUTTON_CAMERA: showCameraButton(true); break; - case RS_BUTTON_SNAPSHOT: showSnapshotButton(true); break; - default: - llwarns << "Unexpected type of button to be shown: " << shown_object_type << llendl; - } + showTrayButton(shown_object_type, true); lldebugs << "processing object type: " << shown_object_type - << ", buttons_required_width: " << buttons_required_width + << ", buttons_required_width: " << *buttons_required_width << llendl; } } return can_be_shown; } +void LLBottomTray::processHideButton(EResizeState shown_object_type, S32* required_width, S32* buttons_freed_width) +{ + LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to process for state: " << shown_object_type << llendl; + return; + } + + if (panel->getVisible()) + { + *required_width += panel->getRect().getWidth(); + + if (*required_width > 0) + { + *buttons_freed_width += *required_width; + } + + showTrayButton(shown_object_type, false); + + lldebugs << "processing object type: " << shown_object_type + << ", buttons_freed_width: " << *buttons_freed_width + << llendl; + } +} + bool LLBottomTray::canButtonBeShown(LLPanel* panel) const { bool can_be_shown = !panel->getVisible(); @@ -677,4 +653,16 @@ void LLBottomTray::initStateProcessedObjectMap() mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_CAMERA, mCamPanel)); mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_SNAPSHOT, mSnapshotPanel)); } + +void LLBottomTray::showTrayButton(EResizeState shown_object_type, bool visible) +{ + LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to show for state: " << shown_object_type << llendl; + return; + } + + panel->setVisible(visible); +} //EOF diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 6509fea63d..2972a2b1ac 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -102,8 +102,10 @@ private: void processWidthIncreased(S32 delta_width); void log(LLView* panel, const std::string& descr); bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); + void processHideButton(EResizeState shown_object_type, S32* required_width, S32* buttons_freed_width); bool canButtonBeShown(LLPanel* panel) const; void initStateProcessedObjectMap(); + void showTrayButton(EResizeState shown_object_type, bool visible); MASK mResizeState; -- cgit v1.3 From fc9741f9ae1b0090db24847b134c193686f6ae59 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 13 Nov 2009 14:32:23 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Implemented functionality to process shrink after bottom tray min width is reached --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 121 ++++++++++++--------- indra/newview/llbottomtray.h | 2 +- .../skins/default/xui/en/panel_bottomtray.xml | 2 +- 3 files changed, 70 insertions(+), 55 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 291f645ea2..2b7a5bc8a9 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -331,74 +331,87 @@ void LLBottomTray::verifyChildControlsSizes() mNearbyChatBar->setRect(rect); } } -#define __FEATURE_EXT_991 + void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { - lldebugs << "****************************************" << llendl; + static S32 debug_calling_number = 0; + lldebugs << "**************************************** " << ++debug_calling_number << llendl; S32 current_width = getRect().getWidth(); + S32 delta_width = width - current_width; lldebugs << "Reshaping: " << ", width: " << width - << ", height: " << height - << ", called_from_parent: " << called_from_parent << ", cur width: " << current_width - << ", cur height: " << getRect().getHeight() + << ", delta_width: " << delta_width + << ", called_from_parent: " << called_from_parent << llendl; if (mNearbyChatBar) log(mNearbyChatBar, "before"); if (mChicletPanel) log(mChicletPanel, "before"); + // stores width size on which bottom tray is less than width required by its children. EXT-991 + static S32 extra_shrink_width = 0; + bool should_be_reshaped = true; + if (mChicletPanel && mToolbarStack && mNearbyChatBar) { mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); verifyChildControlsSizes(); - updateResizeState(width, current_width); - } - - LLPanel::reshape(width, height, called_from_parent); - - - if (mNearbyChatBar) log(mNearbyChatBar, "after"); - if (mChicletPanel) log(mChicletPanel, "after"); -} - -void LLBottomTray::updateResizeState(S32 new_width, S32 cur_width) -{ - mResizeState = RS_NORESIZE; - - S32 delta_width = new_width - cur_width; -// if (delta_width == 0) return; - bool shrink = new_width < cur_width; - - const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); - const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); - - const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); - const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); - const S32 chatbar_panel_max_width = mNearbyChatBar->getMaxWidth(); - lldebugs << "chatbar_panel_width: " << chatbar_panel_width - << ", chatbar_panel_min_width: " << chatbar_panel_min_width - << ", chatbar_panel_max_width: " << chatbar_panel_max_width - << ", chiclet_panel_width: " << chiclet_panel_width - << ", chiclet_panel_min_width: " << chiclet_panel_min_width - << llendl; + // bottom tray is narrowed + if (delta_width < 0) + { + if (extra_shrink_width > 0) + { + // is world rect was extra shrunk and decreasing again only update this value + // to delta_width negative + extra_shrink_width -= delta_width; // use "-=" because delta_width is negative + should_be_reshaped = false; + } + else + { + extra_shrink_width = processWidthDecreased(delta_width); - // bottom tray is narrowed - if (shrink) - { - processWidthDecreased(delta_width); + // increase new width to extra_shrink_width value to not reshape less than bottom tray minimum + width += extra_shrink_width; + } + } + // bottom tray is widen + else + { + if (extra_shrink_width > delta_width) + { + // Less than minimum width is more than increasing (delta_width) + // only reduce it value and make no reshape + extra_shrink_width -= delta_width; + should_be_reshaped = false; + } + else + { + if (extra_shrink_width > 0) + { + // If we have some extra shrink width let's reduce delta_width & width + delta_width -= extra_shrink_width; + width -= extra_shrink_width; + extra_shrink_width = 0; + } + processWidthIncreased(delta_width); + } + } } - // bottom tray is widen - else + + lldebugs << "There is no enough width to reshape all children: " << extra_shrink_width << llendl; + if (should_be_reshaped) { - processWidthIncreased(delta_width); + lldebugs << "Reshape all children with width: " << width << llendl; + LLPanel::reshape(width, height, called_from_parent); } - lldebugs << "New resize state: " << mResizeState << llendl; + if (mNearbyChatBar) log(mNearbyChatBar, "after"); + if (mChicletPanel) log(mChicletPanel, "after"); } -void LLBottomTray::processWidthDecreased(S32 delta_width) +S32 LLBottomTray::processWidthDecreased(S32 delta_width) { bool still_should_be_processed = true; @@ -409,7 +422,6 @@ void LLBottomTray::processWidthDecreased(S32 delta_width) { // we have some space to decrease chiclet panel S32 panel_delta_min = chiclet_panel_width - chiclet_panel_min_width; - mResizeState |= RS_CHICLET_PANEL; S32 delta_panel = llmin(-delta_width, panel_delta_min); @@ -437,27 +449,25 @@ void LLBottomTray::processWidthDecreased(S32 delta_width) { // we have some space to decrease chatbar panel S32 panel_delta_min = chatbar_panel_width - chatbar_panel_min_width; - mResizeState |= RS_CHATBAR_INPUT; S32 delta_panel = llmin(-delta_width, panel_delta_min); - // is chatbar panel width enough to process resizing? + // whether chatbar panel width is enough to process resizing? delta_width += panel_delta_min; - still_should_be_processed = delta_width < 0; mNearbyChatBar->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mNearbyChatBar->getRect().getHeight()); + log(mChicletPanel, "after processing panel decreasing via nearby chatbar panel"); + lldebugs << "RS_CHATBAR_INPUT" << ", delta_panel: " << delta_panel << ", delta_width: " << delta_width << llendl; - - log(mChicletPanel, "after nearby was processed"); - } + S32 extra_shrink_width = 0; S32 buttons_freed_width = 0; if (still_should_be_processed) { @@ -480,7 +490,9 @@ void LLBottomTray::processWidthDecreased(S32 delta_width) if (delta_width < 0) { - llwarns << "WARNING: there is no enough room for bottom tray, resizing still should be processed" << llendl; + extra_shrink_width = -delta_width; + lldebugs << "There is no enough room for bottom tray, resizing still should be processed: " + << extra_shrink_width << llendl; } if (buttons_freed_width > 0) @@ -491,10 +503,14 @@ void LLBottomTray::processWidthDecreased(S32 delta_width) lldebugs << buttons_freed_width << llendl; } } + + return extra_shrink_width; } void LLBottomTray::processWidthIncreased(S32 delta_width) { + if (delta_width <= 0) return; + const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); @@ -573,7 +589,6 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) { - mResizeState |= RS_CHATBAR_INPUT; S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_; S32 delta_panel = llmin(delta_width, delta_panel_max); delta_width -= delta_panel_max; diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 2972a2b1ac..090537042b 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -98,7 +98,7 @@ private: void updateResizeState(S32 new_width, S32 cur_width); void verifyChildControlsSizes(); - void processWidthDecreased(S32 delta_width); + S32 processWidthDecreased(S32 delta_width); void processWidthIncreased(S32 delta_width); void log(LLView* panel, const std::string& descr); bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index 8188016455..3c2971797e 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -333,6 +333,6 @@ as for parent layout_panel (chiclet_list_panel) to resize bottom tray properly. min_width="4" right="-1" top="0" - width="26"/> + width="4"/> -- cgit v1.3 From 977b731dd6cb5ce0ef754633a2c95130ee016ee4 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 13 Nov 2009 17:28:19 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Implemented functionality to process Buttons hidden/shown via context menu 1. hidden buttons are not processed while resizing 2. setTrayButtonVisibleIfPossible() is implemented: * If it is impossible to show required button via context menu due to there is no enough room in bottom tray * it will no be shown. * Method also stores resize state to be processed while future bottom tray extending: * - if hidden while resizing button should be hidden it will not be shown while extending; * - if hidden via context menu button should be shown but there is no enough room for now * it will be shown while extending. --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 76 ++++++++++++++++++++++++++++++++++-------- indra/newview/llbottomtray.h | 22 ++++++++++-- 2 files changed, 81 insertions(+), 17 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 76cb31e2a6..c0ab0b27e5 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -52,6 +52,7 @@ LLBottomTray::LLBottomTray(const LLSD&) mNearbyChatBar(NULL), mToolbarStack(NULL) , mMovementButton(NULL) +, mResizeState(RS_NORESIZE) // Add more members { mFactoryMap["chat_bar"] = LLCallbackMap(LLBottomTray::createNearbyChatBar, NULL); @@ -261,22 +262,22 @@ void LLBottomTray::showBottomTrayContextMenu(S32 x, S32 y, MASK mask) void LLBottomTray::showGestureButton(BOOL visible) { - showTrayButton(RS_BUTTON_GESTURES, visible); + setTrayButtonVisibleIfPossible(RS_BUTTON_GESTURES, visible); } void LLBottomTray::showMoveButton(BOOL visible) { - showTrayButton(RS_BUTTON_MOVEMENT, visible); + setTrayButtonVisibleIfPossible(RS_BUTTON_MOVEMENT, visible); } void LLBottomTray::showCameraButton(BOOL visible) { - showTrayButton(RS_BUTTON_CAMERA, visible); + setTrayButtonVisibleIfPossible(RS_BUTTON_CAMERA, visible); } void LLBottomTray::showSnapshotButton(BOOL visible) { - showTrayButton(RS_BUTTON_SNAPSHOT, visible); + setTrayButtonVisibleIfPossible(RS_BUTTON_SNAPSHOT, visible); } namespace @@ -640,7 +641,7 @@ bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* availa lldebugs << "There is no object to process for state: " << shown_object_type << llendl; return false; } - bool can_be_shown = canButtonBeShown(panel); + bool can_be_shown = canButtonBeShown(shown_object_type); if (can_be_shown) { //validate if we have enough room to show this button @@ -651,22 +652,23 @@ bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* availa *available_width -= required_width; *buttons_required_width += required_width; - showTrayButton(shown_object_type, true); + setTrayButtonVisible(shown_object_type, true); lldebugs << "processing object type: " << shown_object_type << ", buttons_required_width: " << *buttons_required_width << llendl; + mResizeState &= ~shown_object_type; } } return can_be_shown; } -void LLBottomTray::processHideButton(EResizeState shown_object_type, S32* required_width, S32* buttons_freed_width) +void LLBottomTray::processHideButton(EResizeState processed_object_type, S32* required_width, S32* buttons_freed_width) { - LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; + LLPanel* panel = mStateProcessedObjectMap[processed_object_type]; if (NULL == panel) { - lldebugs << "There is no object to process for state: " << shown_object_type << llendl; + lldebugs << "There is no object to process for state: " << processed_object_type << llendl; return; } @@ -679,17 +681,19 @@ void LLBottomTray::processHideButton(EResizeState shown_object_type, S32* requir *buttons_freed_width += *required_width; } - showTrayButton(shown_object_type, false); + setTrayButtonVisible(processed_object_type, false); - lldebugs << "processing object type: " << shown_object_type + mResizeState |= processed_object_type; + + lldebugs << "processing object type: " << processed_object_type << ", buttons_freed_width: " << *buttons_freed_width << llendl; } } -bool LLBottomTray::canButtonBeShown(LLPanel* panel) const +bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const { - bool can_be_shown = !panel->getVisible(); + bool can_be_shown = mResizeState & processed_object_type; if (can_be_shown) { // *TODO: mantipov: synchronize with situation when button was hidden via context menu; @@ -705,7 +709,7 @@ void LLBottomTray::initStateProcessedObjectMap() mStateProcessedObjectMap.insert(std::make_pair(RS_BUTTON_SNAPSHOT, mSnapshotPanel)); } -void LLBottomTray::showTrayButton(EResizeState shown_object_type, bool visible) +void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible) { LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; if (NULL == panel) @@ -716,4 +720,48 @@ void LLBottomTray::showTrayButton(EResizeState shown_object_type, bool visible) panel->setVisible(visible); } + +void LLBottomTray::setTrayButtonVisibleIfPossible(EResizeState shown_object_type, bool visible) +{ + bool can_be_set = true; + + if (visible) + { + LLPanel* panel = mStateProcessedObjectMap[shown_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to process for state: " << shown_object_type << llendl; + return; + } + + const S32 chatbar_panel_width = mNearbyChatBar->getRect().getWidth(); + const S32 chatbar_panel_min_width = mNearbyChatBar->getMinWidth(); + + const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); + const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); + + const S32 available_width = (chatbar_panel_width - chatbar_panel_min_width) + + (chiclet_panel_width - chiclet_panel_min_width); + + const S32 required_width = panel->getRect().getWidth(); + can_be_set = available_width >= required_width; + } + + if (can_be_set) + { + setTrayButtonVisible(shown_object_type, visible); + + // if we hide the button mark it NOT to show while future bottom tray extending + if (!visible) + { + mResizeState &= ~shown_object_type; + } + } + else + { + // mark this button to show it while future bottom tray extending + mResizeState |= shown_object_type; + } +} + //EOF diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index e88cd8edde..86d341f233 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -107,10 +107,26 @@ private: void processWidthIncreased(S32 delta_width); void log(LLView* panel, const std::string& descr); bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); - void processHideButton(EResizeState shown_object_type, S32* required_width, S32* buttons_freed_width); - bool canButtonBeShown(LLPanel* panel) const; + void processHideButton(EResizeState processed_object_type, S32* required_width, S32* buttons_freed_width); + bool canButtonBeShown(EResizeState processed_object_type) const; void initStateProcessedObjectMap(); - void showTrayButton(EResizeState shown_object_type, bool visible); + + /** + * Sets passed visibility to object specified by resize type. + */ + void setTrayButtonVisible(EResizeState shown_object_type, bool visible); + + /** + * Sets passed visibility to object specified by resize type if it is possible. + * + * If it is impossible to show required button due to there is no enough room in bottom tray + * it will no be shown. Is called via context menu commands. + * Method also stores resize state to be processed while future bottom tray extending: + * - if hidden while resizing button should be hidden it will not be shown while extending; + * - if hidden via context menu button should be shown but there is no enough room for now + * it will be shown while extending. + */ + void setTrayButtonVisibleIfPossible(EResizeState shown_object_type, bool visible); MASK mResizeState; -- cgit v1.3 From 806edae08493b746edc46f3def332030f69a02df Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 13 Nov 2009 17:52:57 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Improved functionality to process Buttons showing via context menu - added new alert dialog ("BottomTrayButtonCanNotBeShown") in case when there is no enough space to show button For now it contains a such message: "Selected button can not be shown right now. The button will be shown when there is enough space for it." It should be reviewed by XUI team --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 1 + indra/newview/skins/default/xui/en/notifications.xml | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index c0ab0b27e5..dd06959472 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -761,6 +761,7 @@ void LLBottomTray::setTrayButtonVisibleIfPossible(EResizeState shown_object_type { // mark this button to show it while future bottom tray extending mResizeState |= shown_object_type; + LLNotifications::instance().add("BottomTrayButtonCanNotBeShown"); } } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index ff0cd7ffeb..194378ea94 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -5739,6 +5739,15 @@ Are you sure you want to delete your teleport history? yestext="OK"/> + +Selected button can not be shown right now. +The button will be shown when there is enough space for it. + + + - Your CPU speed does not meet the minimum requirements. -- cgit v1.3 From 8a0341f42e2ba3a91a3ad5bc355966b07ac6801f Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Fri, 13 Nov 2009 18:58:23 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) Fixed issue: "Snapshort button can appear first due to its the least width while Bottom Bar extending" - implemented ordering in which buttons can be shown: Gesture, Move, View, Snapshot. --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 21 ++++++++++++++++++++- indra/newview/llbottomtray.h | 9 +++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index dd06959472..fd711b72b0 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -696,7 +696,26 @@ bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const bool can_be_shown = mResizeState & processed_object_type; if (can_be_shown) { - // *TODO: mantipov: synchronize with situation when button was hidden via context menu; + 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; + + switch(processed_object_type) + { + 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; + } } return can_be_shown; } diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 86d341f233..974289d5e0 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -108,6 +108,13 @@ private: void log(LLView* panel, const std::string& descr); bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); void processHideButton(EResizeState processed_object_type, S32* required_width, S32* buttons_freed_width); + + /** + * Determines if specified by type object can be shown. It should be hidden by shrink before. + * + * Processes buttons a such way to show buttons in constant order: + * - Gestures, Move, View, Snapshot + */ bool canButtonBeShown(EResizeState processed_object_type) const; void initStateProcessedObjectMap(); @@ -121,6 +128,8 @@ private: * * If it is impossible to show required button due to there is no enough room in bottom tray * it will no be shown. Is called via context menu commands. + * In this case Alert Dialog will be shown to notify user about that. + * * Method also stores resize state to be processed while future bottom tray extending: * - if hidden while resizing button should be hidden it will not be shown while extending; * - if hidden via context menu button should be shown but there is no enough room for now -- cgit v1.3 From 75fe049b1817c7a04bad480ae53f42260fecba5e Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Mon, 16 Nov 2009 13:18:42 +0200 Subject: Work on major sub-task EXT-991 (Update bottom bar behavior on resize) - code cleaned up, removed commented out & unused code Functionality was not changed --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 35 ----------------------------------- indra/newview/llbottomtray.h | 2 -- indra/newview/llchiclet.cpp | 2 -- indra/newview/llnearbychatbar.cpp | 13 ------------- 4 files changed, 52 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index fd711b72b0..958dbf226a 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -317,11 +317,6 @@ BOOL LLBottomTray::postBuild() // Registering Chat Bar to receive Voice client status change notifications. gVoiceClient->addObserver(this); - if (mChicletPanel && mToolbarStack && mNearbyChatBar) - { - verifyChildControlsSizes(); - } - return TRUE; } @@ -340,35 +335,6 @@ void LLBottomTray::log(LLView* panel, const std::string& descr) ; } -void LLBottomTray::verifyChildControlsSizes() -{ - LLRect rect = mChicletPanel->getRect(); - /* - if (rect.getWidth() < mChicletPanel->getMinWidth()) - { - llwarns << "QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ: chiclet panel less then min" << llendl; - mChicletPanel->reshape(mChicletPanel->getMinWidth(), rect.getHeight()); - } -*/ - rect = mNearbyChatBar->getRect(); -/* - if (rect.getWidth() < mNearbyChatBar->getMinWidth()) - { - llwarns << "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW: near chat panel less then min" << llendl; - mNearbyChatBar->reshape(mNearbyChatBar->getMinWidth(), rect.getHeight()); - } - else -*/ - if (rect.getWidth() > mNearbyChatBar->getMaxWidth()) - { - llerrs << "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW: near chat panel more then max width" << llendl; - - rect.setLeftTopAndSize(rect.mLeft, rect.mTop, mNearbyChatBar->getMaxWidth(), rect.getHeight()); - mNearbyChatBar->reshape(mNearbyChatBar->getMaxWidth(), rect.getHeight()); - mNearbyChatBar->setRect(rect); - } -} - void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) { static S32 debug_calling_number = 0; @@ -393,7 +359,6 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) if (mChicletPanel && mToolbarStack && mNearbyChatBar) { mToolbarStack->updatePanelAutoResize(PANEL_CHICLET_NAME, TRUE); - verifyChildControlsSizes(); // bottom tray is narrowed if (delta_width < 0) diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 974289d5e0..8989816bfe 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -101,8 +101,6 @@ private: , RS_RESIZABLE_BUTTONS = /*RS_BUTTON_SNAPSHOT | */RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES }EResizeState; - void updateResizeState(S32 new_width, S32 cur_width); - void verifyChildControlsSizes(); S32 processWidthDecreased(S32 delta_width); void processWidthIncreased(S32 delta_width); void log(LLView* panel, const std::string& descr); diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 9e290c8c04..4078fac4ec 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -797,13 +797,11 @@ LLChicletPanel::Params::Params() chiclet_padding = 3; scrolling_offset = 40; -/* if (!min_width.isProvided()) { // min_width = 4 chiclets + 3 paddings min_width = 180 + 3*chiclet_padding; } -*/ }; LLChicletPanel::LLChicletPanel(const Params&p) diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp index 333646d2c5..8fb4ea4211 100644 --- a/indra/newview/llnearbychatbar.cpp +++ b/indra/newview/llnearbychatbar.cpp @@ -252,19 +252,6 @@ bool LLNearbyChatBar::instanceExists() void LLNearbyChatBar::draw() { -// TODO: mantipov: remove -/* - LLRect rect = getRect(); - S32 max_width = getMaxWidth(); - - if (rect.getWidth() > max_width) - { - rect.setLeftTopAndSize(rect.mLeft, rect.mTop, max_width, rect.getHeight()); - reshape(rect.getWidth(), rect.getHeight(), FALSE); - setRect(rect); - } -*/ - displaySpeakingIndicator(); LLPanel::draw(); } -- cgit v1.3 From 812d18515ddefd11fe8c5fc7f655280a231670f5 Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Tue, 17 Nov 2009 13:03:08 +0200 Subject: Completed major sub-task EXT-991 (Update bottom bar behavior on resize) - added possibility to shrink/extend buttons (gestures, move, view) while resizing - I had to add LLLayoutStack::getPanelMinSize interface to validate width of Layout panels with these buttons --HG-- branch : product-engine --- indra/llui/lllayoutstack.cpp | 13 ++ indra/llui/lllayoutstack.h | 8 ++ indra/newview/llbottomtray.cpp | 131 ++++++++++++++++++++- indra/newview/llbottomtray.h | 22 +++- .../skins/default/xui/en/panel_bottomtray.xml | 14 ++- 5 files changed, 178 insertions(+), 10 deletions(-) (limited to 'indra/newview/llbottomtray.cpp') diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 14a6ddb7e0..1fb618adee 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -413,6 +413,19 @@ void LLLayoutStack::updatePanelAutoResize(const std::string& panel_name, BOOL au } } +bool LLLayoutStack::getPanelMinSize(const std::string& panel_name, S32* min_widthp, S32* min_heightp) +{ + LayoutPanel* panel = findEmbeddedPanelByName(panel_name); + + if (panel) + { + if (min_widthp) *min_widthp = panel->mMinWidth; + if (min_heightp) *min_heightp = panel->mMinHeight; + } + + return NULL != panel; +} + static LLFastTimer::DeclareTimer FTM_UPDATE_LAYOUT("Update LayoutStacks"); void LLLayoutStack::updateLayout(BOOL force_resize) { diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 9cbcb285dc..abd5436018 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -82,6 +82,14 @@ public: void updatePanelAutoResize(const std::string& panel_name, BOOL auto_resize); + /** + * Gets minimal width and/or height of the specified by name panel. + * + * If it is necessary to get only the one dimension pass NULL for another one. + * @returns true if specified by panel_name internal panel exists, false otherwise. + */ + bool getPanelMinSize(const std::string& panel_name, S32* min_widthp, S32* min_heightp); + void updateLayout(BOOL force_resize = FALSE); static void updateClass(); diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 958dbf226a..3c34aa4fa4 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -317,6 +317,10 @@ BOOL LLBottomTray::postBuild() // Registering Chat Bar to receive Voice client status change notifications. gVoiceClient->addObserver(this); + mObjectDefaultWidthMap[RS_BUTTON_GESTURES] = mGesturePanel->getRect().getWidth(); + mObjectDefaultWidthMap[RS_BUTTON_MOVEMENT] = mMovementPanel->getRect().getWidth(); + mObjectDefaultWidthMap[RS_BUTTON_CAMERA] = mCamPanel->getRect().getWidth(); + return TRUE; } @@ -402,7 +406,6 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) } } - lldebugs << "There is no enough width to reshape all children: " << extra_shrink_width << llendl; if (should_be_reshaped) { lldebugs << "Reshape all children with width: " << width << llendl; @@ -473,7 +476,12 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) S32 buttons_freed_width = 0; if (still_should_be_processed) { - processHideButton(RS_BUTTON_SNAPSHOT, &delta_width, &buttons_freed_width); + processShrinkButtons(&delta_width); + + if (delta_width < 0) + { + processHideButton(RS_BUTTON_SNAPSHOT, &delta_width, &buttons_freed_width); + } if (delta_width < 0) { @@ -493,7 +501,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) if (delta_width < 0) { extra_shrink_width = -delta_width; - lldebugs << "There is no enough room for bottom tray, resizing still should be processed: " + llwarns << "There is no enough width to reshape all children: " << extra_shrink_width << llendl; } @@ -551,7 +559,7 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) processShowButton(RS_BUTTON_SNAPSHOT, &available_width, &buttons_required_width); } - // if we have to show some buttons but whidth increasing is not enough... + // if we have to show some buttons but width increasing is not enough... if (buttons_required_width > 0 && delta_width < buttons_required_width) { // ... let's shrink nearby chat & chiclet panels @@ -587,6 +595,8 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) // shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels delta_width -= buttons_required_width; + processExtendButtons(&delta_width); + // how many space can nearby chatbar take? S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth(); if (delta_width > 0 && chatbar_panel_width_ < chatbar_panel_max_width) @@ -656,6 +666,119 @@ void LLBottomTray::processHideButton(EResizeState processed_object_type, S32* re } } +void LLBottomTray::processShrinkButtons(S32* required_width) +{ + processShrinkButton(RS_BUTTON_CAMERA, required_width); + + if (*required_width < 0) + { + processShrinkButton(RS_BUTTON_MOVEMENT, required_width); + } + if (*required_width < 0) + { + processShrinkButton(RS_BUTTON_GESTURES, required_width); + } +} + +void LLBottomTray::processShrinkButton(EResizeState processed_object_type, /*const std::string& panel_name, */S32* required_width) +{ + LLPanel* panel = mStateProcessedObjectMap[processed_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to process for type: " << processed_object_type << llendl; + return; + } + + if (panel->getVisible()) + { + S32 panel_width = panel->getRect().getWidth(); + S32 panel_min_width = 0; + std::string panel_name = panel->getName(); + bool success = mToolbarStack->getPanelMinSize(panel_name, &panel_min_width, NULL); + S32 possible_shrink_width = panel_width - panel_min_width; + + if (!success) + { + lldebugs << "Panel was not found to get its min width: " << panel_name << llendl; + } + // we have some space to free by shrinking the button + else if (possible_shrink_width > 0) + { + // let calculate real width to shrink + + // 1. apply all possible width + *required_width += possible_shrink_width; + + // 2. it it is too much... + if (*required_width > 0) + { + // reduce applied shrunk width to the excessive value. + possible_shrink_width -= *required_width; + *required_width = 0; + } + panel->reshape(panel_width - possible_shrink_width, panel->getRect().getHeight()); + + lldebugs << "Shrunk panel: " << panel_name + << ", shrunk width: " << possible_shrink_width + << ", rest width to process: " << *required_width + << llendl; + } + } +} + + +void LLBottomTray::processExtendButtons(S32* available_width) +{ + processExtendButton(RS_BUTTON_GESTURES, available_width); + + if (*available_width > 0) + { + processExtendButton(RS_BUTTON_CAMERA, available_width); + } + if (*available_width > 0) + { + processExtendButton(RS_BUTTON_MOVEMENT, available_width); + } +} + +void LLBottomTray::processExtendButton(EResizeState processed_object_type, S32* available_width) +{ + LLPanel* panel = mStateProcessedObjectMap[processed_object_type]; + if (NULL == panel) + { + lldebugs << "There is no object to process for type: " << processed_object_type << llendl; + return; + } + + if (!panel->getVisible()) return; + + S32 panel_max_width = mObjectDefaultWidthMap[processed_object_type]; + S32 panel_width = panel->getRect().getWidth(); + S32 possible_extend_width = panel_max_width - panel_width; + + if (possible_extend_width > 0) + { + // let calculate real width to extend + + // 1. apply all possible width + *available_width -= possible_extend_width; + + // 2. it it is too much... + if (*available_width < 0) + { + // reduce applied extended width to the excessive value. + possible_extend_width += *available_width; + *available_width = 0; + } + panel->reshape(panel_width + possible_extend_width, panel->getRect().getHeight()); + + lldebugs << "Extending panel: " << panel->getName() + << ", extended width: " << possible_extend_width + << ", rest width to process: " << *available_width + << llendl; + } +} + bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const { bool can_be_shown = mResizeState & processed_object_type; diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 8989816bfe..97bcc23403 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -98,7 +98,6 @@ private: , RS_BUTTON_MOVEMENT = 0x0010 , RS_BUTTON_GESTURES = 0x0020 , RS_BUTTON_SPEAK = 0x0040 - , RS_RESIZABLE_BUTTONS = /*RS_BUTTON_SNAPSHOT | */RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES }EResizeState; S32 processWidthDecreased(S32 delta_width); @@ -107,6 +106,24 @@ private: bool processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width); void processHideButton(EResizeState processed_object_type, S32* required_width, S32* buttons_freed_width); + /** + * Shrinks shown buttons to reduce total taken space. + * + * @param - required_width - width which buttons can use to be shrunk. It is a negative value. + * It is increased on the value processed by buttons. + */ + void processShrinkButtons(S32* required_width); + void processShrinkButton(EResizeState processed_object_type, S32* required_width); + + /** + * Extends shown buttons to increase total taken space. + * + * @param - available_width - width which buttons can use to be extended. It is a positive value. + * It is decreased on the value processed by buttons. + */ + void processExtendButtons(S32* available_width); + void processExtendButton(EResizeState processed_object_type, S32* available_width); + /** * Determines if specified by type object can be shown. It should be hidden by shrink before. * @@ -140,6 +157,9 @@ private: typedef std::map state_object_map_t; state_object_map_t mStateProcessedObjectMap; + typedef std::map state_object_width_map_t; + state_object_width_map_t mObjectDefaultWidthMap; + protected: LLBottomTray(const LLSD& key = LLSD()); diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index a902f50582..d2933c0c0e 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -94,7 +94,7 @@ min_height="28" width="82" top_delta="0" - min_width="82" + min_width="52" name="gesture_panel" user_resize="false"> + tool_tip="Shows/hides gestures"> + + + min_width="49">