Skip to content

Commit

Permalink
Merge pull request #79 from hpi-swa-teaching/feature/55-tool-preview
Browse files Browse the repository at this point in the history
Add Tool Preview
  • Loading branch information
ClFeSc authored Jun 28, 2021
2 parents 5ce44d0 + fe5bafb commit 56c19d4
Show file tree
Hide file tree
Showing 39 changed files with 222 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tool selection
fillShape
self context
isErasing: false;
mode: #fill;
currentTool: #fillShape.
self switchMode
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,54 @@
"class" : {
},
"instance" : {
"addMovementToUserAction:" : "K.P. 6/26/2021 16:38",
"brushSize" : "CS 6/11/2021 18:19",
"brushSize:" : "K.P. 6/26/2021 14:27",
"cachedForm" : "K.P. 6/26/2021 16:38",
"clearCanvas" : "mFr 6/24/2021 16:43",
"clearCanvasAndPushUndoLevel" : "mFr 6/24/2021 16:44",
"commit:at:" : "ms 6/25/2021 17:32",
"createUserActionWithStart:" : "K.P. 6/26/2021 16:39",
"currentGeometricForm:" : "K.P. 6/26/2021 14:29",
"currentUserAction" : "K.P. 6/26/2021 15:05",
"currentUserAction:" : "K.P. 6/26/2021 16:39",
"defaultMaxActionQueueSize" : "K.P. 6/26/2021 16:39",
"drawCircle" : "JP 6/13/2021 16:05",
"drawEraser" : "JP 6/13/2021 16:06",
"drawPencil" : "JP 6/13/2021 16:03",
"drawRectangle" : "JP 6/13/2021 16:02",
"drawTriangle" : "JP 6/13/2021 16:10",
"eraserSize" : "CS 6/23/2021 14:15",
"eraserSize:" : "JP 6/13/2021 15:06",
"addMovementToUserAction:" : "mk 7/3/2020 18:41",
"brushSize" : "wr 5/14/2020 16:42",
"brushSize:" : "mFr 5/26/2021 11:40",
"cachedForm" : "mk 6/13/2020 14:39",
"clearCanvas" : "JP 6/26/2021 18:06",
"clearCanvasAndPushUndoLevel" : "mk 7/27/2020 20:29",
"commit:at:" : " 6/28/2021 21:03:28",
"createUserActionWithStart:" : "NC 8/5/2020 18:34",
"currentGeometricForm:" : "mp 5/22/2020 10:36",
"currentUserAction" : "mk 6/13/2020 13:12",
"currentUserAction:" : "mk 6/13/2020 13:12",
"defaultMaxActionQueueSize" : "mk 7/27/2020 19:46",
"drawCircle" : "CS 6/28/2021 21:20",
"drawEraser" : "CS 6/28/2021 21:23",
"drawPencil" : "CS 6/28/2021 21:23",
"drawRectangle" : "CS 6/28/2021 21:24",
"drawTriangle" : "CS 6/28/2021 21:24",
"eraserSize" : "NC 7/24/2020 12:46",
"eraserSize:" : "NC 7/24/2020 12:46",
"exportAsMorph" : "JP 5/31/2021 19:09",
"exportAsPNG:" : "CS 6/1/2021 15:48",
"finishUserAction" : "K.P. 6/26/2021 16:40",
"importPNG:" : "K.P. 6/26/2021 15:23",
"initialize" : "K.P. 6/26/2021 15:16",
"isErasing:" : "K.P. 6/26/2021 15:18",
"isFillingGeometricForm:" : "JP 6/13/2021 15:12",
"latestActionQueue" : "K.P. 6/26/2021 16:40",
"mode:" : "K.P. 6/26/2021 15:18",
"moveDrawing:" : "CS 6/23/2021 14:44",
"pencilSize" : "CS 6/23/2021 14:12",
"pencilSize:" : "JP 6/13/2021 15:06",
"popUndoStack" : "K.P. 6/26/2021 16:40",
"pushNewUndoLevelWithForm:" : "K.P. 6/26/2021 16:40",
"pushNewUndoLevelWithForm:withAction:" : "mFr 6/24/2021 23:49",
"removeLastUserAction" : "K.P. 6/26/2021 16:40",
"restoreBrushAndEraserSize:color:isFilling:tool:" : "JP 6/13/2021 14:59",
"restoreFormFromStack" : "K.P. 6/26/2021 16:38",
"restoreUserActions" : "JP 6/13/2021 15:10",
"saveSettingsDuring:" : "CS 6/11/2021 19:33",
"saveStateInCurrentUserAction" : "K.P. 6/26/2021 15:18",
"startDrawingAt:" : "CS 6/23/2021 14:53",
"stopDrawing" : "mFr 6/23/2021 15:58",
"switchMode" : "mFr 6/24/2021 17:30",
"undo" : "mFr 6/24/2021 16:35",
"undoStack" : "K.P. 6/26/2021 16:38",
"userActionClickAt:" : "mFr 6/24/2021 17:51",
"userActionMoveDrawing:" : "K.P. 6/26/2021 15:22",
"userActionStopDrawing" : "mFr 6/25/2021 16:13",
"viewPort" : "CS 6/11/2021 18:58",
"viewPort:" : "CS 6/11/2021 18:59" } }
"fillShape" : "CS 6/28/2021 21:24",
"finishUserAction" : "CS 6/1/2021 17:13",
"importPNG:" : "JP 5/31/2021 19:10",
"initialize" : " 6/28/2021 21:03:28",
"isErasing:" : "NC 7/24/2020 13:03",
"isFillingGeometricForm:" : "mp 7/27/2020 17:26",
"latestActionQueue" : "mk 6/13/2020 12:38",
"mode:" : "NC 7/24/2020 12:32",
"moveDrawing:" : "ms 5/26/2021 16:26",
"pencilSize" : "mk 5/10/2020 20:34",
"pencilSize:" : "mk 5/10/2020 20:34",
"popUndoStack" : "NC 7/4/2020 12:50",
"pushNewUndoLevelWithForm:" : "mk 7/27/2020 19:52",
"pushNewUndoLevelWithForm:withAction:" : "mk 7/27/2020 19:59",
"removeLastUserAction" : "NC 7/8/2020 13:50",
"restoreBrushAndEraserSize:color:isFilling:tool:" : "CS 6/3/2021 10:08",
"restoreFormFromStack" : "NC 7/12/2020 09:54",
"restoreUserActions" : "NC 7/12/2020 09:46",
"saveSettingsDuring:" : "CS 6/3/2021 10:11",
"saveStateInCurrentUserAction" : "NC 8/5/2020 18:29",
"startDrawingAt:" : "NC 7/24/2020 12:23",
"stopDrawing" : "NC 7/24/2020 12:23",
"switchMode" : "mFr 6/11/2021 15:50",
"undo" : "CS 6/1/2021 15:49",
"undoStack" : "mk 6/20/2020 16:29",
"userActionClickAt:" : "CS 6/2/2021 11:57",
"userActionMoveDrawing:" : "CS 6/2/2021 20:21",
"userActionStopDrawing" : "JP 6/2/2021 18:37",
"viewPort" : " 6/28/2021 21:03:28",
"viewPort:" : " 6/28/2021 21:03:28" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "K.P. 6/26/2021 14:43",
"commentStamp" : "mp 5/22/2020 10:37",
"instvars" : [
"currentUserAction",
"undoStack",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
event handling
handlesMouseOver: evt
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
event handling
mouseLeave: evt
evt hand showTemporaryCursor: nil
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
event handling
mouseMove: evt
(self gripMorph containsPoint: evt cursorPoint)
ifFalse: [evt hand showTemporaryCursor: self viewPort currentCursor hotSpotOffset: self viewPort brushSize asPoint / 2].
(self isMouseDown: evt) ifFalse: [^ nil].
self hasMouseFocus ifFalse: [^ nil].
self viewPort userActionMoveDrawing: (self relativeMousePosition: evt position).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
{
"class" : {
"defaultCanvasSize" : "mFr 6/25/2021 08:47",
"newWith:ofSize:" : "K.P. 6/26/2021 15:58" },
"defaultCanvasSize" : " 6/28/2021 21:03:28",
"newWith:ofSize:" : " 6/28/2021 21:03:28" },
"instance" : {
"addGripMorph:" : "JP 5/19/2021 00:31",
"backend" : "mFr 6/9/2021 16:42",
"backend" : "mk 7/27/2020 20:43",
"extent:" : "wr 6/22/2020 16:26",
"fastFramingOn" : "JP 5/19/2021 00:17",
"gripMorph" : "CS 5/16/2021 20:20",
"gripMorph:" : "CS 5/16/2021 20:21",
"handlesKeyboard:" : "mFr 6/25/2021 14:57",
"handlesKeyboard:" : " 6/28/2021 21:03:28",
"handlesMouseDown:" : "mp 5/17/2020 11:53",
"handlesMouseMove:" : "mp 5/17/2020 11:52",
"handlesMouseOver:" : "mFr 6/11/2021 15:31",
"handlesMouseOverDragging:" : "mp 5/17/2020 11:52",
"handlesMouseWheel:" : "mFr 6/25/2021 14:57",
"initialize" : "mFr 6/25/2021 08:46",
"isControlKeyEvent:" : "JP 6/26/2021 17:27",
"isCtrlPressed" : "K.P. 6/26/2021 15:28",
"isCtrlPressed:" : "K.P. 6/26/2021 15:28",
"isMouseDown:" : "K.P. 6/26/2021 15:24",
"keyDown:" : "K.P. 6/26/2021 15:28",
"keyUp:" : "K.P. 6/26/2021 15:28",
"handlesMouseWheel:" : " 6/28/2021 21:03:28",
"initialize" : "CS 6/2/2021 14:41",
"isControlKeyEvent:" : " 6/28/2021 21:03:28",
"isCtrlPressed" : " 6/28/2021 21:03:28",
"isCtrlPressed:" : " 6/28/2021 21:03:28",
"isMouseDown:" : "NC 5/16/2020 13:16",
"keyDown:" : " 6/28/2021 21:03:28",
"keyUp:" : " 6/28/2021 21:03:28",
"maximumSize" : "CS 5/19/2021 19:50",
"mouseDown:" : "K.P. 6/26/2021 15:25",
"mouseEnterDragging:" : "JP 6/26/2021 17:46",
"mouseLeaveDragging:" : "JP 6/26/2021 17:46",
"mouseMove:" : "mFr 6/16/2021 16:46",
"mouseUp:" : "K.P. 6/26/2021 15:36",
"mouseWheel:" : "K.P. 6/26/2021 15:29",
"mouseDown:" : "mk 7/3/2020 18:38",
"mouseEnterDragging:" : "mp 7/27/2020 16:58",
"mouseLeave:" : "JP 6/26/2021 18:18",
"mouseLeaveDragging:" : "mFr 6/11/2021 14:36",
"mouseMove:" : "CS 6/28/2021 21:31",
"mouseUp:" : "mk 7/3/2020 19:27",
"mouseWheel:" : " 6/28/2021 21:03:28",
"relativeMousePosition:" : "mp 5/15/2020 12:42",
"setCanvasSize:" : "mFr 6/24/2021 16:30",
"updateExtent" : "K.P. 6/26/2021 15:38",
"setCanvasSize:" : "CS 5/19/2021 19:50",
"updateExtent" : " 6/28/2021 21:03:28",
"updateGripMorphPosition" : "CS 5/17/2021 10:50",
"viewPort" : "CS 6/11/2021 19:03",
"viewPort:" : "CS 6/11/2021 19:13",
"zoomDefault" : "jb 6/16/2021 21:11",
"zoomIn" : "CS 6/16/2021 15:57",
"zoomOut" : "CS 6/16/2021 15:57" } }
"viewPort" : " 6/28/2021 21:03:28",
"viewPort:" : " 6/28/2021 21:03:28",
"zoomDefault" : " 6/28/2021 21:03:28",
"zoomIn" : " 6/28/2021 21:03:28",
"zoomOut" : " 6/28/2021 21:03:28" } }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tool selection
drawTriangle
self pen sourceForm: self prepareTrianglePenSource
self pen sourceForm: (self prepareTrianglePenSource offset: (self penNibOffset: self brushSize asPoint))
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
drawing
prepareTrianglePenSource
| triangleForm temporaryPen |
triangleForm := Form extent: self brushSize asPoint
offset: (self penNibOffset: self brushSize asPoint).
triangleForm := Form extent: self brushSize asPoint.
temporaryPen := (Pen newOnForm: triangleForm)
place: 0 @ (self brushSize - 1);
turn: 90;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
setPenColor: aColor
self
penColor: aColor;
reloadCurrentPen
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"newWithExtent:context:" : "mFr 6/25/2021 08:52" },
"instance" : {
"addText" : "mFr 6/24/2021 22:25",
"addText" : "CS 6/28/2021 21:26",
"brushSize" : "CS 6/11/2021 18:19",
"clearCanvas" : "CS 6/11/2021 18:41",
"clickAt:" : "CS 6/11/2021 18:16",
Expand All @@ -22,15 +22,15 @@
"dragRectangleOn:at:" : "CS 6/11/2021 17:54",
"drawCircle" : "K.P. 6/26/2021 15:47",
"drawEraser" : "CS 6/23/2021 14:16",
"drawGeometricCircle" : "CS 6/11/2021 18:14",
"drawGeometricRectangle" : "CS 6/11/2021 18:14",
"drawGeometricCircle" : "CS 6/28/2021 21:27",
"drawGeometricRectangle" : "CS 6/28/2021 21:28",
"drawPencil" : "CS 6/23/2021 14:12",
"drawRectangle" : "jb 6/16/2021 22:28",
"drawTriangle" : "JP 6/13/2021 16:09",
"drawTriangle" : "CS 6/28/2021 21:11",
"eraser" : "CS 6/11/2021 17:22",
"eraser:" : "CS 6/11/2021 17:22",
"eraserSize" : "CS 6/23/2021 14:15",
"fillShape" : "CS 6/11/2021 18:15",
"fillShape" : "CS 6/28/2021 21:27",
"fillShapeAt:" : "CS 6/11/2021 17:24",
"form" : "CS 6/11/2021 19:11",
"form:" : "CS 6/11/2021 17:01",
Expand All @@ -51,6 +51,7 @@
"rectangleBrushSize" : "jb 6/16/2021 22:28",
"reloadCurrentPen" : "CS 6/11/2021 18:24",
"setBrushAndEraserSizeTo:" : "JP 6/13/2021 14:51",
"setPenColor:" : "CS 6/28/2021 21:09",
"sourceForm" : "CS 6/11/2021 17:35",
"sourceForm:" : "CS 6/11/2021 17:36",
"startDrawing" : "CS 6/11/2021 17:57",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ tool selection
addText
self
isErasing: false;
mode: #text;
mode: (self isInEditingTextMode
ifTrue: [#editingText]
ifFalse: [#text]);
currentTool: #addText
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
},
"instance" : {
"addText" : "CS 6/11/2021 17:17",
"addText" : "CS 6/28/2021 21:54",
"backgroundColor" : "CS 6/11/2021 17:18",
"backgroundColor:" : "CS 6/11/2021 17:18",
"brushSize" : "CS 6/11/2021 17:19",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
instance creation
getMenuItemForTarget: anObject
^ (M2MenuItemMorph new)
contents: self label;
contents: self label;
target: anObject;
selector: self actionSelector;
icon: (self icon scaledToSize: self defaultIconSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"actionSelector" : "mFr 5/19/2021 10:55",
"defaultIconSize" : "mFr 5/19/2021 12:14",
"getMenuItemForTarget:" : "mFr 5/19/2021 10:54",
"getMenuItemForTarget:" : "mFr 6/11/2021 14:47",
"handlesMouseDown:" : "mFr 5/19/2021 10:55",
"icon" : "mFr 5/19/2021 10:55",
"isActivatable" : "mFr 5/19/2021 10:55",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
addText
super addText.
self currentCursor: Cursor text
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cursors
circleCursor
^ Form dotOfSize: self brushSize color: self penColor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
currentCursor: aForm
currentCursor := aForm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
currentCursor
^ currentCursor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawCircle
super drawCircle.
self currentCursor: self circleCursor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawEraser
super drawEraser.
self currentCursor: self eraserCursor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawGeometricCircle
super drawGeometricCircle.
self currentCursor: Cursor crossHair
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawGeometricRectangle
super drawGeometricRectangle.
self currentCursor: Cursor crossHair
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawPencil
super drawPencil.
self currentCursor: (CursorWithAlpha fromIcon: M2Pencil icon)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawRectangle
super drawRectangle.
self currentCursor: self rectangleCursor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
drawTriangle
super drawTriangle.
self currentCursor: self triangleCursor
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cursors
eraserCursor
^ CircleMorph new
extent: self eraserSize asPoint;
color: Color white;
borderWidth: 1;
borderColor: Color black;
imageForm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tool selection
fillShape
super fillShape.
self currentCursor: (CursorWithAlpha fromIcon: M2FillArea icon)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ zooming
getBackendPointFor: aPoint
| translatedPoint |
translatedPoint := aPoint / self scalar.
^ self backend form extent >= translatedPoint
^ self backend formSize >= translatedPoint
ifTrue: [translatedPoint]
ifFalse: [nil]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cursors
rectangleCursor
^ (Form extent: self rectangleBrushSize depth: self defaultDepth)
offset: ((self rectangleBrushSize x / 2) @ 0);
fillWithColor: self context currentColor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cursors
triangleCursor
^ (Form extent: self brushSize asPoint depth: self defaultDepth)
fillShape: self prepareTrianglePenSource
fillColor: self context currentColor
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
zooming
zoomMax
^ 8
^ 3
Loading

0 comments on commit 56c19d4

Please sign in to comment.