Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/119-add-ability-to-mirror-select…
Browse files Browse the repository at this point in the history
…ed-shapes' into 123-refactor-tools
  • Loading branch information
MariusDoe committed Jul 20, 2022
2 parents 53853c8 + 574b0d7 commit 1223c90
Show file tree
Hide file tree
Showing 47 changed files with 224 additions and 79 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
as yet unclassified
actionSelector
^ #mirrorVertical
^ #Platzhalter
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
onClick: anM2DrawingContext
| tool |
tool := anM2DrawingContext cachedTool: #select ifAbsent: [^ self clickMenuItemWith: M2SelectRectangle label].
(tool isActive and: [tool nextStartFinishes])
ifTrue: [self mirror: tool]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
"actionSelector" : "AG 7/19/2022 12:16",
"onClick:" : "AG 7/19/2022 12:20" },
"instance" : {
} }
14 changes: 14 additions & 0 deletions packages/SketchMorph2-Core.package/M2Flip.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "SketchMorph2-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "M2Flip",
"pools" : [
],
"super" : "M2IconMenuItem",
"type" : "normal" }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
as yet unclassified
mirror: anM2Tool
anM2Tool mirrorHorizontal
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"class" : {
"actionSelector" : "AG 6/21/2022 12:16",
"icon" : "KR 6/23/2022 13:17",
"isActivatable" : "AG 6/21/2022 12:10",
"label" : "AG 6/21/2022 12:21" },
"label" : "AG 6/21/2022 12:21",
"mirror:" : "AG 7/19/2022 13:49" },
"instance" : {
} }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "M2FlipHorizontal",
"pools" : [
],
"super" : "M2IconMenuItem",
"super" : "M2Flip",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
as yet unclassified
mirror: anM2Tool
anM2Tool mirrorVertical
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"class" : {
"actionSelector" : "AG 6/21/2022 12:24",
"icon" : "KR 6/23/2022 13:17",
"isActivatable" : "AG 6/21/2022 12:23",
"label" : "AG 6/21/2022 12:24" },
"label" : "AG 6/21/2022 12:24",
"mirror:" : "AG 7/19/2022 13:49" },
"instance" : {
} }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "M2FlipVertical",
"pools" : [
],
"super" : "M2IconMenuItem",
"super" : "M2Flip",
"type" : "normal" }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"initialize" : "AG 6/20/2022 21:05",
"isActive" : "md 5/19/2022 14:09",
"isActive:" : "md 5/19/2022 14:09",
"mirror:" : "AG 6/27/2022 14:38",
"moveHandle" : "ms 5/16/2022 22:53",
"moveHandle:" : "ms 5/16/2022 22:53",
"positionHandles" : "md 5/19/2022 14:33",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
"isInGeometricMode" : "JP 6/26/2021 17:41",
"isInGeometricPreviewMode" : "ms 7/8/2021 16:53",
"isNotInBounds:" : "CS 8/5/2021 20:30",
"mirror:at:" : "AG 6/27/2022 14:34",
"mirrorHorizontal" : "AG 6/27/2022 14:36",
"mirrorVertical" : "AG 6/27/2022 14:37",
"moveToolTo:" : "md 7/16/2022 21:55",
"penColor:" : "md 6/17/2022 16:59",
"pencilSize" : "CS 6/23/2021 14:23",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ menuGeometricCollection
add: (M2GeometricEllipse getMenuItemForContext: self context);
add: (M2GeometricRectangle getMenuItemForContext: self context);
add: (M2GeometricTriangle getMenuItemForContext: self context);
add: (M2FlipHorizontal getMenuItemForTarget: self viewPort);
add: (M2FlipVertical getMenuItemForTarget: self viewPort);
add: (M2FlipHorizontal getMenuItemForContext: self context);
add: (M2FlipVertical getMenuItemForContext: self context);
add: (M2FillGeometricForm getMenuItemForTarget: self backend context);
add: (M2TextFont getMenuItemForContext: self context);
yourself]
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,28 @@
"addToWorldMenu": "K.P. 5/27/2021 11:21",
"newWith:": "CS 8/5/2021 21:57",
"open": "md 6/17/2022 16:08",
"openWith:": "6/28/2021 21:03:28"
},
"openWith:": "6/28/2021 21:03:28" },
"instance": {
"activateDefaultItem": "CS 8/5/2021 22:07",
"allowedFileExtensions": "CS 8/5/2021 22:17",
"applyDefaultSettingsTo:": "CS 8/6/2021 18:57",
"backend": "mFr 5/19/2021 10:58",
"bottomPanel": "ms 6/9/2022 18:08",
"bottomPanel:": "ms 6/9/2022 18:08",
"brushSizeIndicator": "mFr 7/1/2021 15:45",
"bottomPanel": "ms 6/9/2022 18:08",
"brushSizeIndicator:": "mFr 7/1/2021 15:46",
"brushSizeSlider": "mFr 5/26/2021 11:30",
"brushSizeIndicator": "mFr 7/1/2021 15:45",
"brushSizeSlider:": "mFr 5/26/2021 11:31",
"canvas": "mFr 5/19/2021 10:58",
"brushSizeSlider": "mFr 5/26/2021 11:30",
"canvas:": "6/28/2021 21:03:28",
"canvasPanel": "mFr 5/19/2021 10:59",
"canvas": "mFr 5/19/2021 10:58",
"canvasPanel:": "mFr 5/19/2021 10:59",
"canvasPanel": "mFr 5/19/2021 10:59",
"chooseColor": "CS 6/1/2021 19:10",
"clearCanvas": "mFr 5/19/2021 10:59",
"clickMenuItemWith:": "CS 8/5/2021 22:13",
"colorPalette": "NC 6/18/2020 11:39",
"colorPanel": "mFr 5/19/2021 10:59",
"colorPanel:": "mFr 5/19/2021 10:59",
"colorPanel": "mFr 5/19/2021 10:59",
"colorPicker": "mFr 5/19/2021 10:59",
"context": "md 7/17/2022 00:28",
"copyToClipboard": "md 7/19/2022 11:55",
Expand All @@ -44,8 +43,8 @@
"handleKeystroke:": "SW 7/19/2022 19:24",
"handleNoModifierKeystroke:": "SW 7/19/2022 00:24",
"handleShiftKeystroke:": "md 7/19/2022 11:37",
"importImage": "mFr 6/3/2021 21:17",
"importImage:": "CS 8/5/2021 22:41",
"importImage": "mFr 6/3/2021 21:17",
"initialize": "md 7/20/2022 12:31",
"initializeBottomPanel": "ms 6/9/2022 18:19",
"initializeCanvasPanel": "ms 6/9/2022 18:13",
Expand All @@ -55,34 +54,32 @@
"initializeMenuPanel": "mFr 5/26/2021 12:21",
"initializePanels": "ms 6/9/2022 19:04",
"initializeTopPanel": "ms 6/9/2022 18:18",
"layerEditPanel": "ms 6/9/2022 19:03",
"layerEditPanel:": "ms 6/9/2022 19:04",
"layerPanel": "ms 6/9/2022 18:05",
"layerEditPanel": "ms 6/9/2022 19:03",
"layerPanel:": "ms 6/9/2022 18:05",
"layerPanel": "ms 6/9/2022 18:05",
"leftPanelWidth": "ms 6/9/2022 17:59",
"loadMenu": "ms 6/9/2022 19:36",
"menuBrushCollection": "md 7/20/2022 12:32",
"menuBrushCollection:": "mFr 5/19/2021 12:17",
"menuGeometricCollection": "md 7/19/2022 21:10",
"menuBrushCollection": "md 7/20/2022 12:32",
"menuGeometricCollection:": "mFr 5/19/2021 12:17",
"menuGeometricCollection": "md 7/19/2022 21:10",
"menuItemBorderColor": "CS 8/6/2021 18:56",
"menuItemBorderWidth": "CS 8/6/2021 18:56",
"menuMiscCollection": "KR 7/19/2022 23:45",
"menuMiscCollection:": "mFr 5/19/2021 12:17",
"menuPanel": "mFr 5/19/2021 10:57",
"menuMiscCollection": "KR 7/19/2022 23:45",
"menuPanel:": "mFr 5/19/2021 10:57",
"menuPanel": "mFr 5/19/2021 10:57",
"minimumExtent": "md 6/17/2022 16:04",
"paneColor": "6/28/2021 21:03:28",
"pasteClipboard": "md 7/19/2022 12:06",
"rightPanelWidth": "ms 6/9/2022 17:58",
"setColor:": "md 7/16/2022 23:13",
"submenuDict": "CS 8/5/2021 22:19",
"submenuDict:": "mFr 5/19/2021 12:23",
"topPanel": "mFr 5/19/2021 10:58",
"submenuDict": "CS 8/5/2021 22:19",
"topPanel:": "mFr 5/19/2021 10:58",
"topPanel": "mFr 5/19/2021 10:58",
"topPanelHeight": "CS 8/6/2021 18:57",
"undo": "CS 8/5/2021 22:43",
"upperColorRow": "CS 8/4/2021 19:33",
"viewPort": "6/28/2021 21:03:28"
}
}
"viewPort": "6/28/2021 21:03:28" } }

