Skip to content

Commit

Permalink
Layer inspector: do not go out of bounds with a multifield output (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
pianostringquartet authored Dec 12, 2024
1 parent a2023d9 commit 1e58990
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
1 change: 1 addition & 0 deletions Stitch/Graph/LayerInspector/LayerInspectorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct LayerInspectorView: View {
#if targetEnvironment(macCatalyst)
.padding(.trailing, LAYER_INSPECTOR_ROW_SPACING + LAYER_INSPECTOR_ROW_ICON_LENGTH)
#endif
.padding(.bottom)

} // List
.listSectionSpacing(.compact) // reduce spacing between sections
Expand Down
9 changes: 6 additions & 3 deletions Stitch/Graph/Node/Port/View/Field/InputValueEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,16 @@ struct InputValueView: View {
isSelectedInspectorRow: isSelectedInspectorRow,
isPressed: $isButtonPressed)

// TODO: is this relevant for multiselect?
// TODO: is this relevant for multiselect?
// Note: can an input EVER really have a 'read-only' value? Isn't this fieldValue case just for outputs?
case .readOnly(let string):
ReadOnlyValueEntry(value: string,
alignment: .leading,
fontColor: STITCH_FONT_GRAY_COLOR,
isSelectedInspectorRow: isSelectedInspectorRow)
}
isSelectedInspectorRow: isSelectedInspectorRow,
forPropertySidebar: forPropertySidebar,
isFieldInMultifieldInput: isFieldInMultifieldInput)
}
// }
}
}
14 changes: 13 additions & 1 deletion Stitch/Graph/Node/Port/View/Field/InputView/ReadOnlyEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@ struct ReadOnlyValueEntry: View {
let alignment: Alignment // = .trailing
var fontColor: Color = STITCH_FONT_GRAY_COLOR
let isSelectedInspectorRow: Bool

let forPropertySidebar: Bool
let isFieldInMultifieldInput: Bool

@MainActor
var fieldWidth: CGFloat {
if isFieldInMultifieldInput && forPropertySidebar {
return INSPECTOR_MULTIFIELD_INDIVIDUAL_FIELD_WIDTH
} else {
return NODE_INPUT_OR_OUTPUT_WIDTH
}
}

var body: some View {
StitchTextView(string: value,
fontColor: isSelectedInspectorRow ? theme.fontColor : fontColor)
// Monospacing prevents jittery node widths if values change on graphstep
.monospacedDigit()
.frame(width: NODE_INPUT_OR_OUTPUT_WIDTH,
.frame(width: fieldWidth,
alignment: alignment)
}
}
Expand Down
19 changes: 15 additions & 4 deletions Stitch/Graph/Node/Port/View/Field/OutputValueView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct OutputValueEntry: View {
let isCanvasItemSelected: Bool
let forPropertySidebar: Bool
let propertyIsAlreadyOnGraph: Bool
let isFieldInMultifieldInput: Bool
let isSelectedInspectorRow: Bool

// Used by button view to determine if some button has been pressed.
Expand All @@ -45,6 +46,7 @@ struct OutputValueEntry: View {
isCanvasItemSelected: isCanvasItemSelected,
forPropertySidebar: forPropertySidebar,
propertyIsAlreadyOnGraph: propertyIsAlreadyOnGraph,
isFieldInMultifieldInput: isFieldInMultifieldInput,
isSelectedInspectorRow: isSelectedInspectorRow,
isButtonPressed: $isButtonPressed)
.font(STITCH_FONT)
Expand Down Expand Up @@ -74,6 +76,7 @@ struct OutputValueView: View {
let isCanvasItemSelected: Bool
let forPropertySidebar: Bool
let propertyIsAlreadyOnGraph: Bool
let isFieldInMultifieldInput: Bool
let isSelectedInspectorRow: Bool

@Binding var isButtonPressed: Bool
Expand Down Expand Up @@ -111,13 +114,17 @@ struct OutputValueView: View {
ReadOnlyValueEntry(value: string.string,
alignment: outputAlignment,
fontColor: STITCH_FONT_GRAY_COLOR,
isSelectedInspectorRow: isSelectedInspectorRow)
isSelectedInspectorRow: isSelectedInspectorRow,
forPropertySidebar: forPropertySidebar,
isFieldInMultifieldInput: isFieldInMultifieldInput)

case .number, .layerDimension, .spacing:
ReadOnlyValueEntry(value: fieldValue.stringValue,
alignment: outputAlignment,
fontColor: STITCH_FONT_GRAY_COLOR,
isSelectedInspectorRow: isSelectedInspectorRow)
isSelectedInspectorRow: isSelectedInspectorRow,
forPropertySidebar: forPropertySidebar,
isFieldInMultifieldInput: isFieldInMultifieldInput)

case .bool(let bool):
BoolCheckboxView(id: nil,
Expand All @@ -131,7 +138,9 @@ struct OutputValueView: View {
ReadOnlyValueEntry(value: choiceDisplay,
alignment: outputAlignment,
fontColor: STITCH_FONT_GRAY_COLOR,
isSelectedInspectorRow: isSelectedInspectorRow)
isSelectedInspectorRow: isSelectedInspectorRow,
forPropertySidebar: forPropertySidebar,
isFieldInMultifieldInput: isFieldInMultifieldInput)

case .textFontDropdown(let stitchFont):
StitchFontDropdown(input: coordinate,
Expand Down Expand Up @@ -232,7 +241,9 @@ struct OutputValueView: View {
ReadOnlyValueEntry(value: string,
alignment: outputAlignment,
fontColor: STITCH_FONT_GRAY_COLOR,
isSelectedInspectorRow: isSelectedInspectorRow)
isSelectedInspectorRow: isSelectedInspectorRow,
forPropertySidebar: forPropertySidebar,
isFieldInMultifieldInput: isFieldInMultifieldInput)
}
// }
}
Expand Down
2 changes: 2 additions & 0 deletions Stitch/Graph/Node/Port/View/NodeInputOutputView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ struct NodeOutputView: View {
isCanvasItemSelected: isCanvasItemSelected,
forPropertySidebar: forPropertySidebar,
propertyIsAlreadyOnGraph: propertyIsAlreadyOnGraph,
isFieldInMultifieldInput: isMultiField,
isSelectedInspectorRow: propertyIsSelected)
}

Expand All @@ -305,6 +306,7 @@ struct NodeOutputView: View {
// Property sidebar always shows labels on left side, never right
if forPropertySidebar {
labelView
Spacer()
}

// Hide outputs for value node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ extension LayerNodeViewModel {
}
}

// TODO: Need a smarter way of handling this. Blocked and unblocked fields should be by loop-index, but inputs on inspector and canvas items are not displayed by loop-index
// e.g. suppose a layer node's SizingScenario has a loop of `[.constrainHeight, .constrainWidth]` -- why inputs should be blocked?
// TODO: Need a smarter way of handling this. Blocked and unblocked fields should be by loop-index, but inputs on inspector and canvas items are not displayed by loop-index;
// e.g. suppose a layer node's SizingScenario has a loop of `[.constrainHeight, .constrainWidth]` -- which inputs should be blocked?
// ... Should it be according to activeIndex ?
extension LayerNodeViewModel {

@MainActor
Expand Down

0 comments on commit 1e58990

Please sign in to comment.