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.

173 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. GridItem::Property::Property() noexcept : isAuto (true)
  16. {
  17. }
  18. GridItem::Property::Property (GridItem::Keyword keyword) noexcept : isAuto (keyword == GridItem::Keyword::autoValue)
  19. {
  20. jassert (keyword == GridItem::Keyword::autoValue);
  21. }
  22. GridItem::Property::Property (const char* lineNameToUse) noexcept : GridItem::Property (String (lineNameToUse))
  23. {
  24. }
  25. GridItem::Property::Property (const String& lineNameToUse) noexcept : name (lineNameToUse), number (1)
  26. {
  27. }
  28. GridItem::Property::Property (int numberToUse) noexcept : number (numberToUse)
  29. {
  30. }
  31. GridItem::Property::Property (int numberToUse, const String& lineNameToUse) noexcept
  32. : name (lineNameToUse), number (numberToUse)
  33. {
  34. }
  35. GridItem::Property::Property (Span spanToUse) noexcept
  36. : name (spanToUse.name), number (spanToUse.number), isSpan (true)
  37. {
  38. }
  39. //==============================================================================
  40. GridItem::Margin::Margin() noexcept : left(), right(), top(), bottom() {}
  41. GridItem::Margin::Margin (int v) noexcept : GridItem::Margin::Margin (static_cast<float> (v)) {}
  42. GridItem::Margin::Margin (float v) noexcept : left (v), right (v), top (v), bottom (v) {}
  43. GridItem::Margin::Margin (float t, float r, float b, float l) noexcept : left (l), right (r), top (t), bottom (b) {}
  44. //==============================================================================
  45. GridItem::GridItem() noexcept = default;
  46. GridItem::GridItem (Component& componentToUse) noexcept : associatedComponent (&componentToUse) {}
  47. GridItem::GridItem (Component* componentToUse) noexcept : associatedComponent (componentToUse) {}
  48. void GridItem::setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd)
  49. {
  50. column.start = columnStart;
  51. column.end = columnEnd;
  52. row.start = rowStart;
  53. row.end = rowEnd;
  54. }
  55. void GridItem::setArea (Property rowStart, Property columnStart)
  56. {
  57. column.start = columnStart;
  58. row.start = rowStart;
  59. }
  60. void GridItem::setArea (const String& areaName)
  61. {
  62. area = areaName;
  63. }
  64. GridItem GridItem::withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept
  65. {
  66. auto gi = *this;
  67. gi.setArea (rowStart, columnStart, rowEnd, columnEnd);
  68. return gi;
  69. }
  70. GridItem GridItem::withArea (Property rowStart, Property columnStart) const noexcept
  71. {
  72. auto gi = *this;
  73. gi.setArea (rowStart, columnStart);
  74. return gi;
  75. }
  76. GridItem GridItem::withArea (const String& areaName) const noexcept
  77. {
  78. auto gi = *this;
  79. gi.setArea (areaName);
  80. return gi;
  81. }
  82. GridItem GridItem::withRow (StartAndEndProperty newRow) const noexcept
  83. {
  84. auto gi = *this;
  85. gi.row = newRow;
  86. return gi;
  87. }
  88. GridItem GridItem::withColumn (StartAndEndProperty newColumn) const noexcept
  89. {
  90. auto gi = *this;
  91. gi.column = newColumn;
  92. return gi;
  93. }
  94. GridItem GridItem::withAlignSelf (AlignSelf newAlignSelf) const noexcept
  95. {
  96. auto gi = *this;
  97. gi.alignSelf = newAlignSelf;
  98. return gi;
  99. }
  100. GridItem GridItem::withJustifySelf (JustifySelf newJustifySelf) const noexcept
  101. {
  102. auto gi = *this;
  103. gi.justifySelf = newJustifySelf;
  104. return gi;
  105. }
  106. GridItem GridItem::withWidth (float newWidth) const noexcept
  107. {
  108. auto gi = *this;
  109. gi.width = newWidth;
  110. return gi;
  111. }
  112. GridItem GridItem::withHeight (float newHeight) const noexcept
  113. {
  114. auto gi = *this;
  115. gi.height = newHeight;
  116. return gi;
  117. }
  118. GridItem GridItem::withSize (float newWidth, float newHeight) const noexcept
  119. {
  120. auto gi = *this;
  121. gi.width = newWidth;
  122. gi.height = newHeight;
  123. return gi;
  124. }
  125. GridItem GridItem::withMargin (Margin newHeight) const noexcept
  126. {
  127. auto gi = *this;
  128. gi.margin = newHeight;
  129. return gi;
  130. }
  131. GridItem GridItem::withOrder (int newOrder) const noexcept
  132. {
  133. auto gi = *this;
  134. gi.order = newOrder;
  135. return gi;
  136. }
  137. } // namespace juce