Skip to content

Commit e0c0e09

Browse files
V20: Introduce SizingScenario, StitchPadding etc. (#86)
2 parents 1ea4466 + 277056a commit e0c0e09

79 files changed

Lines changed: 5244 additions & 76 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Sources/StitchSchemaKit/SchemaVersions.swift

Lines changed: 83 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,82 +9,84 @@ import Foundation
99
import SwiftUI
1010

1111
// MARK: - UPDATE VERSION NUMBERS HERE
12-
public typealias CurrentAsyncMediaValue = AsyncMediaValue_V19
13-
public typealias CurrentClassicAnimationCurve = ClassicAnimationCurve_V19
14-
public typealias CurrentCameraSettings = CameraSettings_V19
15-
public typealias CurrentCommentBoxData = CommentBoxData_V19
16-
public typealias CurrentCustomShape = CustomShape_V19
17-
public typealias CurrentDataType = DataType_V19
18-
public typealias CurrentDelayStyle = DelayStyle_V19
19-
public typealias CurrentDateAndTimeFormat = DateAndTimeFormat_V19
20-
public typealias CurrentExpansionDirection = ExpansionDirection_V19
21-
public typealias CurrentGroupNodeIDCoordinate = GroupNodeID_V19
22-
public typealias CurrentPatch = Patch_V19
23-
public typealias CurrentPatchNodeEntity = PatchNodeEntity_V19
24-
public typealias CurrentLayerDimension = LayerDimension_V19
25-
public typealias CurrentLayerNodeEntity = LayerNodeEntity_V19
26-
public typealias CurrentLayerNodeId = LayerNodeId_V19
27-
public typealias CurrentNodeEntity = NodeEntity_V19
28-
public typealias CurrentNodePortInputEntity = NodePortInputEntity_V19
29-
public typealias CurrentSplitterNodeEntity = SplitterNodeEntity_V19
30-
public typealias CurrentSplitterType = SplitterType_V19
31-
public typealias CurrentNodeIOCoordinate = NodeIOCoordinate_V19
32-
public typealias CurrentJSONCurveTo = JSONCurveTo_V19
33-
public typealias CurrentJSONShapeCommand = JSONShapeCommand_V19
34-
public typealias CurrentJSONShapeKeys = JSONShapeKeys_V19
35-
public typealias CurrentSidebarLayerData = SidebarLayerData_V19
36-
public typealias CurrentNodeKind = NodeKind_V19
37-
public typealias CurrentAnchoring = Anchoring_V19
38-
public typealias CurrentCameraDirection = CameraDirection_V19
39-
public typealias CurrentLayer = Layer_V19
40-
public typealias CurrentLayerSize = LayerSize_V19
41-
public typealias CurrentLayerTextDecoration = LayerTextDecoration_V19
42-
public typealias CurrentLayerStroke = LayerStroke_V19
43-
public typealias CurrentLayerTextAlignment = LayerTextAlignment_V19
44-
public typealias CurrentLayerTextVerticalAlignment = LayerTextVerticalAlignment_V19
45-
public typealias CurrentLightType = LightType_V19
46-
public typealias CurrentMediaKey = MediaKey_V19
47-
public typealias CurrentMobileHapticStyle = MobileHapticStyle_V19
48-
public typealias CurrentNetworkRequestType = NetworkRequestType_V19
49-
public typealias CurrentPathPoint = PathPoint_V19
50-
public typealias CurrentPlane = Plane_V19
51-
public typealias CurrentPoint3D = Point3D_V19
52-
public typealias CurrentPoint4D = Point4D_V19
53-
public typealias CurrentPortValueComparable = PortValueComparable_V19
54-
public typealias CurrentPreviewSize = PreviewSize_V19
55-
public typealias CurrentRGBA = RGBA_V19
56-
public typealias CurrentRoundedRectangleData = RoundedRectangleData_V19
57-
public typealias CurrentScrollDecelerationRate = ScrollDecelerationRate_V19
58-
public typealias CurrentScrollJumpStyle = ScrollJumpStyle_V19
59-
public typealias CurrentScrollMode = ScrollMode_V19
60-
public typealias CurrentShapeCommand = ShapeCommand_V19
61-
public typealias CurrentShapeCommandType = ShapeCommandType_V19
62-
public typealias CurrentShapeCoordinates = ShapeCoordinates_V19
63-
public typealias CurrentShapeAndRect = ShapeAndRect_V19
64-
public typealias CurrentStitchDocument = StitchDocument_V19
65-
public typealias CurrentStitchBlendMode = StitchBlendMode_V19
66-
public typealias CurrentStitchCameraOrientation = StitchCameraOrientation_V19
67-
public typealias CurrentStitchDeviceOrientation = StitchDeviceOrientation_V19
68-
public typealias CurrentStitchMapType = StitchMapType_V19
69-
public typealias CurrentStitchFont = StitchFont_V19
70-
public typealias CurrentStitchFontChoice = StitchFontChoice_V19
71-
public typealias CurrentStitchFontWeight = StitchFontWeight_V19
72-
public typealias CurrentStitchJSON = StitchJSON_V19
73-
public typealias CurrentStitchOrientation = StitchOrientation_V19
74-
public typealias CurrentStitchProgressIndicatorStyle = ProgressIndicatorStyle_V19
75-
public typealias CurrentTextTransform = TextTransform_V19
76-
public typealias CurrentTriangleData = TriangleData_V19
77-
public typealias CurrentPortValue = PortValue_V19
78-
public typealias CurrentUserVisibleType = UserVisibleType_V19
79-
public typealias CurrentVisualMediaFitStyle = VisualMediaFitStyle_V19
80-
public typealias CurrentNodeConnectionType = NodeConnectionType_V19
81-
public typealias CurrentLayerInputType = LayerInputType_V19
82-
public typealias CurrentNodeIOPortType = NodeIOPortType_V19
83-
public typealias CurrentStrokeLineCap = StrokeLineCap_V19
84-
public typealias CurrentStrokeLineJoin = StrokeLineJoin_V19
85-
public typealias CurrentStitchStringValue = StitchStringValue_V19
86-
public typealias CurrentStitchContentMode = StitchContentMode_V19
87-
public typealias CurrentStitchSpacing = StitchSpacing_V19
12+
public typealias CurrentAsyncMediaValue = AsyncMediaValue_V20
13+
public typealias CurrentClassicAnimationCurve = ClassicAnimationCurve_V20
14+
public typealias CurrentCameraSettings = CameraSettings_V20
15+
public typealias CurrentCommentBoxData = CommentBoxData_V20
16+
public typealias CurrentCustomShape = CustomShape_V20
17+
public typealias CurrentDataType = DataType_V20
18+
public typealias CurrentDelayStyle = DelayStyle_V20
19+
public typealias CurrentDateAndTimeFormat = DateAndTimeFormat_V20
20+
public typealias CurrentExpansionDirection = ExpansionDirection_V20
21+
public typealias CurrentGroupNodeIDCoordinate = GroupNodeID_V20
22+
public typealias CurrentPatch = Patch_V20
23+
public typealias CurrentPatchNodeEntity = PatchNodeEntity_V20
24+
public typealias CurrentLayerDimension = LayerDimension_V20
25+
public typealias CurrentLayerNodeEntity = LayerNodeEntity_V20
26+
public typealias CurrentLayerNodeId = LayerNodeId_V20
27+
public typealias CurrentNodeEntity = NodeEntity_V20
28+
public typealias CurrentNodePortInputEntity = NodePortInputEntity_V20
29+
public typealias CurrentSplitterNodeEntity = SplitterNodeEntity_V20
30+
public typealias CurrentSplitterType = SplitterType_V20
31+
public typealias CurrentNodeIOCoordinate = NodeIOCoordinate_V20
32+
public typealias CurrentJSONCurveTo = JSONCurveTo_V20
33+
public typealias CurrentJSONShapeCommand = JSONShapeCommand_V20
34+
public typealias CurrentJSONShapeKeys = JSONShapeKeys_V20
35+
public typealias CurrentSidebarLayerData = SidebarLayerData_V20
36+
public typealias CurrentNodeKind = NodeKind_V20
37+
public typealias CurrentAnchoring = Anchoring_V20
38+
public typealias CurrentCameraDirection = CameraDirection_V20
39+
public typealias CurrentLayer = Layer_V20
40+
public typealias CurrentLayerSize = LayerSize_V20
41+
public typealias CurrentLayerTextDecoration = LayerTextDecoration_V20
42+
public typealias CurrentLayerStroke = LayerStroke_V20
43+
public typealias CurrentLayerTextAlignment = LayerTextAlignment_V20
44+
public typealias CurrentLayerTextVerticalAlignment = LayerTextVerticalAlignment_V20
45+
public typealias CurrentLightType = LightType_V20
46+
public typealias CurrentMediaKey = MediaKey_V20
47+
public typealias CurrentMobileHapticStyle = MobileHapticStyle_V20
48+
public typealias CurrentNetworkRequestType = NetworkRequestType_V20
49+
public typealias CurrentPathPoint = PathPoint_V20
50+
public typealias CurrentPlane = Plane_V20
51+
public typealias CurrentPoint3D = Point3D_V20
52+
public typealias CurrentPoint4D = Point4D_V20
53+
public typealias CurrentPortValueComparable = PortValueComparable_V20
54+
public typealias CurrentPreviewSize = PreviewSize_V20
55+
public typealias CurrentRGBA = RGBA_V20
56+
public typealias CurrentRoundedRectangleData = RoundedRectangleData_V20
57+
public typealias CurrentScrollDecelerationRate = ScrollDecelerationRate_V20
58+
public typealias CurrentScrollJumpStyle = ScrollJumpStyle_V20
59+
public typealias CurrentScrollMode = ScrollMode_V20
60+
public typealias CurrentShapeCommand = ShapeCommand_V20
61+
public typealias CurrentShapeCommandType = ShapeCommandType_V20
62+
public typealias CurrentShapeCoordinates = ShapeCoordinates_V20
63+
public typealias CurrentShapeAndRect = ShapeAndRect_V20
64+
public typealias CurrentStitchDocument = StitchDocument_V20
65+
public typealias CurrentStitchBlendMode = StitchBlendMode_V20
66+
public typealias CurrentStitchCameraOrientation = StitchCameraOrientation_V20
67+
public typealias CurrentStitchDeviceOrientation = StitchDeviceOrientation_V20
68+
public typealias CurrentStitchMapType = StitchMapType_V20
69+
public typealias CurrentStitchFont = StitchFont_V20
70+
public typealias CurrentStitchFontChoice = StitchFontChoice_V20
71+
public typealias CurrentStitchFontWeight = StitchFontWeight_V20
72+
public typealias CurrentStitchJSON = StitchJSON_V20
73+
public typealias CurrentStitchOrientation = StitchOrientation_V20
74+
public typealias CurrentStitchProgressIndicatorStyle = ProgressIndicatorStyle_V20
75+
public typealias CurrentTextTransform = TextTransform_V20
76+
public typealias CurrentTriangleData = TriangleData_V20
77+
public typealias CurrentPortValue = PortValue_V20
78+
public typealias CurrentUserVisibleType = UserVisibleType_V20
79+
public typealias CurrentVisualMediaFitStyle = VisualMediaFitStyle_V20
80+
public typealias CurrentNodeConnectionType = NodeConnectionType_V20
81+
public typealias CurrentLayerInputType = LayerInputType_V20
82+
public typealias CurrentNodeIOPortType = NodeIOPortType_V20
83+
public typealias CurrentStrokeLineCap = StrokeLineCap_V20
84+
public typealias CurrentStrokeLineJoin = StrokeLineJoin_V20
85+
public typealias CurrentStitchStringValue = StitchStringValue_V20
86+
public typealias CurrentStitchContentMode = StitchContentMode_V20
87+
public typealias CurrentStitchSpacing = StitchSpacing_V20
88+
public typealias CurrentStitchPadding = StitchPadding_V20
89+
public typealias CurrentSizingScenario = SizingScenario_V20
8890

8991
// MARK: - end
9092

@@ -166,6 +168,8 @@ public typealias StrokeLineJoin = CurrentStrokeLineJoin.StrokeLineJoin
166168
public typealias StitchStringValue = CurrentStitchStringValue.StitchStringValue
167169
public typealias StitchContentMode = CurrentStitchContentMode.StitchContentMode
168170
public typealias StitchSpacing = CurrentStitchSpacing.StitchSpacing
171+
public typealias StitchPadding = CurrentStitchPadding.StitchPadding
172+
public typealias SizingScenario = CurrentSizingScenario.SizingScenario
169173

170174
public enum StitchSchemaVersion: Int, VersionType {
171175
case _V1 = 1
@@ -187,6 +191,7 @@ public enum StitchSchemaVersion: Int, VersionType {
187191
case _V17 = 17
188192
case _V18 = 18
189193
case _V19 = 19
194+
case _V20 = 20
190195
}
191196

192197
public protocol VersionType: CaseIterable, Codable, Comparable, RawRepresentable {}
@@ -248,6 +253,8 @@ extension StitchDocumentVersion {
248253
return StitchDocument_V18.StitchDocument.self
249254
case ._V19:
250255
return StitchDocument_V19.StitchDocument.self
256+
case ._V20:
257+
return StitchDocument_V20.StitchDocument.self
251258
}
252259
}
253260
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// CommentBoxData_V20.swift
3+
//
4+
//
5+
// Created by Nicholas Arner on 1/27/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
public enum CommentBoxData_V20: StitchSchemaVersionable {
12+
// MARK: - ensure versions are correct
13+
static var version: StitchSchemaVersion = StitchSchemaVersion._V20
14+
public typealias PreviousInstance = CommentBoxData_V19.CommentBoxData
15+
// MARK: - endif
16+
17+
public struct CommentBoxData: Equatable, Hashable {
18+
public var id: UUID
19+
20+
/*
21+
"Which traversal level (group node) does this comment box belong to?"
22+
23+
nil = top level
24+
25+
TODO: implement this properly, but wait until after SwiftData since e.g. VisibleNodesViewModel etc. may be changing.
26+
27+
For now we just make all comment boxes top-level.
28+
*/
29+
public var groupId: UUID?
30+
public var title: String = "Comment"
31+
public var color: Color
32+
public var nodes: Set<UUID>
33+
public var position: CGPoint
34+
public var size: CGSize
35+
public var zIndex: Double // = .zero
36+
37+
public init(id: CommentBoxId = .init(),
38+
groupId: UUID? = nil,
39+
title: String = "Comment",
40+
color: Color,
41+
nodes: Set<UUID> = .init(),
42+
position: CGPoint = .zero,
43+
size: CGSize,
44+
zIndex: Double) {
45+
self.id = id
46+
self.groupId = groupId
47+
self.title = title
48+
self.color = color
49+
self.nodes = nodes
50+
self.position = position
51+
self.size = size
52+
self.zIndex = zIndex
53+
}
54+
}
55+
}
56+
57+
extension CommentBoxData_V20.CommentBoxData: StitchVersionedCodable {
58+
public init(previousInstance: CommentBoxData_V20.PreviousInstance) {
59+
self.init(id: previousInstance.id,
60+
groupId: previousInstance.groupId,
61+
title: previousInstance.title,
62+
color: previousInstance.color,
63+
nodes: previousInstance.nodes,
64+
position: previousInstance.position,
65+
size: previousInstance.size,
66+
zIndex: previousInstance.zIndex)
67+
}
68+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// StitchDocument.swift
3+
// Stitch
4+
//
5+
// Created by Elliot Boschwitz on 10/19/23.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
public enum StitchDocument_V20: StitchSchemaVersionable {
12+
13+
// MARK: - ensure versions are correct
14+
static let version = StitchSchemaVersion._V20
15+
public typealias PreviousInstance = StitchDocument_V19.StitchDocument
16+
public typealias NodeEntitySchemas = [NodeEntity_V20.NodeEntity]
17+
public typealias CommentBoxes = [CommentBoxData_V20.CommentBoxData]
18+
public typealias PreviewSize = PreviewSize_V20.PreviewSize
19+
public typealias SidebarLayerDataList = [SidebarLayerData_V20.SidebarLayerData]
20+
public typealias CameraSettings = CameraSettings_V20.CameraSettings
21+
// MARK: - end
22+
23+
// TODO: transferable
24+
public struct StitchDocument: StitchVersionedCodable, Equatable {
25+
public var projectId: ProjectId
26+
public var name: String
27+
28+
// Preview window
29+
public let previewWindowSize: CGSize
30+
public let previewSizeDevice: PreviewSize
31+
public let previewWindowBackgroundColor: Color
32+
33+
// Graph positioning data
34+
public let localPosition: CGPoint
35+
public let zoomData: CGFloat
36+
37+
// Node data
38+
public var nodes: NodeEntitySchemas
39+
public var orderedSidebarLayers: SidebarLayerDataList
40+
public let commentBoxes: CommentBoxes
41+
42+
public let cameraSettings: CameraSettings
43+
44+
public init(projectId: ProjectId,
45+
name: String,
46+
previewWindowSize: CGSize,
47+
previewSizeDevice: PreviewSize,
48+
previewWindowBackgroundColor: Color,
49+
localPosition: CGPoint,
50+
zoomData: CGFloat,
51+
nodes: NodeEntitySchemas,
52+
orderedSidebarLayers: SidebarLayerDataList,
53+
commentBoxes: CommentBoxes,
54+
cameraSettings: CameraSettings) {
55+
self.projectId = projectId
56+
self.name = name
57+
self.previewWindowSize = previewWindowSize
58+
self.previewSizeDevice = previewSizeDevice
59+
self.previewWindowBackgroundColor = previewWindowBackgroundColor
60+
self.localPosition = localPosition
61+
self.zoomData = zoomData
62+
self.nodes = nodes
63+
self.orderedSidebarLayers = orderedSidebarLayers
64+
self.commentBoxes = commentBoxes
65+
self.cameraSettings = cameraSettings
66+
}
67+
68+
// MARK: remove `transferRepresentation` from older `StitchDocument` versions
69+
// static var transferRepresentation: some TransferRepresentation {
70+
// FileRepresentation(contentType: .stitchDocument,
71+
// exporting: Self.exportDocument,
72+
// importing: Self.importDocument)
73+
// }
74+
}
75+
}
76+
77+
extension StitchDocument_V20.StitchDocument {
78+
public init(previousInstance: StitchDocument_V20.PreviousInstance) {
79+
self.init(
80+
projectId: previousInstance.projectId,
81+
name: previousInstance.name,
82+
previewWindowSize: previousInstance.previewWindowSize,
83+
previewSizeDevice: PreviewSize_V20.PreviewSize(previousInstance: previousInstance.previewSizeDevice),
84+
previewWindowBackgroundColor: previousInstance.previewWindowBackgroundColor,
85+
localPosition: previousInstance.localPosition,
86+
zoomData: previousInstance.zoomData,
87+
nodes: StitchDocument_V20.NodeEntitySchemas(previousElements: previousInstance.nodes),
88+
orderedSidebarLayers: StitchDocument_V20.SidebarLayerDataList(previousElements: previousInstance.orderedSidebarLayers),
89+
commentBoxes: StitchDocument_V20.CommentBoxes(previousElements: previousInstance.commentBoxes),
90+
cameraSettings: StitchDocument_V20.CameraSettings(previousInstance: previousInstance.cameraSettings)
91+
)
92+
}
93+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// ExpansionDirection_V20.swift
3+
//
4+
//
5+
// Created by Nicholas Arner on 1/27/24.
6+
//
7+
8+
import Foundation
9+
10+
11+
public enum ExpansionDirection_V20: StitchSchemaVersionable {
12+
// MARK: - ensure versions are correct
13+
static var version: StitchSchemaVersion = StitchSchemaVersion._V20
14+
public typealias PreviousInstance = ExpansionDirection_V19.ExpansionDirection
15+
// MARK: - endif
16+
17+
18+
// not just the size of the box,
19+
// but from where the box goes to etc.
20+
public enum ExpansionDirection: Equatable, Hashable {
21+
case topLeft, topRight,
22+
bottomLeft, bottomRight,
23+
none
24+
}
25+
26+
}
27+
28+
extension ExpansionDirection_V20.ExpansionDirection: StitchVersionedCodable {
29+
public init(previousInstance: ExpansionDirection_V20.PreviousInstance) {
30+
switch previousInstance {
31+
32+
case .topLeft:
33+
self = .topLeft
34+
case .topRight:
35+
self = .topRight
36+
case .bottomLeft:
37+
self = .bottomLeft
38+
case .bottomRight:
39+
self = .bottomRight
40+
case .none:
41+
self = .none
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)