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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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 {}
  51. GridItem::~GridItem() noexcept {}
  52. GridItem::GridItem (Component& componentToUse) noexcept : associatedComponent (&componentToUse) {}
  53. GridItem::GridItem (Component* componentToUse) noexcept : associatedComponent (componentToUse) {}
  54. void GridItem::setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd)
  55. {
  56. column.start = columnStart;
  57. column.end = columnEnd;
  58. row.start = rowStart;
  59. row.end = rowEnd;
  60. }
  61. void GridItem::setArea (Property rowStart, Property columnStart)
  62. {
  63. column.start = columnStart;
  64. row.start = rowStart;
  65. }
  66. void GridItem::setArea (const String& areaName)
  67. {
  68. area = areaName;
  69. }
  70. GridItem GridItem::withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept
  71. {
  72. auto gi = *this;
  73. gi.setArea (rowStart, columnStart, rowEnd, columnEnd);
  74. return gi;
  75. }
  76. GridItem GridItem::withArea (Property rowStart, Property columnStart) const noexcept
  77. {
  78. auto gi = *this;
  79. gi.setArea (rowStart, columnStart);
  80. return gi;
  81. }
  82. GridItem GridItem::withArea (const String& areaName) const noexcept
  83. {
  84. auto gi = *this;
  85. gi.setArea (areaName);
  86. return gi;
  87. }
  88. GridItem GridItem::withRow (StartAndEndProperty newRow) const noexcept
  89. {
  90. auto gi = *this;
  91. gi.row = newRow;
  92. return gi;
  93. }
  94. GridItem GridItem::withColumn (StartAndEndProperty newColumn) const noexcept
  95. {
  96. auto gi = *this;
  97. gi.column = newColumn;
  98. return gi;
  99. }
  100. GridItem GridItem::withAlignSelf (AlignSelf newAlignSelf) const noexcept
  101. {
  102. auto gi = *this;
  103. gi.alignSelf = newAlignSelf;
  104. return gi;
  105. }
  106. GridItem GridItem::withJustifySelf (JustifySelf newJustifySelf) const noexcept
  107. {
  108. auto gi = *this;
  109. gi.justifySelf = newJustifySelf;
  110. return gi;
  111. }
  112. GridItem GridItem::withWidth (float newWidth) const noexcept
  113. {
  114. auto gi = *this;
  115. gi.width = newWidth;
  116. return gi;
  117. }
  118. GridItem GridItem::withHeight (float newHeight) const noexcept
  119. {
  120. auto gi = *this;
  121. gi.height = newHeight;
  122. return gi;
  123. }
  124. GridItem GridItem::withSize (float newWidth, float newHeight) const noexcept
  125. {
  126. auto gi = *this;
  127. gi.width = newWidth;
  128. gi.height = newHeight;
  129. return gi;
  130. }
  131. GridItem GridItem::withMargin (Margin newHeight) const noexcept
  132. {
  133. auto gi = *this;
  134. gi.margin = newHeight;
  135. return gi;
  136. }
  137. GridItem GridItem::withOrder (int newOrder) const noexcept
  138. {
  139. auto gi = *this;
  140. gi.order = newOrder;
  141. return gi;
  142. }
  143. } // namespace juce