summaryrefslogtreecommitdiff
path: root/indra/newview/llbottomtray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llbottomtray.cpp')
-rw-r--r--indra/newview/llbottomtray.cpp240
1 files changed, 218 insertions, 22 deletions
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 958dbf226a..c4f0fa53a7 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -48,6 +48,7 @@
LLBottomTray::LLBottomTray(const LLSD&)
: mChicletPanel(NULL),
mSysWell(NULL),
+ mSpeakPanel(NULL),
mSpeakBtn(NULL),
mNearbyChatBar(NULL),
mToolbarStack(NULL)
@@ -237,7 +238,7 @@ void LLBottomTray::setVisible(BOOL visible)
LLView* viewp = *child_it;
std::string name = viewp->getName();
- if ("chat_bar" == name || "movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name)
+ if ("chat_bar" == name || "movement_panel" == name || "cam_panel" == name || "snapshot_panel" == name || "gesture_panel" == name)
continue;
else
{
@@ -304,6 +305,7 @@ BOOL LLBottomTray::postBuild()
mSnapshotPanel = getChild<LLPanel>("snapshot_panel");
setRightMouseDownCallback(boost::bind(&LLBottomTray::showBottomTrayContextMenu,this, _2, _3,_4));
+ mSpeakPanel = getChild<LLPanel>("speak_panel");
mSpeakBtn = getChild<LLSpeakButton>("talk");
// Speak button should be initially disabled because
@@ -317,6 +319,11 @@ 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();
+ mObjectDefaultWidthMap[RS_BUTTON_SPEAK] = mSpeakPanel->getRect().getWidth();
+
return TRUE;
}
@@ -402,7 +409,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 +479,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, &buttons_freed_width);
+
+ if (delta_width < 0)
+ {
+ processHideButton(RS_BUTTON_SNAPSHOT, &delta_width, &buttons_freed_width);
+ }
if (delta_width < 0)
{
@@ -493,7 +504,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;
}
@@ -524,38 +535,43 @@ void LLBottomTray::processWidthIncreased(S32 delta_width)
const S32 available_width_chiclet = chiclet_panel_width - chiclet_panel_min_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
+ S32 total_available_width = delta_width + chatbar_available_shrink_width + available_width_chiclet;
+
+ lldebugs << "Processing extending, available width:"
+ << ", chatbar - " << chatbar_available_shrink_width
+ << ", chiclets - " << available_width_chiclet
+ << ", total - " << total_available_width
+ << llendl;
+ S32 available_width = total_available_width;
if (available_width > 0)
{
- lldebugs << "Trying to process: RS_BUTTON_GESTURES" << llendl;
- processShowButton(RS_BUTTON_GESTURES, &available_width, &buttons_required_width);
+ processShowButton(RS_BUTTON_GESTURES, &available_width);
}
if (available_width > 0)
{
- lldebugs << "Trying to process: RS_BUTTON_MOVEMENT" << llendl;
- processShowButton(RS_BUTTON_MOVEMENT, &available_width, &buttons_required_width);
+ processShowButton(RS_BUTTON_MOVEMENT, &available_width);
}
if (available_width > 0)
{
- lldebugs << "Trying to process: RS_BUTTON_CAMERA" << llendl;
- processShowButton(RS_BUTTON_CAMERA, &available_width, &buttons_required_width);
+ processShowButton(RS_BUTTON_CAMERA, &available_width);
}
if (available_width > 0)
{
- lldebugs << "Trying to process: RS_BUTTON_SNAPSHOT" << llendl;
- processShowButton(RS_BUTTON_SNAPSHOT, &available_width, &buttons_required_width);
+ processShowButton(RS_BUTTON_SNAPSHOT, &available_width);
}
- // if we have to show some buttons but whidth increasing is not enough...
- if (buttons_required_width > 0 && delta_width < buttons_required_width)
+ processExtendButtons(&available_width);
+
+ // 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)
{
// ... let's shrink nearby chat & chiclet panels
- S32 required_to_process_width = buttons_required_width;
+ S32 required_to_process_width = processed_width;
// 1. use delta width of resizing
required_to_process_width -= delta_width;
@@ -585,7 +601,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;
+ delta_width -= processed_width;
+
// how many space can nearby chatbar take?
S32 chatbar_panel_width_ = mNearbyChatBar->getRect().getWidth();
@@ -593,13 +610,21 @@ void LLBottomTray::processWidthIncreased(S32 delta_width)
{
S32 delta_panel_max = chatbar_panel_max_width - chatbar_panel_width_;
S32 delta_panel = llmin(delta_width, delta_panel_max);
+ lldebugs << "Unprocesed delta width: " << delta_width
+ << ", can be applied to chatbar: " << delta_panel_max
+ << ", will be applied: " << delta_panel
+ << llendl;
+
delta_width -= delta_panel_max;
mNearbyChatBar->reshape(chatbar_panel_width_ + delta_panel, mNearbyChatBar->getRect().getHeight());
+ log(mNearbyChatBar, "applied unprocessed delta width");
}
}
-bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* available_width, S32* buttons_required_width)
+bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* available_width)
{
+ lldebugs << "Trying to show object type: " << shown_object_type << llendl;
+
LLPanel* panel = mStateProcessedObjectMap[shown_object_type];
if (NULL == panel)
{
@@ -615,12 +640,11 @@ bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* availa
if (can_be_shown)
{
*available_width -= required_width;
- *buttons_required_width += required_width;
setTrayButtonVisible(shown_object_type, true);
- lldebugs << "processing object type: " << shown_object_type
- << ", buttons_required_width: " << *buttons_required_width
+ lldebugs << "processed object type: " << shown_object_type
+ << ", rest available width: " << *available_width
<< llendl;
mResizeState &= ~shown_object_type;
}
@@ -630,6 +654,8 @@ bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* availa
void LLBottomTray::processHideButton(EResizeState processed_object_type, S32* required_width, S32* buttons_freed_width)
{
+ lldebugs << "Trying to hide object type: " << processed_object_type << llendl;
+
LLPanel* panel = mStateProcessedObjectMap[processed_object_type];
if (NULL == panel)
{
@@ -656,6 +682,176 @@ void LLBottomTray::processHideButton(EResizeState processed_object_type, S32* re
}
}
+void LLBottomTray::processShrinkButtons(S32* required_width, S32* buttons_freed_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);
+ }
+ if (*required_width < 0)
+ {
+
+ S32 panel_min_width = 0;
+ std::string panel_name = mSpeakPanel->getName();
+ bool success = mToolbarStack->getPanelMinSize(panel_name, &panel_min_width, NULL);
+ if (!success)
+ {
+ lldebugs << "Panel was not found to get its min width: " << panel_name << llendl;
+ }
+ else
+ {
+ //
+ mSpeakBtn->setLabelVisible(false);
+ S32 panel_width = mSpeakPanel->getRect().getWidth();
+ S32 possible_shrink_width = panel_width - panel_min_width;
+
+ if (possible_shrink_width > 0)
+ {
+ mSpeakPanel->reshape(panel_width - possible_shrink_width, mSpeakPanel->getRect().getHeight());
+
+ *required_width += possible_shrink_width;
+
+ if (*required_width > 0)
+ {
+ *buttons_freed_width += *required_width;
+ }
+
+ lldebugs << "Shrunk panel: " << panel_name
+ << ", shrunk width: " << possible_shrink_width
+ << ", rest width to process: " << *required_width
+ << llendl;
+ }
+ }
+ }
+}
+
+void LLBottomTray::processShrinkButton(EResizeState processed_object_type, 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)
+{
+ // do not allow extending any buttons if we have some buttons hidden
+ if (mResizeState & RS_BUTTONS_CAN_BE_HIDDEN) return;
+
+ 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);
+ }
+ if (*available_width > 0)
+ {
+ S32 panel_max_width = mObjectDefaultWidthMap[RS_BUTTON_SPEAK];
+ S32 panel_width = mSpeakPanel->getRect().getWidth();
+ S32 possible_extend_width = panel_max_width - panel_width;
+ if (possible_extend_width > 0 && possible_extend_width <= *available_width)
+ {
+ mSpeakBtn->setLabelVisible(true);
+ mSpeakPanel->reshape(panel_max_width, mSpeakPanel->getRect().getHeight());
+ log(mSpeakBtn, "speak button is extended");
+
+ *available_width -= possible_extend_width;
+
+ lldebugs << "Extending panel: " << mSpeakPanel->getName()
+ << ", extended width: " << possible_extend_width
+ << ", rest width to process: " << *available_width
+ << llendl;
+ }
+ }
+}
+
+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;