Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Tree View for the SVG Editor #34

Merged
merged 8 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
buildInfoPanelWith: aToolBuilder

^ aToolBuilder pluggableMultiColumnListSpec new
name: #infoPanel;
model: self model;
list: #infoForSelectedElement.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
toolbuilder
buildTreeViewWith: aToolBuilder

^ aToolBuilder pluggableTreeSpec new
roots: #svgTree;
name: #treeView;
model: self model;
getChildren: #getChildrenOf:;
hasChildren: #hasChildren:;
setSelected: #selectedElement:;
getSelected: #selectedElement;
getSelectedPath: #selectedPath;
label: #displayNameOf:
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ buildWith: aToolBuilder
| window |
window := self model buildWindowWith: aToolBuilder specs: {
(self switchesFrame) -> (self buildSwitchesWIth: aToolBuilder) .
(self panelDrawingFrame) -> (self buildDrawingAreaWith: aToolBuilder)
(self panelDrawingFrame) -> (self buildDrawingAreaWith: aToolBuilder) .
(self treeFrame) -> (self buildTreeViewWith: aToolBuilder) .
(self infoPanelFrame) -> (self buildInfoPanelWith: aToolBuilder)
}.

^ aToolBuilder build: window
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
toolbuilder
infoPanelFrame

^ LayoutFrame new
leftFraction: 0.7 offset: 0;
topFraction: 0 offset: self buttonHeight;
rightFraction: 1 offset: 0;
bottomFraction: 0.3 offset: 0;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ panelDrawingFrame
^ LayoutFrame new
leftFraction: 0 offset: 0;
topFraction: 0 offset: self buttonHeight;
rightFraction: 1 offset: 0;
rightFraction: 0.7 offset: 0;
bottomFraction: 1 offset: 0;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
toolbuilder
treeFrame

^ LayoutFrame new
leftFraction: 0.7 offset: 0;
topFraction: 0.3 offset:0;
rightFraction: 1 offset: 0;
bottomFraction: 1 offset: 0;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"buildAndOpenFromString:" : "lha 5/17/2022 19:37",
"buildCloseButtonWith:" : "lha 5/17/2022 19:31",
"buildDrawingAreaWith:" : "lha 5/17/2022 19:32",
"buildInfoPanelWith:" : "aes 5/28/2022 12:42",
"buildOpenButtonWith:" : "lha 5/17/2022 19:32",
"buildSaveButtonWith:" : "lha 5/17/2022 19:32",
"buildSwitchesWIth:" : "nh 5/16/2022 15:54",
"buildWith:" : "lha 5/17/2022 19:34",
"buildTreeViewWith:" : "aes 5/28/2022 14:37",
"buildWith:" : "aes 5/28/2022 12:28",
"buttonHeight" : "nh 5/15/2022 15:51",
"infoPanelFrame" : "aes 5/28/2022 12:29",
"initialize" : "lha 5/17/2022 19:31",
"model" : "lha 5/17/2022 19:30",
"model:" : "lha 5/17/2022 19:30",
"panelDrawingFrame" : "lha 5/15/2022 19:10",
"switchesFrame" : "lha 5/15/2022 19:10" } }
"panelDrawingFrame" : "aes 5/27/2022 13:48",
"switchesFrame" : "lha 5/15/2022 19:10",
"treeFrame" : "aes 5/28/2022 12:30" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
displayNameOf: aNode

^ aNode displayName
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
getChildrenOf: aNode

^ aNode submorphs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
hasChildren: aNode

^ aNode submorphs isEmpty not
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
infoForSelectedElement

^ SVGInfoPanelGenerator for: self selectedElement
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
accessing
selectElement: anElement

|current|
selectedPath := OrderedCollection new.
current := anElement.
selectedPath addFirst: current.
[current = self svg]
whileFalse: [current := current owner.
selectedPath addFirst: current].
self changed: #selectedPath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
accessing
selectedElement: anObject

selectedElement := anObject.
self
changed: #selectedElement;
changed: #infoForSelectedElement
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
selectedElement

^ selectedElement
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
selectedPath

^ selectedPath
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ svg: anSVGMorph
self
changed: #svg;
changed: #canCloseFile;
changed: #canSaveFile
changed: #canSaveFile;
changed: #svgTree
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
svgTree

