Skip to content

Commit 0a34701

Browse files
authored
Added support for layer inspector (#87)
1 parent e0c0e09 commit 0a34701

86 files changed

Lines changed: 5495 additions & 78 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/.DS_Store

0 Bytes
Binary file not shown.

Sources/StitchSchemaKit/SchemaVersions.swift

Lines changed: 93 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,84 +9,90 @@ import Foundation
99
import SwiftUI
1010

1111
// MARK: - UPDATE VERSION NUMBERS HERE
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
12+
public typealias CurrentAsyncMediaValue = AsyncMediaValue_V21
13+
public typealias CurrentClassicAnimationCurve = ClassicAnimationCurve_V21
14+
public typealias CurrentCameraSettings = CameraSettings_V21
15+
public typealias CurrentCommentBoxData = CommentBoxData_V21
16+
public typealias CurrentCustomShape = CustomShape_V21
17+
public typealias CurrentDataType = DataType_V21
18+
public typealias CurrentDelayStyle = DelayStyle_V21
19+
public typealias CurrentDateAndTimeFormat = DateAndTimeFormat_V21
20+
public typealias CurrentExpansionDirection = ExpansionDirection_V21
21+
public typealias CurrentGroupNodeIDCoordinate = GroupNodeID_V21
22+
public typealias CurrentPatch = Patch_V21
23+
public typealias CurrentPatchNodeEntity = PatchNodeEntity_V21
24+
public typealias CurrentLayerDimension = LayerDimension_V21
25+
public typealias CurrentLayerNodeEntity = LayerNodeEntity_V21
26+
public typealias CurrentLayerNodeId = LayerNodeId_V21
27+
public typealias CurrentNodeEntity = NodeEntity_V21
28+
public typealias CurrentNodePortInputEntity = NodePortInputEntity_V21
29+
public typealias CurrentSplitterNodeEntity = SplitterNodeEntity_V21
30+
public typealias CurrentSplitterType = SplitterType_V21
31+
public typealias CurrentNodeIOCoordinate = NodeIOCoordinate_V21
32+
public typealias CurrentJSONCurveTo = JSONCurveTo_V21
33+
public typealias CurrentJSONShapeCommand = JSONShapeCommand_V21
34+
public typealias CurrentJSONShapeKeys = JSONShapeKeys_V21
35+
public typealias CurrentSidebarLayerData = SidebarLayerData_V21
36+
public typealias CurrentNodeKind = NodeKind_V21
37+
public typealias CurrentAnchoring = Anchoring_V21
38+
public typealias CurrentCameraDirection = CameraDirection_V21
39+
public typealias CurrentLayer = Layer_V21
40+
public typealias CurrentLayerSize = LayerSize_V21
41+
public typealias CurrentLayerTextDecoration = LayerTextDecoration_V21
42+
public typealias CurrentLayerStroke = LayerStroke_V21
43+
public typealias CurrentLayerTextAlignment = LayerTextAlignment_V21
44+
public typealias CurrentLayerTextVerticalAlignment = LayerTextVerticalAlignment_V21
45+
public typealias CurrentLightType = LightType_V21
46+
public typealias CurrentMediaKey = MediaKey_V21
47+
public typealias CurrentMobileHapticStyle = MobileHapticStyle_V21
48+
public typealias CurrentNetworkRequestType = NetworkRequestType_V21
49+
public typealias CurrentPathPoint = PathPoint_V21
50+
public typealias CurrentPlane = Plane_V21
51+
public typealias CurrentPoint3D = Point3D_V21
52+
public typealias CurrentPoint4D = Point4D_V21
53+
public typealias CurrentPortValueComparable = PortValueComparable_V21
54+
public typealias CurrentPreviewSize = PreviewSize_V21
55+
public typealias CurrentRGBA = RGBA_V21
56+
public typealias CurrentRoundedRectangleData = RoundedRectangleData_V21
57+
public typealias CurrentScrollDecelerationRate = ScrollDecelerationRate_V21
58+
public typealias CurrentScrollJumpStyle = ScrollJumpStyle_V21
59+
public typealias CurrentScrollMode = ScrollMode_V21
60+
public typealias CurrentShapeCommand = ShapeCommand_V21
61+
public typealias CurrentShapeCommandType = ShapeCommandType_V21
62+
public typealias CurrentShapeCoordinates = ShapeCoordinates_V21
63+
public typealias CurrentShapeAndRect = ShapeAndRect_V21
64+
public typealias CurrentStitchDocument = StitchDocument_V21
65+
public typealias CurrentStitchBlendMode = StitchBlendMode_V21
66+
public typealias CurrentStitchCameraOrientation = StitchCameraOrientation_V21
67+
public typealias CurrentStitchDeviceOrientation = StitchDeviceOrientation_V21
68+
public typealias CurrentStitchMapType = StitchMapType_V21
69+
public typealias CurrentStitchFont = StitchFont_V21
70+
public typealias CurrentStitchFontChoice = StitchFontChoice_V21
71+
public typealias CurrentStitchFontWeight = StitchFontWeight_V21
72+
public typealias CurrentStitchJSON = StitchJSON_V21
73+
public typealias CurrentStitchOrientation = StitchOrientation_V21
74+
public typealias CurrentStitchProgressIndicatorStyle = ProgressIndicatorStyle_V21
75+
public typealias CurrentTextTransform = TextTransform_V21
76+
public typealias CurrentTriangleData = TriangleData_V21
77+
public typealias CurrentPortValue = PortValue_V21
78+
public typealias CurrentUserVisibleType = UserVisibleType_V21
79+
public typealias CurrentVisualMediaFitStyle = VisualMediaFitStyle_V21
80+
public typealias CurrentNodeConnectionType = NodeConnectionType_V21
81+
public typealias CurrentLayerInputType = LayerInputType_V21
82+
public typealias CurrentNodeIOPortType = NodeIOPortType_V21
83+
public typealias CurrentStrokeLineCap = StrokeLineCap_V21
84+
public typealias CurrentStrokeLineJoin = StrokeLineJoin_V21
85+
public typealias CurrentStitchStringValue = StitchStringValue_V21
86+
public typealias CurrentStitchContentMode = StitchContentMode_V21
87+
public typealias CurrentStitchSpacing = StitchSpacing_V21
88+
public typealias CurrentStitchPadding = StitchPadding_V21
89+
public typealias CurrentSizingScenario = SizingScenario_V21
90+
public typealias CurrentNodeTypeEntity = NodeTypeEntity_V21
91+
public typealias CurrentCanvasNodeEntity = CanvasNodeEntity_V21
92+
public typealias CurrentLayerInputDataEntity = LayerInputDataEntity_V21
93+
public typealias CurrentCanvasItemId = CanvasItemId_V21
94+
public typealias CurrentLayerInputCoordinate = LayerInputCoordinate_V21
95+
public typealias CurrentLayerOutputCoordinate = LayerOutputCoordinate_V21
9096

9197
// MARK: - end
9298

@@ -170,6 +176,12 @@ public typealias StitchContentMode = CurrentStitchContentMode.StitchContentMode
170176
public typealias StitchSpacing = CurrentStitchSpacing.StitchSpacing
171177
public typealias StitchPadding = CurrentStitchPadding.StitchPadding
172178
public typealias SizingScenario = CurrentSizingScenario.SizingScenario
179+
public typealias NodeTypeEntity = CurrentNodeTypeEntity.NodeTypeEntity
180+
public typealias CanvasNodeEntity = CurrentCanvasNodeEntity.CanvasNodeEntity
181+
public typealias LayerInputDataEntity = CurrentLayerInputDataEntity.LayerInputDataEntity
182+
public typealias CanvasItemId = CurrentCanvasItemId.CanvasItemId
183+
public typealias LayerInputCoordinate = CurrentLayerInputCoordinate.LayerInputCoordinate
184+
public typealias LayerOutputCoordinate = CurrentLayerOutputCoordinate.LayerOutputCoordinate
173185

174186
public enum StitchSchemaVersion: Int, VersionType {
175187
case _V1 = 1
@@ -192,6 +204,7 @@ public enum StitchSchemaVersion: Int, VersionType {
192204
case _V18 = 18
193205
case _V19 = 19
194206
case _V20 = 20
207+
case _V21 = 21
195208
}
196209

197210
public protocol VersionType: CaseIterable, Codable, Comparable, RawRepresentable {}
@@ -255,6 +268,8 @@ extension StitchDocumentVersion {
255268
return StitchDocument_V19.StitchDocument.self
256269
case ._V20:
257270
return StitchDocument_V20.StitchDocument.self
271+
case ._V21:
272+
return StitchDocument_V21.StitchDocument.self
258273
}
259274
}
260275
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// CommentBoxData_V21.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_V21: StitchSchemaVersionable {
12+
// MARK: - ensure versions are correct
13+
static var version: StitchSchemaVersion = StitchSchemaVersion._V21
14+
public typealias PreviousInstance = CommentBoxData_V20.CommentBoxData
15+
public typealias CanvasItemId = CanvasItemId_V21.CanvasItemId
16+
// MARK: - endif
17+
18+
public struct CommentBoxData: Equatable, Hashable {
19+
public var id: UUID
20+
21+
/*
22+
"Which traversal level (group node) does this comment box belong to?"
23+
24+
nil = top level
25+
26+
TODO: implement this properly, but wait until after SwiftData since e.g. VisibleNodesViewModel etc. may be changing.
27+
28+
For now we just make all comment boxes top-level.
29+
*/
30+
public var groupId: UUID?
31+
public var title: String = "Comment"
32+
public var color: Color
33+
public var nodes: Set<CanvasItemId>
34+
public var position: CGPoint
35+
public var size: CGSize
36+
public var zIndex: Double // = .zero
37+
38+
public init(id: CommentBoxId = .init(),
39+
groupId: UUID? = nil,
40+
title: String = "Comment",
41+
color: Color,
42+
nodes: Set<CanvasItemId> = .init(),
43+
position: CGPoint = .zero,
44+
size: CGSize,
45+
zIndex: Double) {
46+
self.id = id
47+
self.groupId = groupId
48+
self.title = title
49+
self.color = color
50+
self.nodes = nodes
51+
self.position = position
52+
self.size = size
53+
self.zIndex = zIndex
54+
}
55+
}
56+
}
57+
58+
extension CommentBoxData_V21.CommentBoxData: StitchVersionedCodable {
59+
public init(previousInstance: CommentBoxData_V21.PreviousInstance) {
60+
self.init(id: previousInstance.id,
61+
groupId: previousInstance.groupId,
62+
title: previousInstance.title,
63+
color: previousInstance.color,
64+
65+
// MARK: just needed for v21, should point to property in future versions
66+
nodes: .init(),
67+
68+
position: previousInstance.position,
69+
size: previousInstance.size,
70+
zIndex: previousInstance.zIndex)
71+
}
72+
}
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_V21: StitchSchemaVersionable {
12+
13+
// MARK: - ensure versions are correct
14+
static let version = StitchSchemaVersion._V21
15+
public typealias PreviousInstance = StitchDocument_V20.StitchDocument
16+
public typealias NodeEntitySchemas = [NodeEntity_V21.NodeEntity]
17+
public typealias CommentBoxes = [CommentBoxData_V21.CommentBoxData]
18+
public typealias PreviewSize = PreviewSize_V21.PreviewSize
19+
public typealias SidebarLayerDataList = [SidebarLayerData_V21.SidebarLayerData]
20+
public typealias CameraSettings = CameraSettings_V21.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_V21.StitchDocument {
78+
public init(previousInstance: StitchDocument_V21.PreviousInstance) {
79+
self.init(
80+
projectId: previousInstance.projectId,
81+
name: previousInstance.name,
82+
previewWindowSize: previousInstance.previewWindowSize,
83+
previewSizeDevice: PreviewSize_V21.PreviewSize(previousInstance: previousInstance.previewSizeDevice),
84+
previewWindowBackgroundColor: previousInstance.previewWindowBackgroundColor,
85+
localPosition: previousInstance.localPosition,
86+
zoomData: previousInstance.zoomData,
87+
nodes: StitchDocument_V21.NodeEntitySchemas(previousElements: previousInstance.nodes),
88+
orderedSidebarLayers: StitchDocument_V21.SidebarLayerDataList(previousElements: previousInstance.orderedSidebarLayers),
89+
commentBoxes: StitchDocument_V21.CommentBoxes(previousElements: previousInstance.commentBoxes),
90+
cameraSettings: StitchDocument_V21.CameraSettings(previousInstance: previousInstance.cameraSettings)
91+
)
92+
}
93+
}

0 commit comments

Comments
 (0)