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.

juce_GridItem.cpp 4.8KB

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