aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lloverlaybar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lloverlaybar.cpp')
-rw-r--r--linden/indra/newview/lloverlaybar.cpp506
1 files changed, 167 insertions, 339 deletions
diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp
index 544fbf5..9ef2eba 100644
--- a/linden/indra/newview/lloverlaybar.cpp
+++ b/linden/indra/newview/lloverlaybar.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -39,6 +39,7 @@
39#include "audioengine.h" 39#include "audioengine.h"
40#include "llagent.h" 40#include "llagent.h"
41#include "llbutton.h" 41#include "llbutton.h"
42#include "llchatbar.h"
42#include "llfocusmgr.h" 43#include "llfocusmgr.h"
43#include "llimview.h" 44#include "llimview.h"
44#include "llmediaengine.h" 45#include "llmediaengine.h"
@@ -71,37 +72,14 @@ extern S32 MENU_BAR_HEIGHT;
71// 72//
72 73
73 74
74//static
75void* LLOverlayBar::createMasterRemote(void* userdata)
76{
77 LLOverlayBar *self = (LLOverlayBar*)userdata;
78 self->mMasterRemote = new LLMediaRemoteCtrl ( "master_volume",
79 "volume",
80 LLRect(),
81 "panel_master_volume.xml");
82 return self->mMasterRemote;
83}
84 75
85void* LLOverlayBar::createMediaRemote(void* userdata) 76void* LLOverlayBar::createMediaRemote(void* userdata)
86{ 77{
87 LLOverlayBar *self = (LLOverlayBar*)userdata; 78 LLOverlayBar *self = (LLOverlayBar*)userdata;
88 self->mMediaRemote = new LLMediaRemoteCtrl ( "media_remote", 79 self->mMediaRemote = new LLMediaRemoteCtrl ();
89 "media",
90 LLRect(),
91 "panel_media_remote.xml");
92 return self->mMediaRemote; 80 return self->mMediaRemote;
93} 81}
94 82
95void* LLOverlayBar::createMusicRemote(void* userdata)
96{
97 LLOverlayBar *self = (LLOverlayBar*)userdata;
98 self->mMusicRemote = new LLMediaRemoteCtrl ( "music_remote",
99 "music",
100 LLRect(),
101 "panel_music_remote.xml" );
102 return self->mMusicRemote;
103}
104
105void* LLOverlayBar::createVoiceRemote(void* userdata) 83void* LLOverlayBar::createVoiceRemote(void* userdata)
106{ 84{
107 LLOverlayBar *self = (LLOverlayBar*)userdata; 85 LLOverlayBar *self = (LLOverlayBar*)userdata;
@@ -109,13 +87,14 @@ void* LLOverlayBar::createVoiceRemote(void* userdata)
109 return self->mVoiceRemote; 87 return self->mVoiceRemote;
110} 88}
111 89
90void* LLOverlayBar::createChatBar(void* userdata)
91{
92 gChatBar = new LLChatBar();
93 return gChatBar;
94}
112 95
113 96LLOverlayBar::LLOverlayBar()
114 97 : LLPanel(),
115LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
116 : LLPanel(name, rect, FALSE), // not bordered
117 mMasterRemote(NULL),
118 mMusicRemote(NULL),
119 mMediaRemote(NULL), 98 mMediaRemote(NULL),
120 mVoiceRemote(NULL), 99 mVoiceRemote(NULL),
121 mMediaState(STOPPED), 100 mMediaState(STOPPED),
@@ -127,25 +106,27 @@ LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
127 mBuilt = false; 106 mBuilt = false;
128 107
129 LLCallbackMap::map_t factory_map; 108 LLCallbackMap::map_t factory_map;
130 factory_map["master_volume"] = LLCallbackMap(LLOverlayBar::createMasterRemote, this);
131 factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this); 109 factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this);
132 factory_map["music_remote"] = LLCallbackMap(LLOverlayBar::createMusicRemote, this);
133 factory_map["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this); 110 factory_map["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this);
111 factory_map["chat_bar"] = LLCallbackMap(LLOverlayBar::createChatBar, this);
134 112
135 gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map); 113 gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map);
136 114}
115
116BOOL LLOverlayBar::postBuild()
117{
137 childSetAction("IM Received",onClickIMReceived,this); 118 childSetAction("IM Received",onClickIMReceived,this);
138 childSetAction("Set Not Busy",onClickSetNotBusy,this); 119 childSetAction("Set Not Busy",onClickSetNotBusy,this);
139 childSetAction("Release Keys",onClickReleaseKeys,this); 120 childSetAction("Release Keys",onClickReleaseKeys,this);
140 childSetAction("Mouselook",onClickMouselook,this); 121 childSetAction("Mouselook",onClickMouselook,this);
141 childSetAction("Stand Up",onClickStandUp,this); 122 childSetAction("Stand Up",onClickStandUp,this);
123 childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible"));
142 124
143 mIsFocusRoot = TRUE; 125 mIsFocusRoot = TRUE;
144 mBuilt = true; 126 mBuilt = true;
145 127
146 // make overlay bar conform to window size
147 setRect(rect);
148 layoutButtons(); 128 layoutButtons();
129 return TRUE;
149} 130}
150 131
151LLOverlayBar::~LLOverlayBar() 132LLOverlayBar::~LLOverlayBar()
@@ -176,236 +157,132 @@ void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent)
176 157
177void LLOverlayBar::layoutButtons() 158void LLOverlayBar::layoutButtons()
178{ 159{
179 S32 width = mRect.getWidth(); 160 LLView* state_buttons_panel = getChildByName("state_buttons", TRUE);
180 if (width > 1024) width = 1024;
181
182 S32 count = getChildCount();
183 const S32 PAD = gSavedSettings.getS32("StatusBarPad");
184
185 const S32 num_media_controls = 3;
186 S32 media_remote_width = mMediaRemote ? mMediaRemote->getRect().getWidth() : 0;
187 S32 music_remote_width = mMusicRemote ? mMusicRemote->getRect().getWidth() : 0;
188 S32 voice_remote_width = mVoiceRemote ? mVoiceRemote->getRect().getWidth() : 0;
189 S32 master_remote_width = mMasterRemote ? mMasterRemote->getRect().getWidth() : 0;
190
191 // total reserved width for all media remotes
192 const S32 ENDPAD = 20;
193 S32 remote_total_width = media_remote_width + PAD + music_remote_width + PAD + voice_remote_width + PAD + master_remote_width + ENDPAD;
194 161
195 // calculate button widths 162 if (state_buttons_panel && state_buttons_panel->getVisible())
196 F32 segment_width = (F32)(width - remote_total_width) / (F32)(count - num_media_controls);
197
198 S32 btn_width = lltrunc(segment_width - PAD);
199
200 // Evenly space all views
201 LLRect r;
202 S32 i = 0;
203 for (child_list_const_iter_t child_iter = getChildList()->begin();
204 child_iter != getChildList()->end(); ++child_iter)
205 { 163 {
206 LLView *view = *child_iter; 164 LLViewQuery query;
207 r = view->getRect(); 165 LLWidgetTypeFilter widget_filter(WIDGET_TYPE_BUTTON);
208 r.mLeft = (width) - llround(remote_total_width + (i-num_media_controls+1)*segment_width); 166 query.addPreFilter(LLVisibleFilter::getInstance());
209 r.mRight = r.mLeft + btn_width; 167 query.addPreFilter(LLEnabledFilter::getInstance());
210 view->setRect(r); 168 query.addPreFilter(&widget_filter);
211 i++;
212 }
213 169
214 // Fix up remotes to have constant width because they can't shrink 170 child_list_t button_list = query(state_buttons_panel);
215 S32 right = mRect.getWidth() - remote_total_width - PAD;
216 if (mMediaRemote)
217 {
218 r = mMediaRemote->getRect();
219 r.mLeft = right + PAD;
220 right = r.mLeft + media_remote_width;
221 r.mRight = right;
222 mMediaRemote->setRect(r);
223 }
224 if (mMusicRemote)
225 {
226 r = mMusicRemote->getRect();
227 r.mLeft = right + PAD;
228 right = r.mLeft + music_remote_width;
229 r.mRight = right;
230 mMusicRemote->setRect(r);
231 }
232 if (mVoiceRemote)
233 {
234 r = mVoiceRemote->getRect();
235 r.mLeft = right + PAD;
236 right = r.mLeft + voice_remote_width;
237 r.mRight = right;
238 mVoiceRemote->setRect(r);
239 }
240 if (mMasterRemote)
241 {
242 r = mMasterRemote->getRect();
243 r.mLeft = right + PAD;
244 right = r.mLeft + master_remote_width;
245 r.mRight = right;
246 mMasterRemote->setRect(r);
247 }
248
249 updateRect();
250}
251
252void LLOverlayBar::draw()
253{
254 // retrieve rounded rect image
255 LLUUID image_id;
256 image_id.set(gViewerArt.getString("rounded_square.tga"));
257 LLViewerImage* imagep = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
258 171
259 if (imagep) 172 const S32 MAX_BAR_WIDTH = 600;
260 { 173 S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH);
261 LLGLSTexture texture_enabled;
262 LLViewerImage::bindTexture(imagep);
263 174
264 const S32 PAD = gSavedSettings.getS32("StatusBarPad"); 175 // calculate button widths
176 const S32 MAX_BUTTON_WIDTH = 150;
177 S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_list.size()), 0, MAX_BUTTON_WIDTH);
178 S32 btn_width = segment_width - gSavedSettings.getS32("StatusBarPad");
265 179
266 // draw rounded rect tabs behind all children 180 // Evenly space all buttons, starting from left
267 LLRect r; 181 S32 left = 0;
268 // focus highlights 182 S32 bottom = 1;
269 LLColor4 color = gColors.getColor("FloaterFocusBorderColor");
270 glColor4fv(color.mV);
271 if(gFocusMgr.childHasKeyboardFocus(gBottomPanel))
272 {
273 for (child_list_const_iter_t child_iter = getChildList()->begin();
274 child_iter != getChildList()->end(); ++child_iter)
275 {
276 LLView *view = *child_iter;
277 if(view->getEnabled() && view->getVisible())
278 {
279 r = view->getRect();
280 gl_segmented_rect_2d_tex(r.mLeft - PAD/3 - 1,
281 r.mTop + 3,
282 r.mRight + PAD/3 + 1,
283 r.mBottom,
284 imagep->getWidth(),
285 imagep->getHeight(),
286 16,
287 ROUNDED_RECT_TOP);
288 }
289 }
290 }
291 183
292 // main tabs 184 for (child_list_reverse_iter_t child_iter = button_list.rbegin();
293 for (child_list_const_iter_t child_iter = getChildList()->begin(); 185 child_iter != button_list.rend(); ++child_iter)
294 child_iter != getChildList()->end(); ++child_iter)
295 { 186 {
296 LLView *view = *child_iter; 187 LLView *view = *child_iter;
297 if(view->getEnabled() && view->getVisible()) 188 LLRect r = view->getRect();
298 { 189 r.setOriginAndSize(left, bottom, btn_width, r.getHeight());
299 r = view->getRect(); 190 view->setRect(r);
300 // draw a nice little pseudo-3D outline 191 left += segment_width;
301 color = gColors.getColor("DefaultShadowDark");
302 glColor4fv(color.mV);
303 gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 2, r.mRight + PAD/3, r.mBottom,
304 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
305 color = gColors.getColor("DefaultHighlightLight");
306 glColor4fv(color.mV);
307 gl_segmented_rect_2d_tex(r.mLeft - PAD/3, r.mTop + 2, r.mRight + PAD/3 - 3, r.mBottom,
308 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
309 // here's the main background. Note that it overhangs on the bottom so as to hide the
310 // focus highlight on the bottom panel, thus producing the illusion that the focus highlight
311 // continues around the tabs
312 color = gColors.getColor("FocusBackgroundColor");
313 glColor4fv(color.mV);
314 gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 1, r.mRight + PAD/3 - 1, r.mBottom - 1,
315 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
316 }
317 } 192 }
318 } 193 }
319
320 // draw children on top
321 LLPanel::draw();
322} 194}
323 195
324
325// Per-frame updates of visibility 196// Per-frame updates of visibility
326void LLOverlayBar::refresh() 197void LLOverlayBar::refresh()
327{ 198{
199 BOOL buttons_changed = FALSE;
200
328 BOOL im_received = gIMMgr->getIMReceived(); 201 BOOL im_received = gIMMgr->getIMReceived();
329 childSetVisible("IM Received", im_received); 202 LLButton* button = LLUICtrlFactory::getButtonByName(this, "IM Received");
330 childSetEnabled("IM Received", im_received); 203 if (button && button->getVisible() != im_received)
204 {
205 button->setVisible(im_received);
206 sendChildToFront(button);
207 moveChildToBackOfTabGroup(button);
208 buttons_changed = TRUE;
209 }
331 210
332 BOOL busy = gAgent.getBusy(); 211 BOOL busy = gAgent.getBusy();
333 childSetVisible("Set Not Busy", busy); 212 button = LLUICtrlFactory::getButtonByName(this, "Set Not Busy");
334 childSetEnabled("Set Not Busy", busy); 213 if (button && button->getVisible() != busy)
214 {
215 button->setVisible(busy);
216 sendChildToFront(button);
217 moveChildToBackOfTabGroup(button);
218 buttons_changed = TRUE;
219 }
335 220
336 BOOL controls_grabbed = gAgent.anyControlGrabbed(); 221 BOOL controls_grabbed = gAgent.anyControlGrabbed();
222 button = LLUICtrlFactory::getButtonByName(this, "Release Keys");
337 223
338 childSetVisible("Release Keys", controls_grabbed); 224 if (button && button->getVisible() != controls_grabbed)
339 childSetEnabled("Release Keys", controls_grabbed); 225 {
340 226 button->setVisible(controls_grabbed);
227 sendChildToFront(button);
228 moveChildToBackOfTabGroup(button);
229 buttons_changed = TRUE;
230 }
341 231
342 BOOL mouselook_grabbed; 232 BOOL mouselook_grabbed;
343 mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX) 233 mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX)
344 || gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX); 234 || gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX);
235 button = LLUICtrlFactory::getButtonByName(this, "Mouselook");
345 236
346 237 if (button && button->getVisible() != mouselook_grabbed)
347 childSetVisible("Mouselook", mouselook_grabbed); 238 {
348 childSetEnabled("Mouselook", mouselook_grabbed); 239 button->setVisible(mouselook_grabbed);
240 sendChildToFront(button);
241 moveChildToBackOfTabGroup(button);
242 buttons_changed = TRUE;
243 }
349 244
350 BOOL sitting = FALSE; 245 BOOL sitting = FALSE;
351 if (gAgent.getAvatarObject()) 246 if (gAgent.getAvatarObject())
352 { 247 {
353 sitting = gAgent.getAvatarObject()->mIsSitting; 248 sitting = gAgent.getAvatarObject()->mIsSitting;
354 childSetVisible("Stand Up", sitting);
355 childSetEnabled("Stand Up", sitting);
356
357 } 249 }
250 button = LLUICtrlFactory::getButtonByName(this, "Stand Up");
358 251
359 if ( mMusicRemote && gAudiop ) 252 if (button && button->getVisible() != sitting)
360 { 253 {
361 LLParcel* parcel = gParcelMgr->getAgentParcel(); 254 button->setVisible(sitting);
362 if (!parcel 255 sendChildToFront(button);
363 || parcel->getMusicURL().empty() 256 moveChildToBackOfTabGroup(button);
364 || !gSavedSettings.getBOOL("AudioStreamingMusic")) 257 buttons_changed = TRUE;
365 {
366 mMusicRemote->setVisible(FALSE);
367 mMusicRemote->setEnabled(FALSE);
368 }
369 else
370 {
371 mMusicRemote->setVisible(TRUE);
372 mMusicRemote->setEnabled(TRUE);
373 }
374 } 258 }
375 259
376 // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!) 260 enableMediaButtons();
377 if ( mMediaRemote ) 261
378 { 262 moveChildToBackOfTabGroup(mMediaRemote);
379 if (LLMediaEngine::getInstance () && 263 moveChildToBackOfTabGroup(mVoiceRemote);
380 LLMediaEngine::getInstance ()->getUrl ().length () && 264
381 LLMediaEngine::getInstance ()->getImageUUID ().notNull () &&
382 LLMediaEngine::getInstance ()->isEnabled () &&
383 LLMediaEngine::getInstance ()->isAvailable () &&
384 gSavedSettings.getBOOL ( "AudioStreamingVideo" ) )
385 {
386 // display remote control
387 mMediaRemote->setVisible ( TRUE );
388 mMediaRemote->setEnabled ( TRUE );
389 }
390 else
391 {
392 mMediaRemote->setVisible ( FALSE );
393 mMediaRemote->setEnabled ( FALSE );
394 }
395 }
396 if (mVoiceRemote)
397 {
398 mVoiceRemote->setVisible(LLVoiceClient::voiceEnabled());
399 }
400
401 // turn off the whole bar in mouselook 265 // turn off the whole bar in mouselook
402 if (gAgent.cameraMouselook()) 266 if (gAgent.cameraMouselook())
403 { 267 {
404 setVisible(FALSE); 268 childSetVisible("media_remote_container", FALSE);
269 childSetVisible("voice_remote_container", FALSE);
270 childSetVisible("state_buttons", FALSE);
405 } 271 }
406 else 272 else
407 { 273 {
408 setVisible(TRUE); 274 // update "remotes"
275 childSetVisible("media_remote_container", TRUE);
276 childSetVisible("voice_remote_container", LLVoiceClient::voiceEnabled());
277 childSetVisible("state_buttons", TRUE);
278 }
279
280 // always let user toggle into and out of chatbar
281 childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible"));
282
283 if (buttons_changed)
284 {
285 layoutButtons();
409 } 286 }
410} 287}
411 288
@@ -462,33 +339,25 @@ void LLOverlayBar::mediaPlay(void*)
462 { 339 {
463 return; 340 return;
464 } 341 }
465 gOverlayBar->mMediaState = PLAYING; // desired state 342
466 LLParcel* parcel = gParcelMgr->getAgentParcel(); 343 if (gOverlayBar->mMediaState != PLAYING)
467 if (parcel)
468 {
469 LLString path("");
470 LLMediaEngine::getInstance()->convertImageAndLoadUrl( true, false, path );
471 }
472}
473//static
474void LLOverlayBar::mediaPause(void*)
475{
476 if (!gOverlayBar)
477 { 344 {
478 return; 345 gOverlayBar->mMediaState = PLAYING; // desired state
346 LLParcel* parcel = gParcelMgr->getAgentParcel();
347 if (parcel)
348 {
349 LLString path("");
350 LLMediaEngine::getInstance()->convertImageAndLoadUrl( true, false, path );
351 }
479 } 352 }
480 gOverlayBar->mMediaState = PAUSED; // desired state 353 else
481 LLMediaEngine::getInstance()->pause();
482}
483//static
484void LLOverlayBar::mediaStop(void*)
485{
486 if (!gOverlayBar)
487 { 354 {
488 return; 355 gOverlayBar->mMediaState = PAUSED; // desired state
356 LLMediaEngine::getInstance()->pause();
489 } 357 }
490 gOverlayBar->mMediaState = STOPPED; // desired state 358
491 LLMediaEngine::getInstance()->stop(); 359 //gOverlayBar->mMediaState = STOPPED; // desired state
360 //LLMediaEngine::getInstance()->stop();
492} 361}
493 362
494//static 363//static
@@ -498,116 +367,75 @@ void LLOverlayBar::musicPlay(void*)
498 { 367 {
499 return; 368 return;
500 } 369 }
501 gOverlayBar->mMusicState = PLAYING; // desired state 370
502 if (gAudiop) 371 if (gOverlayBar->mMusicState != PLAYING)
503 { 372 {
504 LLParcel* parcel = gParcelMgr->getAgentParcel(); 373 gOverlayBar->mMusicState = PLAYING; // desired state
505 if ( parcel ) 374 if (gAudiop)
506 { 375 {
507 // this doesn't work properly when crossing parcel boundaries - even when the 376 LLParcel* parcel = gParcelMgr->getAgentParcel();
508 // stream is stopped, it doesn't return the right thing - commenting out for now. 377 if ( parcel )
509// if ( gAudiop->isInternetStreamPlaying() == 0 )
510 { 378 {
511 gAudiop->startInternetStream(parcel->getMusicURL().c_str()); 379 // this doesn't work properly when crossing parcel boundaries - even when the
380 // stream is stopped, it doesn't return the right thing - commenting out for now.
381 // if ( gAudiop->isInternetStreamPlaying() == 0 )
382 {
383 gAudiop->startInternetStream(parcel->getMusicURL().c_str());
384 }
512 } 385 }
513 } 386 }
514 } 387 }
515} 388 //else
516//static 389 //{
517void LLOverlayBar::musicPause(void*) 390 // gOverlayBar->mMusicState = PAUSED; // desired state
518{ 391 // if (gAudiop)
519 if (!gOverlayBar) 392 // {
520 { 393 // gAudiop->pauseInternetStream(1);
521 return; 394 // }
522 } 395 //}
523 gOverlayBar->mMusicState = PAUSED; // desired state 396 else
524 if (gAudiop)
525 {
526 gAudiop->pauseInternetStream(1);
527 }
528}
529//static
530void LLOverlayBar::musicStop(void*)
531{
532 if (!gOverlayBar)
533 {
534 return;
535 }
536 gOverlayBar->mMusicState = STOPPED; // desired state
537 if (gAudiop)
538 { 397 {
539 gAudiop->stopInternetStream(); 398 gOverlayBar->mMusicState = STOPPED; // desired state
399 if (gAudiop)
400 {
401 gAudiop->stopInternetStream();
402 }
540 } 403 }
541} 404}
542 405
543//static 406void LLOverlayBar::enableMediaButtons()
544void LLOverlayBar::enableMusicButtons(LLPanel* panel) 407{
545{ 408 if (mMediaRemote)
546 BOOL play_enabled = FALSE;
547 BOOL play_visible = TRUE;
548 BOOL pause_visible = FALSE;
549 BOOL stop_enabled = FALSE;
550 if ( gAudiop && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingMusic"))
551 { 409 {
552 play_enabled = TRUE; 410 // Music
553 S32 is_playing = gAudiop->isInternetStreamPlaying(); 411 LLParcel* parcel = gParcelMgr->getAgentParcel();
554 if (is_playing == 1) 412 if (parcel
413 && gAudiop
414 && !parcel->getMusicURL().empty()
415 && gSavedSettings.getBOOL("AudioStreamingMusic"))
555 { 416 {
556 play_visible = FALSE; 417 mMediaRemote->childSetEnabled("music_play", TRUE);
557 pause_visible = TRUE;
558 stop_enabled = TRUE;
559 } 418 }
560 else if (is_playing == 2) 419 else
561 { 420 {
562 play_visible = TRUE; 421 mMediaRemote->childSetEnabled("music_play", FALSE);
563 pause_visible = FALSE;
564 stop_enabled = TRUE;
565 } 422 }
566 }
567 panel->childSetEnabled("music_play", play_enabled);
568 panel->childSetEnabled("music_pause", play_enabled);
569 panel->childSetVisible("music_play", play_visible);
570 panel->childSetVisible("music_pause", pause_visible);
571 panel->childSetEnabled("music_stop", stop_enabled);
572}
573 423
574//static 424 // Media
575void LLOverlayBar::enableMediaButtons(LLPanel* panel) 425 // if there is a url and a texture and media is enabled and available and media streaming is on... (phew!)
576{ 426 if (LLMediaEngine::getInstance()
577 // Media 427 && LLMediaEngine::getInstance()->getUrl ().length ()
578 BOOL play_enabled = FALSE; 428 && LLMediaEngine::getInstance()->getImageUUID ().notNull ()
579 BOOL play_visible = TRUE; 429 && LLMediaEngine::getInstance()->isEnabled ()
580 BOOL pause_visible = FALSE; 430 && LLMediaEngine::getInstance()->isAvailable ()
581 BOOL stop_enabled = FALSE; 431 && gSavedSettings.getBOOL ( "AudioStreamingVideo" ) )
582
583 if ( LLMediaEngine::getInstance() && gOverlayBar && gSavedSettings.getBOOL("AudioStreamingVideo") )
584 {
585 play_enabled = TRUE;
586 if (LLMediaEngine::getInstance()->getMediaRenderer())
587 { 432 {
588 if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPlaying() || 433 mMediaRemote->childSetEnabled("media_play", TRUE);
589 LLMediaEngine::getInstance()->getMediaRenderer()->isLooping() ) 434 }
590 { 435 else
591 play_visible = FALSE; 436 {
592 pause_visible = TRUE; 437 mMediaRemote->childSetEnabled("media_play", FALSE);
593 stop_enabled = TRUE;
594 }
595 else if ( LLMediaEngine::getInstance()->getMediaRenderer()->isPaused() )
596 {
597 play_visible = TRUE;
598 pause_visible = FALSE;
599 stop_enabled = TRUE;
600 }
601 } 438 }
602 } 439 }
603 panel->childSetEnabled("media_play", play_enabled);
604 panel->childSetEnabled("media_pause", play_enabled);
605 panel->childSetVisible("media_play", play_visible);
606 panel->childSetVisible("media_pause", pause_visible);
607 panel->childSetEnabled("media_stop", stop_enabled);
608} 440}
609 441
610void LLOverlayBar::toggleAudioVolumeFloater(void* user_data)
611{
612 LLFloaterAudioVolume::toggleInstance(LLSD());
613}