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.

101 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. /**
  20. A component that acts as one of the vertical or horizontal bars you see being
  21. used to resize panels in a window.
  22. One of these acts with a StretchableLayoutManager to resize the other components.
  23. @see StretchableLayoutManager
  24. */
  25. class JUCE_API StretchableLayoutResizerBar : public Component
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a resizer bar for use on a specified layout.
  30. @param layoutToUse the layout that will be affected when this bar
  31. is dragged
  32. @param itemIndexInLayout the item index in the layout that corresponds to
  33. this bar component. You'll need to set up the item
  34. properties in a suitable way for a divider bar, e.g.
  35. for an 8-pixel wide bar which, you could call
  36. myLayout->setItemLayout (barIndex, 8, 8, 8)
  37. @param isBarVertical true if it's an upright bar that you drag left and
  38. right; false for a horizontal one that you drag up and
  39. down
  40. */
  41. StretchableLayoutResizerBar (StretchableLayoutManager* layoutToUse,
  42. int itemIndexInLayout,
  43. bool isBarVertical);
  44. /** Destructor. */
  45. ~StretchableLayoutResizerBar();
  46. //==============================================================================
  47. /** This is called when the bar is dragged.
  48. This method must update the positions of any components whose position is
  49. determined by the StretchableLayoutManager, because they might have just
  50. moved.
  51. The default implementation calls the resized() method of this component's
  52. parent component, because that's often where you're likely to apply the
  53. layout, but it can be overridden for more specific needs.
  54. */
  55. virtual void hasBeenMoved();
  56. //==============================================================================
  57. /** This abstract base class is implemented by LookAndFeel classes. */
  58. struct JUCE_API LookAndFeelMethods
  59. {
  60. virtual ~LookAndFeelMethods() {}
  61. virtual void drawStretchableLayoutResizerBar (Graphics&, int w, int h,
  62. bool isVerticalBar, bool isMouseOver, bool isMouseDragging) = 0;
  63. };
  64. //==============================================================================
  65. /** @internal */
  66. void paint (Graphics&) override;
  67. /** @internal */
  68. void mouseDown (const MouseEvent&) override;
  69. /** @internal */
  70. void mouseDrag (const MouseEvent&) override;
  71. private:
  72. //==============================================================================
  73. StretchableLayoutManager* layout;
  74. int itemIndex, mouseDownPos;
  75. bool isVertical;
  76. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar)
  77. };