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.

168 lines
6.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. /**
  22. Describes the properties of an item inside a FlexBox container.
  23. @see FlexBox
  24. */
  25. class JUCE_API FlexItem
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates an item with default parameters, and zero size. */
  30. FlexItem() noexcept;
  31. /** Creates an item with the given size. */
  32. FlexItem (float width, float height) noexcept;
  33. /** Creates an item with the given size and target component. */
  34. FlexItem (float width, float height, Component& targetComponent) noexcept;
  35. /** Creates an item that represents an embedded FlexBox with a given size. */
  36. FlexItem (float width, float height, FlexBox& flexBoxToControl) noexcept;
  37. /** Creates an item with a given target component. */
  38. FlexItem (Component& componentToControl) noexcept;
  39. /** Creates an item that represents an embedded FlexBox. */
  40. FlexItem (FlexBox& flexBoxToControl) noexcept;
  41. //==============================================================================
  42. /** The item's current bounds. */
  43. Rectangle<float> currentBounds;
  44. /** If this is non-null, it represents a Component whose bounds are controlled by this item. */
  45. Component* associatedComponent = nullptr;
  46. /** If this is non-null, it represents a FlexBox whose bounds are controlled by this item. */
  47. FlexBox* associatedFlexBox = nullptr;
  48. /** Determines the order used to lay out items in their flex container.
  49. Elements are laid out in ascending order of thus order value. Elements with the same order value
  50. are laid out in the order in which they appear in the array.
  51. */
  52. int order = 0;
  53. /** Specifies the flex grow factor of this item.
  54. This indicates the amount of space inside the flex container the item should take up.
  55. */
  56. float flexGrow = 0.0f;
  57. /** Specifies the flex shrink factor of the item.
  58. This indicates the rate at which the item shrinks if there is insufficient space in
  59. the container.
  60. */
  61. float flexShrink = 1.0f;
  62. /** Specifies the flex-basis of the item.
  63. This is the initial main size of a flex item in the direction of flow. It determines the size
  64. of the content-box unless specified otherwise using box-sizing.
  65. */
  66. float flexBasis = 0.0f;
  67. /** Possible value for the alignSelf property */
  68. enum class AlignSelf { autoAlign, flexStart, flexEnd, center, stretch };
  69. /** This is the aligh-self property of the item.
  70. This determines the alignment of the item along the corss-axis (perpendicular to the direction
  71. of flow).
  72. */
  73. AlignSelf alignSelf = AlignSelf::stretch;
  74. //==============================================================================
  75. /** This constant can be used for sizes to indicate that 'auto' mode should be used. */
  76. static const int autoValue = -2;
  77. /** This constant can be used for sizes to indicate that no value has been set. */
  78. static const int notAssigned = -1;
  79. float width = (float) notAssigned; /**< The item's width. */
  80. float minWidth = 0.0f; /**< The item's minimum width */
  81. float maxWidth = (float) notAssigned; /**< The item's maximum width */
  82. float height = (float) notAssigned; /**< The item's height */
  83. float minHeight = 0.0f; /**< The item's minimum height */
  84. float maxHeight = (float) notAssigned; /**< The item's maximum height */
  85. /** Represents a margin. */
  86. struct Margin
  87. {
  88. Margin() noexcept; /**< Creates a margin of size zero. */
  89. Margin (float size) noexcept; /**< Creates a margin with this size on all sides. */
  90. Margin (float top, float right, float bottom, float left) noexcept; /**< Creates a margin with these sizes. */
  91. float left; /**< Left margin size */
  92. float right; /**< Right margin size */
  93. float top; /**< Top margin size */
  94. float bottom; /**< Bottom margin size */
  95. };
  96. /** The margin to leave around this item. */
  97. Margin margin;
  98. //==============================================================================
  99. /** Returns a copy of this object with a new flex-grow value. */
  100. FlexItem withFlex (float newFlexGrow) const noexcept;
  101. /** Returns a copy of this object with new flex-grow and flex-shrink values. */
  102. FlexItem withFlex (float newFlexGrow, float newFlexShrink) const noexcept;
  103. /** Returns a copy of this object with new flex-grow, flex-shrink and flex-basis values. */
  104. FlexItem withFlex (float newFlexGrow, float newFlexShrink, float newFlexBasis) const noexcept;
  105. /** Returns a copy of this object with a new width. */
  106. FlexItem withWidth (float newWidth) const noexcept;
  107. /** Returns a copy of this object with a new minimum width. */
  108. FlexItem withMinWidth (float newMinWidth) const noexcept;
  109. /** Returns a copy of this object with a new maximum width. */
  110. FlexItem withMaxWidth (float newMaxWidth) const noexcept;
  111. /** Returns a copy of this object with a new height. */
  112. FlexItem withHeight (float newHeight) const noexcept;
  113. /** Returns a copy of this object with a new minimum height. */
  114. FlexItem withMinHeight (float newMinHeight) const noexcept;
  115. /** Returns a copy of this object with a new maximum height. */
  116. FlexItem withMaxHeight (float newMaxHeight) const noexcept;
  117. /** Returns a copy of this object with a new margin. */
  118. FlexItem withMargin (Margin) const noexcept;
  119. /** Returns a copy of this object with a new order. */
  120. FlexItem withOrder (int newOrder) const noexcept;
  121. /** Returns a copy of this object with a new alignSelf value. */
  122. FlexItem withAlignSelf (AlignSelf newAlignSelf) const noexcept;
  123. };
  124. } // namespace juce