Skip to content
Snippets Groups Projects
Commit 4da728e7 authored by Vadim ProductEngine's avatar Vadim ProductEngine
Browse files

Merging STORM-1028

parents b5c834c6 9a518aaa
No related branches found
No related tags found
No related merge requests found
...@@ -936,15 +936,14 @@ void LLBottomTray::log(LLView* panel, const std::string& descr) ...@@ -936,15 +936,14 @@ void LLBottomTray::log(LLView* panel, const std::string& descr)
{ {
if (NULL == panel) return; if (NULL == panel) return;
LLView* layout = panel->getParent(); LLView* layout = panel->getParent();
lldebugs << descr << ": " LL_DEBUGS("Bottom Tray Rects") << descr << ": "
<< "panel: " << panel->getName() << "panel: " << panel->getName()
<< ", rect: " << panel->getRect() << ", rect: " << panel->getRect()
<< "layout: " << layout->getName() << " layout: " << layout->getName()
<< ", rect: " << layout->getRect() << ", rect: " << layout->getRect()
<< llendl << LL_ENDL;
;
} }
void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent)
...@@ -964,7 +963,9 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) ...@@ -964,7 +963,9 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent)
if (mNearbyChatBar) log(mNearbyChatBar, "before"); if (mNearbyChatBar) log(mNearbyChatBar, "before");
if (mChicletPanel) log(mChicletPanel, "before"); if (mChicletPanel) log(mChicletPanel, "before");
// stores width size on which bottom tray is less than width required by its children. EXT-991 // Difference between bottom tray width required to fit its children and the actual width. (see EXT-991)
// Positive value means that bottom tray is not wide enough.
// Negative value means that there is free space.
static S32 extra_shrink_width = 0; static S32 extra_shrink_width = 0;
bool should_be_reshaped = true; bool should_be_reshaped = true;
...@@ -986,11 +987,9 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) ...@@ -986,11 +987,9 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent)
// bottom tray is narrowed // bottom tray is narrowed
if (delta_width < 0) if (delta_width < 0)
{ {
if (extra_shrink_width > 0) if (extra_shrink_width > 0) // not enough space
{ {
// is world rect was extra shrunk and decreasing again only update this value extra_shrink_width += llabs(delta_width);
// to delta_width negative
extra_shrink_width -= delta_width; // use "-=" because delta_width is negative
should_be_reshaped = false; should_be_reshaped = false;
} }
else else
...@@ -1001,13 +1000,13 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) ...@@ -1001,13 +1000,13 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent)
width += extra_shrink_width; width += extra_shrink_width;
} }
} }
// bottom tray is widen // bottom tray is widened
else else
{ {
if (extra_shrink_width > delta_width) if (extra_shrink_width > delta_width)
{ {
// Less than minimum width is more than increasing (delta_width) // Still not enough space.
// only reduce it value and make no reshape // Only subtract the delta from the required delta and don't reshape.
extra_shrink_width -= delta_width; extra_shrink_width -= delta_width;
should_be_reshaped = false; should_be_reshaped = false;
} }
...@@ -1047,6 +1046,7 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent) ...@@ -1047,6 +1046,7 @@ void LLBottomTray::reshape(S32 width, S32 height, BOOL called_from_parent)
{ {
mDesiredNearbyChatWidth = new_width; mDesiredNearbyChatWidth = new_width;
processChatbarCustomization(new_width); processChatbarCustomization(new_width);
lldebugs << "Setting nearby chat bar width to " << new_width << " px" << llendl;
mChatBarContainer->reshape(new_width, mChatBarContainer->getRect().getHeight()); mChatBarContainer->reshape(new_width, mChatBarContainer->getRect().getHeight());
} }
needs_restore_custom_state = false; needs_restore_custom_state = false;
...@@ -1058,30 +1058,28 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) ...@@ -1058,30 +1058,28 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width)
{ {
bool still_should_be_processed = true; bool still_should_be_processed = true;
const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); const S32 chiclet_panel_shrink_headrom = getChicletPanelShrinkHeadroom();
const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth();
// There are four steps of processing width decrease. If in one of them required width was reached, // There are four steps of processing width decrease. If in one of them required width was reached,
// further are not needed. // further are not needed.
// 1. Decreasing width of chiclet panel. // 1. Decreasing width of chiclet panel.
if (chiclet_panel_width > chiclet_panel_min_width) if (chiclet_panel_shrink_headrom > 0)
{ {
// we have some space to decrease chiclet panel // we have some space to decrease chiclet panel
S32 panel_delta_min = chiclet_panel_width - chiclet_panel_min_width; S32 shrink_by = llmin(-delta_width, chiclet_panel_shrink_headrom);
S32 delta_panel = llmin(-delta_width, panel_delta_min);
lldebugs << "delta_width: " << delta_width lldebugs << "delta_width: " << delta_width
<< ", panel_delta_min: " << panel_delta_min << ", panel_delta_min: " << chiclet_panel_shrink_headrom
<< ", delta_panel: " << delta_panel << ", shrink_by: " << shrink_by
<< llendl; << llendl;
// is chiclet panel width enough to process resizing? // is chiclet panel wide enough to process resizing?
delta_width += panel_delta_min; delta_width += chiclet_panel_shrink_headrom;
still_should_be_processed = delta_width < 0; still_should_be_processed = delta_width < 0;
mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - delta_panel, mChicletPanel->getParent()->getRect().getHeight()); lldebugs << "Shrinking chiclet panel by " << shrink_by << " px" << llendl;
mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - shrink_by, mChicletPanel->getParent()->getRect().getHeight());
log(mChicletPanel, "after processing panel decreasing via chiclet panel"); log(mChicletPanel, "after processing panel decreasing via chiclet panel");
lldebugs << "RS_CHICLET_PANEL" lldebugs << "RS_CHICLET_PANEL"
...@@ -1105,7 +1103,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) ...@@ -1105,7 +1103,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width)
S32 delta_panel = llmin(-delta_width, panel_delta_min); S32 delta_panel = llmin(-delta_width, panel_delta_min);
// whether chatbar panel width is enough to process resizing? // is chatbar panel wide enough to process resizing?
delta_width += panel_delta_min; delta_width += panel_delta_min;
still_should_be_processed = delta_width < 0; still_should_be_processed = delta_width < 0;
...@@ -1113,6 +1111,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) ...@@ -1113,6 +1111,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width)
// chatbar should only be shrunk here, not stretched // chatbar should only be shrunk here, not stretched
if(delta_panel > 0) if(delta_panel > 0)
{ {
lldebugs << "Shrinking nearby chat bar by " << delta_panel << " px " << llendl;
mChatBarContainer->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mChatBarContainer->getRect().getHeight()); mChatBarContainer->reshape(mNearbyChatBar->getRect().getWidth() - delta_panel, mChatBarContainer->getRect().getHeight());
} }
...@@ -1144,6 +1143,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width) ...@@ -1144,6 +1143,7 @@ S32 LLBottomTray::processWidthDecreased(S32 delta_width)
{ {
S32 compensative_width = nearby_needed_width > buttons_freed_width ? buttons_freed_width : nearby_needed_width; S32 compensative_width = nearby_needed_width > buttons_freed_width ? buttons_freed_width : nearby_needed_width;
log(mNearbyChatBar, "before applying compensative width"); log(mNearbyChatBar, "before applying compensative width");
lldebugs << "Extending nearby chat bar by " << compensative_width << " px" << llendl;
mChatBarContainer->reshape(mChatBarContainer->getRect().getWidth() + compensative_width, mChatBarContainer->getRect().getHeight() ); mChatBarContainer->reshape(mChatBarContainer->getRect().getWidth() + compensative_width, mChatBarContainer->getRect().getHeight() );
log(mNearbyChatBar, "after applying compensative width"); log(mNearbyChatBar, "after applying compensative width");
lldebugs << buttons_freed_width << llendl; lldebugs << buttons_freed_width << llendl;
...@@ -1158,52 +1158,46 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) ...@@ -1158,52 +1158,46 @@ void LLBottomTray::processWidthIncreased(S32 delta_width)
{ {
if (delta_width <= 0) return; if (delta_width <= 0) return;
const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); // how much room we have to show hidden buttons
static const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); S32 available_width = delta_width + getChicletPanelShrinkHeadroom();
const S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; lldebugs << "Distributing (" << getChicletPanelShrinkHeadroom()
<< " + " << delta_width << ") = " << available_width << " px" << llendl;
// how many room we have to show hidden buttons // 1. Try showing buttons that have been auto-hidden.
S32 total_available_width = delta_width + available_width_chiclet; S32 processed_width = processShowButtons(available_width);
lldebugs << "processed_width = " << processed_width << ", delta_width = " << delta_width << llendl;
lldebugs << "Processing extending, available width:" lldebugs << "Available_width after showing buttons: " << available_width << llendl;
<< ", chiclets - " << available_width_chiclet
<< ", total - " << total_available_width
<< llendl;
S32 available_width = total_available_width;
processShowButtons(available_width); // If the newly shown buttons have consumed more than delta_width pixels,
// shrink the chiclet panel.
// if we have to show/extend some buttons but resized delta width is not enough...
S32 processed_width = total_available_width - available_width;
if (processed_width > delta_width) if (processed_width > delta_width)
{ {
// ... let's shrink nearby chat & chiclet panels
S32 required_to_process_width = processed_width;
// 1. use delta width of resizing // 1. use delta width of resizing
required_to_process_width -= delta_width; S32 shrink_by = processed_width - delta_width;
// 2. use width available via decreasing of chiclet panel // 2. use width available via decreasing of chiclet panel
if (required_to_process_width > 0) if (shrink_by > 0)
{ {
mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_to_process_width, mChicletPanel->getParent()->getRect().getHeight()); lldebugs << "Shrinking chiclet panel by " << shrink_by << " px" << llendl;
mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - shrink_by, mChicletPanel->getParent()->getRect().getHeight());
log(mChicletPanel, "after applying compensative width for chiclets: "); log(mChicletPanel, "after applying compensative width for chiclets: ");
lldebugs << required_to_process_width << llendl; lldebugs << shrink_by << llendl;
} }
// shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels
delta_width -= processed_width;
} }
// shown buttons take some space, rest should be processed by nearby chatbar & chiclet panels // 2. Expand the nearby chat bar if needed.
delta_width -= processed_width; S32 chatbar_panel_width = mChatBarContainer->getRect().getWidth();
lldebugs << "delta_width = " << delta_width
<< ", chatbar_panel_width = " << chatbar_panel_width
// how many space can nearby chatbar take? << ", mDesiredNearbyChatWidth = " << mDesiredNearbyChatWidth << llendl;
S32 chatbar_panel_width_ = mChatBarContainer->getRect().getWidth(); if (delta_width > 0 && chatbar_panel_width < mDesiredNearbyChatWidth)
if (delta_width > 0 && chatbar_panel_width_ < mDesiredNearbyChatWidth)
{ {
S32 delta_panel_max = mDesiredNearbyChatWidth - chatbar_panel_width_; S32 delta_panel_max = mDesiredNearbyChatWidth - chatbar_panel_width;
S32 delta_panel = llmin(delta_width, delta_panel_max); S32 delta_panel = llmin(delta_width, delta_panel_max);
lldebugs << "Unprocesed delta width: " << delta_width lldebugs << "Unprocesed delta width: " << delta_width
<< ", can be applied to chatbar: " << delta_panel_max << ", can be applied to chatbar: " << delta_panel_max
...@@ -1211,17 +1205,25 @@ void LLBottomTray::processWidthIncreased(S32 delta_width) ...@@ -1211,17 +1205,25 @@ void LLBottomTray::processWidthIncreased(S32 delta_width)
<< llendl; << llendl;
delta_width -= delta_panel_max; delta_width -= delta_panel_max;
mChatBarContainer->reshape(chatbar_panel_width_ + delta_panel, mChatBarContainer->getRect().getHeight()); lldebugs << "Extending nearby chat bar by " << delta_panel << " px " << llendl;
mChatBarContainer->reshape(chatbar_panel_width + delta_panel, mChatBarContainer->getRect().getHeight());
log(mNearbyChatBar, "applied unprocessed delta width"); log(mNearbyChatBar, "applied unprocessed delta width");
} }
// 3. Expand buttons that have been auto-shrunk,
// if we haven't yet consumed all the available headroom.
if (delta_width > 0) if (delta_width > 0)
{ {
processExtendButtons(delta_width); S32 available_width = delta_width + getChicletPanelShrinkHeadroom();
processExtendButtons(available_width);
} }
} }
void LLBottomTray::processShowButtons(S32& available_width) S32 LLBottomTray::processShowButtons(S32& available_width)
{ {
lldebugs << "Distributing " << available_width << " px" << llendl;
S32 original_available_width = available_width;
// process buttons from left to right // process buttons from left to right
resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin(); resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin();
const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end(); const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end();
...@@ -1234,37 +1236,20 @@ void LLBottomTray::processShowButtons(S32& available_width) ...@@ -1234,37 +1236,20 @@ void LLBottomTray::processShowButtons(S32& available_width)
// try to show next button // try to show next button
processShowButton(*it, available_width); processShowButton(*it, available_width);
} }
return original_available_width - available_width;
} }
bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32& available_width) bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32& available_width)
{ {
lldebugs << "Trying to show object type: " << shown_object_type << llendl; // Check if the button was previously auto-hidden (due to lack of space).
if ((mResizeState & shown_object_type) == 0)
LLPanel* panel = getButtonPanel(shown_object_type);
if (NULL == panel)
{ {
lldebugs << "There is no object to process for state: " << shown_object_type << llendl;
return false; return false;
} }
bool can_be_shown = canButtonBeShown(shown_object_type);
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;
setTrayButtonVisible(shown_object_type, true);
lldebugs << "processed object type: " << shown_object_type // Ok. Try showing the button.
<< ", rest available width: " << available_width return showButton(shown_object_type, available_width);
<< llendl;
mResizeState &= ~shown_object_type;
}
}
return can_be_shown;
} }
void LLBottomTray::processHideButtons(S32& required_width, S32& buttons_freed_width) void LLBottomTray::processHideButtons(S32& required_width, S32& buttons_freed_width)
...@@ -1289,7 +1274,6 @@ void LLBottomTray::processHideButton(EResizeState processed_object_type, S32& re ...@@ -1289,7 +1274,6 @@ void LLBottomTray::processHideButton(EResizeState processed_object_type, S32& re
LLPanel* panel = getButtonPanel(processed_object_type); LLPanel* panel = getButtonPanel(processed_object_type);
if (NULL == panel) if (NULL == panel)
{ {
lldebugs << "There is no object to process for state: " << processed_object_type << llendl;
return; return;
} }
...@@ -1369,7 +1353,6 @@ void LLBottomTray::processShrinkButton(EResizeState processed_object_type, S32& ...@@ -1369,7 +1353,6 @@ void LLBottomTray::processShrinkButton(EResizeState processed_object_type, S32&
LLPanel* panel = getButtonPanel(processed_object_type); LLPanel* panel = getButtonPanel(processed_object_type);
if (NULL == panel) if (NULL == panel)
{ {
lldebugs << "There is no object to process for type: " << processed_object_type << llendl;
return; return;
} }
...@@ -1416,120 +1399,128 @@ void LLBottomTray::processExtendButtons(S32& available_width) ...@@ -1416,120 +1399,128 @@ void LLBottomTray::processExtendButtons(S32& available_width)
// do not allow extending any buttons if we have some buttons hidden via resize // do not allow extending any buttons if we have some buttons hidden via resize
if (mResizeState & RS_BUTTONS_CAN_BE_HIDDEN) return; if (mResizeState & RS_BUTTONS_CAN_BE_HIDDEN) return;
// process buttons from left to right lldebugs << "Distributing " << available_width << " px" << llendl;
resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin();
const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end();
// iterate through buttons in the mButtonsProcessOrder first // First try extending the Speak button.
for (; it != it_end; ++it) if (available_width > 0)
{ {
// is there available space? if (!processExtendSpeakButton(available_width))
if (available_width <= 0) break; {
// The Speak button needs extension but lacks some space.
// try to extend next button // Don't extend other buttons in this case: the Speak button
processExtendButton(*it, available_width); // should consume the available headroom first.
return;
}
} }
const S32 chiclet_panel_width = mChicletPanel->getParent()->getRect().getWidth(); // Then process the other buttons from left to right.
static const S32 chiclet_panel_min_width = mChicletPanel->getMinWidth(); if (available_width > 0)
const S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_width; {
resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin();
const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end();
// then try to extend Speak button // iterate through buttons in the mButtonsProcessOrder first
if (available_width > 0 || available_width_chiclet > 0) for (; it != it_end; ++it)
{
// is there available space?
if (available_width <= 0) break;
// try to extend next button
processExtendButton(*it, available_width);
}
}
}
bool LLBottomTray::processExtendSpeakButton(S32& available_width)
{
if (available_width <= 0)
{ {
S32 panel_max_width = mObjectDefaultWidthMap[RS_BUTTON_SPEAK]; llassert(available_width > 0);
S32 panel_width = mSpeakPanel->getRect().getWidth(); return true;
S32 possible_extend_width = panel_max_width - panel_width; }
const S32 panel_max_width = mObjectDefaultWidthMap[RS_BUTTON_SPEAK];
const S32 panel_width = mSpeakPanel->getRect().getWidth();
const S32 required_headroom = panel_max_width - panel_width;
if (possible_extend_width >= 0 && possible_extend_width <= available_width + available_width_chiclet) // HACK: this button doesn't change size so possible_extend_width will be 0 if (panel_width < panel_max_width) // if the button isn't extended already
{
if (available_width < required_headroom) // not enough space
{ {
mSpeakBtn->setLabelVisible(true); lldebugs << "Need (" << required_headroom << " - " << available_width << ") = "
mSpeakPanel->reshape(panel_max_width, mSpeakPanel->getRect().getHeight()); << (required_headroom - available_width) << " more px"
log(mSpeakBtn, "speak button is extended"); << " to extend the Speak button"<< llendl;
if( available_width > possible_extend_width) return false; // Don't extend other buttons until we extend Speak.
{
available_width -= possible_extend_width;
}
else
{
S32 required_width = possible_extend_width - available_width;
available_width = 0;
mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - required_width, mChicletPanel->getParent()->getRect().getHeight());
}
lldebugs << "Extending Speak button panel: " << mSpeakPanel->getName()
<< ", extended width: " << possible_extend_width
<< ", rest width to process: " << available_width
<< llendl;
} }
// Reshape the Speak button to its maximum width.
mSpeakBtn->setLabelVisible(true);
mSpeakPanel->reshape(panel_max_width, mSpeakPanel->getRect().getHeight());
available_width -= required_headroom;
llassert(available_width >= 0);
lldebugs << "Extending Speak button panel: " << mSpeakPanel->getName()
<< ", extended width: " << required_headroom
<< ", rest width to process: " << available_width
<< llendl;
} }
return true;
} }
void LLBottomTray::processExtendButton(EResizeState processed_object_type, S32& available_width) void LLBottomTray::processExtendButton(EResizeState processed_object_type, S32& available_width)
{ {
llassert(available_width >= 0);
LLPanel* panel = getButtonPanel(processed_object_type); LLPanel* panel = getButtonPanel(processed_object_type);
if (NULL == panel) if (NULL == panel)
{ {
lldebugs << "There is no object to process for type: " << processed_object_type << llendl;
return; return;
} }
if (!panel->getVisible()) return; if (!panel->getVisible()) return;
// Widen the button up to its maximum width, but by not more than <available_width> px.
S32 panel_max_width = mObjectDefaultWidthMap[processed_object_type]; S32 panel_max_width = mObjectDefaultWidthMap[processed_object_type];
S32 panel_width = panel->getRect().getWidth(); S32 panel_width = panel->getRect().getWidth();
S32 possible_extend_width = panel_max_width - panel_width; S32 required_headroom = panel_max_width - panel_width;
if (possible_extend_width > 0) S32 extend_by = llmin(available_width, required_headroom);
if (extend_by > 0)
{ {
// let calculate real width to extend panel->reshape(panel_width + extend_by, panel->getRect().getHeight());
// 1. apply all possible width // Decrease amount of headroom available for other panels.
available_width -= possible_extend_width; available_width -= extend_by;
// 2. it it is too much... lldebugs << "Extending " << panel->getName()
if (available_width < 0) << " by " << extend_by
{ << " px; remaining available width: " << available_width
// 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; << llendl;
} }
} }
bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const bool LLBottomTray::canButtonBeShown(EResizeState processed_object_type) const
{ {
// 0. Check if passed button was previously hidden on resize // Check that all buttons (that can be hidden on resize)
bool can_be_shown = mResizeState & processed_object_type; // to the left of the given one are already shown.
if (can_be_shown)
{
// Yes, it was. Lets now check that all buttons before it (that can be hidden on resize)
// are already shown
// process buttons in direct order (from left to right)
resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin();
const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end();
// 1. Find and accumulate all buttons types before one passed into the method. // process buttons in direct order (from left to right)
MASK buttons_before_mask = RS_NORESIZE; resize_state_vec_t::const_iterator it = mButtonsProcessOrder.begin();
for (; it != it_end; ++it) const resize_state_vec_t::const_iterator it_end = mButtonsProcessOrder.end();
{
const EResizeState button_type = *it;
if (button_type == processed_object_type) break;
buttons_before_mask |= button_type; MASK buttons_before_mask = RS_NORESIZE;
} for (; it != it_end; ++it)
{
const EResizeState button_type = *it;
if (button_type == processed_object_type) break;
// 2. Check if some previous buttons are still hidden on resize buttons_before_mask |= button_type;
can_be_shown = !(buttons_before_mask & mResizeState);
} }
return can_be_shown;
return !(buttons_before_mask & mResizeState);
} }
void LLBottomTray::initResizeStateContainers() void LLBottomTray::initResizeStateContainers()
...@@ -1592,6 +1583,7 @@ void LLBottomTray::initButtonsVisibility() ...@@ -1592,6 +1583,7 @@ void LLBottomTray::initButtonsVisibility()
setVisibleAndFitWidths(RS_BUTTON_SEARCH, gSavedSettings.getBOOL("ShowSearchButton")); setVisibleAndFitWidths(RS_BUTTON_SEARCH, gSavedSettings.getBOOL("ShowSearchButton"));
setVisibleAndFitWidths(RS_BUTTON_WORLD_MAP, gSavedSettings.getBOOL("ShowWorldMapButton")); setVisibleAndFitWidths(RS_BUTTON_WORLD_MAP, gSavedSettings.getBOOL("ShowWorldMapButton"));
setVisibleAndFitWidths(RS_BUTTON_MINI_MAP, gSavedSettings.getBOOL("ShowMiniMapButton")); setVisibleAndFitWidths(RS_BUTTON_MINI_MAP, gSavedSettings.getBOOL("ShowMiniMapButton"));
lldebugs << "mResizeState = " << resizeStateMaskToString(mResizeState) << llendl;
} }
void LLBottomTray::setButtonsControlsAndListeners() void LLBottomTray::setButtonsControlsAndListeners()
...@@ -1623,12 +1615,53 @@ bool LLBottomTray::toggleShowButton(LLBottomTray::EResizeState button_type, cons ...@@ -1623,12 +1615,53 @@ bool LLBottomTray::toggleShowButton(LLBottomTray::EResizeState button_type, cons
return true; return true;
} }
bool LLBottomTray::showButton(EResizeState button_type, S32& available_width)
{
LLPanel* panel = getButtonPanel(button_type);
if (NULL == panel)
{
return false;
}
if (panel->getVisible())
{
return false;
}
// Check if none of the buttons to the left of the given one was auto-hidden.
// (we auto-show the buttons left to right).
if (!canButtonBeShown(button_type))
{
return false;
}
// Make sure we have enough room to show this button.
const S32 required_width = panel->getRect().getWidth();
if (available_width < required_width)
{
lldebugs << "Need " << (required_width - available_width) << " more px to show " << resizeStateToString(button_type) << llendl;
return false;
}
// All good. Show the button.
setTrayButtonVisible(button_type, true);
// Let the caller know that there is now less available space.
available_width -= required_width;
lldebugs << "Showing button " << resizeStateToString(button_type)
<< ", remaining available width: " << available_width
<< llendl;
mResizeState &= ~button_type;
return true;
}
void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible) void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible)
{ {
LLPanel* panel = getButtonPanel(shown_object_type); LLPanel* panel = getButtonPanel(shown_object_type);
if (NULL == panel) if (NULL == panel)
{ {
lldebugs << "There is no object to show for state: " << shown_object_type << llendl;
return; return;
} }
...@@ -1659,7 +1692,6 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible ...@@ -1659,7 +1692,6 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible
LLPanel* cur_panel = getButtonPanel(object_type); LLPanel* cur_panel = getButtonPanel(object_type);
if (NULL == cur_panel) if (NULL == cur_panel)
{ {
lldebugs << "There is no object to process for state: " << object_type << llendl;
return false; return false;
} }
...@@ -1668,17 +1700,13 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible ...@@ -1668,17 +1700,13 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible
if (visible) if (visible)
{ {
// Assume that only chiclet panel can be auto-resized // Assume that only chiclet panel can be auto-resized
const S32 available_width = const S32 available_width = getChicletPanelShrinkHeadroom();
mChicletPanel->getParent()->getRect().getWidth() - mChicletPanel->getMinWidth();
S32 preferred_width = mObjectDefaultWidthMap[object_type]; S32 preferred_width = mObjectDefaultWidthMap[object_type];
S32 current_width = cur_panel->getRect().getWidth(); S32 current_width = cur_panel->getRect().getWidth();
S32 result_width = 0; S32 result_width = 0;
bool decrease_width = false; bool decrease_width = false;
// Mark this button to be shown
mResizeState |= object_type;
if (preferred_width > 0 && available_width >= preferred_width) if (preferred_width > 0 && available_width >= preferred_width)
{ {
result_width = preferred_width; result_width = preferred_width;
...@@ -1733,7 +1761,7 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible ...@@ -1733,7 +1761,7 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible
current_width = result_width; current_width = result_width;
} }
is_set = processShowButton(object_type, current_width); is_set = showButton(object_type, current_width);
// Shrink buttons if needed // Shrink buttons if needed
if (is_set && decrease_width) if (is_set && decrease_width)
...@@ -1748,6 +1776,7 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible ...@@ -1748,6 +1776,7 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible
setTrayButtonVisible(object_type, false); setTrayButtonVisible(object_type, false);
// Mark button NOT to show while future bottom tray extending // Mark button NOT to show while future bottom tray extending
lldebugs << "Removing " << resizeStateToString(object_type) << " from mResizeState" << llendl;
mResizeState &= ~object_type; mResizeState &= ~object_type;
// Extend other buttons if need // Extend other buttons if need
...@@ -1805,12 +1834,14 @@ void LLBottomTray::processChatbarCustomization(S32 new_width) ...@@ -1805,12 +1834,14 @@ void LLBottomTray::processChatbarCustomization(S32 new_width)
if (delta_width == 0) return; if (delta_width == 0) return;
{
static unsigned dbg_cnt = 0;
lldebugs << llformat("*** (%03d) ************************************* %d", delta_width, ++dbg_cnt) << llendl;
}
mDesiredNearbyChatWidth = new_width; mDesiredNearbyChatWidth = new_width;
LLView * chiclet_layout_panel = mChicletPanel->getParent(); const S32 available_chiclet_shrink_width = getChicletPanelShrinkHeadroom();
const S32 chiclet_min_width = get_panel_min_width(mToolbarStack, chiclet_layout_panel);
const S32 chiclet_panel_width = chiclet_layout_panel->getRect().getWidth();
const S32 available_chiclet_shrink_width = chiclet_panel_width - chiclet_min_width;
llassert(available_chiclet_shrink_width >= 0); llassert(available_chiclet_shrink_width >= 0);
if (delta_width > 0) // panel gets narrowly if (delta_width > 0) // panel gets narrowly
...@@ -1829,6 +1860,16 @@ void LLBottomTray::processChatbarCustomization(S32 new_width) ...@@ -1829,6 +1860,16 @@ void LLBottomTray::processChatbarCustomization(S32 new_width)
} }
} }
S32 LLBottomTray::getChicletPanelShrinkHeadroom() const
{
static const S32 min_width = mChicletPanel->getMinWidth();
const S32 cur_width = mChicletPanel->getParent()->getRect().getWidth();
S32 shrink_headroom = cur_width - min_width;
llassert(shrink_headroom >= 0); // the panel cannot get narrower than the minimum
return shrink_headroom;
}
// static // static
std::string LLBottomTray::resizeStateToString(EResizeState state) std::string LLBottomTray::resizeStateToString(EResizeState state)
{ {
...@@ -1854,4 +1895,37 @@ std::string LLBottomTray::resizeStateToString(EResizeState state) ...@@ -1854,4 +1895,37 @@ std::string LLBottomTray::resizeStateToString(EResizeState state)
return "UNKNOWN_BUTTON"; return "UNKNOWN_BUTTON";
} }
// static
std::string LLBottomTray::resizeStateMaskToString(MASK mask)
{
std::string res;
bool add_delimiter = false;
for (U32 i = 0; i < 16; i++)
{
EResizeState state = (EResizeState) (1 << i);
if (mask & state)
{
if (!add_delimiter)
{
add_delimiter = true;
}
else
{
res += ", ";
}
res += resizeStateToString(state);
}
}
if (res.empty())
{
res = resizeStateToString(RS_NORESIZE);
}
res += llformat(" (0x%X)", mask);
return res;
}
//EOF //EOF
...@@ -240,8 +240,9 @@ class LLBottomTray ...@@ -240,8 +240,9 @@ class LLBottomTray
* *
* @params[in, out] available_width - reference to available width to be used to show buttons. * @params[in, out] available_width - reference to available width to be used to show buttons.
* @see processShowButton() * @see processShowButton()
* @return consumed pixels (difference in available width).
*/ */
void processShowButtons(S32& available_width); S32 processShowButtons(S32& available_width);
/** /**
* Tries to show panel with specified button using available width. * Tries to show panel with specified button using available width.
...@@ -316,6 +317,20 @@ class LLBottomTray ...@@ -316,6 +317,20 @@ class LLBottomTray
*/ */
void processExtendButtons(S32& available_width); void processExtendButtons(S32& available_width);
/**
* Extends the Speak button if there is anough headroom.
*
* Unlike other buttons, the Speak buttons has only two possible widths:
* the minimal one (without label) and the maximal (default) one.
*
* If the button is at its minimum width there is not enough headroom to
* reshape it to the maximum width, the method does nothing.
*
* @param available_width Available headroom.
* @return false if the button requires extension but there's not enough headroom, true otherwise.
*/
bool processExtendSpeakButton(S32& available_width);
/** /**
* Extends shown button to increase total taken space. * Extends shown button to increase total taken space.
* *
...@@ -364,6 +379,16 @@ class LLBottomTray ...@@ -364,6 +379,16 @@ class LLBottomTray
*/ */
static bool toggleShowButton(EResizeState button_type, const LLSD& new_visibility); static bool toggleShowButton(EResizeState button_type, const LLSD& new_visibility);
/**
* Show the button if there is enough space.
*
* @param[in] button_type - type of button to be shown.
* @param[in, out] available_width amount of available space on the bottom bar.
*
* @return true if button was shown, false that's not possible (not enough space, etc)
*/
bool showButton(EResizeState button_type, S32& available_width);
/** /**
* Sets passed visibility to object specified by resize type. * Sets passed visibility to object specified by resize type.
*/ */
...@@ -417,9 +442,17 @@ class LLBottomTray ...@@ -417,9 +442,17 @@ class LLBottomTray
*/ */
void processChatbarCustomization(S32 new_width); void processChatbarCustomization(S32 new_width);
/**
* @return difference between current chiclet panel width and the minimum.
*/
S32 getChicletPanelShrinkHeadroom() const;
/// Get button name for debugging. /// Get button name for debugging.
static std::string resizeStateToString(EResizeState state); static std::string resizeStateToString(EResizeState state);
/// Dump a mask for debugging
static std::string resizeStateMaskToString(MASK mask);
/// Buttons automatically hidden due to lack of space. /// Buttons automatically hidden due to lack of space.
MASK mResizeState; MASK mResizeState;
......
...@@ -341,7 +341,7 @@ Disabled for now. ...@@ -341,7 +341,7 @@ Disabled for now.
height="28" height="28"
layout="topleft" layout="topleft"
min_height="28" min_height="28"
min_width="52" min_width="62"
mouse_opaque="false" mouse_opaque="false"
name="mini_map_btn_panel" name="mini_map_btn_panel"
user_resize="false" user_resize="false"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment