The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

106 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A component that acts as one of the vertical or horizontal bars you see being
  23. used to resize panels in a window.
  24. One of these acts with a StretchableLayoutManager to resize the other components.
  25. @see StretchableLayoutManager
  26. @tags{GUI}
  27. */
  28. class JUCE_API StretchableLayoutResizerBar : public Component
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates a resizer bar for use on a specified layout.
  33. @param layoutToUse the layout that will be affected when this bar
  34. is dragged
  35. @param itemIndexInLayout the item index in the layout that corresponds to
  36. this bar component. You'll need to set up the item
  37. properties in a suitable way for a divider bar, e.g.
  38. for an 8-pixel wide bar which, you could call
  39. myLayout->setItemLayout (barIndex, 8, 8, 8)
  40. @param isBarVertical true if it's an upright bar that you drag left and
  41. right; false for a horizontal one that you drag up and
  42. down
  43. */
  44. StretchableLayoutResizerBar (StretchableLayoutManager* layoutToUse,
  45. int itemIndexInLayout,
  46. bool isBarVertical);
  47. /** Destructor. */
  48. ~StretchableLayoutResizerBar() override;
  49. //==============================================================================
  50. /** This is called when the bar is dragged.
  51. This method must update the positions of any components whose position is
  52. determined by the StretchableLayoutManager, because they might have just
  53. moved.
  54. The default implementation calls the resized() method of this component's
  55. parent component, because that's often where you're likely to apply the
  56. layout, but it can be overridden for more specific needs.
  57. */
  58. virtual void hasBeenMoved();
  59. //==============================================================================
  60. /** This abstract base class is implemented by LookAndFeel classes. */
  61. struct JUCE_API LookAndFeelMethods
  62. {
  63. virtual ~LookAndFeelMethods() = default;
  64. virtual void drawStretchableLayoutResizerBar (Graphics&, int w, int h,
  65. bool isVerticalBar, bool isMouseOver, bool isMouseDragging) = 0;
  66. };
  67. //==============================================================================
  68. /** @internal */
  69. void paint (Graphics&) override;
  70. /** @internal */
  71. void mouseDown (const MouseEvent&) override;
  72. /** @internal */
  73. void mouseDrag (const MouseEvent&) override;
  74. private:
  75. //==============================================================================
  76. StretchableLayoutManager* layout;
  77. int itemIndex, mouseDownPos;
  78. bool isVertical;
  79. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar)
  80. };
  81. } // namespace juce