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.

95 lines
3.8KB

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