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
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__
  19. #define __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__
  20. #include "../components/juce_Component.h"
  21. #include "juce_StretchableLayoutManager.h"
  22. //==============================================================================
  23. /**
  24. A component that acts as one of the vertical or horizontal bars you see being
  25. used to resize panels in a window.
  26. One of these acts with a StretchableLayoutManager to resize the other components.
  27. @see StretchableLayoutManager
  28. */
  29. class JUCE_API StretchableLayoutResizerBar : public Component
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates a resizer bar for use on a specified layout.
  34. @param layoutToUse the layout that will be affected when this bar
  35. is dragged
  36. @param itemIndexInLayout the item index in the layout that corresponds to
  37. this bar component. You'll need to set up the item
  38. properties in a suitable way for a divider bar, e.g.
  39. for an 8-pixel wide bar which, you could call
  40. myLayout->setItemLayout (barIndex, 8, 8, 8)
  41. @param isBarVertical true if it's an upright bar that you drag left and
  42. right; false for a horizontal one that you drag up and
  43. down
  44. */
  45. StretchableLayoutResizerBar (StretchableLayoutManager* layoutToUse,
  46. int itemIndexInLayout,
  47. bool isBarVertical);
  48. /** Destructor. */
  49. ~StretchableLayoutResizerBar();
  50. //==============================================================================
  51. /** This is called when the bar is dragged.
  52. This method must update the positions of any components whose position is
  53. determined by the StretchableLayoutManager, because they might have just
  54. moved.
  55. The default implementation calls the resized() method of this component's
  56. parent component, because that's often where you're likely to apply the
  57. layout, but it can be overridden for more specific needs.
  58. */
  59. virtual void hasBeenMoved();
  60. //==============================================================================
  61. /** @internal */
  62. void paint (Graphics& g);
  63. /** @internal */
  64. void mouseDown (const MouseEvent& e);
  65. /** @internal */
  66. void mouseDrag (const MouseEvent& e);
  67. private:
  68. //==============================================================================
  69. StretchableLayoutManager* layout;
  70. int itemIndex, mouseDownPos;
  71. bool isVertical;
  72. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StretchableLayoutResizerBar);
  73. };
  74. #endif // __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__