Audio plugin host https://kx.studio/carla
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.

162 lines
6.7KB

  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. Describes the properties of an item inside a FlexBox container.
  19. @see FlexBox
  20. */
  21. class JUCE_API FlexItem
  22. {
  23. public:
  24. //==============================================================================
  25. /** Creates an item with default parameters, and zero size. */
  26. FlexItem() noexcept;
  27. /** Creates an item with the given size. */
  28. FlexItem (float width, float height) noexcept;
  29. /** Creates an item with the given size and target component. */
  30. FlexItem (float width, float height, Component& targetComponent) noexcept;
  31. /** Creates an item that represents an embedded FlexBox with a given size. */
  32. FlexItem (float width, float height, FlexBox& flexBoxToControl) noexcept;
  33. /** Creates an item with a given target component. */
  34. FlexItem (Component& componentToControl) noexcept;
  35. /** Creates an item that represents an embedded FlexBox. */
  36. FlexItem (FlexBox& flexBoxToControl) noexcept;
  37. //==============================================================================
  38. /** The item's current bounds. */
  39. Rectangle<float> currentBounds;
  40. /** If this is non-null, it represents a Component whose bounds are controlled by this item. */
  41. Component* associatedComponent = nullptr;
  42. /** If this is non-null, it represents a FlexBox whose bounds are controlled by this item. */
  43. FlexBox* associatedFlexBox = nullptr;
  44. /** Determines the order used to lay out items in their flex container.
  45. Elements are laid out in ascending order of thus order value. Elements with the same order value
  46. are laid out in the order in which they appear in the array.
  47. */
  48. int order = 0;
  49. /** Specifies the flex grow factor of this item.
  50. This indicates the amount of space inside the flex container the item should take up.
  51. */
  52. float flexGrow = 0.0f;
  53. /** Specifies the flex shrink factor of the item.
  54. This indicates the rate at which the item shrinks if there is insufficient space in
  55. the container.
  56. */
  57. float flexShrink = 1.0f;
  58. /** Specifies the flex-basis of the item.
  59. This is the initial main size of a flex item in the direction of flow. It determines the size
  60. of the content-box unless specified otherwise using box-sizing.
  61. */
  62. float flexBasis = 0.0f;
  63. /** Possible value for the alignSelf property */
  64. enum class AlignSelf { autoAlign, flexStart, flexEnd, center, stretch };
  65. /** This is the aligh-self property of the item.
  66. This determines the alignment of the item along the corss-axis (perpendicular to the direction
  67. of flow).
  68. */
  69. AlignSelf alignSelf = AlignSelf::stretch;
  70. //==============================================================================
  71. /** This constant can be used for sizes to indicate that 'auto' mode should be used. */
  72. static const int autoValue = -2;
  73. /** This constant can be used for sizes to indicate that no value has been set. */
  74. static const int notAssigned = -1;
  75. float width = (float) notAssigned; /**< The item's width. */
  76. float minWidth = 0.0f; /**< The item's minimum width */
  77. float maxWidth = (float) notAssigned; /**< The item's maximum width */
  78. float height = (float) notAssigned; /**< The item's height */
  79. float minHeight = 0.0f; /**< The item's minimum height */
  80. float maxHeight = (float) notAssigned; /**< The item's maximum height */
  81. /** Represents a margin. */
  82. struct Margin
  83. {
  84. Margin() noexcept; /**< Creates a margin of size zero. */
  85. Margin (float size) noexcept; /**< Creates a margin with this size on all sides. */
  86. Margin (float top, float right, float bottom, float left) noexcept; /**< Creates a margin with these sizes. */
  87. float left; /**< Left margin size */
  88. float right; /**< Right margin size */
  89. float top; /**< Top margin size */
  90. float bottom; /**< Bottom margin size */
  91. };
  92. /** The margin to leave around this item. */
  93. Margin margin;
  94. //==============================================================================
  95. /** Returns a copy of this object with a new flex-grow value. */
  96. FlexItem withFlex (float newFlexGrow) const noexcept;
  97. /** Returns a copy of this object with new flex-grow and flex-shrink values. */
  98. FlexItem withFlex (float newFlexGrow, float newFlexShrink) const noexcept;
  99. /** Returns a copy of this object with new flex-grow, flex-shrink and flex-basis values. */
  100. FlexItem withFlex (float newFlexGrow, float newFlexShrink, float newFlexBasis) const noexcept;
  101. /** Returns a copy of this object with a new width. */
  102. FlexItem withWidth (float newWidth) const noexcept;
  103. /** Returns a copy of this object with a new minimum width. */
  104. FlexItem withMinWidth (float newMinWidth) const noexcept;
  105. /** Returns a copy of this object with a new maximum width. */
  106. FlexItem withMaxWidth (float newMaxWidth) const noexcept;
  107. /** Returns a copy of this object with a new height. */
  108. FlexItem withHeight (float newHeight) const noexcept;
  109. /** Returns a copy of this object with a new minimum height. */
  110. FlexItem withMinHeight (float newMinHeight) const noexcept;
  111. /** Returns a copy of this object with a new maximum height. */
  112. FlexItem withMaxHeight (float newMaxHeight) const noexcept;
  113. /** Returns a copy of this object with a new margin. */
  114. FlexItem withMargin (Margin) const noexcept;
  115. /** Returns a copy of this object with a new order. */
  116. FlexItem withOrder (int newOrder) const noexcept;
  117. /** Returns a copy of this object with a new alignSelf value. */
  118. FlexItem withAlignSelf (AlignSelf newAlignSelf) const noexcept;
  119. };