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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
/**
* @file llmoveview.cpp
* @brief Container for movement buttons like forward, left, fly
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llmoveview.h"
// Library includes
#include "indra_constants.h"
#include "llparcel.h"
// Viewer includes
#include "llagent.h"
#include "llagentcamera.h"
#include "llvoavatarself.h" // to check gAgentAvatarp->isSitting()
#include "llbottomtray.h"
#include "llbutton.h"
#include "llfloaterreg.h"
#include "lljoystickbutton.h"
#include "lluictrlfactory.h"
#include "llviewerwindow.h"
#include "llviewercontrol.h"
#include "llselectmgr.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "lltooltip.h"
//
// Constants
//
const F32 MOVE_BUTTON_DELAY = 0.0f;
const F32 YAW_NUDGE_RATE = 0.05f; // fraction of normal speed
const F32 NUDGE_TIME = 0.25f; // in seconds
const std::string BOTTOM_TRAY_BUTTON_NAME = "movement_btn";
//
// Member functions
//
// protected
LLFloaterMove::LLFloaterMove(const LLSD& key)
: LLTransientDockableFloater(NULL, true, key),
mForwardButton(NULL),
mBackwardButton(NULL),
mTurnLeftButton(NULL),
mTurnRightButton(NULL),
mMoveUpButton(NULL),
mMoveDownButton(NULL),
mModeActionsPanel(NULL),
mCurrentMode(MM_WALK)
{
}
// virtual
BOOL LLFloaterMove::postBuild()
{
setIsChrome(TRUE);
setTitleVisible(TRUE); // restore title visibility after chrome applying
LLDockableFloater::postBuild();
mForwardButton = getChild<LLJoystickAgentTurn>("forward btn");
mForwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mBackwardButton = getChild<LLJoystickAgentTurn>("backward btn");
mBackwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mTurnLeftButton = getChild<LLButton>("turn left btn");
mTurnLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mTurnLeftButton->setHeldDownCallback(boost::bind(&LLFloaterMove::turnLeft, this));
mTurnRightButton = getChild<LLButton>("turn right btn");
mTurnRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mTurnRightButton->setHeldDownCallback(boost::bind(&LLFloaterMove::turnRight, this));
mMoveUpButton = getChild<LLButton>("move up btn");
mMoveUpButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mMoveUpButton->setHeldDownCallback(boost::bind(&LLFloaterMove::moveUp, this));
mMoveDownButton = getChild<LLButton>("move down btn");
mMoveDownButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
mMoveDownButton->setHeldDownCallback(boost::bind(&LLFloaterMove::moveDown, this));
mModeActionsPanel = getChild<LLPanel>("panel_modes");
LLButton* btn;
btn = getChild<LLButton>("mode_walk_btn");
btn->setCommitCallback(boost::bind(&LLFloaterMove::onWalkButtonClick, this));
btn = getChild<LLButton>("mode_run_btn");
btn->setCommitCallback(boost::bind(&LLFloaterMove::onRunButtonClick, this));
btn = getChild<LLButton>("mode_fly_btn");
btn->setCommitCallback(boost::bind(&LLFloaterMove::onFlyButtonClick, this));
showFlyControls(false);
initModeTooltips();
initModeButtonMap();
initMovementMode();
LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(LLFloaterMove::sUpdateFlyingStatus);
return TRUE;
}
// virtual
void LLFloaterMove::setEnabled(BOOL enabled)
{
//we need to enable/disable only buttons, EXT-1061.
// is called before postBuild() - use findChild here.
LLPanel *panel_actions = findChild<LLPanel>("panel_actions");
if (panel_actions) panel_actions->setEnabled(enabled);
showModeButtons(enabled);
}
// *NOTE: we assume that setVisible() is called on floater close.
// virtual
void LLFloaterMove::setVisible(BOOL visible)
{
// Do nothing with Stand/Stop Flying panel in excessive calls of this method (from LLTransientFloaterMgr?).
if (getVisible() == visible)
{
LLTransientDockableFloater::setVisible(visible);
return;
}
if (visible)
{
// Attach the Stand/Stop Flying panel.
LLPanelStandStopFlying* ssf_panel = LLPanelStandStopFlying::getInstance();
ssf_panel->reparent(this);
const LLRect& mode_actions_rect = mModeActionsPanel->getRect();
ssf_panel->setOrigin(mode_actions_rect.mLeft, mode_actions_rect.mBottom);
}
else
{
// Detach the Stand/Stop Flying panel.
LLPanelStandStopFlying::getInstance()->reparent(NULL);
}
LLTransientDockableFloater::setVisible(visible);
}
// static
F32 LLFloaterMove::getYawRate( F32 time )
{
if( time < NUDGE_TIME )
{
F32 rate = YAW_NUDGE_RATE + time * (1 - YAW_NUDGE_RATE)/ NUDGE_TIME;
return rate;
}
else
{
return 1.f;
}
}
// static
void LLFloaterMove::setFlyingMode(BOOL fly)
{
LLFloaterMove* instance = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview");
if (instance)
{
instance->setFlyingModeImpl(fly);
LLVOAvatarSelf* avatar_object = gAgent.getAvatarObject();
bool is_sitting = avatar_object
&& (avatar_object->getRegion() != NULL)
&& (!avatar_object->isDead())
&& avatar_object->isSitting();
instance->showModeButtons(!fly && !is_sitting);
}
if (fly)
{
LLPanelStandStopFlying::setStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STOP_FLYING);
}
else
{
LLPanelStandStopFlying::clearStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STOP_FLYING);
}
}
//static
void LLFloaterMove::setAlwaysRunMode(bool run)
{
LLFloaterMove* instance = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview");
if (instance)
{
instance->setAlwaysRunModeImpl(run);
}
}
void LLFloaterMove::setFlyingModeImpl(BOOL fly)
{
updateButtonsWithMovementMode(fly ? MM_FLY : (gAgent.getAlwaysRun() ? MM_RUN : MM_WALK));
}
void LLFloaterMove::setAlwaysRunModeImpl(bool run)
{
if (!gAgent.getFlying())
{
updateButtonsWithMovementMode(run ? MM_RUN : MM_WALK);
}
}
//static
void LLFloaterMove::setSittingMode(BOOL bSitting)
{
if (bSitting)
{
LLPanelStandStopFlying::setStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STAND);
}
else
{
LLPanelStandStopFlying::clearStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STAND);
// show "Stop Flying" button if needed. EXT-871
if (gAgent.getFlying())
{
LLPanelStandStopFlying::setStandStopFlyingMode(LLPanelStandStopFlying::SSFM_STOP_FLYING);
}
}
enableInstance(!bSitting);
}
// protected
void LLFloaterMove::turnLeft()
{
F32 time = mTurnLeftButton->getHeldDownTime();
gAgent.moveYaw( getYawRate( time ) );
}
// protected
void LLFloaterMove::turnRight()
{
F32 time = mTurnRightButton->getHeldDownTime();
gAgent.moveYaw( -getYawRate( time ) );
}
// protected
void LLFloaterMove::moveUp()
{
// Jumps or flys up, depending on fly state
gAgent.moveUp(1);
}
// protected
void LLFloaterMove::moveDown()
{
// Crouches or flys down, depending on fly state
gAgent.moveUp(-1);
}
//////////////////////////////////////////////////////////////////////////
// Private Section:
//////////////////////////////////////////////////////////////////////////
void LLFloaterMove::onWalkButtonClick()
{
setMovementMode(MM_WALK);
}
void LLFloaterMove::onRunButtonClick()
{
setMovementMode(MM_RUN);
}
void LLFloaterMove::onFlyButtonClick()
{
setMovementMode(MM_FLY);
}
void LLFloaterMove::setMovementMode(const EMovementMode mode)
{
mCurrentMode = mode;
gAgent.setFlying(MM_FLY == mode);
// attempts to set avatar flying can not set it real flying in some cases.
// For ex. when avatar fell down & is standing up.
// So, no need to continue processing FLY mode. See EXT-1079
if (MM_FLY == mode && !gAgent.getFlying())
{
return;
}
switch (mode)
{
case MM_RUN:
gAgent.setAlwaysRun();
gAgent.setRunning();
break;
case MM_WALK:
gAgent.clearAlwaysRun();
gAgent.clearRunning();
break;
default:
//do nothing for other modes (MM_FLY)
break;
}
// tell the simulator.
gAgent.sendWalkRun(gAgent.getAlwaysRun());
updateButtonsWithMovementMode(mode);
bool bHideModeButtons = MM_FLY == mode
|| (isAgentAvatarValid() && gAgentAvatarp->isSitting());
showModeButtons(!bHideModeButtons);
}
void LLFloaterMove::updateButtonsWithMovementMode(const EMovementMode newMode)
{
showFlyControls(MM_FLY == newMode);
setModeTooltip(newMode);
setModeButtonToggleState(newMode);
setModeTitle(newMode);
}
void LLFloaterMove::showFlyControls(bool bShow)
{
mMoveUpButton->setVisible(bShow);
mMoveDownButton->setVisible(bShow);
}
void LLFloaterMove::initModeTooltips()
{
control_tooltip_map_t walkTipMap;
walkTipMap.insert(std::make_pair(mForwardButton, getString("walk_forward_tooltip")));
walkTipMap.insert(std::make_pair(mBackwardButton, getString("walk_back_tooltip")));
mModeControlTooltipsMap[MM_WALK] = walkTipMap;
control_tooltip_map_t runTipMap;
runTipMap.insert(std::make_pair(mForwardButton, getString("run_forward_tooltip")));
runTipMap.insert(std::make_pair(mBackwardButton, getString("run_back_tooltip")));
mModeControlTooltipsMap[MM_RUN] = runTipMap;
control_tooltip_map_t flyTipMap;
flyTipMap.insert(std::make_pair(mForwardButton, getString("fly_forward_tooltip")));
flyTipMap.insert(std::make_pair(mBackwardButton, getString("fly_back_tooltip")));
mModeControlTooltipsMap[MM_FLY] = flyTipMap;
setModeTooltip(MM_WALK);
}
void LLFloaterMove::initModeButtonMap()
{
mModeControlButtonMap[MM_WALK] = getChild<LLButton>("mode_walk_btn");
mModeControlButtonMap[MM_RUN] = getChild<LLButton>("mode_run_btn");
mModeControlButtonMap[MM_FLY] = getChild<LLButton>("mode_fly_btn");
}
void LLFloaterMove::initMovementMode()
{
EMovementMode initMovementMode = gAgent.getAlwaysRun() ? MM_RUN : MM_WALK;
if (gAgent.getFlying())
{
initMovementMode = MM_FLY;
}
setMovementMode(initMovementMode);
if (isAgentAvatarValid())
{
setEnabled(!gAgentAvatarp->isSitting());
}
}
void LLFloaterMove::setModeTooltip(const EMovementMode mode)
{
llassert_always(mModeControlTooltipsMap.end() != mModeControlTooltipsMap.find(mode));
control_tooltip_map_t controlsTipMap = mModeControlTooltipsMap[mode];
control_tooltip_map_t::const_iterator it = controlsTipMap.begin();
for (; it != controlsTipMap.end(); ++it)
{
LLView* ctrl = it->first;
std::string tooltip = it->second;
ctrl->setToolTip(tooltip);
}
}
void LLFloaterMove::setModeTitle(const EMovementMode mode)
{
std::string title;
switch(mode)
{
case MM_WALK:
title = getString("walk_title");
break;
case MM_RUN:
title = getString("run_title");
break;
case MM_FLY:
title = getString("fly_title");
break;
default:
// title should be provided for all modes
llassert(false);
break;
}
setTitle(title);
}
/**
* Updates position of the floater to be center aligned with Move button.
*/
void LLFloaterMove::updatePosition()
{
LLBottomTray* tray = LLBottomTray::getInstance();
if (!tray) return;
LLButton* movement_btn = tray->getChild<LLButton>(BOTTOM_TRAY_BUTTON_NAME);
//align centers of a button and a floater
S32 x = movement_btn->calcScreenRect().getCenterX() - getRect().getWidth()/2;
S32 y = 0;
if (!mModeActionsPanel->getVisible())
{
y = mModeActionsPanel->getRect().getHeight();
}
setOrigin(x, y);
}
//static
void LLFloaterMove::sUpdateFlyingStatus()
{
LLFloaterMove *floater = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview");
if (floater) floater->mModeControlButtonMap[MM_FLY]->setEnabled(gAgent.canFly());
}
void LLFloaterMove::showModeButtons(BOOL bShow)
{
// is called from setEnabled so can be called before postBuild(), check mModeActionsPanel agains to NULL
if (NULL == mModeActionsPanel || mModeActionsPanel->getVisible() == bShow)
return;
mModeActionsPanel->setVisible(bShow);
}
//static
void LLFloaterMove::enableInstance(BOOL bEnable)
{
LLFloaterMove* instance = LLFloaterReg::findTypedInstance<LLFloaterMove>("moveview");
if (instance)
{
instance->setEnabled(bEnable);
if (gAgent.getFlying())
{
instance->showModeButtons(FALSE);
}
}
}
void LLFloaterMove::onOpen(const LLSD& key)
{
LLButton *anchor_panel = LLBottomTray::getInstance()->getChild<LLButton>("movement_btn");
if (gAgent.getFlying())
{
setFlyingMode(TRUE);
showModeButtons(FALSE);
}
if (isAgentAvatarValid() && gAgentAvatarp->isSitting())
{
setSittingMode(TRUE);
showModeButtons(FALSE);
}
setDockControl(new LLDockControl(
anchor_panel, this,
getDockTongue(), LLDockControl::TOP));
sUpdateFlyingStatus();
}
//virtual
void LLFloaterMove::setDocked(bool docked, bool pop_on_undock/* = true*/)
{
LLTransientDockableFloater::setDocked(docked, pop_on_undock);
}
void LLFloaterMove::setModeButtonToggleState(const EMovementMode mode)
{
llassert_always(mModeControlButtonMap.end() != mModeControlButtonMap.find(mode));
mode_control_button_map_t::const_iterator it = mModeControlButtonMap.begin();
for (; it != mModeControlButtonMap.end(); ++it)
{
it->second->setToggleState(FALSE);
}
mModeControlButtonMap[mode]->setToggleState(TRUE);
}
/************************************************************************/
/* LLPanelStandStopFlying */
/************************************************************************/
LLPanelStandStopFlying::LLPanelStandStopFlying() :
mStandButton(NULL),
mStopFlyingButton(NULL),
mAttached(false)
{
// make sure we have the only instance of this class
static bool b = true;
llassert_always(b);
b=false;
}
// static
inline LLPanelStandStopFlying* LLPanelStandStopFlying::getInstance()
{
static LLPanelStandStopFlying* panel = getStandStopFlyingPanel();
return panel;
}
//static
void LLPanelStandStopFlying::setStandStopFlyingMode(EStandStopFlyingMode mode)
{
LLPanelStandStopFlying* panel = getInstance();
panel->mStandButton->setVisible(SSFM_STAND == mode);
panel->mStopFlyingButton->setVisible(SSFM_STOP_FLYING == mode);
//visibility of it should be updated after updating visibility of the buttons
panel->setVisible(TRUE);
}
//static
void LLPanelStandStopFlying::clearStandStopFlyingMode(EStandStopFlyingMode mode)
{
LLPanelStandStopFlying* panel = getInstance();
switch(mode) {
case SSFM_STAND:
panel->mStandButton->setVisible(FALSE);
break;
case SSFM_STOP_FLYING:
panel->mStopFlyingButton->setVisible(FALSE);
break;
default:
llerrs << "Unexpected EStandStopFlyingMode is passed: " << mode << llendl;
}
}
BOOL LLPanelStandStopFlying::postBuild()
{
mStandButton = getChild<LLButton>("stand_btn");
mStandButton->setCommitCallback(boost::bind(&LLPanelStandStopFlying::onStandButtonClick, this));
mStandButton->setCommitCallback(boost::bind(&LLFloaterMove::enableInstance, TRUE));
mStandButton->setVisible(FALSE);
mStopFlyingButton = getChild<LLButton>("stop_fly_btn");
//mStopFlyingButton->setCommitCallback(boost::bind(&LLFloaterMove::setFlyingMode, FALSE));
mStopFlyingButton->setCommitCallback(boost::bind(&LLPanelStandStopFlying::onStopFlyingButtonClick, this));
mStopFlyingButton->setVisible(FALSE);
return TRUE;
}
//virtual
void LLPanelStandStopFlying::setVisible(BOOL visible)
{
//we dont need to show the panel if these buttons are not activated
if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK) visible = false;
if (visible)
{
updatePosition();
}
// do not change parent visibility in case panel is attached into Move Floater: EXT-3632, EXT-4646
if (!mAttached)
{
//change visibility of parent layout_panel to animate in/out. EXT-2504
if (getParent()) getParent()->setVisible(visible);
}
// also change own visibility to avoid displaying the panel in mouselook (broken when EXT-2504 was implemented).
// See EXT-4718.
LLPanel::setVisible(visible);
}
BOOL LLPanelStandStopFlying::handleToolTip(S32 x, S32 y, MASK mask)
{
LLToolTipMgr::instance().unblockToolTips();
if (mStandButton->getVisible())
{
LLToolTipMgr::instance().show(mStandButton->getToolTip());
}
else if (mStopFlyingButton->getVisible())
{
LLToolTipMgr::instance().show(mStopFlyingButton->getToolTip());
}
return LLPanel::handleToolTip(x, y, mask);
}
void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view)
{
LLPanel* parent = dynamic_cast<LLPanel*>(getParent());
if (!parent)
{
llwarns << "Stand/stop flying panel parent is unset, already attached?: " << mAttached << ", new parent: " << (move_view == NULL ? "NULL" : "Move Floater") << llendl;
return;
}
if (move_view != NULL)
{
llassert(move_view != parent); // sanity check
// Save our original container.
if (!mOriginalParent.get())
mOriginalParent = parent->getHandle();
// Attach to movement controls.
parent->removeChild(this);
move_view->addChild(this);
// Origin must be set by movement controls.
mAttached = true;
}
else
{
if (!mOriginalParent.get())
{
llwarns << "Original parent of the stand / stop flying panel not found" << llendl;
return;
}
// Detach from movement controls.
parent->removeChild(this);
mOriginalParent.get()->addChild(this);
// update parent with self visibility (it is changed in setVisible()). EXT-4743
mOriginalParent.get()->setVisible(getVisible());
mAttached = false;
updatePosition(); // don't defer until next draw() to avoid flicker
}
}
//////////////////////////////////////////////////////////////////////////
// Private Section
//////////////////////////////////////////////////////////////////////////
//static
LLPanelStandStopFlying* LLPanelStandStopFlying::getStandStopFlyingPanel()
{
LLPanelStandStopFlying* panel = new LLPanelStandStopFlying();
LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_stand_stop_flying.xml");
panel->setVisible(FALSE);
//LLUI::getRootView()->addChild(panel);
llinfos << "Build LLPanelStandStopFlying panel" << llendl;
panel->updatePosition();
return panel;
}
void LLPanelStandStopFlying::onStandButtonClick()
{
LLSelectMgr::getInstance()->deselectAllForStandingUp();
gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
setFocus(FALSE); // EXT-482
mStandButton->setVisible(FALSE); // force visibility changing to avoid seeing Stand & Move buttons at once.
}
void LLPanelStandStopFlying::onStopFlyingButtonClick()
{
gAgent.setFlying(FALSE);
setFocus(FALSE); // EXT-482
setVisible(FALSE);
}
/**
* Updates position of the Stand & Stop Flying panel to be center aligned with Move button.
*/
void LLPanelStandStopFlying::updatePosition()
{
LLBottomTray* tray = LLBottomTray::getInstance();
if (!tray || mAttached) return;
LLButton* movement_btn = tray->getChild<LLButton>(BOTTOM_TRAY_BUTTON_NAME);
// Align centers of the button and the panel.
S32 x = movement_btn->calcScreenRect().getCenterX() - getRect().getWidth()/2;
setOrigin(x, 0);
}
// EOF
|