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.

107 lines
4.1KB

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