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.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. /**
  18. Represents a FlexBox container, which contains and manages the layout of a set
  19. of FlexItem objects.
  20. To use this class, set its parameters appropriately (you can search online for
  21. more help on exactly how the FlexBox protocol works!), then add your sub-items
  22. to the items array, and call performLayout().
  23. @see FlexItem
  24. */
  25. class JUCE_API FlexBox
  26. {
  27. public:
  28. /** Possible values for the flexDirection property. */
  29. enum class Direction { row, rowReverse, column, columnReverse };
  30. /** Possible values for the flexWrap property. */
  31. enum class Wrap { noWrap, wrap, wrapReverse };
  32. /** Possible values for the alignContent property. */
  33. enum class AlignContent { stretch, flexStart, flexEnd, center, spaceBetween, spaceAround };
  34. /** Possible values for the alignItems property. */
  35. enum class AlignItems { stretch, flexStart, flexEnd, center };
  36. /** Possible values for the justifyContent property. */
  37. enum class JustifyContent { flexStart, flexEnd, center, spaceBetween, spaceAround };
  38. //==============================================================================
  39. /** Creates an empty FlexBox container with default parameters. */
  40. FlexBox() noexcept;
  41. /** Creates an empty FlexBox container with these parameters. */
  42. FlexBox (Direction, Wrap, AlignContent, AlignItems, JustifyContent) noexcept;
  43. /** Creates an empty FlexBox container with the given content-justification mode. */
  44. FlexBox (JustifyContent) noexcept;
  45. /** Destructor. */
  46. ~FlexBox() noexcept;
  47. //==============================================================================
  48. /** Lays-out the box's items within the given rectangle. */
  49. void performLayout (Rectangle<float> targetArea);
  50. /** Lays-out the box's items within the given rectangle. */
  51. void performLayout (Rectangle<int> targetArea);
  52. //==============================================================================
  53. /** Specifies how flex items are placed in the flex container, and defines the
  54. direction of the main axis.
  55. */
  56. Direction flexDirection = Direction::row;
  57. /** Specifies whether items are forced into a single line or can be wrapped onto multiple lines.
  58. If wrapping is allowed, this property also controls the direction in which lines are stacked.
  59. */
  60. Wrap flexWrap = Wrap::noWrap;
  61. /** Specifies how a flex container's lines are placed within the flex container when
  62. there is extra space on the cross-axis.
  63. This property has no effect on single line layouts.
  64. */
  65. AlignContent alignContent = AlignContent::stretch;
  66. /** Specifies the alignment of flex items along the cross-axis of each line. */
  67. AlignItems alignItems = AlignItems::stretch;
  68. /** Defines how the container distributes space between and around items along the main-axis.
  69. The alignment is done after the lengths and auto margins are applied, so that if there is at
  70. least one flexible element, with flex-grow different from 0, it will have no effect as there
  71. won't be any available space.
  72. */
  73. JustifyContent justifyContent = JustifyContent::flexStart;
  74. /** The set of items to lay-out. */
  75. Array<FlexItem> items;
  76. private:
  77. JUCE_LEAK_DETECTOR (FlexBox)
  78. };