diff --git a/modules/juce_gui_basics/layout/juce_Grid.cpp b/modules/juce_gui_basics/layout/juce_Grid.cpp index a681121a6d..e239e80cf9 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.cpp +++ b/modules/juce_gui_basics/layout/juce_Grid.cpp @@ -29,13 +29,13 @@ namespace juce struct Grid::SizeCalculation { - static float getTotalAbsoluteSize (const juce::Array& tracks, Px gapSize) noexcept + static float getTotalAbsoluteSize (const Array& tracks, Px gapSize) noexcept { float totalCellSize = 0.0f; for (const auto& trackInfo : tracks) - if (! trackInfo.isFraction || trackInfo.hasKeyword) - totalCellSize += trackInfo.size; + if (! trackInfo.isFractional() || trackInfo.isAuto()) + totalCellSize += trackInfo.getSize(); float totalGap = tracks.size() > 1 ? static_cast ((tracks.size() - 1) * gapSize.pixels) : 0.0f; @@ -43,45 +43,45 @@ struct Grid::SizeCalculation return totalCellSize + totalGap; } - static float getRelativeUnitSize (float size, float totalAbsolute, const juce::Array& tracks) noexcept + static float getRelativeUnitSize (float size, float totalAbsolute, const Array& tracks) noexcept { - const float totalRelative = juce::jlimit (0.0f, size, size - totalAbsolute); + const float totalRelative = jlimit (0.0f, size, size - totalAbsolute); float factorsSum = 0.0f; for (const auto& trackInfo : tracks) - if (trackInfo.isFraction) - factorsSum += trackInfo.size; + if (trackInfo.isFractional()) + factorsSum += trackInfo.getSize(); jassert (factorsSum != 0.0f); return totalRelative / factorsSum; } //============================================================================== - static float getTotalAbsoluteHeight (const juce::Array& rowTracks, Px rowGap) + static float getTotalAbsoluteHeight (const Array& rowTracks, Px rowGap) { return getTotalAbsoluteSize (rowTracks, rowGap); } - static float getTotalAbsoluteWidth (const juce::Array& columnTracks, Px columnGap) + static float getTotalAbsoluteWidth (const Array& columnTracks, Px columnGap) { return getTotalAbsoluteSize (columnTracks, columnGap); } - static float getRelativeWidthUnit (float gridWidth, Px columnGap, const juce::Array& columnTracks) + static float getRelativeWidthUnit (float gridWidth, Px columnGap, const Array& columnTracks) { return getRelativeUnitSize (gridWidth, getTotalAbsoluteWidth (columnTracks, columnGap), columnTracks); } - static float getRelativeHeightUnit (float gridHeight, Px rowGap, const juce::Array& rowTracks) + static float getRelativeHeightUnit (float gridHeight, Px rowGap, const Array& rowTracks) { return getRelativeUnitSize (gridHeight, getTotalAbsoluteHeight (rowTracks, rowGap), rowTracks); } //============================================================================== - static bool hasAnyFractions (const juce::Array& tracks) + static bool hasAnyFractions (const Array& tracks) { for (auto& t : tracks) - if (t.isFraction) + if (t.isFractional()) return true; return false; @@ -89,8 +89,8 @@ struct Grid::SizeCalculation void computeSizes (float gridWidth, float gridHeight, Px columnGapToUse, Px rowGapToUse, - const juce::Array& columnTracks, - const juce::Array& rowTracks) + const Array& columnTracks, + const Array& rowTracks) { if (hasAnyFractions (columnTracks)) relativeWidthUnit = getRelativeWidthUnit (gridWidth, columnGapToUse, columnTracks); @@ -118,19 +118,19 @@ struct Grid::PlacementHelpers //============================================================================== struct LineRange { int start, end; }; struct LineArea { LineRange column, row; }; - struct LineInfo { juce::StringArray lineNames; }; + struct LineInfo { StringArray lineNames; }; struct NamedArea { - juce::String name; + String name; LineArea lines; }; //============================================================================== - static juce::Array getArrayOfLinesFromTracks (const juce::Array& tracks) + static Array getArrayOfLinesFromTracks (const Array& tracks) { // fill line info array - juce::Array lines; + Array lines; for (int i = 1; i <= tracks.size(); ++i) { @@ -139,7 +139,7 @@ struct Grid::PlacementHelpers if (i == 1) // start line { LineInfo li; - li.lineNames.add (currentTrack.startLineName); + li.lineNames.add (currentTrack.getStartLineName()); lines.add (li); } @@ -148,8 +148,8 @@ struct Grid::PlacementHelpers const auto& prevTrack = tracks.getReference (i - 2); LineInfo li; - li.lineNames.add (prevTrack.endLineName); - li.lineNames.add (currentTrack.startLineName); + li.lineNames.add (prevTrack.getEndLineName()); + li.lineNames.add (currentTrack.getStartLineName()); lines.add (li); } @@ -157,7 +157,7 @@ struct Grid::PlacementHelpers if (i == tracks.size()) // end line { LineInfo li; - li.lineNames.add (currentTrack.endLineName); + li.lineNames.add (currentTrack.getEndLineName()); lines.add (li); } } @@ -169,7 +169,7 @@ struct Grid::PlacementHelpers //============================================================================== static int deduceAbsoluteLineNumberFromLineName (GridItem::Property prop, - const juce::Array& tracks) + const Array& tracks) { jassert (prop.hasAbsolute()); @@ -180,14 +180,14 @@ struct Grid::PlacementHelpers { for (const auto& name : lines.getReference (i).lineNames) { - if (prop.name == name) + if (prop.getName() == name) { ++count; break; } } - if (count == prop.number) + if (count == prop.getNumber()) return i + 1; } @@ -196,19 +196,19 @@ struct Grid::PlacementHelpers } static int deduceAbsoluteLineNumber (GridItem::Property prop, - const juce::Array& tracks) + const Array& tracks) { jassert (prop.hasAbsolute()); if (prop.hasName()) return deduceAbsoluteLineNumberFromLineName (prop, tracks); - return prop.number > 0 ? prop.number : tracks.size() + 2 + prop.number; + return prop.getNumber() > 0 ? prop.getNumber() : tracks.size() + 2 + prop.getNumber(); } static int deduceAbsoluteLineNumberFromNamedSpan (int startLineNumber, GridItem::Property propertyWithSpan, - const juce::Array& tracks) + const Array& tracks) { jassert (propertyWithSpan.hasSpan()); @@ -219,14 +219,14 @@ struct Grid::PlacementHelpers { for (const auto& name : lines.getReference (i).lineNames) { - if (propertyWithSpan.name == name) + if (propertyWithSpan.getName() == name) { ++count; break; } } - if (count == propertyWithSpan.number) + if (count == propertyWithSpan.getNumber()) return i + 1; } @@ -236,18 +236,18 @@ struct Grid::PlacementHelpers static int deduceAbsoluteLineNumberBasedOnSpan (int startLineNumber, GridItem::Property propertyWithSpan, - const juce::Array& tracks) + const Array& tracks) { jassert (propertyWithSpan.hasSpan()); if (propertyWithSpan.hasName()) return deduceAbsoluteLineNumberFromNamedSpan (startLineNumber, propertyWithSpan, tracks); - return startLineNumber + propertyWithSpan.number; + return startLineNumber + propertyWithSpan.getNumber(); } //============================================================================== - static LineRange deduceLineRange (GridItem::StartAndEndProperty prop, const juce::Array& tracks) + static LineRange deduceLineRange (GridItem::StartAndEndProperty prop, const Array& tracks) { LineRange s; @@ -295,7 +295,7 @@ struct Grid::PlacementHelpers static LineArea deduceLineArea (const GridItem& item, const Grid& grid, - const std::map& namedAreas) + const std::map& namedAreas) { if (item.area.isNotEmpty() && ! grid.templateAreas.isEmpty()) { @@ -310,12 +310,12 @@ struct Grid::PlacementHelpers } //============================================================================== - static juce::Array parseAreasProperty (const juce::StringArray& areasStrings) + static Array parseAreasProperty (const StringArray& areasStrings) { - juce::Array strings; + Array strings; for (const auto& areaString : areasStrings) - strings.add (juce::StringArray::fromTokens (areaString, false)); + strings.add (StringArray::fromTokens (areaString, false)); if (strings.size() > 0) { @@ -328,7 +328,7 @@ struct Grid::PlacementHelpers return strings; } - static NamedArea findArea (juce::Array& stringsArrays) + static NamedArea findArea (Array& stringsArrays) { NamedArea area; @@ -370,11 +370,11 @@ struct Grid::PlacementHelpers } //============================================================================== - static std::map deduceNamedAreas (const juce::StringArray& areasStrings) + static std::map deduceNamedAreas (const StringArray& areasStrings) { auto stringsArrays = parseAreasProperty (areasStrings); - std::map areas; + std::map areas; for (auto area = findArea (stringsArrays); area.name.isNotEmpty(); area = findArea (stringsArrays)) { @@ -389,19 +389,19 @@ struct Grid::PlacementHelpers } //============================================================================== - static float getCoord (int trackNumber, float relativeUnit, Px gap, const juce::Array& tracks) + static float getCoord (int trackNumber, float relativeUnit, Px gap, const Array& tracks) { float c = 0; for (const auto* it = tracks.begin(); it != tracks.begin() + trackNumber - 1; ++it) - c += (it->isFraction ? it->size * relativeUnit : it->size) + static_cast (gap.pixels); + c += it->getAbsoluteSize (relativeUnit) + static_cast (gap.pixels); return c; } - static juce::Rectangle getCellBounds (int columnNumber, int rowNumber, - const juce::Array& columnTracks, - const juce::Array& rowTracks, + static Rectangle getCellBounds (int columnNumber, int rowNumber, + const Array& columnTracks, + const Array& rowTracks, Grid::SizeCalculation calculation, Px columnGap, Px rowGap) { @@ -412,17 +412,15 @@ struct Grid::PlacementHelpers const auto y = getCoord (rowNumber, calculation.relativeHeightUnit, rowGap, rowTracks); const auto& columnTrackInfo = columnTracks.getReference (columnNumber - 1); - const float width = columnTrackInfo.isFraction ? columnTrackInfo.size * calculation.relativeWidthUnit - : columnTrackInfo.size; + const float width = columnTrackInfo.getAbsoluteSize (calculation.relativeWidthUnit); const auto& rowTrackInfo = rowTracks.getReference (rowNumber - 1); - const float height = rowTrackInfo.isFraction ? rowTrackInfo.size * calculation.relativeHeightUnit - : rowTrackInfo.size; + const float height = rowTrackInfo.getAbsoluteSize (calculation.relativeHeightUnit); return { x, y, width, height }; } - static juce::Rectangle alignCell (juce::Rectangle area, + static Rectangle alignCell (Rectangle area, int columnNumber, int rowNumber, int numberOfColumns, int numberOfRows, Grid::SizeCalculation calculation, @@ -486,10 +484,10 @@ struct Grid::PlacementHelpers return area; } - static juce::Rectangle getAreaBounds (int columnLineNumberStart, int columnLineNumberEnd, + static Rectangle getAreaBounds (int columnLineNumberStart, int columnLineNumberEnd, int rowLineNumberStart, int rowLineNumberEnd, - const juce::Array& columnTracks, - const juce::Array& rowTracks, + const Array& columnTracks, + const Array& rowTracks, Grid::SizeCalculation calculation, Grid::AlignContent alignContent, Grid::JustifyContent justifyContent, @@ -529,7 +527,7 @@ struct Grid::PlacementHelpers //============================================================================== struct Grid::AutoPlacement { - using ItemPlacementArray = juce::Array>; + using ItemPlacementArray = Array>; //============================================================================== struct OccupancyPlane @@ -722,10 +720,10 @@ struct Grid::AutoPlacement static int getSpanFromAuto (GridItem::StartAndEndProperty prop) { if (prop.end.hasSpan()) - return prop.end.number; + return prop.end.getNumber(); if (prop.start.hasSpan()) - return prop.start.number; + return prop.start.getNumber(); return 1; } @@ -735,12 +733,12 @@ struct Grid::AutoPlacement { const auto namedAreas = Grid::PlacementHelpers::deduceNamedAreas (grid.templateAreas); - OccupancyPlane plane (juce::jmax (grid.templateColumns.size() + 1, 2), - juce::jmax (grid.templateRows.size() + 1, 2), + OccupancyPlane plane (jmax (grid.templateColumns.size() + 1, 2), + jmax (grid.templateRows.size() + 1, 2), isColumnAutoFlow (grid.autoFlow)); ItemPlacementArray itemPlacementArray; - juce::Array sortedItems; + Array sortedItems; for (auto& item : grid.items) sortedItems.add (&item); @@ -836,12 +834,12 @@ struct Grid::AutoPlacement return { columnEndLine, rowEndLine }; } - static std::pair, juce::Array> createImplicitTracks (const Grid& grid, + static std::pair, Array> createImplicitTracks (const Grid& grid, const ItemPlacementArray& items) { const auto columnAndRowLineEnds = getHighestEndLinesNumbers (items); - juce::Array implicitColumnTracks, implicitRowTracks; + Array implicitColumnTracks, implicitRowTracks; for (int i = grid.templateColumns.size() + 1; i < columnAndRowLineEnds.first; i++) implicitColumnTracks.add (grid.autoColumns); @@ -853,8 +851,8 @@ struct Grid::AutoPlacement } //============================================================================== - static void applySizeForAutoTracks (juce::Array& columns, - juce::Array& rows, + static void applySizeForAutoTracks (Array& columns, + Array& rows, const ItemPlacementArray& itemPlacementArray) { auto isSpan = [](Grid::PlacementHelpers::LineRange r) -> bool { return std::abs (r.end - r.start) > 1; }; @@ -881,11 +879,11 @@ struct Grid::AutoPlacement }; for (int i = 0; i < rows.size(); i++) - if (rows.getReference (i).hasKeyword) + if (rows.getReference (i).isAuto()) rows.getReference (i).size = getHighestItemOnRow (i + 1, itemPlacementArray); for (int i = 0; i < columns.size(); i++) - if (columns.getReference (i).hasKeyword) + if (columns.getReference (i).isAuto()) columns.getReference (i).size = getHighestItemOnColumn (i + 1, itemPlacementArray); } }; @@ -893,9 +891,9 @@ struct Grid::AutoPlacement //============================================================================== struct Grid::BoxAlignment { - static juce::Rectangle alignItem (const GridItem& item, + static Rectangle alignItem (const GridItem& item, const Grid& grid, - juce::Rectangle area) + Rectangle area) { // if item align is auto, inherit value from grid Grid::AlignItems alignType = Grid::AlignItems::start; @@ -912,7 +910,7 @@ struct Grid::BoxAlignment justifyType = static_cast (item.justifySelf); // subtract margin from area - area = juce::BorderSize (item.margin.top, item.margin.left, item.margin.bottom, item.margin.right) + area = BorderSize (item.margin.top, item.margin.left, item.margin.bottom, item.margin.right) .subtractedFrom (area); // align and justify @@ -944,44 +942,52 @@ Grid::TrackInfo::TrackInfo (Px sizeInPixels) noexcept : size (static_cast Grid::TrackInfo::TrackInfo (Fr fractionOfFreeSpace) noexcept : size ((float)fractionOfFreeSpace.fraction), isFraction (true) {} -Grid::TrackInfo::TrackInfo (Px sizeInPixels, const juce::String& endLineNameToUse) noexcept : Grid::TrackInfo (sizeInPixels) +Grid::TrackInfo::TrackInfo (Px sizeInPixels, const String& endLineNameToUse) noexcept : Grid::TrackInfo (sizeInPixels) { endLineName = endLineNameToUse; } -Grid::TrackInfo::TrackInfo (Fr fractionOfFreeSpace, const juce::String& endLineNameToUse) noexcept : Grid::TrackInfo (fractionOfFreeSpace) +Grid::TrackInfo::TrackInfo (Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept : Grid::TrackInfo (fractionOfFreeSpace) { endLineName = endLineNameToUse; } -Grid::TrackInfo::TrackInfo (const juce::String& startLineNameToUse, Px sizeInPixels) noexcept : Grid::TrackInfo (sizeInPixels) +Grid::TrackInfo::TrackInfo (const String& startLineNameToUse, Px sizeInPixels) noexcept : Grid::TrackInfo (sizeInPixels) { startLineName = startLineNameToUse; } -Grid::TrackInfo::TrackInfo (const juce::String& startLineNameToUse, Fr fractionOfFreeSpace) noexcept : Grid::TrackInfo (fractionOfFreeSpace) +Grid::TrackInfo::TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace) noexcept : Grid::TrackInfo (fractionOfFreeSpace) { startLineName = startLineNameToUse; } -Grid::TrackInfo::TrackInfo (const juce::String& startLineNameToUse, Px sizeInPixels, const juce::String& endLineNameToUse) noexcept +Grid::TrackInfo::TrackInfo (const String& startLineNameToUse, Px sizeInPixels, const String& endLineNameToUse) noexcept : Grid::TrackInfo (startLineNameToUse, sizeInPixels) { endLineName = endLineNameToUse; } -Grid::TrackInfo::TrackInfo (const juce::String& startLineNameToUse, Fr fractionOfFreeSpace, const juce::String& endLineNameToUse) noexcept +Grid::TrackInfo::TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept : Grid::TrackInfo (startLineNameToUse, fractionOfFreeSpace) { endLineName = endLineNameToUse; } +float Grid::TrackInfo::getAbsoluteSize (float relativeFractionalUnit) const +{ + if (isFractional()) + return size * relativeFractionalUnit; + else + return size; +} + //============================================================================== Grid::Grid() noexcept {} Grid::~Grid() noexcept {} //============================================================================== -void Grid::performLayout (juce::Rectangle targetArea) +void Grid::performLayout (Rectangle targetArea) { const auto itemsAndAreas = Grid::AutoPlacement().deduceAllItems (*this); diff --git a/modules/juce_gui_basics/layout/juce_Grid.h b/modules/juce_gui_basics/layout/juce_Grid.h index 86e87719ad..64c5d3e01a 100644 --- a/modules/juce_gui_basics/layout/juce_Grid.h +++ b/modules/juce_gui_basics/layout/juce_Grid.h @@ -67,35 +67,37 @@ public: { /** Creates a track with auto dimension. */ TrackInfo() noexcept; - /** */ + TrackInfo (Px sizeInPixels) noexcept; - /** */ TrackInfo (Fr fractionOfFreeSpace) noexcept; - /** */ - TrackInfo (Px sizeInPixels, const juce::String& endLineNameToUse) noexcept; - /** */ - TrackInfo (Fr fractionOfFreeSpace, const juce::String& endLineNameToUse) noexcept; + TrackInfo (Px sizeInPixels, const String& endLineNameToUse) noexcept; + TrackInfo (Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept; + + TrackInfo (const String& startLineNameToUse, Px sizeInPixels) noexcept; + TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace) noexcept; + + TrackInfo (const String& startLineNameToUse, Px sizeInPixels, const String& endLineNameToUse) noexcept; + TrackInfo (const String& startLineNameToUse, Fr fractionOfFreeSpace, const String& endLineNameToUse) noexcept; - /** */ - TrackInfo (const juce::String& startLineNameToUse, Px sizeInPixels) noexcept; - /** */ - TrackInfo (const juce::String& startLineNameToUse, Fr fractionOfFreeSpace) noexcept; + bool isAuto() const noexcept { return hasKeyword; } + bool isFractional() const noexcept { return isFraction; } + bool isPixels() const noexcept { return ! isFraction; } + const String& getStartLineName() const noexcept { return startLineName; } + const String& getEndLineName() const noexcept { return endLineName; } - /** */ - TrackInfo (const juce::String& startLineNameToUse, Px sizeInPixels, const juce::String& endLineNameToUse) noexcept; - /** */ - TrackInfo (const juce::String& startLineNameToUse, Fr fractionOfFreeSpace, const juce::String& endLineNameToUse) noexcept; + /** Get the track's size - which might mean an absolute pixels value or a fractional ratio. */ + float getSize() const noexcept { return size; } private: friend class Grid; - friend class GridItem; + float getAbsoluteSize (float relativeFractionalUnit) const; float size = 0; // Either a fraction or an absolute size in pixels bool isFraction = false; bool hasKeyword = false; - juce::String startLineName, endLineName; + String startLineName, endLineName; }; //============================================================================== @@ -177,13 +179,13 @@ public: //============================================================================== /** The set of column tracks to lay out. */ - juce::Array templateColumns; + Array templateColumns; /** The set of row tracks to lay out. */ - juce::Array templateRows; + Array templateRows; /** Template areas */ - juce::StringArray templateAreas; + StringArray templateAreas; /** The row track for auto dimension. */ TrackInfo autoRows; @@ -201,11 +203,11 @@ public: //============================================================================== /** The set of items to lay-out. */ - juce::Array items; + Array items; //============================================================================== /** Lays-out the grid's items within the given rectangle. */ - void performLayout (juce::Rectangle); + void performLayout (Rectangle); //============================================================================== /** Returns the number of columns. */ diff --git a/modules/juce_gui_basics/layout/juce_GridItem.cpp b/modules/juce_gui_basics/layout/juce_GridItem.cpp index da6c9356b6..f85e0d85ee 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.cpp +++ b/modules/juce_gui_basics/layout/juce_GridItem.cpp @@ -36,11 +36,11 @@ GridItem::Property::Property (GridItem::Keyword keyword) noexcept : isAuto (keyw jassert (keyword == GridItem::Keyword::autoValue); } -GridItem::Property::Property (const char* lineNameToUse) noexcept : GridItem::Property (juce::String (lineNameToUse)) +GridItem::Property::Property (const char* lineNameToUse) noexcept : GridItem::Property (String (lineNameToUse)) { } -GridItem::Property::Property (const juce::String& lineNameToUse) noexcept : name (lineNameToUse), number (1) +GridItem::Property::Property (const String& lineNameToUse) noexcept : name (lineNameToUse), number (1) { } @@ -48,7 +48,7 @@ GridItem::Property::Property (int numberToUse) noexcept : number (numberToUse) { } -GridItem::Property::Property (int numberToUse, const juce::String& lineNameToUse) noexcept +GridItem::Property::Property (int numberToUse, const String& lineNameToUse) noexcept : name (lineNameToUse), number (numberToUse) { } @@ -72,8 +72,8 @@ GridItem::Margin::Margin (float t, float r, float b, float l) noexcept : left (l GridItem::GridItem() noexcept {} GridItem::~GridItem() noexcept {} -GridItem::GridItem (juce::Component& componentToUse) noexcept : associatedComponent (&componentToUse) {} -GridItem::GridItem (juce::Component* componentToUse) noexcept : associatedComponent (componentToUse) {} +GridItem::GridItem (Component& componentToUse) noexcept : associatedComponent (&componentToUse) {} +GridItem::GridItem (Component* componentToUse) noexcept : associatedComponent (componentToUse) {} void GridItem::setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) { @@ -89,7 +89,7 @@ void GridItem::setArea (Property rowStart, Property columnStart) row.start = rowStart; } -void GridItem::setArea (const juce::String& areaName) +void GridItem::setArea (const String& areaName) { area = areaName; } @@ -108,7 +108,7 @@ GridItem GridItem::withArea (Property rowStart, Property columnStart) const noex return gi; } -GridItem GridItem::withArea (const juce::String& areaName) const noexcept +GridItem GridItem::withArea (const String& areaName) const noexcept { auto gi = *this; gi.setArea (areaName); diff --git a/modules/juce_gui_basics/layout/juce_GridItem.h b/modules/juce_gui_basics/layout/juce_GridItem.h index 3139e3f4ac..9361334897 100644 --- a/modules/juce_gui_basics/layout/juce_GridItem.h +++ b/modules/juce_gui_basics/layout/juce_GridItem.h @@ -48,57 +48,50 @@ public: jassert (numberToUse > 0); } - explicit Span (int numberToUse, const juce::String& nameToUse) : Span (numberToUse) + explicit Span (int numberToUse, const String& nameToUse) : Span (numberToUse) { /* Name must not be empty */ jassert (nameToUse.isNotEmpty()); name = nameToUse; } - explicit Span (const juce::String& nameToUse) : name (nameToUse) + explicit Span (const String& nameToUse) : name (nameToUse) { /* Name must not be empty */ jassert (nameToUse.isNotEmpty()); } int number = 1; - juce::String name; + String name; }; //============================================================================== /** Represents a property. */ struct Property { - /** */ Property() noexcept; - /** */ Property (Keyword keyword) noexcept; - /** */ Property (const char* lineNameToUse) noexcept; - /** */ - Property (const juce::String& lineNameToUse) noexcept; + Property (const String& lineNameToUse) noexcept; - /** */ Property (int numberToUse) noexcept; - /** */ - Property (int numberToUse, const juce::String& lineNameToUse) noexcept; + Property (int numberToUse, const String& lineNameToUse) noexcept; - /** */ Property (Span spanToUse) noexcept; - private: - bool hasSpan() const noexcept { return isSpan && ! isAuto; } - bool hasAbsolute() const noexcept { return ! (isSpan || isAuto); } - bool hasAuto() const noexcept { return isAuto; } - bool hasName() const noexcept { return name.isNotEmpty(); } - - friend class Grid; + bool hasSpan() const noexcept { return isSpan && ! isAuto; } + bool hasAbsolute() const noexcept { return ! (isSpan || isAuto); } + bool hasAuto() const noexcept { return isAuto; } + bool hasName() const noexcept { return name.isNotEmpty(); } + const String& getName() const noexcept { return name; } + int getNumber() const noexcept { return number; } - juce::String name; + private: + String name; int number = 1; /** Either an absolute line number or number of lines to span across. */ bool isSpan = false; bool isAuto = false; @@ -132,16 +125,16 @@ public: /** Creates an item with default parameters. */ GridItem() noexcept; /** Creates an item with a given Component to use. */ - GridItem (juce::Component& componentToUse) noexcept; + GridItem (Component& componentToUse) noexcept; /** Creates an item with a given Component to use. */ - GridItem (juce::Component* componentToUse) noexcept; + GridItem (Component* componentToUse) noexcept; /** Destructor. */ ~GridItem() noexcept; //============================================================================== /** If this is non-null, it represents a Component whose bounds are controlled by this item. */ - juce::Component* associatedComponent = nullptr; + Component* associatedComponent = nullptr; //============================================================================== /** Determines the order used to lay out items in their grid container. */ @@ -164,7 +157,7 @@ public: StartAndEndProperty row = { Keyword::autoValue, Keyword::autoValue }; /** */ - juce::String area; + String area; //============================================================================== enum @@ -200,7 +193,7 @@ public: Margin margin; /** The item's current bounds. */ - juce::Rectangle currentBounds; + Rectangle currentBounds; /** Short-hand */ void setArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd); @@ -209,7 +202,7 @@ public: void setArea (Property rowStart, Property columnStart); /** Short-hand */ - void setArea (const juce::String& areaName); + void setArea (const String& areaName); /** Short-hand */ GridItem withArea (Property rowStart, Property columnStart, Property rowEnd, Property columnEnd) const noexcept; @@ -218,7 +211,7 @@ public: GridItem withArea (Property rowStart, Property columnStart) const noexcept; /** Short-hand */ - GridItem withArea (const juce::String& areaName) const noexcept; + GridItem withArea (const String& areaName) const noexcept; /** Returns a copy of this object with a new row property. */ GridItem withRow (StartAndEndProperty row) const noexcept;