1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
/**
* @file lloverlaybar.cpp
* @brief LLOverlayBar class implementation
*
* Copyright (c) 2002-2007, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
*/
// Temporary buttons that appear at the bottom of the screen when you
// are in a mode.
#include "llviewerprecompiledheaders.h"
#include "lloverlaybar.h"
#include "audioengine.h"
#include "llparcel.h"
#include "llagent.h"
#include "llbutton.h"
#include "llviewercontrol.h"
#include "llimview.h"
#include "lltextbox.h"
#include "llvoavatar.h"
#include "llmediaengine.h"
#include "viewer.h"
#include "llui.h"
#include "llviewermenu.h" // handle_reset_view()
#include "llviewerparcelmgr.h"
#include "llwebbrowserctrl.h"
#include "llvieweruictrlfactory.h"
#include "llviewerimagelist.h"
#include "llviewerwindow.h"
#include "llfocusmgr.h"
//
// Globals
//
LLOverlayBar *gOverlayBar = NULL;
extern S32 MENU_BAR_HEIGHT;
//
// Functions
//
//static
void* LLOverlayBar::createMediaRemote(void* userdata)
{
LLOverlayBar *self = (LLOverlayBar*)userdata;
self->mMediaRemote = new LLMediaRemoteCtrl ( "media_remote",
"media",
LLRect(),
"panel_media_remote.xml");
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;
}
LLOverlayBar::LLOverlayBar(const std::string& name, const LLRect& rect)
: LLPanel(name, rect, FALSE) // not bordered
{
setMouseOpaque(FALSE);
setIsChrome(TRUE);
isBuilt = FALSE;
LLCallbackMap::map_t factory_map;
factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this);
factory_map["music_remote"] = LLCallbackMap(LLOverlayBar::createMusicRemote, this);
gUICtrlFactory->buildPanel(this, "panel_overlaybar.xml", &factory_map);
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);
mMusicRemote->addObserver ( this );
if ( gAudiop )
{
mMusicRemote->setVolume ( gSavedSettings.getF32 ( "AudioLevelMusic" ) );
mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
};
mIsFocusRoot = TRUE;
mMediaRemote->addObserver ( this );
mMediaRemote->setVolume ( gSavedSettings.getF32 ( "MediaAudioVolume" ) );
isBuilt = true;
layoutButtons();
}
LLOverlayBar::~LLOverlayBar()
{
// LLView destructor cleans up children
mMusicRemote->remObserver ( this );
mMediaRemote->remObserver ( this );
}
EWidgetType LLOverlayBar::getWidgetType() const
{
return WIDGET_TYPE_OVERLAY_BAR;
}
LLString LLOverlayBar::getWidgetTag() const
{
return LL_OVERLAY_BAR_TAG;
}
// virtual
void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent)
{
LLView::reshape(width, height, called_from_parent);
if (isBuilt)
{
layoutButtons();
}
}
void LLOverlayBar::layoutButtons()
{
S32 width = mRect.getWidth();
if (width > 800) width = 800;
S32 count = getChildCount();
const S32 PAD = gSavedSettings.getS32("StatusBarPad");
F32 segment_width = (F32)(width) / (F32)count;
S32 btn_width = lltrunc(segment_width - PAD);
S32 remote_width = mMusicRemote->getRect().getWidth();
// 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)
{
LLView *view = *child_iter;
r = view->getRect();
r.mLeft = (width) - llround((i+1)*segment_width);
r.mRight = r.mLeft + btn_width;
view->setRect(r);
i++;
}
// Fix up remotes to have constant width because they can't shrink
r = mMusicRemote->getRect();
r.mRight = r.mLeft + remote_width;
mMusicRemote->setRect(r);
r = mMediaRemote->getRect();
r.mLeft = mMusicRemote->getRect().mRight + PAD;
r.mRight = r.mLeft + remote_width;
mMediaRemote->setRect(r);
updateRect();
}
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);
if (imagep)
{
LLGLSTexture texture_enabled;
LLViewerImage::bindTexture(imagep);
const S32 PAD = gSavedSettings.getS32("StatusBarPad");
// 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)
{
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);
}
}
}
// draw children on top
LLPanel::draw();
}
// Per-frame updates of visibility
void LLOverlayBar::refresh()
{
BOOL im_received = gIMView->getIMReceived();
childSetVisible("IM Received", im_received);
childSetEnabled("IM Received", im_received);
BOOL busy = gAgent.getBusy();
childSetVisible("Set Not Busy", busy);
childSetEnabled("Set Not Busy", busy);
BOOL controls_grabbed = gAgent.anyControlGrabbed();
childSetVisible("Release Keys", controls_grabbed);
childSetEnabled("Release Keys", controls_grabbed);
BOOL mouselook_grabbed;
mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX)
|| gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX);
childSetVisible("Mouselook", mouselook_grabbed);
childSetEnabled("Mouselook", mouselook_grabbed);
BOOL sitting = FALSE;
if (gAgent.getAvatarObject())
{
sitting = gAgent.getAvatarObject()->mIsSitting;
childSetVisible("Stand Up", sitting);
childSetEnabled("Stand Up", sitting);
}
if ( gAudiop )
{
LLParcel* parcel = gParcelMgr->getAgentParcel();
if (!parcel
|| !parcel->getMusicURL()
|| !parcel->getMusicURL()[0]
|| !gSavedSettings.getBOOL("AudioStreamingMusic"))
{
mMusicRemote->setVisible(FALSE);
mMusicRemote->setEnabled(FALSE);
}
else
{
mMusicRemote->setVisible(TRUE);
mMusicRemote->setEnabled(TRUE);
}
}
// 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" ) )
{
// display remote control
mMediaRemote->setVisible ( TRUE );
mMediaRemote->setEnabled ( TRUE );
if ( LLMediaEngine::getInstance ()->getMediaRenderer () )
{
if ( LLMediaEngine::getInstance ()->getMediaRenderer ()->isPlaying () ||
LLMediaEngine::getInstance ()->getMediaRenderer ()->isLooping () )
{
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Pause, TRUE );
}
else
if ( LLMediaEngine::getInstance ()->getMediaRenderer ()->isPaused () )
{
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Play, TRUE );
}
else
{
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE );
};
};
}
else
{
mMediaRemote->setVisible ( FALSE );
mMediaRemote->setEnabled ( FALSE );
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE );
};
BOOL any_button = (childIsVisible("IM Received")
|| childIsVisible("Set Not Busy")
|| childIsVisible("Release Keys")
|| childIsVisible("Mouselook")
|| childIsVisible("Stand Up")
|| mMusicRemote->getVisible()
|| mMediaRemote->getVisible() );
// turn off the whole bar in mouselook
if (gAgent.cameraMouselook())
{
setVisible(FALSE);
}
else
{
setVisible(any_button);
};
}
//-----------------------------------------------------------------------
// Static functions
//-----------------------------------------------------------------------
// static
void LLOverlayBar::onClickIMReceived(void*)
{
gIMView->setFloaterOpen(TRUE);
}
// static
void LLOverlayBar::onClickSetNotBusy(void*)
{
gAgent.clearBusy();
}
// static
void LLOverlayBar::onClickReleaseKeys(void*)
{
gAgent.forceReleaseControls();
}
// static
void LLOverlayBar::onClickResetView(void* data)
{
handle_reset_view();
}
//static
void LLOverlayBar::onClickMouselook(void*)
{
gAgent.changeCameraToMouselook();
}
//static
void LLOverlayBar::onClickStandUp(void*)
{
gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
}
////////////////////////////////////////////////////////////////////////////////
//
//
void
LLOverlayBar::
onVolumeChange ( const LLMediaRemoteCtrlObserver::EventType& eventIn )
{
LLUICtrl* control = eventIn.getControl ();
F32 value = eventIn.getValue ();
if ( control == mMusicRemote )
{
if (gAudiop)
{
gAudiop->setInternetStreamGain ( value );
};
gSavedSettings.setF32 ( "AudioLevelMusic", value );
}
else
if ( control == mMediaRemote )
{
LLMediaEngine::getInstance ()->setVolume ( value );
gSavedSettings.setF32 ( "MediaAudioVolume", value );
};
}
////////////////////////////////////////////////////////////////////////////////
//
//
void
LLOverlayBar::
onStopButtonPressed ( const LLMediaRemoteCtrlObserver::EventType& eventIn )
{
LLUICtrl* control = eventIn.getControl ();
if ( control == mMusicRemote )
{
if ( gAudiop )
{
gAudiop->stopInternetStream ();
};
mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
}
else
if ( control == mMediaRemote )
{
LLMediaEngine::getInstance ()->stop ();
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Stop, TRUE );
};
}
////////////////////////////////////////////////////////////////////////////////
//
//
void LLOverlayBar::onPlayButtonPressed( const LLMediaRemoteCtrlObserver::EventType& eventIn )
{
LLUICtrl* control = eventIn.getControl ();
LLParcel* parcel = gParcelMgr->getAgentParcel();
if ( control == mMusicRemote )
{
if (gAudiop)
{
if ( parcel )
{
// 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 )
//{
const char* music_url = parcel->getMusicURL();
gAudiop->startInternetStream(music_url);
mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Play, FALSE );
//}
}
};
// CP: this is the old way of doing things (click play each time on a parcel to start stream)
//if (gAudiop)
//{
// if (gAudiop->isInternetStreamPlaying() > 0)
// {
// gAudiop->pauseInternetStream ( 0 );
// }
// else
// {
// if (parcel)
// {
// const char* music_url = parcel->getMusicURL();
// gAudiop->startInternetStream(music_url);
// }
// }
//};
//mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Stop, FALSE );
}
else
if ( control == mMediaRemote )
{
LLParcel* parcel = gParcelMgr->getAgentParcel();
if (parcel)
{
LLString path( "" );
LLMediaEngine::getInstance ()->convertImageAndLoadUrl( true, false, path );
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Play, TRUE );
}
};
}
////////////////////////////////////////////////////////////////////////////////
//
//
void LLOverlayBar::onPauseButtonPressed( const LLMediaRemoteCtrlObserver::EventType& eventIn )
{
LLUICtrl* control = eventIn.getControl ();
if ( control == mMusicRemote )
{
if (gAudiop)
{
gAudiop->pauseInternetStream ( 1 );
};
mMusicRemote->setTransportState ( LLMediaRemoteCtrl::Play, FALSE );
}
else
if ( control == mMediaRemote )
{
LLMediaEngine::getInstance ()->pause ();
mMediaRemote->setTransportState ( LLMediaRemoteCtrl::Pause, TRUE );
};
}
|