llfloatercamera.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /**
  2. * @file llfloatercamera.cpp
  3. * @brief Container for camera control buttons (zoom, pan, orbit)
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-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. #include "llviewerprecompiledheaders.h"
  33. #include "llfloatercamera.h"
  34. #include "llcheckboxctrl.h"
  35. #include "llspinctrl.h"
  36. #include "lluictrlfactory.h"
  37. #include "llagent.h"
  38. #include "lljoystickbutton.h"
  39. #include "llviewercontrol.h"
  40. // Constants
  41. constexpr F32 CAMERA_BUTTON_DELAY = 0.0f;
  42. //
  43. // Member functions
  44. //
  45. LLFloaterCamera::LLFloaterCamera(const LLSD& val)
  46. : LLFloater("camera controls") // Uses "FloaterCameraRect3a"
  47. {
  48. setIsChrome(true);
  49. // For now, only used for size and tooltip strings
  50. LLUICtrlFactory::getInstance()->buildFloater(this, "floater_camera.xml",
  51. NULL, false); // Do not open
  52. }
  53. //virtual
  54. bool LLFloaterCamera::postBuild()
  55. {
  56. S32 top = getRect().getHeight();
  57. S32 bottom = 0;
  58. S32 left = 4;
  59. constexpr S32 ROTATE_WIDTH = 64;
  60. mRotate = new LLJoystickCameraRotate("cam rotate stick",
  61. LLRect(left, top,
  62. left + ROTATE_WIDTH, bottom),
  63. "cam_rotate_out.tga",
  64. "cam_rotate_in.tga");
  65. mRotate->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  66. mRotate->setHeldDownDelay(CAMERA_BUTTON_DELAY);
  67. mRotate->setToolTip(getString("rotate_tooltip"));
  68. mRotate->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
  69. addChild(mRotate);
  70. left += ROTATE_WIDTH;
  71. constexpr S32 ZOOM_WIDTH = 16;
  72. mZoom = new LLJoystickCameraZoom("zoom",
  73. LLRect(left, top,
  74. left + ZOOM_WIDTH, bottom),
  75. "cam_zoom_out.tga",
  76. "cam_zoom_plus_in.tga",
  77. "cam_zoom_minus_in.tga");
  78. mZoom->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  79. mZoom->setHeldDownDelay(CAMERA_BUTTON_DELAY);
  80. mZoom->setToolTip(getString("zoom_tooltip"));
  81. mZoom->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
  82. addChild(mZoom);
  83. left += ZOOM_WIDTH;
  84. constexpr S32 TRACK_WIDTH = 64;
  85. mTrack = new LLJoystickCameraTrack("cam track stick",
  86. LLRect(left, top, left + TRACK_WIDTH, bottom),
  87. "cam_tracking_out.tga",
  88. "cam_tracking_in.tga");
  89. mTrack->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  90. mTrack->setHeldDownDelay(CAMERA_BUTTON_DELAY);
  91. mTrack->setToolTip(getString("move_tooltip"));
  92. mTrack->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
  93. addChild(mTrack);
  94. mFrontViewCheck = getChild<LLCheckBoxCtrl>("front_view");
  95. return true;
  96. }
  97. //virtual
  98. void LLFloaterCamera::onOpen()
  99. {
  100. LLFloater::onOpen();
  101. gSavedSettings.setBool("ShowCameraControls", true);
  102. }
  103. //virtual
  104. void LLFloaterCamera::onClose(bool app_quitting)
  105. {
  106. LLFloater::onClose(app_quitting);
  107. if (!app_quitting)
  108. {
  109. gSavedSettings.setBool("ShowCameraControls", false);
  110. }
  111. }
  112. //virtual
  113. void LLFloaterCamera::draw()
  114. {
  115. static ECameraMode mode = CAMERA_MODE_THIRD_PERSON;
  116. ECameraMode current_mode = gAgent.getCameraMode();
  117. if (current_mode != mode)
  118. {
  119. mode = current_mode;
  120. mFrontViewCheck->setEnabled(mode != CAMERA_MODE_MOUSELOOK &&
  121. mode != CAMERA_MODE_CUSTOMIZE_AVATAR);
  122. }
  123. LLFloater::draw();
  124. }