diff options
Diffstat (limited to 'linden/indra/newview/llpanelmediahud.cpp')
-rw-r--r-- | linden/indra/newview/llpanelmediahud.cpp | 667 |
1 files changed, 667 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelmediahud.cpp b/linden/indra/newview/llpanelmediahud.cpp new file mode 100644 index 0000000..39c4b63 --- /dev/null +++ b/linden/indra/newview/llpanelmediahud.cpp | |||
@@ -0,0 +1,667 @@ | |||
1 | /** | ||
2 | * @file llpanelmsgs.cpp | ||
3 | * @brief Message popup preferences panel | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2003-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
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 | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
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 | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | //LLPanelMediaHUD | ||
36 | #include "llagent.h" | ||
37 | #include "llparcel.h" | ||
38 | #include "llpanel.h" | ||
39 | #include "llselectmgr.h" | ||
40 | #include "llrender.h" | ||
41 | #include "lldrawable.h" | ||
42 | #include "llviewerwindow.h" | ||
43 | #include "lluictrlfactory.h" | ||
44 | #include "llbutton.h" | ||
45 | #include "llface.h" | ||
46 | #include "llhudview.h" | ||
47 | #include "lliconctrl.h" | ||
48 | #include "lltoolpie.h" | ||
49 | #include "llviewercamera.h" | ||
50 | #include "llpanelmediahud.h" | ||
51 | #include "llpluginclassmedia.h" | ||
52 | #include "llviewercontrol.h" | ||
53 | #include "llviewerparcelmgr.h" | ||
54 | #include "llviewermedia.h" | ||
55 | #include "llviewermediafocus.h" | ||
56 | #include "llvovolume.h" | ||
57 | #include "llweb.h" | ||
58 | |||
59 | glh::matrix4f glh_get_current_modelview(); | ||
60 | glh::matrix4f glh_get_current_projection(); | ||
61 | |||
62 | const F32 ZOOM_NEAR_PADDING = 1.0f; | ||
63 | const F32 ZOOM_MEDIUM_PADDING = 1.2f; | ||
64 | const F32 ZOOM_FAR_PADDING = 1.5f; | ||
65 | |||
66 | // | ||
67 | // LLPanelMediaHUD | ||
68 | // | ||
69 | |||
70 | LLPanelMediaHUD::LLPanelMediaHUD(viewer_media_t media_impl) | ||
71 | : mMediaImpl(media_impl) | ||
72 | { | ||
73 | mMediaFocus = false; | ||
74 | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_media_hud.xml"); | ||
75 | mMouseMoveTimer.reset(); | ||
76 | mFadeTimer.stop(); | ||
77 | mCurrentZoom = ZOOM_NONE; | ||
78 | mScrollState = SCROLL_NONE; | ||
79 | |||
80 | mPanelHandle.bind(this); | ||
81 | } | ||
82 | LLPanelMediaHUD::~LLPanelMediaHUD() | ||
83 | { | ||
84 | mMediaImpl = NULL; | ||
85 | } | ||
86 | |||
87 | BOOL LLPanelMediaHUD::postBuild() | ||
88 | { | ||
89 | LLButton* close_btn = getChild<LLButton>("close"); | ||
90 | close_btn->setClickedCallback(onClickClose, this); | ||
91 | |||
92 | LLButton* back_btn = getChild<LLButton>("back"); | ||
93 | back_btn->setClickedCallback(onClickBack, this); | ||
94 | |||
95 | LLButton* fwd_btn = getChild<LLButton>("fwd"); | ||
96 | fwd_btn->setClickedCallback(onClickForward, this); | ||
97 | |||
98 | LLButton* home_btn = getChild<LLButton>("home"); | ||
99 | home_btn->setClickedCallback(onClickHome, this); | ||
100 | |||
101 | LLButton* stop_btn = getChild<LLButton>("stop"); | ||
102 | stop_btn->setClickedCallback(onClickStop, this); | ||
103 | |||
104 | LLButton* media_stop_btn = getChild<LLButton>("media_stop"); | ||
105 | media_stop_btn->setClickedCallback(onClickStop, this); | ||
106 | |||
107 | LLButton* reload_btn = getChild<LLButton>("reload"); | ||
108 | reload_btn->setClickedCallback(onClickReload, this); | ||
109 | |||
110 | LLButton* play_btn = getChild<LLButton>("play"); | ||
111 | play_btn->setClickedCallback(onClickPlay, this); | ||
112 | |||
113 | LLButton* pause_btn = getChild<LLButton>("pause"); | ||
114 | pause_btn->setClickedCallback(onClickPause, this); | ||
115 | |||
116 | LLButton* open_btn = getChild<LLButton>("new_window"); | ||
117 | open_btn->setClickedCallback(onClickOpen, this); | ||
118 | |||
119 | LLButton* zoom_btn = getChild<LLButton>("zoom_frame"); | ||
120 | zoom_btn->setClickedCallback(onClickZoom, this); | ||
121 | |||
122 | LLButton* open_btn_h = getChild<LLButton>("new_window_hover"); | ||
123 | open_btn_h->setClickedCallback(onClickOpen, this); | ||
124 | |||
125 | LLButton* zoom_btn_h = getChild<LLButton>("zoom_frame_hover"); | ||
126 | zoom_btn_h->setClickedCallback(onClickZoom, this); | ||
127 | |||
128 | LLButton* scroll_up_btn = getChild<LLButton>("scrollup"); | ||
129 | scroll_up_btn->setClickedCallback(onScrollUp, this); | ||
130 | scroll_up_btn->setHeldDownCallback(onScrollUpHeld); | ||
131 | scroll_up_btn->setMouseUpCallback(onScrollStop); | ||
132 | LLButton* scroll_left_btn = getChild<LLButton>("scrollleft"); | ||
133 | scroll_left_btn->setClickedCallback(onScrollLeft, this); | ||
134 | scroll_left_btn->setHeldDownCallback(onScrollLeftHeld); | ||
135 | scroll_left_btn->setMouseUpCallback(onScrollStop); | ||
136 | LLButton* scroll_right_btn = getChild<LLButton>("scrollright"); | ||
137 | scroll_right_btn->setClickedCallback(onScrollRight, this); | ||
138 | scroll_right_btn->setHeldDownCallback(onScrollLeftHeld); | ||
139 | scroll_right_btn->setMouseUpCallback(onScrollStop); | ||
140 | LLButton* scroll_down_btn = getChild<LLButton>("scrolldown"); | ||
141 | scroll_down_btn->setClickedCallback(onScrollDown, this); | ||
142 | scroll_down_btn->setHeldDownCallback(onScrollDownHeld); | ||
143 | scroll_down_btn->setMouseUpCallback(onScrollStop); | ||
144 | |||
145 | mMouseInactiveTime = gSavedSettings.getF32("MediaControlTimeout"); | ||
146 | mControlFadeTime = gSavedSettings.getF32("MediaControlFadeTime"); | ||
147 | |||
148 | mCurrentZoom = ZOOM_NONE; | ||
149 | // clicks on HUD buttons do not remove keyboard focus from media | ||
150 | setIsChrome(TRUE); | ||
151 | return TRUE; | ||
152 | } | ||
153 | |||
154 | void LLPanelMediaHUD::updateShape() | ||
155 | { | ||
156 | const S32 MIN_HUD_WIDTH=200; | ||
157 | const S32 MIN_HUD_HEIGHT=120; | ||
158 | |||
159 | LLPluginClassMedia* media_plugin = NULL; | ||
160 | if(mMediaImpl.notNull() && mMediaImpl->hasMedia()) | ||
161 | { | ||
162 | media_plugin = mMediaImpl->getMediaPlugin(); | ||
163 | } | ||
164 | |||
165 | // Early out for no media plugin | ||
166 | if(media_plugin == NULL) | ||
167 | { | ||
168 | setVisible(FALSE); | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); | ||
173 | |||
174 | bool can_navigate = parcel->getMediaAllowNavigate(); | ||
175 | |||
176 | // LLObjectSelectionHandle selection = LLViewerMediaFocus::getInstance()->getSelection(); | ||
177 | |||
178 | LLSelectNode* nodep = mMediaFocus ? LLSelectMgr::getInstance()->getSelection()->getFirstNode() : LLSelectMgr::getInstance()->getHoverNode(); | ||
179 | if(! nodep) | ||
180 | { | ||
181 | return; | ||
182 | } | ||
183 | setVisible(FALSE); | ||
184 | LLViewerObject* objectp = nodep->getObject(); | ||
185 | |||
186 | if (objectp) | ||
187 | { | ||
188 | |||
189 | // Set the state of the buttons | ||
190 | LLButton* back_btn = getChild<LLButton>("back"); | ||
191 | LLButton* fwd_btn = getChild<LLButton>("fwd"); | ||
192 | LLButton* reload_btn = getChild<LLButton>("reload"); | ||
193 | LLButton* play_btn = getChild<LLButton>("play"); | ||
194 | LLButton* pause_btn = getChild<LLButton>("pause"); | ||
195 | LLButton* stop_btn = getChild<LLButton>("stop"); | ||
196 | LLButton* media_stop_btn = getChild<LLButton>("media_stop"); | ||
197 | LLButton* home_btn = getChild<LLButton>("home"); | ||
198 | LLButton* close_btn = getChild<LLButton>("close"); | ||
199 | LLButton* open_btn = getChild<LLButton>("new_window"); | ||
200 | LLPanel* media_focused_panel = getChild<LLPanel>("media_focused_controls"); | ||
201 | LLPanel* media_hover_panel = getChild<LLPanel>("media_hover_controls"); | ||
202 | back_btn->setVisible(true); | ||
203 | fwd_btn->setVisible(true); | ||
204 | reload_btn->setVisible(true); | ||
205 | stop_btn->setVisible(false); | ||
206 | home_btn->setVisible(true); | ||
207 | close_btn->setVisible(true); | ||
208 | open_btn->setVisible(true); | ||
209 | |||
210 | |||
211 | if(mMediaFocus) | ||
212 | { | ||
213 | back_btn->setEnabled(mMediaImpl->canNavigateBack() && can_navigate); | ||
214 | fwd_btn->setEnabled(mMediaImpl->canNavigateForward() && can_navigate); | ||
215 | stop_btn->setEnabled(can_navigate); | ||
216 | home_btn->setEnabled(can_navigate); | ||
217 | LLPluginClassMediaOwner::EMediaStatus result = media_plugin->getStatus(); | ||
218 | |||
219 | if(media_plugin->pluginSupportsMediaTime()) | ||
220 | { | ||
221 | reload_btn->setEnabled(FALSE); | ||
222 | reload_btn->setVisible(FALSE); | ||
223 | media_stop_btn->setVisible(TRUE); | ||
224 | home_btn->setVisible(FALSE); | ||
225 | back_btn->setEnabled(TRUE); | ||
226 | fwd_btn->setEnabled(TRUE); | ||
227 | switch(result) | ||
228 | { | ||
229 | case LLPluginClassMediaOwner::MEDIA_PLAYING: | ||
230 | play_btn->setEnabled(FALSE); | ||
231 | play_btn->setVisible(FALSE); | ||
232 | pause_btn->setEnabled(TRUE); | ||
233 | pause_btn->setVisible(TRUE); | ||
234 | media_stop_btn->setEnabled(TRUE); | ||
235 | break; | ||
236 | case LLPluginClassMediaOwner::MEDIA_PAUSED: | ||
237 | default: | ||
238 | pause_btn->setEnabled(FALSE); | ||
239 | pause_btn->setVisible(FALSE); | ||
240 | play_btn->setEnabled(TRUE); | ||
241 | play_btn->setVisible(TRUE); | ||
242 | media_stop_btn->setEnabled(FALSE); | ||
243 | break; | ||
244 | } | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | play_btn->setVisible(FALSE); | ||
249 | pause_btn->setVisible(FALSE); | ||
250 | media_stop_btn->setVisible(FALSE); | ||
251 | if(result == LLPluginClassMediaOwner::MEDIA_LOADING) | ||
252 | { | ||
253 | reload_btn->setEnabled(FALSE); | ||
254 | reload_btn->setVisible(FALSE); | ||
255 | stop_btn->setEnabled(TRUE); | ||
256 | stop_btn->setVisible(TRUE); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | reload_btn->setEnabled(TRUE); | ||
261 | reload_btn->setVisible(TRUE); | ||
262 | stop_btn->setEnabled(FALSE); | ||
263 | stop_btn->setVisible(FALSE); | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | media_focused_panel->setVisible(mMediaFocus); | ||
268 | media_hover_panel->setVisible(!mMediaFocus); | ||
269 | |||
270 | if(media_plugin == NULL) | ||
271 | // Handle Scrolling | ||
272 | switch (mScrollState) | ||
273 | { | ||
274 | case SCROLL_UP: | ||
275 | media_plugin->scrollEvent(0, -1, MASK_NONE); | ||
276 | break; | ||
277 | case SCROLL_DOWN: | ||
278 | media_plugin->scrollEvent(0, 1, MASK_NONE); | ||
279 | break; | ||
280 | case SCROLL_LEFT: | ||
281 | mMediaImpl->handleKeyHere(KEY_LEFT, MASK_NONE); | ||
282 | break; | ||
283 | case SCROLL_RIGHT: | ||
284 | mMediaImpl->handleKeyHere(KEY_RIGHT, MASK_NONE); | ||
285 | break; | ||
286 | case SCROLL_NONE: | ||
287 | default: | ||
288 | break; | ||
289 | } | ||
290 | LLBBox screen_bbox; | ||
291 | setVisible(TRUE); | ||
292 | glh::matrix4f mat = glh_get_current_projection()*glh_get_current_modelview(); | ||
293 | std::vector<LLVector3>::iterator vert_it; | ||
294 | std::vector<LLVector3>::iterator vert_end; | ||
295 | std::vector<LLVector3> vect_face; | ||
296 | |||
297 | LLVolume* volume = objectp->getVolume(); | ||
298 | |||
299 | if (volume) | ||
300 | { | ||
301 | const LLVolumeFace& vf = volume->getVolumeFace(nodep->getLastSelectedTE()); | ||
302 | |||
303 | const LLVector3* ext = vf.mExtents; | ||
304 | |||
305 | LLVector3 center = (ext[0]+ext[1])*0.5f; | ||
306 | LLVector3 size = (ext[1]-ext[0])*0.5f; | ||
307 | LLVector3 vert[] = | ||
308 | { | ||
309 | center + size.scaledVec(LLVector3(1,1,1)), | ||
310 | center + size.scaledVec(LLVector3(-1,1,1)), | ||
311 | center + size.scaledVec(LLVector3(1,-1,1)), | ||
312 | center + size.scaledVec(LLVector3(-1,-1,1)), | ||
313 | center + size.scaledVec(LLVector3(1,1,-1)), | ||
314 | center + size.scaledVec(LLVector3(-1,1,-1)), | ||
315 | center + size.scaledVec(LLVector3(1,-1,-1)), | ||
316 | center + size.scaledVec(LLVector3(-1,-1,-1)), | ||
317 | }; | ||
318 | |||
319 | LLVOVolume* vo = (LLVOVolume*) objectp; | ||
320 | |||
321 | for (U32 i = 0; i < 8; i++) | ||
322 | { | ||
323 | vect_face.push_back(vo->volumePositionToAgent(vert[i])); | ||
324 | } | ||
325 | } | ||
326 | vert_it = vect_face.begin(); | ||
327 | vert_end = vect_face.end(); | ||
328 | |||
329 | LLVector3 min = LLVector3(1,1,1); | ||
330 | LLVector3 max = LLVector3(-1,-1,-1); | ||
331 | for(; vert_it != vert_end; ++vert_it) | ||
332 | { | ||
333 | // project silhouette vertices into screen space | ||
334 | glh::vec3f screen_vert = glh::vec3f(vert_it->mV); | ||
335 | mat.mult_matrix_vec(screen_vert); | ||
336 | |||
337 | // add to screenspace bounding box | ||
338 | update_min_max(min, max, LLVector3(screen_vert.v)); | ||
339 | } | ||
340 | |||
341 | LLCoordGL screen_min; | ||
342 | screen_min.mX = llround((F32)gViewerWindow->getWindowWidth() * (min.mV[VX] + 1.f) * 0.5f); | ||
343 | screen_min.mY = llround((F32)gViewerWindow->getWindowHeight() * (min.mV[VY] + 1.f) * 0.5f); | ||
344 | |||
345 | LLCoordGL screen_max; | ||
346 | screen_max.mX = llround((F32)gViewerWindow->getWindowWidth() * (max.mV[VX] + 1.f) * 0.5f); | ||
347 | screen_max.mY = llround((F32)gViewerWindow->getWindowHeight() * (max.mV[VY] + 1.f) * 0.5f); | ||
348 | |||
349 | // grow panel so that screenspace bounding box fits inside "media_region" element of HUD | ||
350 | LLRect media_hud_rect; | ||
351 | getParent()->screenRectToLocal(LLRect(screen_min.mX, screen_max.mY, screen_max.mX, screen_min.mY), &media_hud_rect); | ||
352 | LLView* media_region = getChild<LLView>("media_region"); | ||
353 | media_hud_rect.mLeft -= media_region->getRect().mLeft; | ||
354 | media_hud_rect.mBottom -= media_region->getRect().mBottom; | ||
355 | media_hud_rect.mTop += getRect().getHeight() - media_region->getRect().mTop; | ||
356 | media_hud_rect.mRight += getRect().getWidth() - media_region->getRect().mRight; | ||
357 | |||
358 | |||
359 | LLRect old_hud_rect = media_hud_rect; | ||
360 | // keep all parts of HUD on-screen | ||
361 | media_hud_rect.intersectWith(getParent()->getLocalRect()); | ||
362 | |||
363 | // If we had to clip the rect, don't display the border | ||
364 | childSetVisible("bg_image", false); | ||
365 | |||
366 | // clamp to minimum size, keeping centered | ||
367 | media_hud_rect.setCenterAndSize(media_hud_rect.getCenterX(), media_hud_rect.getCenterY(), | ||
368 | llmax(MIN_HUD_WIDTH, media_hud_rect.getWidth()), llmax(MIN_HUD_HEIGHT, media_hud_rect.getHeight())); | ||
369 | |||
370 | userSetShape(media_hud_rect); | ||
371 | |||
372 | // Test mouse position to see if the cursor is stationary | ||
373 | LLCoordWindow cursor_pos_window; | ||
374 | getWindow()->getCursorPosition(&cursor_pos_window); | ||
375 | |||
376 | // If last pos is not equal to current pos, the mouse has moved | ||
377 | // We need to reset the timer, and make sure the panel is visible | ||
378 | if(cursor_pos_window.mX != mLastCursorPos.mX || | ||
379 | cursor_pos_window.mY != mLastCursorPos.mY || | ||
380 | mScrollState != SCROLL_NONE) | ||
381 | { | ||
382 | mMouseMoveTimer.start(); | ||
383 | mLastCursorPos = cursor_pos_window; | ||
384 | } | ||
385 | |||
386 | // Mouse has been stationary, but not for long enough to fade the UI | ||
387 | if(mMouseMoveTimer.getElapsedTimeF32() < mMouseInactiveTime) | ||
388 | { | ||
389 | // If we have started fading, reset the alpha values | ||
390 | if(mFadeTimer.getStarted()) | ||
391 | { | ||
392 | F32 alpha = 1.0f; | ||
393 | setAlpha(alpha); | ||
394 | mFadeTimer.stop(); | ||
395 | } | ||
396 | } | ||
397 | // If we need to start fading the UI (and we have not already started) | ||
398 | else if(! mFadeTimer.getStarted()) | ||
399 | { | ||
400 | mFadeTimer.reset(); | ||
401 | mFadeTimer.start(); | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | /*virtual*/ | ||
406 | void LLPanelMediaHUD::draw() | ||
407 | { | ||
408 | if(mFadeTimer.getStarted()) | ||
409 | { | ||
410 | if(mFadeTimer.getElapsedTimeF32() >= mControlFadeTime) | ||
411 | { | ||
412 | setVisible(FALSE); | ||
413 | } | ||
414 | else | ||
415 | { | ||
416 | F32 time = mFadeTimer.getElapsedTimeF32(); | ||
417 | F32 alpha = llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); | ||
418 | setAlpha(alpha); | ||
419 | } | ||
420 | } | ||
421 | LLPanel::draw(); | ||
422 | } | ||
423 | void LLPanelMediaHUD::setAlpha(F32 alpha) | ||
424 | { | ||
425 | LLViewQuery query; | ||
426 | |||
427 | LLView* query_view = mMediaFocus ? getChildView("media_focused_controls") : getChildView("media_hover_controls"); | ||
428 | child_list_t children = query(query_view); | ||
429 | for (child_list_iter_t child_iter = children.begin(); | ||
430 | child_iter != children.end(); ++child_iter) | ||
431 | { | ||
432 | LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(*child_iter); | ||
433 | if (ctrl) | ||
434 | ctrl->setAlpha(alpha); | ||
435 | } | ||
436 | |||
437 | LLPanel::setAlpha(alpha); | ||
438 | } | ||
439 | BOOL LLPanelMediaHUD::handleScrollWheel(S32 x, S32 y, S32 clicks) | ||
440 | { | ||
441 | return LLViewerMediaFocus::getInstance()->handleScrollWheel(x, y, clicks); | ||
442 | } | ||
443 | bool LLPanelMediaHUD::isMouseOver() | ||
444 | { | ||
445 | if( ! getVisible() ) | ||
446 | { | ||
447 | return false; | ||
448 | } | ||
449 | LLRect screen_rect; | ||
450 | LLCoordWindow cursor_pos_window; | ||
451 | getWindow()->getCursorPosition(&cursor_pos_window); | ||
452 | |||
453 | localRectToScreen(getLocalRect(), &screen_rect); | ||
454 | // screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y); | ||
455 | |||
456 | if(screen_rect.pointInRect(cursor_pos_window.mX, cursor_pos_window.mY)) | ||
457 | { | ||
458 | return true; | ||
459 | } | ||
460 | return false; | ||
461 | } | ||
462 | |||
463 | //static | ||
464 | void LLPanelMediaHUD::onClickClose(void* user_data) | ||
465 | { | ||
466 | LLViewerMediaFocus::getInstance()->setFocusFace(FALSE, NULL, 0, NULL); | ||
467 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
468 | if(this_panel->mCurrentZoom != ZOOM_NONE) | ||
469 | { | ||
470 | // gAgent.setFocusOnAvatar(TRUE, ANIMATE); | ||
471 | this_panel->mCurrentZoom = ZOOM_NONE; | ||
472 | } | ||
473 | this_panel->setVisible(FALSE); | ||
474 | |||
475 | } | ||
476 | |||
477 | //static | ||
478 | void LLPanelMediaHUD::onClickBack(void* user_data) | ||
479 | { | ||
480 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
481 | if (this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
482 | { | ||
483 | if(this_panel->mMediaImpl->getMediaPlugin()->pluginSupportsMediaTime()) | ||
484 | { | ||
485 | this_panel->mMediaImpl->getMediaPlugin()->start(-2.0); | ||
486 | } | ||
487 | else | ||
488 | { | ||
489 | this_panel->mMediaImpl->getMediaPlugin()->browse_back(); | ||
490 | } | ||
491 | |||
492 | } | ||
493 | } | ||
494 | //static | ||
495 | void LLPanelMediaHUD::onClickForward(void* user_data) | ||
496 | { | ||
497 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
498 | if (this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
499 | { | ||
500 | if(this_panel->mMediaImpl->getMediaPlugin()->pluginSupportsMediaTime()) | ||
501 | { | ||
502 | this_panel->mMediaImpl->getMediaPlugin()->start(2.0); | ||
503 | } | ||
504 | else | ||
505 | { | ||
506 | this_panel->mMediaImpl->getMediaPlugin()->browse_forward(); | ||
507 | } | ||
508 | } | ||
509 | } | ||
510 | //static | ||
511 | void LLPanelMediaHUD::onClickHome(void* user_data) | ||
512 | { | ||
513 | //LLViewerMedia::navigateHome(); | ||
514 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
515 | if(this_panel->mMediaImpl.notNull()) | ||
516 | { | ||
517 | this_panel->mMediaImpl->navigateHome(); | ||
518 | } | ||
519 | } | ||
520 | //static | ||
521 | void LLPanelMediaHUD::onClickOpen(void* user_data) | ||
522 | { | ||
523 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
524 | if(this_panel->mMediaImpl.notNull()) | ||
525 | { | ||
526 | LLWeb::loadURL(this_panel->mMediaImpl->getMediaURL()); | ||
527 | } | ||
528 | } | ||
529 | //static | ||
530 | void LLPanelMediaHUD::onClickReload(void* user_data) | ||
531 | { | ||
532 | //LLViewerMedia::navigateHome(); | ||
533 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
534 | LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); | ||
535 | if(objectp && this_panel->mMediaImpl.notNull()) | ||
536 | { | ||
537 | this_panel->mMediaImpl->navigateTo(objectp->getMediaURL()); | ||
538 | } | ||
539 | } | ||
540 | //static | ||
541 | void LLPanelMediaHUD::onClickPlay(void* user_data) | ||
542 | { | ||
543 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
544 | if (this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
545 | { | ||
546 | this_panel->mMediaImpl->getMediaPlugin()->start(); | ||
547 | } | ||
548 | } | ||
549 | //static | ||
550 | void LLPanelMediaHUD::onClickPause(void* user_data) | ||
551 | { | ||
552 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
553 | if (this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
554 | { | ||
555 | this_panel->mMediaImpl->getMediaPlugin()->pause(); | ||
556 | } | ||
557 | } | ||
558 | //static | ||
559 | void LLPanelMediaHUD::onClickStop(void* user_data) | ||
560 | { | ||
561 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
562 | if (this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
563 | { | ||
564 | if(this_panel->mMediaImpl->getMediaPlugin()->pluginSupportsMediaTime()) | ||
565 | { | ||
566 | this_panel->mMediaImpl->getMediaPlugin()->stop(); | ||
567 | } | ||
568 | else | ||
569 | { | ||
570 | this_panel->mMediaImpl->getMediaPlugin()->browse_stop(); | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | //static | ||
575 | void LLPanelMediaHUD::onClickZoom(void* user_data) | ||
576 | { | ||
577 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
578 | this_panel->nextZoomLevel(); | ||
579 | } | ||
580 | void LLPanelMediaHUD::nextZoomLevel() | ||
581 | { | ||
582 | F32 zoom_padding = 0.0f; | ||
583 | S32 last_zoom_level = (S32)mCurrentZoom; | ||
584 | mCurrentZoom = (EZoomLevel)((last_zoom_level + 1) % (S32)ZOOM_END); | ||
585 | |||
586 | switch (mCurrentZoom) | ||
587 | { | ||
588 | case ZOOM_NONE: | ||
589 | { | ||
590 | gAgent.setFocusOnAvatar(TRUE, ANIMATE); | ||
591 | break; | ||
592 | } | ||
593 | case ZOOM_MEDIUM: | ||
594 | { | ||
595 | zoom_padding = ZOOM_MEDIUM_PADDING; | ||
596 | break; | ||
597 | } | ||
598 | default: | ||
599 | { | ||
600 | gAgent.setFocusOnAvatar(TRUE, ANIMATE); | ||
601 | break; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | if (zoom_padding > 0.0f) | ||
606 | LLViewerMediaFocus::getInstance()->setCameraZoom(zoom_padding); | ||
607 | } | ||
608 | void LLPanelMediaHUD::onScrollUp(void* user_data) | ||
609 | { | ||
610 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
611 | if(this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
612 | { | ||
613 | this_panel->mMediaImpl->getMediaPlugin()->scrollEvent(0, -1, MASK_NONE); | ||
614 | } | ||
615 | } | ||
616 | void LLPanelMediaHUD::onScrollUpHeld(void* user_data) | ||
617 | { | ||
618 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
619 | this_panel->mScrollState = SCROLL_UP; | ||
620 | } | ||
621 | void LLPanelMediaHUD::onScrollRight(void* user_data) | ||
622 | { | ||
623 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
624 | if(this_panel->mMediaImpl.notNull()) | ||
625 | { | ||
626 | this_panel->mMediaImpl->handleKeyHere(KEY_RIGHT, MASK_NONE); | ||
627 | } | ||
628 | } | ||
629 | void LLPanelMediaHUD::onScrollRightHeld(void* user_data) | ||
630 | { | ||
631 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
632 | this_panel->mScrollState = SCROLL_RIGHT; | ||
633 | } | ||
634 | |||
635 | void LLPanelMediaHUD::onScrollLeft(void* user_data) | ||
636 | { | ||
637 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
638 | if(this_panel->mMediaImpl.notNull()) | ||
639 | { | ||
640 | this_panel->mMediaImpl->handleKeyHere(KEY_LEFT, MASK_NONE); | ||
641 | } | ||
642 | } | ||
643 | void LLPanelMediaHUD::onScrollLeftHeld(void* user_data) | ||
644 | { | ||
645 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
646 | this_panel->mScrollState = SCROLL_LEFT; | ||
647 | } | ||
648 | |||
649 | void LLPanelMediaHUD::onScrollDown(void* user_data) | ||
650 | { | ||
651 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
652 | if(this_panel->mMediaImpl.notNull() && this_panel->mMediaImpl->hasMedia()) | ||
653 | { | ||
654 | this_panel->mMediaImpl->getMediaPlugin()->scrollEvent(0, 1, MASK_NONE); | ||
655 | } | ||
656 | } | ||
657 | void LLPanelMediaHUD::onScrollDownHeld(void* user_data) | ||
658 | { | ||
659 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
660 | this_panel->mScrollState = SCROLL_DOWN; | ||
661 | } | ||
662 | |||
663 | void LLPanelMediaHUD::onScrollStop(void* user_data) | ||
664 | { | ||
665 | LLPanelMediaHUD* this_panel = static_cast<LLPanelMediaHUD*> (user_data); | ||
666 | this_panel->mScrollState = SCROLL_NONE; | ||
667 | } | ||