llvirtualtrackball.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * @file llvirtualtrackball.h
  3. * @brief LLVirtualTrackball class declaration
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2018, 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. #ifndef LL_LLVIRTUALTRACKBALL_H
  33. #define LL_LLVIRTUALTRACKBALL_H
  34. #include "lluictrl.h"
  35. class LLButton;
  36. class LLPanel;
  37. class LLTextBox;
  38. class LLUICtrlFactory;
  39. class LLUIImage;
  40. class LLViewBorder;
  41. class LLVirtualTrackball : public LLUICtrl
  42. {
  43. protected:
  44. LOG_CLASS(LLVirtualTrackball);
  45. public:
  46. LLVirtualTrackball(const std::string& name, const LLRect& rect,
  47. void (*commit_cb)(LLUICtrl*, void*), void* userdata);
  48. void draw() override;
  49. void setValue(F32 x, F32 y, F32 z, F32 w);
  50. void setValue(const LLSD& value) override;
  51. LLSD getValue() const override;
  52. bool handleKeyHere(KEY key, MASK mask) override;
  53. bool handleHover(S32 x, S32 y, MASK mask) override;
  54. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  55. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  56. const std::string& getTag() const override;
  57. LLXMLNodePtr getXML(bool save_children = true) const override;
  58. static LLView* fromXML(LLXMLNodePtr node, LLView* parent,
  59. LLUICtrlFactory* factory);
  60. LL_INLINE void setRotation(const LLQuaternion& val) { mValue = val; }
  61. LL_INLINE LLQuaternion getRotation() const { return mValue; }
  62. void getAzimuthAndElevationDeg(F32& azim, F32& elev);
  63. private:
  64. enum EThumbMode
  65. {
  66. SUN,
  67. MOON
  68. };
  69. enum EDragMode
  70. {
  71. DRAG_SET,
  72. DRAG_SCROLL
  73. };
  74. void setValueAndCommit(const LLQuaternion& value);
  75. void drawThumb(S32 x, S32 y, EThumbMode mode, bool upper_hemi = true);
  76. bool pointInTouchCircle(S32 x, S32 y) const;
  77. static void onRotateTopClick(void* userdata);
  78. static void onRotateBottomClick(void* userdata);
  79. static void onRotateLeftClick(void* userdata);
  80. static void onRotateRightClick(void* userdata);
  81. static void onRotateTopClickNoSound(void* userdata);
  82. static void onRotateBottomClickNoSound(void* userdata);
  83. static void onRotateLeftClickNoSound(void* userdata);
  84. static void onRotateRightClickNoSound(void* userdata);
  85. static void onEditChange(LLUICtrl*, void* userdata);
  86. private:
  87. LLPanel* mTouchArea;
  88. LLViewBorder* mBorder;
  89. LLButton* mBtnRotateTop;
  90. LLButton* mBtnRotateBottom;
  91. LLButton* mBtnRotateLeft;
  92. LLButton* mBtnRotateRight;
  93. LLTextBox* mLabelN;
  94. LLTextBox* mLabelS;
  95. LLTextBox* mLabelW;
  96. LLTextBox* mLabelE;
  97. LLUIImage* mImgMoonBack;
  98. LLUIImage* mImgMoonFront;
  99. LLUIImage* mImgSunBack;
  100. LLUIImage* mImgSunFront;
  101. LLUIImage* mImgBtnRotTop;
  102. LLUIImage* mImgBtnRotLeft;
  103. LLUIImage* mImgBtnRotRight;
  104. LLUIImage* mImgBtnRotBottom;
  105. LLUIImage* mImgSphere;
  106. LLQuaternion mValue;
  107. S32 mPrevX;
  108. S32 mPrevY;
  109. F32 mIncrementMouse;
  110. F32 mIncrementBtn;
  111. EThumbMode mThumbMode;
  112. EDragMode mDragMode;
  113. };
  114. #endif // LL_LLVIRTUALTRACKBALL_H