Large diffs are not rendered by default.

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,12 @@
testing
testFormAfterLassoHorizontalFlip
self
contextFillGeometricModeWithForm: #ellipse;
drawFrom: (10 @ 10) to: (50 @ 90).
self backend clickAt: 50 asPoint.
self
contextSelectionLassoMode;
dragAlong: {30 @ 50 . 40 @ 20 . 60 @ 5 . 60 @ 95 . 45 @ 70 . 35 @ 55}.
self viewPort mirrorHorizontal.
self backend clickAt: 50 asPoint.
self compareBackendFormWith: #mirroredLassoHorizontal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testFormAfterLassoVerticalFlip
self
contextFillGeometricModeWithForm: #ellipse;
drawFrom: (10 @ 5) to: (90 @ 45).
self backend clickAt: 50 asPoint.
self
contextSelectionLassoMode;
dragAlong: {5 @ 50 . 50 @ 15 . 70 @ 5 . 95 @ 46}.
self viewPort mirrorVertical.
self backend clickAt: 50 asPoint.
self compareBackendFormWith: #mirroredLassoVertical
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testFormAfterRectangleHorizontalFlip
self
contextFillGeometricModeWithForm: #ellipse;
drawFrom: (40 @ 10) to: (80 @ 90).
self backend clickAt: 50 asPoint.
self
contextSelectionRectangleMode;
drawFrom: (60 @ 10) to: 100 asPoint.
self viewPort mirrorHorizontal.
self backend clickAt: 50 asPoint.
self compareBackendFormWith: #mirroredRectangleHorizontal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testFormAfterRectangleVerticalFlip
self
contextFillGeometricModeWithForm: #ellipse;
drawFrom: (40 @ 10) to: (80 @ 90).
self backend clickAt: 50 asPoint.
self
contextSelectionRectangleMode;
drawFrom: 30 asPoint to: 100 asPoint.
self viewPort mirrorVertical.
self backend clickAt: 50 asPoint.
self compareBackendFormWith: #mirroredRectangleVertical
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"generateTestsFrom:into:source:" : "md 6/26/2022 14:17",
"importTestJPEG" : "CS 6/29/2021 11:31",
"importTestPNG" : "wr 6/18/2020 16:44",
"mirroredLassoHorizontal" : "AG 7/18/2022 15:11",
"mirroredLassoVertical" : "AG 7/18/2022 15:18",
"mirroredRectangleHorizontal" : "AG 7/18/2022 14:51",
"mirroredRectangleVertical" : "AG 7/18/2022 14:56",
"notFilledCircle" : "md 5/26/2022 19:06",
"notFilledEllipse" : "kbr 5/31/2022 10:01",
"notFilledEquilateralTriangle" : "kbr 5/31/2022 10:08",
Expand Down Expand Up @@ -120,7 +124,11 @@
"testEraserSizeOnNewLayer" : "md 6/26/2022 14:21",
"testExportAsMorph" : "kbr 5/30/2022 21:14",
"testFormAfterJPEGImport" : "CS 6/29/2021 11:36",
"testFormAfterLassoHorizontalFlip" : "AG 7/18/2022 15:14",
"testFormAfterLassoVerticalFlip" : "AG 7/18/2022 15:18",
"testFormAfterPNGImport" : "CS 6/29/2021 11:37",
"testFormAfterRectangleHorizontalFlip" : "AG 7/18/2022 14:53",
"testFormAfterRectangleVerticalFlip" : "AG 7/18/2022 14:57",
"testMultipleUndoAction" : "kbr 5/30/2022 21:12",
"testRectangleBrush" : "CS 8/4/2021 17:52",
"testRectangleBrushOnNewLayer" : "md 6/26/2022 14:21",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mirroring
getMirrorPos: aBoundary For: aSymbol
^ aBoundary topLeft + (1 @ 1)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"createMorph" : "md 7/18/2022 20:37",
"getMirrorPos:For:" : "AG 7/19/2022 22:44",
"shiftResizeExtent:" : "md 7/18/2022 20:36" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mirroring
getMirrorPos: aBoundary For: aSymbol
| pos|
aSymbol = #horizontal
ifTrue: [pos:= aBoundary topRight]
ifFalse: [pos := aBoundary bottomLeft].
^ pos
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mirroring
mirrorByAxis: aSymbol
^ self
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"context" : "md 7/18/2022 21:25",
"context:" : "md 7/18/2022 21:25",
"createMorph" : "md 7/18/2022 20:34",
"getMirrorPos:For:" : "AG 7/19/2022 22:43",
"initialize" : "md 7/18/2022 20:34",
"mirrorByAxis:" : "AG 7/19/2022 15:06",
"morph" : "md 7/18/2022 20:08",
"morph:" : "md 7/18/2022 20:08",
"moveTo:" : "md 7/18/2022 20:08" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mirroring
mirrorByAxis: aSymbol
aSymbol = #horizontal ifTrue: [self morph flipHAroundX: nil] ifFalse: [self morph flipVAroundY: nil]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"createMorph" : "md 7/18/2022 22:28",
"mirrorByAxis:" : "AG 7/19/2022 15:04",
"moveTo:" : "md 7/18/2022 20:24" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mirroring
getMirrorPos: aBoundary For: aSymbol
^ aBoundary topLeft + (1 @ 1)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"createMorph" : "md 7/18/2022 20:37",
"getMirrorPos:For:" : "AG 7/19/2022 13:51",
"shiftResizeExtent:" : "md 7/18/2022 20:37" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mirroring
cutSelection
| form|
form := self backend activeForm contentsOfArea: self bounds.
form := self clip: form.
self backend project: self getMask at: self bounds topLeft rule: Form rgbMul.
^ form
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
accessing
getMask
|mask|
mask := self mask.
mask replaceColor: Color white withColor: Color black.
mask replaceColor: Color transparent withColor: Color white.
mask replaceColor: Color black withColor: Color transparent.

^ mask
Loading

0 comments on commit 1223c90

Please sign in to comment.