The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

177 lines
4.6KB

  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 (float v) noexcept : left (v), right (v), top (v), bottom (v)
  47. {}
  48. //==============================================================================
  49. GridItem::GridItem() noexcept {}
  50. GridItem::~GridItem() noexcept {}
  51. GridItem::GridItem (juce::Component& componentToUse) noexcept : associatedComponent (&componentToUse) {}
  52. GridItem::GridItem (juce::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 juce::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 juce::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. }