Completed normal task EXT-3397 (Hide well buttons if there are no active IM sessions and unresolved notifications)

* Implemented hiding of bottom tray's wells if there are no active IMs or unresolved notifications (via LLBottomTray::notifyParent)

* Also refactored initializing code to init a pointer to a chiclet panel and map with bottomtray parts in postBuild BEFORE initializing start wells' visibility.

For now minimal viewer width when all buttons are still visible (and have non-truncated labels in the 'EN' locale) with opened sidetray is 1041 px; with short Speak button (without text label) is 990 px. (with implemented patch in https://codereview.productengine.com/secondlife/r/126/)

Each well button takes 37 px (with a padding). So, they can free up to 74 px when invisible.

reviewed by Vadim at https://codereview.productengine.com/secondlife/r/136/

--HG--
branch : product-engine
master
Mike Antipov 2010-03-30 17:42:05 +03:00
parent c73dcb0799
commit 67a7112a7c
4 changed files with 78 additions and 33 deletions

View File

@ -160,10 +160,6 @@ LLBottomTray::LLBottomTray(const LLSD&)
LLUICtrlFactory::getInstance()->buildPanel(this,"panel_bottomtray.xml");
mChicletPanel = getChild<LLChicletPanel>("chiclet_list");
mChicletPanel->setChicletClickedCallback(boost::bind(&LLBottomTray::onChicletClick,this,_1));
LLUICtrl::CommitCallbackRegistry::defaultRegistrar().add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraPresets, _2));
//this is to fix a crash that occurs because LLBottomTray is a singleton
@ -171,8 +167,6 @@ 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);
@ -371,6 +365,23 @@ void LLBottomTray::setVisible(BOOL visible)
gFloaterView->setSnapOffsetBottom(0);
}
S32 LLBottomTray::notifyParent(const LLSD& info)
{
if(info.has("well_empty")) // implementation of EXT-3397
{
const std::string chiclet_name = info["well_name"];
// only "im_well" or "notification_well" names are expected.
// They are set in panel_bottomtray.xml in <chiclet_im_well> & <chiclet_notification>
llassert("im_well" == chiclet_name || "notification_well" == chiclet_name);
BOOL should_be_visible = !info["well_empty"];
showWellButton("im_well" == chiclet_name ? RS_IM_WELL : RS_NOTIFICATION_WELL, should_be_visible);
return 1;
}
return LLPanel::notifyParent(info);
}
void LLBottomTray::showBottomTrayContextMenu(S32 x, S32 y, MASK mask)
{
// We should show BottomTrayContextMenu in last turn
@ -487,6 +498,15 @@ BOOL LLBottomTray::postBuild()
mNearbyChatBar->getChatBox()->setContextMenu(NULL);
mChicletPanel = getChild<LLChicletPanel>("chiclet_list");
mChicletPanel->setChicletClickedCallback(boost::bind(&LLBottomTray::onChicletClick,this,_1));
initStateProcessedObjectMap();
// update wells visibility:
showWellButton(RS_IM_WELL, !LLIMWellWindow::getInstance()->isWindowEmpty());
showWellButton(RS_NOTIFICATION_WELL, !LLNotificationWellWindow::getInstance()->isWindowEmpty());
return TRUE;
}
@ -855,6 +875,7 @@ void LLBottomTray::processWidthIncreased(S32 delta_width)
bool LLBottomTray::processShowButton(EResizeState shown_object_type, S32* available_width)
{
lldebugs << "Trying to show object type: " << shown_object_type << llendl;
llassert(mStateProcessedObjectMap[shown_object_type] != NULL);
LLPanel* panel = mStateProcessedObjectMap[shown_object_type];
if (NULL == panel)
@ -886,6 +907,7 @@ 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;
llassert(mStateProcessedObjectMap[processed_object_type] != NULL);
LLPanel* panel = mStateProcessedObjectMap[processed_object_type];
if (NULL == panel)
@ -963,6 +985,7 @@ void LLBottomTray::processShrinkButtons(S32* required_width, S32* buttons_freed_
void LLBottomTray::processShrinkButton(EResizeState processed_object_type, S32* required_width)
{
llassert(mStateProcessedObjectMap[processed_object_type] != NULL);
LLPanel* panel = mStateProcessedObjectMap[processed_object_type];
if (NULL == panel)
{
@ -1046,6 +1069,7 @@ void LLBottomTray::processExtendButtons(S32* available_width)
void LLBottomTray::processExtendButton(EResizeState processed_object_type, S32* available_width)
{
llassert(mStateProcessedObjectMap[processed_object_type] != NULL);
LLPanel* panel = mStateProcessedObjectMap[processed_object_type];
if (NULL == panel)
{
@ -1126,6 +1150,7 @@ void LLBottomTray::initStateProcessedObjectMap()
void LLBottomTray::setTrayButtonVisible(EResizeState shown_object_type, bool visible)
{
llassert(mStateProcessedObjectMap[shown_object_type] != NULL);
LLPanel* panel = mStateProcessedObjectMap[shown_object_type];
if (NULL == panel)
{
@ -1264,4 +1289,29 @@ bool LLBottomTray::setVisibleAndFitWidths(EResizeState object_type, bool visible
return is_set;
}
void LLBottomTray::showWellButton(EResizeState object_type, bool visible)
{
llassert( ((RS_NOTIFICATION_WELL | RS_IM_WELL) & object_type) == object_type );
const std::string panel_name = RS_IM_WELL == object_type ? "im_well_panel" : "notification_well_panel";
LLView * panel = getChild<LLView>(panel_name);
// if necessary visibility is set nothing to do here
if (panel->getVisible() == (BOOL)visible) return;
S32 panel_width = panel->getRect().getWidth();
panel->setVisible(visible);
if (visible)
{
// method assumes that input param is a negative value
processWidthDecreased(-panel_width);
}
else
{
processWidthIncreased(panel_width);
}
}
//EOF

View File

@ -83,6 +83,8 @@ public:
virtual void setVisible(BOOL visible);
/*virtual*/ S32 notifyParent(const LLSD& info);
// Implements LLVoiceClientStatusObserver::onChange() to enable the speak
// button when voice is available
/*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
@ -116,6 +118,8 @@ private:
, RS_BUTTON_MOVEMENT = 0x0010
, RS_BUTTON_GESTURES = 0x0020
, RS_BUTTON_SPEAK = 0x0040
, RS_IM_WELL = 0x0080
, RS_NOTIFICATION_WELL = 0x0100
/**
* Specifies buttons which can be hidden when bottom tray is shrunk.
@ -184,6 +188,15 @@ private:
*/
bool setVisibleAndFitWidths(EResizeState object_type, bool visible);
/**
* Shows/hides panel with specified well button (IM or Notification)
*
* @param[in] object_type - type of well button to be processed.
* Must be one of RS_IM_WELL or RS_NOTIFICATION_WELL.
* @param[in] visible - flag specified whether button should be shown or hidden.
*/
void showWellButton(EResizeState object_type, bool visible);
MASK mResizeState;
typedef std::map<EResizeState, LLPanel*> state_object_map_t;

View File

@ -229,6 +229,11 @@ void LLSysWellChiclet::setNewMessagesState(bool new_messages)
void LLSysWellChiclet::updateWidget(bool is_window_empty)
{
mButton->setEnabled(!is_window_empty);
LLSD params;
params["well_empty"] = is_window_empty;
params["well_name"] = getName();
notifyParent(params);
}
// virtual
BOOL LLSysWellChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask)

View File

@ -339,8 +339,8 @@ as for parent layout_panel (chiclet_list_panel) to resize bottom tray properly.
min_height="28"
top="0"
name="im_well_panel"
width="35"
min_width="35"
width="37"
min_width="37"
user_resize="false">
<chiclet_im_well
max_displayed_count="99"
@ -388,22 +388,10 @@ image_pressed_selected "Lit" + "Selected" - there are new messages and the Well
layout="topleft"
min_height="28"
top="0"
left_pad="3"
name="notification_well_panel"
width="40"
min_width="40"
width="37"
min_width="37"
user_resize="false">
<icon
auto_resize="false"
color="0 0 0 0"
follows="left|right"
height="10"
image_name="spacer24.tga"
layout="topleft"
left="0"
min_width="4"
top="0"
width="5" />
<chiclet_notification
flash_period="0.25"
follows="right"
@ -434,17 +422,6 @@ image_pressed_selected "Lit" + "Selected" - there are new messages and the Well
function="Button.SetDockableFloaterToggle"
parameter="notification_well_window" />
</button>
<icon
auto_resize="false"
color="0 0 0 0"
follows="left|right"
height="10"
image_name="spacer24.tga"
layout="topleft"
left="0"
min_width="4"
top="0"
width="5" />
</chiclet_notification>
</layout_panel>
</layout_stack>