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.

175 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  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 {}
  46. GridItem::~GridItem() noexcept {}
  47. GridItem::GridItem (Component& componentToUse) noexcept : associatedComponent (&componentToUse) {}
  48. GridItem::GridItem (Component* componentToUse) noexcept : associatedComponent (componentToUse) {}
  49. void GridItem::setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd)
  50. {
  51. column.start = columnStart;
  52. column.end = columnEnd;
  53. row.start = rowStart;
  54. row.end = rowEnd;
  55. }
  56. void GridItem::setArea (Property rowStart, Property columnStart)
  57. {
  58. column.start = columnStart;
  59. row.start = rowStart;
  60. }
  61. void GridItem::setArea (const String& areaName)
  62. {
  63. area = areaName;
  64. }
  65. GridItem GridItem::withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept
  66. {
  67. auto gi = *this;
  68. gi.setArea (rowStart, columnStart, rowEnd, columnEnd);
  69. return gi;
  70. }
  71. GridItem GridItem::withArea (Property rowStart, Property columnStart) const noexcept
  72. {
  73. auto gi = *this;
  74. gi.setArea (rowStart, columnStart);
  75. return gi;
  76. }
  77. GridItem GridItem::withArea (const String& areaName) const noexcept
  78. {
  79. auto gi = *this;
  80. gi.setArea (areaName);
  81. return gi;
  82. }
  83. GridItem GridItem::withRow (StartAndEndProperty newRow) const noexcept
  84. {
  85. auto gi = *this;
  86. gi.row = newRow;
  87. return gi;
  88. }
  89. GridItem GridItem::withColumn (StartAndEndProperty newColumn) const noexcept
  90. {
  91. auto gi = *this;
  92. gi.column = newColumn;
  93. return gi;
  94. }
  95. GridItem GridItem::withAlignSelf (AlignSelf newAlignSelf) const noexcept
  96. {
  97. auto gi = *this;
  98. gi.alignSelf = newAlignSelf;
  99. return gi;
  100. }
  101. GridItem GridItem::withJustifySelf (JustifySelf newJustifySelf) const noexcept
  102. {
  103. auto gi = *this;
  104. gi.justifySelf = newJustifySelf;
  105. return gi;
  106. }
  107. GridItem GridItem::withWidth (float newWidth) const noexcept
  108. {
  109. auto gi = *this;
  110. gi.width = newWidth;
  111. return gi;
  112. }
  113. GridItem GridItem::withHeight (float newHeight) const noexcept
  114. {
  115. auto gi = *this;
  116. gi.height = newHeight;
  117. return gi;
  118. }
  119. GridItem GridItem::withSize (float newWidth, float newHeight) const noexcept
  120. {
  121. auto gi = *this;
  122. gi.width = newWidth;
  123. gi.height = newHeight;
  124. return gi;
  125. }
  126. GridItem GridItem::withMargin (Margin newHeight) const noexcept
  127. {
  128. auto gi = *this;
  129. gi.margin = newHeight;
  130. return gi;
  131. }
  132. GridItem GridItem::withOrder (int newOrder) const noexcept
  133. {
  134. auto gi = *this;
  135. gi.order = newOrder;
  136. return gi;
  137. }
  138. } // namespace juce