BsEditorSettings.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsDegree.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Contains various globally accessible editor preferences.
  8. */
  9. class BS_ED_EXPORT EditorSettings
  10. {
  11. public:
  12. EditorSettings();
  13. /**
  14. * @brief Checks is snapping enabled for move handles in scene view.
  15. */
  16. bool getMoveHandleSnapActive() const { return mMoveSnapActive; }
  17. /**
  18. * @brief Checks is angle snapping enabled for rotate handles in scene view.
  19. */
  20. bool getRotateHandleSnapActive() const { return mRotateSnapActive; }
  21. /**
  22. * @brief Gets the snap amount if move snapping is enabled. All move handles
  23. * will move in multiples of this amount.
  24. */
  25. float getMoveHandleSnap() const { return mMoveSnap; }
  26. /**
  27. * @brief Gets the snap amount if rotate snapping is enabled. All rotate handles
  28. * will rotate in multiples of this amount.
  29. */
  30. Degree getRotationHandleSnap() const { return mRotationSnap; }
  31. /**
  32. * @brief Returns the size that determines to total size of the scene view grid (its width and height).
  33. */
  34. UINT32 getGridSize() const { return mGridSize; }
  35. /**
  36. * @brief Returns the distance between scene view grid lines.
  37. */
  38. float getGridSpacing() const { return mGridAxisSpacing; }
  39. /**
  40. * @brief Gets the default size of all scene view handles.
  41. */
  42. float getHandleSize() const { return mHandleSize; }
  43. /**
  44. * @brief Returns the currently active scene view tool (e.g. move, rotate, etc.)
  45. */
  46. UINT32 getActiveSceneTool() const { return mActiveSceneTool; }
  47. /**
  48. * @brief Returns the currently active coordinate mode for scene view (e.g. global/local)
  49. */
  50. UINT32 getActiveCoordinateMode() const { return mActiveCoordinateMode; }
  51. /**
  52. * @brief Returns the currently active pivot mode for scene view (e.g. pivot/center)
  53. */
  54. UINT32 getActivePivotMode() const { return mActivePivotMode; }
  55. /**
  56. * @brief Enables/disables snapping for move handles in scene view.
  57. */
  58. void setMoveHandleSnapActive(bool snapActive) { mMoveSnapActive = snapActive; markAsDirty(); }
  59. /**
  60. * @brief Enables/disables angle snapping for rotate handles in scene view.
  61. */
  62. void setRotateHandleSnapActive(bool snapActive) { mRotateSnapActive = snapActive; markAsDirty(); }
  63. /**
  64. * @brief Sets the move snap amount. All move handles will move in multiples of this amount.
  65. */
  66. void setMoveHandleSnap(float value) { mMoveSnap = value; markAsDirty(); }
  67. /**
  68. * @brief Sets the rotate snap amount. All rotate handles will rotate in multiples of this amount.
  69. */
  70. void setRotationHandleSnap(Degree value) { mRotationSnap = value; markAsDirty(); }
  71. /**
  72. * @brief Sets the size that determines to total size of the scene view grid (its width and height).
  73. */
  74. void setGridSize(UINT32 value) { mGridSize = value; markAsDirty(); }
  75. /**
  76. * @brief Sets the distance between scene view grid lines.
  77. */
  78. void setGridSpacing(float value) { mGridAxisSpacing = value; markAsDirty(); }
  79. /**
  80. * @brief Sets the default size of all scene view handles.
  81. */
  82. void setHandleSize(float value) { mHandleSize = value; markAsDirty(); }
  83. /**
  84. * @brief Changes the currently active scene view tool (e.g. move, rotate, etc.)
  85. */
  86. void setActiveSceneTool(UINT32 value) { mActiveSceneTool = value; markAsDirty(); }
  87. /**
  88. * @brief Changes the currently active coordinate mode for scene view (e.g. global/local)
  89. */
  90. void setActiveCoordinateMode(UINT32 value) { mActiveCoordinateMode = value; markAsDirty(); }
  91. /**
  92. * @brief Changes the currently active pivot mode for scene view (e.g. pivot/center)
  93. */
  94. void setActivePivotMode(UINT32 value) { mActivePivotMode = value; markAsDirty(); }
  95. /**
  96. * @brief Returns a hash value that may be used for checking if any internal settings were
  97. * modified.
  98. */
  99. UINT32 getHash() const { return mHash; }
  100. private:
  101. /**
  102. * @brief Marks the object as dirty so that outside objects know when to update.
  103. */
  104. void markAsDirty() const { mHash++; }
  105. bool mMoveSnapActive;
  106. bool mRotateSnapActive;
  107. float mMoveSnap;
  108. Degree mRotationSnap;
  109. UINT32 mGridSize;
  110. float mGridAxisSpacing;
  111. UINT32 mActiveSceneTool;
  112. UINT32 mActiveCoordinateMode;
  113. UINT32 mActivePivotMode;
  114. float mHandleSize;
  115. mutable UINT32 mHash;
  116. };
  117. }