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.

187 lines
4.9KB

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