self svg ifNotNil: [^ Array with: self svg].
^ Array new
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
"askSavePath" : "lha 5/17/2022 19:28",
"canCloseFile" : "lha 5/17/2022 19:28",
"canSaveFile" : "lha 5/17/2022 19:28",
"displayNameOf:" : "aes 5/27/2022 14:20",
"getChildrenOf:" : "aes 5/27/2022 13:58",
"getReadStreamForFileNamed:" : "lha 5/17/2022 19:28",
"getWriteStreamForFileNamed:" : "lha 5/17/2022 19:28",
"hasChildren:" : "aes 5/27/2022 14:23",
"infoForSelectedElement" : "aes 5/28/2022 13:05",
"selectElement:" : "aes 5/28/2022 14:39",
"selectedElement" : "aes 5/27/2022 14:19",
"selectedElement:" : "aes 5/28/2022 12:30",
"selectedPath" : "aes 5/28/2022 14:36",
"svg" : "lha 5/17/2022 19:28",
"svg:" : "lha 5/17/2022 19:36",
"svg:" : "aes 5/27/2022 14:11",
"svgTree" : "aes 5/27/2022 14:22",
"windowTitle" : "lha 5/17/2022 20:29" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
],
"commentStamp" : "",
"instvars" : [
"svg" ],
"svg",
"selectedElement",
"selectedPath" ],
"name" : "SVGEditorModel",
"pools" : [
],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
accessing
for: aMorph

aMorph
ifNil: [^ Array new].
^ aMorph accept: self new
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
asList

^ {self keys . self values}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
at: aString put: aValue

self keys add: aString.
self values add: aValue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
initialize-release
initialize

self
keys: OrderedCollection new;
values: OrderedCollection new

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
keys: anObject
keys := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
keys
^ keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
helpers
readCircleAttributesOf: aCircle

self
at: 'Position' put: aCircle rectangle center asString;
at: 'Radius' put: (aCircle rectangle width / 2) asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
helpers
readCommonAttributesOf: aMorph

self
at: 'Type' put: aMorph humanReadableClassName;
at: 'ID' put: aMorph id;
readStylesOf: aMorph.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
helpers
readEllipseAttributesOf: anEllipse

self
at: 'Position' put: anEllipse rectangle center asString;
at: 'Horizontal Radius' put: (anEllipse rectangle width / 2) asString;
at: 'Vertical Radius' put: (anEllipse rectangle height / 2) asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
helpers
readLineAttributesOf: aLine

self
at: 'Start' put: aLine rectangle origin asString;
at: 'End' put: aLine rectangle corner asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
helpers
readPointsOf: aPolygonalMorph

self at: 'Points' put: (aPolygonalMorph points joinSeparatedBy: ' ')

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
helpers
readRectangleAttributesOf: aRectangle

self
at: 'Position' put: aRectangle rectangle origin asString;
at: 'Width' put: (aRectangle rectangle width) asString;
at: 'Height' put: (aRectangle rectangle height) asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
helpers
readStylesOf: aMorph

aMorph style keysAndValuesDo: [ :key :value |
self at: key put: value asString]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
helpers
readTextAttributesOf: aText

self at: 'Text' put: aText text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
values: anObject
values := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
values
^ values
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
visiting
visitSVGCircle: aCircle

^ self
readCommonAttributesOf: aCircle;
readCircleAttributesOf: aCircle;
asList

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGEllipse: anEllipse

^ self
readCommonAttributesOf: anEllipse;
readEllipseAttributesOf: anEllipse;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
visiting
visitSVGGroup: aGroup

^ self
readCommonAttributesOf: aGroup;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGLine: aLine

^ self
readCommonAttributesOf: aLine;
readLineAttributesOf: aLine;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
visiting
visitSVGMorph: aMorph

^ self
readCommonAttributesOf: aMorph;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
visiting
visitSVGPath: aPath

^ self
readCommonAttributesOf: aPath;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGPolygon: aPolygon

^ self
readCommonAttributesOf: aPolygon;
readPointsOf: aPolygon;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGPolyline: aPolyline

^ self
readCommonAttributesOf: aPolyline;
readPointsOf: aPolyline;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGRectangle: aRectangle

^ self
readCommonAttributesOf: aRectangle;
readRectangleAttributesOf: aRectangle;
asList
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
visiting
visitSVGTSpan: aTSpan

^ self
readCommonAttributesOf: aTSpan;
readTextAttributesOf: aTSpan;
asList
Loading