Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
8.0KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_MOUSECURSOR_H_INCLUDED
  18. #define JUCE_MOUSECURSOR_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Represents a mouse cursor image.
  22. This object can either be used to represent one of the standard mouse
  23. cursor shapes, or a custom one generated from an image.
  24. */
  25. class JUCE_API MouseCursor
  26. {
  27. public:
  28. //==============================================================================
  29. /** The set of available standard mouse cursors. */
  30. enum StandardCursorType
  31. {
  32. ParentCursor = 0, /**< Indicates that the component's parent's cursor should be used. */
  33. NoCursor, /**< An invisible cursor. */
  34. NormalCursor, /**< The stardard arrow cursor. */
  35. WaitCursor, /**< The normal hourglass or spinning-beachball 'busy' cursor. */
  36. IBeamCursor, /**< A vertical I-beam for positioning within text. */
  37. CrosshairCursor, /**< A pair of crosshairs. */
  38. CopyingCursor, /**< The normal arrow cursor, but with a "+" on it to indicate
  39. that you're dragging a copy of something. */
  40. PointingHandCursor, /**< A hand with a pointing finger, for clicking on web-links. */
  41. DraggingHandCursor, /**< An open flat hand for dragging heavy objects around. */
  42. LeftRightResizeCursor, /**< An arrow pointing left and right. */
  43. UpDownResizeCursor, /**< an arrow pointing up and down. */
  44. UpDownLeftRightResizeCursor, /**< An arrow pointing up, down, left and right. */
  45. TopEdgeResizeCursor, /**< A platform-specific cursor for resizing the top-edge of a window. */
  46. BottomEdgeResizeCursor, /**< A platform-specific cursor for resizing the bottom-edge of a window. */
  47. LeftEdgeResizeCursor, /**< A platform-specific cursor for resizing the left-edge of a window. */
  48. RightEdgeResizeCursor, /**< A platform-specific cursor for resizing the right-edge of a window. */
  49. TopLeftCornerResizeCursor, /**< A platform-specific cursor for resizing the top-left-corner of a window. */
  50. TopRightCornerResizeCursor, /**< A platform-specific cursor for resizing the top-right-corner of a window. */
  51. BottomLeftCornerResizeCursor, /**< A platform-specific cursor for resizing the bottom-left-corner of a window. */
  52. BottomRightCornerResizeCursor, /**< A platform-specific cursor for resizing the bottom-right-corner of a window. */
  53. NumStandardCursorTypes
  54. };
  55. //==============================================================================
  56. /** Creates the standard arrow cursor. */
  57. MouseCursor();
  58. /** Creates one of the standard mouse cursor */
  59. MouseCursor (StandardCursorType type);
  60. /** Creates a custom cursor from an image.
  61. @param image the image to use for the cursor - if this is bigger than the
  62. system can manage, it might get scaled down first, and might
  63. also have to be turned to black-and-white if it can't do colour
  64. cursors.
  65. @param hotSpotX the x position of the cursor's hotspot within the image
  66. @param hotSpotY the y position of the cursor's hotspot within the image
  67. */
  68. MouseCursor (const Image& image, int hotSpotX, int hotSpotY);
  69. /** Creates a custom cursor from an image.
  70. @param image the image to use for the cursor - if this is bigger than the
  71. system can manage, it might get scaled down first, and might
  72. also have to be turned to black-and-white if it can't do colour
  73. cursors.
  74. @param hotSpotX the x position of the cursor's hotspot within the image
  75. @param hotSpotY the y position of the cursor's hotspot within the image
  76. @param scaleFactor the factor by which this image is larger than the target
  77. screen size of the cursor.
  78. */
  79. MouseCursor (const Image& image, int hotSpotX, int hotSpotY, float scaleFactor);
  80. //==============================================================================
  81. /** Creates a copy of another cursor object. */
  82. MouseCursor (const MouseCursor&);
  83. /** Copies this cursor from another object. */
  84. MouseCursor& operator= (const MouseCursor&);
  85. /** Destructor. */
  86. ~MouseCursor();
  87. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  88. MouseCursor (MouseCursor&&) noexcept;
  89. MouseCursor& operator= (MouseCursor&&) noexcept;
  90. #endif
  91. /** Checks whether two mouse cursors are the same.
  92. For custom cursors, two cursors created from the same image won't be
  93. recognised as the same, only MouseCursor objects that have been
  94. copied from the same object.
  95. */
  96. bool operator== (const MouseCursor&) const noexcept;
  97. /** Checks whether two mouse cursors are the same.
  98. For custom cursors, two cursors created from the same image won't be
  99. recognised as the same, only MouseCursor objects that have been
  100. copied from the same object.
  101. */
  102. bool operator!= (const MouseCursor&) const noexcept;
  103. /** Checks whether this cursor is of the standard type mentioned. */
  104. bool operator== (StandardCursorType type) const noexcept;
  105. /** Checks whether this cursor is of the standard type mentioned. */
  106. bool operator!= (StandardCursorType type) const noexcept;
  107. //==============================================================================
  108. /** Makes the system show its default 'busy' cursor.
  109. This will turn the system cursor to an hourglass or spinning beachball
  110. until the next time the mouse is moved, or hideWaitCursor() is called.
  111. This is handy if the message loop is about to block for a couple of
  112. seconds while busy and you want to give the user feedback about this.
  113. @see MessageManager::setTimeBeforeShowingWaitCursor
  114. */
  115. static void showWaitCursor();
  116. /** If showWaitCursor has been called, this will return the mouse to its
  117. normal state.
  118. This will look at what component is under the mouse, and update the
  119. cursor to be the correct one for that component.
  120. @see showWaitCursor
  121. */
  122. static void hideWaitCursor();
  123. private:
  124. //==============================================================================
  125. class SharedCursorHandle;
  126. friend class SharedCursorHandle;
  127. SharedCursorHandle* cursorHandle;
  128. friend class MouseInputSourceInternal;
  129. void showInWindow (ComponentPeer* window) const;
  130. void showInAllWindows() const;
  131. void* getHandle() const noexcept;
  132. static void* createStandardMouseCursor (MouseCursor::StandardCursorType type);
  133. static void deleteMouseCursor (void* cursorHandle, bool isStandard);
  134. JUCE_LEAK_DETECTOR (MouseCursor)
  135. };
  136. #endif // JUCE_MOUSECURSOR_H_INCLUDED