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.

183 lines
4.8KB

  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. GridItem::Property::Property() noexcept : isAuto (true)
  20. {
  21. }
  22. GridItem::Property::Property (GridItem::Keyword keyword) noexcept : isAuto (keyword == GridItem::Keyword::autoValue)
  23. {
  24. jassert (keyword == GridItem::Keyword::autoValue);
  25. }
  26. GridItem::Property::Property (const char* lineNameToUse) noexcept : GridItem::Property (juce::String (lineNameToUse))
  27. {
  28. }
  29. GridItem::Property::Property (const juce::String& lineNameToUse) noexcept : name (lineNameToUse), number (1)
  30. {
  31. }
  32. GridItem::Property::Property (int numberToUse) noexcept : number (numberToUse)
  33. {
  34. }
  35. GridItem::Property::Property (int numberToUse, const juce::String& lineNameToUse) noexcept
  36. : name (lineNameToUse), number (numberToUse)
  37. {
  38. }
  39. GridItem::Property::Property (Span spanToUse) noexcept
  40. : name (spanToUse.name), number (spanToUse.number), isSpan (true)
  41. {
  42. }
  43. //==============================================================================
  44. GridItem::Margin::Margin() noexcept : left(), right(), top(), bottom()
  45. {}
  46. GridItem::Margin::Margin (int v) noexcept : GridItem::Margin::Margin (static_cast<float> (v))
  47. {}
  48. GridItem::Margin::Margin (float v) noexcept : left (v), right (v), top (v), bottom (v)
  49. {}
  50. GridItem::Margin::Margin (float t, float r, float b, float l) noexcept : left (l), right (r), top (t), bottom (b)
  51. {}
  52. //==============================================================================
  53. GridItem::GridItem() noexcept {}
  54. GridItem::~GridItem() noexcept {}
  55. GridItem::GridItem (juce::Component& componentToUse) noexcept : associatedComponent (&componentToUse) {}
  56. GridItem::GridItem (juce::Component* componentToUse) noexcept : associatedComponent (componentToUse) {}
  57. void GridItem::setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd)
  58. {
  59. column.start = columnStart;
  60. column.end = columnEnd;
  61. row.start = rowStart;
  62. row.end = rowEnd;
  63. }
  64. void GridItem::setArea (Property rowStart, Property columnStart)
  65. {
  66. column.start = columnStart;
  67. row.start = rowStart;
  68. }
  69. void GridItem::setArea (const juce::String& areaName)
  70. {
  71. area = areaName;
  72. }
  73. GridItem GridItem::withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept
  74. {
  75. auto gi = *this;
  76. gi.setArea (rowStart, columnStart, rowEnd, columnEnd);
  77. return gi;
  78. }
  79. GridItem GridItem::withArea (Property rowStart, Property columnStart) const noexcept
  80. {
  81. auto gi = *this;
  82. gi.setArea (rowStart, columnStart);
  83. return gi;
  84. }
  85. GridItem GridItem::withArea (const juce::String& areaName) const noexcept
  86. {
  87. auto gi = *this;
  88. gi.setArea (areaName);
  89. return gi;
  90. }
  91. GridItem GridItem::withRow (StartAndEndProperty newRow) const noexcept
  92. {
  93. auto gi = *this;
  94. gi.row = newRow;
  95. return gi;
  96. }
  97. GridItem GridItem::withColumn (StartAndEndProperty newColumn) const noexcept
  98. {
  99. auto gi = *this;
  100. gi.column = newColumn;
  101. return gi;
  102. }
  103. GridItem GridItem::withAlignSelf (AlignSelf newAlignSelf) const noexcept
  104. {
  105. auto gi = *this;
  106. gi.alignSelf = newAlignSelf;
  107. return gi;
  108. }
  109. GridItem GridItem::withJustifySelf (JustifySelf newJustifySelf) const noexcept
  110. {
  111. auto gi = *this;
  112. gi.justifySelf = newJustifySelf;
  113. return gi;
  114. }
  115. GridItem GridItem::withWidth (float newWidth) const noexcept
  116. {
  117. auto gi = *this;
  118. gi.width = newWidth;
  119. return gi;
  120. }
  121. GridItem GridItem::withHeight (float newHeight) const noexcept
  122. {
  123. auto gi = *this;
  124. gi.height = newHeight;
  125. return gi;
  126. }
  127. GridItem GridItem::withSize (float newWidth, float newHeight) const noexcept
  128. {
  129. auto gi = *this;
  130. gi.width = newWidth;
  131. gi.height = newHeight;
  132. return gi;
  133. }
  134. GridItem GridItem::withMargin (Margin newHeight) const noexcept
  135. {
  136. auto gi = *this;
  137. gi.margin = newHeight;
  138. return gi;
  139. }
  140. GridItem GridItem::withOrder (int newOrder) const noexcept
  141. {
  142. auto gi = *this;
  143. gi.order = newOrder;
  144. return gi;
  145. }