From d23d3a64a8e0b5869c125b320bd32d27e8d8c021 Mon Sep 17 00:00:00 2001 From: Kyle Bashour Date: Wed, 9 Sep 2020 21:17:18 -0700 Subject: [PATCH 1/2] Add convenience methods for adding children to stacks --- BlueprintUI/Sources/Layout/Stack.swift | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/BlueprintUI/Sources/Layout/Stack.swift b/BlueprintUI/Sources/Layout/Stack.swift index b02e6f0fe..2ae7369b3 100644 --- a/BlueprintUI/Sources/Layout/Stack.swift +++ b/BlueprintUI/Sources/Layout/Stack.swift @@ -74,7 +74,7 @@ extension StackElement { /// /// - child: The child element to add to this stack /// - mutating public func add(growPriority: CGFloat = 1.0, shrinkPriority: CGFloat = 1.0, key: AnyHashable? = nil, child: Element) { + public mutating func add(growPriority: CGFloat = 1.0, shrinkPriority: CGFloat = 1.0, key: AnyHashable? = nil, child: Element) { children.append(( element: child, traits: StackLayout.Traits(growPriority: growPriority, shrinkPriority: shrinkPriority), @@ -82,6 +82,24 @@ extension StackElement { )) } + + /// Convenience method for adding a child with a grow and shrink priority of 0.0 + /// + /// - parameters: + /// - child: The child element to add to this stack + /// + public mutating func addFixed(child: Element) { + self.add(growPriority: 0, shrinkPriority: 0, child: child) + } + + /// Convenience method for adding a child with a grow and shrink priority of 1.0 + /// + /// - parameters: + /// - child: The child element to add to this stack + /// + public mutating func addFlexible(child: Element) { + self.add(growPriority: 1, shrinkPriority: 1, child: child) + } } From b09d10cef8178706e839464d5ea54f958fa3cba4 Mon Sep 17 00:00:00 2001 From: Kyle Bashour Date: Wed, 9 Sep 2020 12:26:03 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 853e6e05d..ef0a42689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add `addFixed(child:)` and `addFlexible(child:)` methods to `StackElement` for adding children with a grow & shrink priority of 0.0 and 1.0 respectively. + ### Removed ### Changed