summaryrefslogtreecommitdiff
path: root/indra/newview/lloverlaybar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lloverlaybar.cpp')
-rw-r--r--indra/newview/lloverlaybar.cpp493
1 files changed, 162 insertions, 331 deletions
diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp
index 15c993e552..e7c313638b 100644
--- a/indra/newview/lloverlaybar.cpp
+++ b/indra/newview/lloverlaybar.cpp
@@ -39,6 +39,7 @@
#include "audioengine.h"
#include "llagent.h"
#include "llbutton.h"
+#include "llchatbar.h"
#include "llfocusmgr.h"
#include "llimview.h"
#include "llmediaengine.h"
@@ -71,37 +72,14 @@ extern S32 MENU_BAR_HEIGHT;
//
-//static
-void* LLOverlayBar::createMasterRemote(void* userdata)
-{
- LLOverlayBar *self = (LLOverlayBar*)userdata;
- self->mMasterRemote = new LLMediaRemoteCtrl ( "master_volume",
- "volume",
- LLRect(),
- "panel_master_volume.xml");
- return self->mMasterRemote;
-}
void* LLOverlayBar::createMediaRemote(void* userdata)
{
LLOverlayBar *self = (LLOverlayBar*)userdata;
- self->mMediaRemote = new LLMediaRemoteCtrl ( "media_remote",
- "media",
- LLRect(),
- "panel_media_remote.xml");
+ self->mMediaRemote = new LLMediaRemoteCtrl ();
return self->mMediaRemote;
}
-void* LLOverlayBar::createMusicRemote(void* userdata)
-{
- LLOverlayBar *self = (LLOverlayBar*)userdata;
- self->mMusicRemote = new LLMediaRemoteCtrl ( "music_remote",
- "music",
- LLRect(),
- "panel_music_remote.xml" );
- return self->mMusicRemote;
-}
-
void* LLOverlayBar::createVoiceRemote(void* userdata)
{
LLOverlayBar *self = (LLOverlayBar*)userdata;
@@ -109,13 +87,14 @@ void* LLOverlayBar::createVoiceRemote(void* userdata)
return self->mVoiceRemote;
}
+void* LLOverlayBar::createChatBar(void* userdata)
+{
+ gChatBar = new LLChatBar();
+ return gChatBar;
+}
-
-
-LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
- : LLPanel(name, rect, FALSE), // not bordered
- mMasterRemote(NULL),
- mMusicRemote(NULL),
+LLOverlayBar::LLOverlayBar()
+ : LLPanel(),
mMediaRemote(NULL),
mVoiceRemote(NULL),
mMediaState(STOPPED),
@@ -127,25 +106,27 @@ LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
mBuilt = false;
LLCallbackMap::map_t factory_map;
- factory_map["master_volume"] = LLCallbackMap(LLOverlayBar::createMasterRemote, this);
factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this);
- factory_map["music_remote"] = LLCallbackMap(LLOverlayBar::createMusicRemote, this);
factory_map["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this);
+ factory_map["chat_bar"] = LLCallbackMap(LLOverlayBar::createChatBar, this);
gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map);
-
+}
+
+BOOL LLOverlayBar::postBuild()
+{
childSetAction("IM Received",onClickIMReceived,this);
childSetAction("Set Not Busy",onClickSetNotBusy,this);
childSetAction("Release Keys",onClickReleaseKeys,this);
childSetAction("Mouselook",onClickMouselook,this);
childSetAction("Stand Up",onClickStandUp,this);
+ childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible"));
mIsFocusRoot = TRUE;
mBuilt = true;
- // make overlay bar conform to window size
- setRect(rect);
layoutButtons();
+ return TRUE;
}
LLOverlayBar::~LLOverlayBar()
@@ -176,146 +157,45 @@ void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent)
void LLOverlayBar::layoutButtons()
{
- S32 width = mRect.getWidth();
- if (width > 1024) width = 1024;
-
- S32 count = getChildCount();
- const S32 PAD = gSavedSettings.getS32("StatusBarPad");
-
- const S32 num_media_controls = 3;
- S32 media_remote_width = mMediaRemote ? mMediaRemote->getRect().getWidth() : 0;
- S32 music_remote_width = mMusicRemote ? mMusicRemote->getRect().getWidth() : 0;
- S32 voice_remote_width = mVoiceRemote ? mVoiceRemote->getRect().getWidth() : 0;
- S32 master_remote_width = mMasterRemote ? mMasterRemote->getRect().getWidth() : 0;
-
- // total reserved width for all media remotes
- const S32 ENDPAD = 20;
- S32 remote_total_width = media_remote_width + PAD + music_remote_width + PAD + voice_remote_width + PAD + master_remote_width + ENDPAD;
+ LLView* state_buttons_panel = getChildByName("state_buttons", TRUE);
- // calculate button widths
- F32 segment_width = (F32)(width - remote_total_width) / (F32)(count - num_media_controls);
-
- S32 btn_width = lltrunc(segment_width - PAD);
-
- // Evenly space all views
- LLRect r;
- S32 i = 0;
- for (child_list_const_iter_t child_iter = getChildList()->begin();
- child_iter != getChildList()->end(); ++child_iter)
+ if (state_buttons_panel)
{
- LLView *view = *child_iter;
- r = view->getRect();
- r.mLeft = (width) - llround(remote_total_width + (i-num_media_controls+1)*segment_width);
- r.mRight = r.mLeft + btn_width;
- view->setRect(r);
- i++;
- }
+ LLViewQuery query;
+ LLWidgetTypeFilter widget_filter(WIDGET_TYPE_BUTTON);
+ query.addPreFilter(LLVisibleFilter::getInstance());
+ query.addPreFilter(LLEnabledFilter::getInstance());
+ query.addPreFilter(&widget_filter);
- // Fix up remotes to have constant width because they can't shrink
- S32 right = mRect.getWidth() - remote_total_width - PAD;
- if (mMediaRemote)
- {
- r = mMediaRemote->getRect();
- r.mLeft = right + PAD;
- right = r.mLeft + media_remote_width;
- r.mRight = right;
- mMediaRemote->setRect(r);
- }
- if (mMusicRemote)
- {
- r = mMusicRemote->getRect();
- r.mLeft = right + PAD;
- right = r.mLeft + music_remote_width;
- r.mRight = right;
- mMusicRemote->setRect(r);
- }
- if (mVoiceRemote)
- {
- r = mVoiceRemote->getRect();
- r.mLeft = right + PAD;
- right = r.mLeft + voice_remote_width;
- r.mRight = right;
- mVoiceRemote->setRect(r);
- }
- if (mMasterRemote)
- {
- r = mMasterRemote->getRect();
- r.mLeft = right + PAD;
- right = r.mLeft + master_remote_width;
- r.mRight = right;
- mMasterRemote->setRect(r);
- }
-
- updateRect();
-}
+ child_list_t button_list = query(state_buttons_panel);
-void LLOverlayBar::draw()
-{
- // retrieve rounded rect image
- LLUUID image_id;
- image_id.set(gViewerArt.getString("rounded_square.tga"));
- LLViewerImage* imagep = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
+ const S32 MAX_BAR_WIDTH = 600;
+ S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH);
- if (imagep)
- {
- LLGLSTexture texture_enabled;
- LLViewerImage::bindTexture(imagep);
+ // calculate button widths
+ const S32 MAX_BUTTON_WIDTH = 150;
+ S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_list.size()), 0, MAX_BUTTON_WIDTH);
+ S32 btn_width = segment_width - gSavedSettings.getS32("StatusBarPad");
- const S32 PAD = gSavedSettings.getS32("StatusBarPad");
+ // Evenly space all buttons, starting from left
+ S32 left = 0;
+ S32 bottom = 1;
- // draw rounded rect tabs behind all children
- LLRect r;
- // focus highlights
- LLColor4 color = gColors.getColor("FloaterFocusBorderColor");
- glColor4fv(color.mV);
- if(gFocusMgr.childHasKeyboardFocus(gBottomPanel))
- {
- for (child_list_const_iter_t child_iter = getChildList()->begin();
- child_iter != getChildList()->end(); ++child_iter)
- {
- LLView *view = *child_iter;
- if(view->getEnabled() && view->getVisible())
- {
- r = view->getRect();
- gl_segmented_rect_2d_tex(r.mLeft - PAD/3 - 1,
- r.mTop + 3,
- r.mRight + PAD/3 + 1,
- r.mBottom,
- imagep->getWidth(),
- imagep->getHeight(),
- 16,
- ROUNDED_RECT_TOP);
- }
- }
- }
-
- // main tabs
- for (child_list_const_iter_t child_iter = getChildList()->begin();
- child_iter != getChildList()->end(); ++child_iter)
+ for (child_list_reverse_iter_t child_iter = button_list.rbegin();
+ child_iter != button_list.rend(); ++child_iter)
{
LLView *view = *child_iter;
- if(view->getEnabled() && view->getVisible())
- {
- r = view->getRect();
- // draw a nice little pseudo-3D outline
- color = gColors.getColor("DefaultShadowDark");
- glColor4fv(color.mV);
- gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 2, r.mRight + PAD/3, r.mBottom,
- imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
- color = gColors.getColor("DefaultHighlightLight");
- glColor4fv(color.mV);
- gl_segmented_rect_2d_tex(r.mLeft - PAD/3, r.mTop + 2, r.mRight + PAD/3 - 3, r.mBottom,
- imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
- // here's the main background. Note that it overhangs on the bottom so as to hide the
- // focus highlight on the bottom panel, thus producing the illusion that the focus highlight
- // continues around the tabs
- color = gColors.getColor("FocusBackgroundColor");
- glColor4fv(color.mV);
- gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 1, r.mRight + PAD/3 - 1, r.mBottom - 1,
- imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
- }
+ LLRect r = view->getRect();
+ r.setOriginAndSize(left, bottom, btn_width, r.getHeight());
+ view->setRect(r);
+ left += segment_width;
}
}
+}
+
+void LLOverlayBar::draw()
+{
+ childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible"));
// draw children on top
LLPanel::draw();
@@ -325,79 +205,74 @@ void LLOverlayBar::draw()
// Per-frame updates of visibility
void LLOverlayBar::refresh()
{
+ BOOL buttons_changed = FALSE;
+
BOOL im_received = gIMMgr->getIMReceived();
- childSetVisible("IM Received", im_received);
- childSetEnabled("IM Received", im_received);
+ LLButton* button = LLUICtrlFactory::getButtonByName(this, "IM Received");
+ if (button && button->getVisible() != im_received)
+ {
+ button->setVisible(im_received);
+ sendChildToFront(button);
+ moveChildToBackOfTabGroup(button);
+ buttons_changed = TRUE;
+ }
BOOL busy = gAgent.getBusy();
- childSetVisible("Set Not Busy", busy);
- childSetEnabled("Set Not Busy", busy);
+ button = LLUICtrlFactory::getButtonByName(this, "Set Not Busy");
+ if (button && button->getVisible() != busy)
+ {
+ button->setVisible(busy);
+ sendChildToFront(button);
+ moveChildToBackOfTabGroup(button);
+ buttons_changed = TRUE;
+ }
BOOL controls_grabbed = gAgent.anyControlGrabbed();
+ button = LLUICtrlFactory::getButtonByName(this, "Release Keys");
- childSetVisible("Release Keys", controls_grabbed);
- childSetEnabled("Release Keys", controls_grabbed);
-
+ if (button && button->getVisible() != controls_grabbed)
+ {
+ button->setVisible(controls_grabbed);
+ sendChildToFront(button);
+ moveChildToBackOfTabGroup(button);
+ buttons_changed = TRUE;
+ }
BOOL mouselook_grabbed;
mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX)
|| gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX);
+ button = LLUICtrlFactory::getButtonByName(this, "Mouselook");
-
- childSetVisible("Mouselook", mouselook_grabbed);
- childSetEnabled("Mouselook", mouselook_grabbed);
+ if (button && button->getVisible() != mouselook_grabbed)
+ {
+ button->setVisible(mouselook_grabbed);
+ sendChildToFront(button);
+ moveChildToBackOfTabGroup(button);
+ buttons_changed = TRUE;
+ }
BOOL sitting = FALSE;
if (gAgent.getAvatarObject())
{
sitting = gAgent.getAvatarObject()->mIsSitting;
- childSetVisible("Stand Up", sitting);
- childSetEnabled("Stand Up", sitting);
-
}
+ button = LLUICtrlFactory::getButtonByName(this, "Stand Up");
- if ( mMusicRemote && gAudiop )
+ if (button && button->getVisible() != sitting)
{
- LLParcel* parcel = gParcelMgr->getAgentParcel();
- if (!parcel
- || parcel->getMusicURL().empty()
- || !gSavedSettings.getBOOL("AudioStreamingMusic"))
- {
- mMusicRemote->setVisible(FALSE);
- mMusicRemote->setEnabled(FALSE);
- }
- else
- {
- mMusicRemote->setVisible(TRUE);
- mMusicRemote->setEnabled(TRUE);
- }
+ button->setVisible(sitting);
+ sendChildToFront(button);
+ moveChildToBackOfTabGroup(button);
+ buttons_changed = TRUE;
}
- // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!)
- if ( mMediaRemote )
- {
- if (LLMediaEngine::getInstance () &&
- LLMediaEngine::getInstance ()->getUrl ().length () &&
- LLMediaEngine::getInstance ()->getImageUUID ().notNull () &&
- LLMediaEngine::getInstance ()->isEnabled () &&
- LLMediaEngine::getInstance ()->isAvailable () &&
- gSavedSettings.getBOOL ( "AudioStreamingVideo" ) )
- {
- // display remote control
- mMediaRemote->setVisible ( TRUE );
- mMediaRemote->setEnabled ( TRUE );
- }
- else
- {
- mMediaRemote->setVisible ( FALSE );
- mMediaRemote->setEnabled ( FALSE );
- }
- }
- if (mVoiceRemote)
- {
- mVoiceRemote->setVisible(LLVoiceClient::voiceEnabled());
- }
-
+ // update "remotes"
+ childSetVisible("voice_remote_container", LLVoiceClient::voiceEnabled());
+ enableMediaButtons();
+
+ moveChildToBackOfTabGroup(mMediaRemote);
+ moveChildToBackOfTabGroup(mVoiceRemote);
+
// turn off the whole bar in mouselook
if (gAgent.cameraMouselook())
{
@@ -407,6 +282,11 @@ void LLOverlayBar::refresh()
{
setVisible(TRUE);
}
+
+ if (buttons_changed)
+ {
+ layoutButtons();
+ }
}
//-----------------------------------------------------------------------
@@ -462,33 +342,25 @@ void LLOverlayBar::mediaPlay(void*)
{
return;
}
- gOverlayBar->mMediaState = PLAYING; // desired state
- LLParcel* parcel = gParcelMgr->getAgentParcel();
- if (parcel)
- {
- LLString path("");
- LLMediaEngine::getInstance()->convertImageAndLoadUrl( true, false, path );
- }
-}
-//static
-void LLOverlayBar::mediaPause(void*)
-{
- if (!gOverlayBar)
+
+ if (gOverlayBar->mMediaState != PLAYING)
{
- return;
+ gOverlayBar->mMediaState = PLAYING; // desired state
+ LLParcel* parcel = gParcelMgr->getAgentParcel();
+ if (parcel)
+ {
+ LLString path("");
+ LLMediaEngine::getInstance()->convertImageAndLoadUrl( true, false, path );
+ }
}
- gOverlayBar->mMediaState = PAUSED; // desired state
- LLMediaEngine::getInstance()->pause();
-}
-//static
-void LLOverlayBar::mediaStop(void*)
-{
- if (!gOverlayBar)
+ else
{
- return;
+ gOverlayBar->mMediaState = PAUSED; // desired state
+ LLMediaEngine::getInstance()->pause();
}
- gOverlayBar->mMediaState = STOPPED; // desired state
- LLMediaEngine::getInstance()->stop();
+
+ //gOverlayBar->mMediaState = STOPPED; // desired state
+ //LLMediaEngine::getInstance()->stop();
}
//static
@@ -498,116 +370,75 @@ void LLOverlayBar::musicPlay(void*)
{
return;
}
- gOverlayBar->mMusicState = PLAYING; // desired state
- if (gAudiop)
+
+ if (gOverlayBar->mMusicState != PLAYING)
{
- LLParcel* parcel = gParcelMgr->getAgentParcel();
- if ( parcel )
+ gOverlayBar->mMusicState = PLAYING; // desired state
+ if (gAudiop)
{
- // this doesn't work properly when crossing parcel boundaries - even when the
- // stream is stopped, it doesn't return the right thing - commenting out for now.
-// if ( gAudiop->isInternetStreamPlaying() == 0 )
+ LLParcel* parcel = gParcelMgr->getAgentParcel();
+ if ( parcel )
{
- gAudiop->startInternetStream(parcel->getMusicURL().c_str());
+ // this doesn't work properly when crossing parcel boundaries - even when the
+ // stream is stopped, it doesn't return the right thing - commenting out for now.
+ // if ( gAudiop->isInternetStreamPlaying() == 0 )
+ {
+ gAudiop->startInternetStream(parcel->getMusicURL().c_str());
+ }
}
}
}
-}
-//static
-void LLOverlayBar::musicPause(void*)
-{
- if (!gOverlayBar)
- {
- return;
- }
- gOverlayBar->mMusicState = PAUSED; // desired state
- if (gAudiop)
- {
- gAudiop->pauseInternetStream(1);
- }
-}
-//static
-void LLOverlayBar::musicStop(void*)
-{
- if (!gOverlayBar)
- {
- return;
- }
- gOverlayBar->mMusicState = STOPPED; // desired state
- if (gAudiop)
+ //else
+ //{
+ // gOverlayBar->mMusicState = PAUSED; // desired state
+ // if (gAudiop)
+ // {
+ // gAudiop->pauseInternetStream(1);
+ // }
+ //}
+ else
{
- gAudiop->stopInternetStream();
+ gOverlayBar->mMusicState = STOPPED; // desired state
+ if (gAudiop)
+ {
+ gAudiop->stopInternetStream();
+ }
}
}
-//static
-void LLOverlayBar::enableMusicButtons(LLPanel* panel)
-{
- BOOL play_enabled = FALSE;
- BOOL play_visible = TRUE;
- BOOL pause_visible = FALSE;
- BOOL stop_enabled = FALSE;
- if ( gAudiop && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingMusic"))
+void LLOverlayBar::enableMediaButtons()
+{
+ if (mMediaRemote)
{
- play_enabled = TRUE;
- S32 is_playing = gAudiop->isInternetStreamPlaying();
- if (is_playing == 1)
+ // Music
+ LLParcel* parcel = gParcelMgr->getAgentParcel();
+ if (parcel
+ && gAudiop
+ && !parcel->getMusicURL().empty()
+ && gSavedSettings.getBOOL("AudioStreamingMusic"))
{
- play_visible = FALSE;
- pause_visible = TRUE;
- stop_enabled = TRUE;
+ mMediaRemote->childSetEnabled("music_play", TRUE);
}
- else if (is_playing == 2)
+ else
{
- play_visible = TRUE;
- pause_visible = FALSE;
- stop_enabled = TRUE;
+ mMediaRemote->childSetEnabled("music_play", FALSE);
}
- }
- panel->childSetEnabled("music_play", play_enabled);
- panel->childSetEnabled("music_pause", play_enabled);
- panel->childSetVisible("music_play", play_visible);
- panel->childSetVisible("music_pause", pause_visible);
- panel->childSetEnabled("music_stop", stop_enabled);
-}
-//static
-void LLOverlayBar::enableMediaButtons(LLPanel* panel)
-{
- // Media
- BOOL play_enabled = FALSE;
- BOOL play_visible = TRUE;
- BOOL pause_visible = FALSE;
- BOOL stop_enabled = FALSE;
-
- if ( LLMediaEngine::getInstance() && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingVideo") )
- {
- play_enabled = TRUE;
- if (LLMediaEngine::getInstance()->getMediaRenderer())
+ // Media
+ // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!)
+ if (LLMediaEngine::getInstance()
+ && LLMediaEngine::getInstance()->getUrl ().length ()
+ && LLMediaEngine::getInstance()->getImageUUID ().notNull ()
+ && LLMediaEngine::getInstance()->isEnabled ()
+ && LLMediaEngine::getInstance()->isAvailable ()
+ && gSavedSettings.getBOOL ( "AudioStreamingVideo" ) )
{
- if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPlaying() ||
- LLMediaEngine::getInstance()->getMediaRenderer()->isLooping() )
- {
- play_visible = FALSE;
- pause_visible = TRUE;
- stop_enabled = TRUE;
- }
- else if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPaused() )
- {
- play_visible = TRUE;
- pause_visible = FALSE;
- stop_enabled = TRUE;
- }
+ mMediaRemote->childSetEnabled("media_play", TRUE);
+ }
+ else
+ {
+ mMediaRemote->childSetEnabled("media_play", FALSE);
}
}
- panel->childSetEnabled("media_play", play_enabled);
- panel->childSetEnabled("media_pause", play_enabled);
- panel->childSetVisible("media_play", play_visible);
- panel->childSetVisible("media_pause", pause_visible);
- panel->childSetEnabled("media_stop", stop_enabled);
}
-void LLOverlayBar::toggleAudioVolumeFloater(void* user_data)
-{
- LLFloaterAudioVolume::toggleInstance(LLSD());
-}