Skip to content

Commit

Permalink
Merge branch '106-extend-circle-tool' into sprint-2022-cw-20-22
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroschke committed May 30, 2022
2 parents 515dc5f + 2c6aef8 commit 38fef3d
Show file tree
Hide file tree
Showing 51 changed files with 187 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isShiftPressed: aBoolean
isShiftPressed := aBoolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isShiftPressed
^ isShiftPressed ifNil: [isShiftPressed := false]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
event handling
keyDown: aKeyboardEvent
(self isControlKeyEvent: aKeyboardEvent) ifTrue: [self isCtrlPressed: true]
(self isControlKeyEvent: aKeyboardEvent) ifTrue: [self isCtrlPressed: true].
(aKeyboardEvent shiftPressed) ifTrue: [self isShiftPressed: true]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
event handling
keyUp: aKeyboardEvent
(self isControlKeyEvent: aKeyboardEvent) ifTrue: [self isCtrlPressed: false]
(self isControlKeyEvent: aKeyboardEvent) ifTrue: [self isCtrlPressed: false].
self isShiftPressed: (aKeyboardEvent shiftPressed)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"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",
"isShiftPressed" : "ms 5/23/2022 22:34",
"isShiftPressed:" : "ms 5/23/2022 22:34",
"keyDown:" : "ms 5/27/2022 16:02",
"keyUp:" : "ms 5/27/2022 16:02",
"mouseDown:" : "mk 7/3/2020 18:38",
"mouseEnterDragging:" : "CS 8/5/2021 17:25",
"mouseLeave:" : "JP 6/26/2021 18:18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"instvars" : [
"gripMorph",
"isCtrlPressed",
"isShiftPressed",
"viewPort" ],
"name" : "M2Canvas",
"pools" : [
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tool selection
drawGeometricEllipse
self context
isErasing: false;
mode: #geometric;
currentGeometricPreviewShape: #ellipse;
currentTool: #drawGeometricEllipse.
self switchMode
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"defaultStartPoint" : "CS 8/5/2021 18:18",
"drawCircle" : "md 5/26/2022 21:33",
"drawEraser" : "md 5/26/2022 21:33",
"drawGeometricCircle" : "ms 7/8/2021 16:31",
"drawGeometricEllipse" : "ms 5/25/2022 00:36",
"drawGeometricRectangle" : "ms 7/8/2021 16:31",
"drawGeometricTriangle" : "SW 5/16/2022 20:05",
"drawPencil" : "md 5/26/2022 21:29",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessing
actionSelector
^ #drawGeometricCircle
^ #drawGeometricEllipse
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
label
^ 'Ellipse Tool'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"class" : {
"actionSelector" : "ms 5/25/2022 00:33",
"icon" : "ms 5/25/2022 00:34",
"isActivatable" : "ms 5/25/2022 00:33",
"label" : "ms 5/25/2022 00:33" },
"instance" : {
} }
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
],
"classvars" : [
],
"commentStamp" : "wr 8/4/2020 13:06",
"commentStamp" : "",
"instvars" : [
],
"name" : "M2GeometricCircle",
"name" : "M2GeometricEllipse",
"pools" : [
],
"super" : "M2IconMenuItem",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tool selection
drawGeometricCircle
super drawGeometricCircle.
drawGeometricEllipse
super drawGeometricEllipse.
self currentCursor: Cursor crossHair
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ drawing
geometricMorph
| constructors constructor |
constructors := {
#circle -> [CircleMorph new].
#ellipse -> [EllipseMorph new].
#rectangle -> [RectangleMorph new].
#triangle -> [M2TriangleMorph new].
#selectionRectangle -> [RectangleMorph new].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
drawing
resizeTemporaryGeometricMorphAt: aPoint
| extent movementVector minimalSquare position |
| extent movementVector rect offset |
(aPoint > 0 asPoint) ifFalse: [^ self].

movementVector := aPoint - self startPoint.


extent := movementVector abs.
minimalSquare := (extent x min: extent y) asPoint * (movementVector sign).

position := (self context currentGeometricPreviewShape = #circle)
ifTrue: [self getCircleOrigin: minimalSquare]
ifFalse: [aPoint min: self startPoint].
self canvas isShiftPressed ifTrue: [extent := self shiftResizeExtent: extent].

rect := Rectangle origin: (aPoint min: self startPoint) extent: extent.
offset := self startPoint - (rect pointNearestTo: self startPoint).

self temporaryGeometricMorph
position: self canvas position + position;
extent: (extent max: 1 asPoint)
position: self canvas position + rect origin + offset;
extent: (extent)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
drawing
shiftResizeExtent: extent
| switch minExtent maxSide |
minExtent := extent min: (extent transposed).
maxSide := (extent max: (extent transposed) )x.
switch := Dictionary new.
switch at: #ellipse put: [minExtent].
switch at: #rectangle put: [minExtent].
switch at: #triangle put: [maxSide@((3 sqrt)/2*maxSide)].
^ (switch at: self context currentGeometricPreviewShape ifAbsent: [extent]) value
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"defaultScalar" : "mFr 6/25/2021 15:18",
"drawCircle" : "CS 6/28/2021 21:21",
"drawEraser" : "CS 6/28/2021 21:23",
"drawGeometricCircle" : "CS 6/28/2021 21:27",
"drawGeometricEllipse" : "ms 5/25/2022 00:39",
"drawGeometricRectangle" : "CS 6/28/2021 21:28",
"drawGeometricTriangle" : "SW 5/16/2022 20:06",
"drawPencil" : "CS 6/28/2021 21:23",
Expand All @@ -37,7 +37,7 @@
"finishGeometricForm" : "md 5/19/2022 14:15",
"finishSelection" : "md 5/27/2022 22:52",
"formExtent" : "JP 6/26/2021 17:26",
"geometricMorph" : "kbr 5/29/2022 08:01",
"geometricMorph" : "kbr 5/30/2022 20:20",
"geometricMorphColor" : "md 5/27/2022 20:09",
"getBackendPointFor:" : "CS 8/5/2021 20:22",
"getBackendPointFor:ifAbsent:" : "CS 8/5/2021 20:26",
Expand All @@ -59,7 +59,7 @@
"projectText:styled:colored:at:" : "CS 8/6/2021 15:50",
"rectangleCursor" : "CS 8/4/2021 19:33",
"refresh" : "mFr 6/24/2021 16:30",
"resizeTemporaryGeometricMorphAt:" : "ms 7/8/2021 16:31",
"resizeTemporaryGeometricMorphAt:" : "ms 5/27/2022 17:49",
"scalar" : "mFr 6/25/2021 15:19",
"scalar:" : "mFr 6/9/2021 16:46",
"scaleFormTo:" : "ms 6/28/2021 18:20",
Expand All @@ -68,6 +68,7 @@
"setTemporaryGeometricMorphBorder" : "md 5/27/2022 20:25",
"setTemporaryGeometricMorphDashedBorder" : "md 5/27/2022 20:40",
"setToolPreviewCursorFor:" : "CS 8/4/2021 18:49",
"shiftResizeExtent:" : "ms 5/25/2022 00:41",
"startDrawingAt:" : "md 5/19/2022 14:35",
"startEditingTextAt:" : "CS 8/5/2021 20:10",
"startLassoSelection" : "md 5/27/2022 20:49",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ handleShiftKeystroke: aKeyboardEvent
} otherwise: [^ aKeyboardEvent "no hit"]]
ifFalse: [
aKeyboardEvent keyCharacter caseOf: {
[$C] -> [self clickMenuItemWith: M2GeometricCircle label].
[$E] -> [self clickMenuItemWith: M2GeometricEllipse label].
[$R] -> [self clickMenuItemWith: M2GeometricRectangle label].
[$F] -> [self backend toggleFillGeometricForm]
} otherwise: [^ aKeyboardEvent "no hit"]].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ menuGeometricCollection
add: (M2SelectLasso getMenuItemForTarget: self viewPort);
add: (M2InsertSelection getMenuItemForTarget: self viewPort);
add: (M2FillArea getMenuItemForTarget: self viewPort);
add: (M2GeometricCircle getMenuItemForTarget: self viewPort);
add: (M2GeometricEllipse getMenuItemForTarget: self viewPort);
add: (M2GeometricRectangle getMenuItemForTarget: self viewPort);
add: (M2GeometricTriangle getMenuItemForTarget: self viewPort);
add: (M2FillGeometricForm getMenuItemForTarget: self backend context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
tooling
pasteClipboard
self importImage: Clipboard clipboardText asString

(self backend context isInTextMode
or: [(self findMenuItemWith: M2InsertSelection label) isEnabled not])
ifTrue: [
self importImage: Clipboard clipboardText asString.
] ifFalse: [
self clickMenuItemWith: M2InsertSelection label.
]
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"handleCommandKeystroke:" : "K.P. 7/8/2021 13:44",
"handleKeystroke:" : "K.P. 8/1/2021 19:47",
"handleNoModifierKeystroke:" : "K.P. 8/1/2021 19:49",
"handleShiftKeystroke:" : "CS 8/5/2021 22:27",
"handleShiftKeystroke:" : "ms 5/27/2022 17:10",
"importImage" : "mFr 6/3/2021 21:17",
"importImage:" : "CS 8/5/2021 22:41",
"initialize" : "CS 8/6/2021 18:58",
Expand All @@ -60,7 +60,7 @@
"menuPanel:" : "mFr 5/19/2021 10:57",
"minimumExtent" : "mFr 5/26/2021 12:05",
"paneColor" : "6/28/2021 21:03:28",
"pasteClipboard" : "CS 8/5/2021 22:42",
"pasteClipboard" : "ms 5/27/2022 18:09",
"setColor:" : "CS 8/5/2021 18:17",
"submenuDict" : "CS 8/5/2021 22:19",
"submenuDict:" : "mFr 5/19/2021 12:23",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
support
holdShift

self viewPort canvas isShiftPressed: true.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
support
releaseShift

self viewPort canvas isShiftPressed: false.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
testing
testCompareGeometricCircleFilled
self
contextFillGeometricModeWithForm: #circle;
contextFillGeometricModeWithForm: #ellipse;
holdShift;
drawFrom: (40 @ 10) to: (80 @ 90);
compareBackendFormWith: #filledCircle
compareBackendFormWith: #filledCircle;
releaseShift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
testing
testCompareGeometricCircleFilledNarrow
self
contextFillGeometricModeWithForm: #circle;
contextFillGeometricModeWithForm: #ellipse;
holdShift;
drawFrom: (10 @ 80) to: (80 @ 90);
compareBackendFormWith: #filledCircleNarrow
compareBackendFormWith: #filledCircleNarrow;
releaseShift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
testing
testCompareGeometricCircleNotFilled
self
contextGeometricModeWithForm: #circle;
contextGeometricModeWithForm: #ellipse;
holdShift;
drawFrom: (40 @ 10) to: (80 @ 90);
compareBackendFormWith: #notFilledCircle
compareBackendFormWith: #notFilledCircle;
releaseShift
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
testing
testCompareGeometricCircleOverlapping
self
contextGeometricModeWithForm: #circle;
contextGeometricModeWithForm: #ellipse;
holdShift;
drawFrom: 10 asPoint to: 40 asPoint.
self context isFillingGeometricForm: true.
self
drawFrom: 20 asPoint to: 80 asPoint;
compareBackendFormWith: #overlappingCircles
compareBackendFormWith: #overlappingCircles;
releaseShift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
testing
testCompareGeometricEllipseNotFilled
self
contextFillGeometricModeWithForm: #ellipse;
drawFrom: (40 @ 10) to: (80 @ 90);
compareBackendFormWith: #notFilledEllipse
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
testing
testCompareGeometricEquilateralTriangleNotFilled
self
contextFillGeometricModeWithForm: #triangle;
holdShift;
drawFrom: (40 @ 10) to: (80 @ 90);
compareBackendFormWith: #notFilledEquilateralTriangle;
releaseShift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
testing
testCompareGeometricTriangleNotFilled
self
contextFillGeometricModeWithForm: #triangle;
drawFrom: (40 @ 10) to: (80 @ 90);
compareBackendFormWith: #notFilledTriangle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
testing
testSingleUndoAction
self
contextFillGeometricModeWithForm: #circle;
contextFillGeometricModeWithForm: #ellipse;
holdShift;
drawFrom: (40 @ 10) to: (80 @ 90);
drawFrom: (80 @ 10) to: (80 @ 200).
drawFrom: (80 @ 10) to: (80 @ 200);
releaseShift.
self backend undo.
self compareBackendFormWith: #filledCircle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
testing
testUncommittedTemporaryCircle
self
contextFillGeometricModeWithForm: #circle;
contextFillGeometricModeWithForm: #ellipse;
holdShift;
dragFrom: 40 @ 10 to: 80 @ 90;
compareBackendFormWith: #whiteBackground;
releaseShift;
finishDrawingIfNecessary;
compareBackendFormWith: #filledCircle
Loading

0 comments on commit 38fef3d

Please sign in to comment.