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.

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