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.

99 lines
3.9KB

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