Skip to content

Commit d4ef6c4

Browse files
committed
Adapt layout system to behave well with chained edge pins. Fix alignment selector corners not rendering red for bad alignment selection & not resetting to alignment when fit or parent changes.
1 parent 262d891 commit d4ef6c4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/src/api/models/pins_model.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ class EdgePinsModel with EquatableMixin, SerializableMixin {
151151
/// bottom pins are not null.
152152
bool get isVerticallyExpanded => top != null && bottom != null;
153153

154+
/// Returns the sum of the horizontal pins.
155+
double sumHorizontalPins() => (left ?? 0) + (right ?? 0);
156+
157+
/// Returns the sum of the vertical pins.
158+
double sumVerticalPins() => (top ?? 0) + (bottom ?? 0);
159+
160+
/// Returns the sum of the pins on the given [axis].
161+
double sumPinsOnAxis(AxisC axis) => switch (axis) {
162+
AxisC.horizontal => sumHorizontalPins(),
163+
AxisC.vertical => sumVerticalPins(),
164+
};
165+
154166
/// Due to the null-pattern of the pins, default copyWith method does not
155167
/// work. So, there's a separate copyWith method for each pin.
156168
///

lib/src/api/nodes/base_node.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ abstract class BaseNode
779779
void clearAlignmentAndPins() {
780780
_alignment = AlignmentModel.none;
781781
edgePins = EdgePinsModel.standard;
782+
positioningMode = PositioningMode.align;
782783
}
783784

784785
@override

0 commit comments

Comments
 (0)