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.

98 lines
3.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software 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. #ifndef __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__
  18. #define __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__
  19. #include "../components/juce_Component.h"
  20. #include "juce_StretchableLayoutManager.h"
  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. */
  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();
  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. /** @internal */
  61. void paint (Graphics&) override;
  62. /** @internal */
  63. void mouseDown (const MouseEvent&) override;
  64. /** @internal */
  65. void mouseDrag (const MouseEvent&) override;
  66. private:
  67. //==============================================================================
  68. StretchableLayoutManager* layout;
  69. int itemIndex, mouseDownPos;
  70. bool isVertical;
  71. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar)
  72. };
  73. #endif // __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__