-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from LinqLover/basic-radial-menu
WIP: Basic radial menu
- Loading branch information
Showing
127 changed files
with
732 additions
and
177 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/angleWidth.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
accessing | ||
angleWidth | ||
|
||
self isArc ifFalse: [^ Float pi * 2]. | ||
|
||
^ (self startAngle <= self stopAngle | ||
ifTrue: [self stopAngle] | ||
ifFalse: [self stopAngle + (Float pi * 2)]) | ||
- self startAngle |
6 changes: 6 additions & 0 deletions
6
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/centerAngle..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
accessing | ||
centerAngle: radialNumber | ||
|
||
^ self | ||
centerAngle: radialNumber | ||
angleWidth: self angleWidth |
6 changes: 6 additions & 0 deletions
6
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/centerAngle.angleWidth..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
accessing | ||
centerAngle: radialNumberCenter angleWidth: radialNumberWidth | ||
|
||
^ self | ||
startAngle: radialNumberCenter - (radialNumberWidth / 2) | ||
stopAngle: radialNumberCenter + (radialNumberWidth / 2) |
4 changes: 4 additions & 0 deletions
4
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/centerAngle.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
centerAngle | ||
|
||
^ self startAngle + (self angleWidth / 2) |
5 changes: 0 additions & 5 deletions
5
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/changed.st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/innerRadius.outerRadius..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
accessing | ||
innerRadius: innerRadius outerRadius: outerRadius | ||
|
||
self assert: innerRadius x / innerRadius y = (outerRadius x / outerRadius y). | ||
self radius: outerRadius. | ||
self innerFraction: innerRadius r / outerRadius r outerFraction: 1. |
5 changes: 5 additions & 0 deletions
5
src/ColorContextMenu-Core.package/ArcRingMorph.class/instance/radius..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
accessing | ||
radius: aNumber | ||
|
||
self flag: #deprecate. "ct: Do we need it?" | ||
self extent: self extent * (aNumber / self radius) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ontextMenu-Core.package/ColorChooserMorph.class/instance/addToMenu.coloredItem.action..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
menus | ||
addToMenu: menu coloredItem: label action: action | ||
|
||
| item | | ||
item := menu add: label action: action. | ||
|
||
(item isKindOf: RadialMenuItemMorph) ifTrue: [ | ||
(self colorForLabel: label) ifNotNil: [:labelColor | | ||
item baseColor: (labelColor mixed: 0.6 with: item defaultBaseColor)]]. |
9 changes: 9 additions & 0 deletions
9
...ntextMenu-Core.package/ColorChooserMorph.class/instance/addToMenu.coloredItem.subMenu..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
menus | ||
addToMenu: menu coloredItem: label subMenu: subMenu | ||
|
||
| item | | ||
item := menu add: label subMenu: subMenu. | ||
|
||
(item isKindOf: RadialMenuItemMorph) ifTrue: [ | ||
(self colorForLabel: label) ifNotNil: [:labelColor | | ||
item baseColor: (labelColor mixed: 0.6 with: item defaultBaseColor)]]. |
22 changes: 22 additions & 0 deletions
22
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/buildDiscreteMenu..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
menus | ||
buildDiscreteMenu: menuFactory | ||
|
||
| menu | | ||
menu := menuFactory value. | ||
|
||
"These buttons do not open a submenu; hence they are handled separately." | ||
menu | ||
add: 'random' action: #setRandom; | ||
addLine. | ||
self | ||
addToMenu: menu coloredItem: 'lighter' action: #setLighter; | ||
addToMenu: menu coloredItem: 'darker' action: #setDarker. | ||
menu addLine. | ||
|
||
self labelGroups do: [:group | | ||
group do: [:attrib | | ||
self addToMenu: menu coloredItem: attrib asString subMenu: ( | ||
self buildDiscreteMenu: menuFactory attribute: attrib)]. | ||
menu addLine]. | ||
|
||
^ menu |
4 changes: 4 additions & 0 deletions
4
...ContextMenu-Core.package/ColorChooserMorph.class/instance/buildDiscreteMenu.attribute..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
menus | ||
buildDiscreteMenu: menuFactory attribute: aSymbol | ||
|
||
^ self buildDiscreteMenu: menuFactory attribute: aSymbol levels: self defaultNumberOfLevels |
8 changes: 4 additions & 4 deletions
8
...tance/contextMenuWithLevels.forAttrib..st → ...ce/buildDiscreteMenu.attribute.levels..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
menus | ||
contextMenuWithLevels: levels forAttrib: aSymbol | ||
buildDiscreteMenu: menuFactory attribute: aSymbol levels: levels | ||
|
||
| menu setter | | ||
menu := MenuMorph new defaultTarget: self. | ||
menu := menuFactory value. | ||
setter := ('set{1}:' format: {aSymbol capitalized}) asSymbol. | ||
|
||
0 to: levels - 1 do: [:level | | ||
menu add: ('{1}%' format: {(level / (levels - 1) * 100) rounded}) action: [ | ||
menu defaultTarget perform: setter with: level / (levels - 1)]]. | ||
self perform: setter with: level / (levels - 1)]]. | ||
|
||
^ menu | ||
^ menu |
13 changes: 13 additions & 0 deletions
13
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/colorForLabel..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
menus | ||
colorForLabel: label | ||
|
||
| symbol | | ||
symbol := label asSymbol. | ||
|
||
symbol = #darker ifTrue: [ ^ Color veryVeryDarkGray ]. | ||
symbol = #lighter ifTrue: [ ^ Color lightGray ]. | ||
symbol = #random ifTrue: [ ^ nil ]. | ||
|
||
(Color class canUnderstand: symbol) ifTrue: [ ^ Color perform: symbol ]. | ||
|
||
^ nil |
19 changes: 3 additions & 16 deletions
19
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/contextMenu.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
menus | ||
contextMenu | ||
|
||
| menu | | ||
menu := MenuMorph new defaultTarget: self. | ||
|
||
menu | ||
add: 'random' action: #setRandom; | ||
addLine. | ||
|
||
#((red green blue) (hue saturation lightness brightness) (cyan magenta yellow black) (alpha)) | ||
do: [:group | | ||
group do: [:attrib | | ||
menu | ||
add: attrib asString | ||
subMenu: (self contextMenuWithLevelsForAttrib: attrib)]] | ||
separatedBy: [menu addLine]. | ||
|
||
^ menu | ||
^ self buildDiscreteMenu: [MenuMorph new | ||
defaultTarget: self; | ||
yourself] |
4 changes: 0 additions & 4 deletions
4
...textMenu-Core.package/ColorChooserMorph.class/instance/contextMenuWithLevelsForAttrib..st
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/defaultNumberOfLevels.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
private | ||
defaultNumberOfLevels | ||
|
||
^ 6 |
21 changes: 4 additions & 17 deletions
21
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/discreteRadialMenu.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
menus | ||
discreteRadialMenu | ||
"Menu items are only chosen in an illustrative fashion. To be replaced soon in order to align with #contextMenu." | ||
|
||
| menu | | ||
menu := RadialMenuMorph new. | ||
menu target: self. | ||
menu addItemMorph: (RadialMenuItemMorph new | ||
label: 'random'; | ||
action: #setRandom; | ||
yourself). | ||
menu addItemMorph: (RadialMenuItemMorph new | ||
label: 'lighter'; | ||
action: [self setBrightness: self color brightness + 0.2]; | ||
yourself). | ||
menu addItemMorph: (RadialMenuItemMorph new | ||
label: 'darker'; | ||
action: [self setBrightness: self color brightness - 0.2]; | ||
yourself). | ||
^ menu | ||
^ self buildDiscreteMenu: [RadialMenuMorph new | ||
target: self; | ||
innerFraction: 0.35; | ||
yourself] |
4 changes: 4 additions & 0 deletions
4
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/labelGroups.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
menus | ||
labelGroups | ||
|
||
^ #((red green blue) (hue saturation lightness brightness) (cyan magenta yellow black) (alpha)) |
4 changes: 4 additions & 0 deletions
4
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/setDarker.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
actions | ||
setDarker | ||
|
||
self setBrightness: self color brightness - (1 / (self defaultNumberOfLevels - 1)) asFloat |
4 changes: 4 additions & 0 deletions
4
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/setLighter.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
actions | ||
setLighter | ||
|
||
self setBrightness: self color brightness + (1 / (self defaultNumberOfLevels - 1)) asFloat |
10 changes: 5 additions & 5 deletions
10
src/ColorContextMenu-Core.package/ColorChooserMorph.class/instance/yellowButtonActivity..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
event handling | ||
yellowButtonActivity: shiftState | ||
|
||
self menuMode caseOf: { | ||
[nil] -> [self flash]. | ||
[#popUp] -> [self contextMenu popUpInWorld: self currentWorld]. | ||
[#discrete] -> [self discreteRadialMenu popUpFor: self currentEvent]. | ||
}. | ||
(self menuMode caseOf: { | ||
[nil] -> [^ self flash]. | ||
[#popUp] -> [self contextMenu]. | ||
[#discrete] -> [self discreteRadialMenu]. | ||
}) popUpInWorld. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/ColorContextMenu-Core.package/HandMorph.extension/instance/newMouseFocus..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*ColorContextMenu-Core-focus handling-override | ||
newMouseFocus: aMorphOrNil | ||
"Make the given morph the new mouse focus, canceling the previous mouse focus if any. If the argument is nil, the current mouse focus is cancelled." | ||
|
||
| newFocus oldFocus | | ||
oldFocus := self mouseFocus. | ||
newFocus := aMorphOrNil. | ||
|
||
self mouseFocus: newFocus. | ||
|
||
oldFocus == newFocus ifFalse: [ | ||
oldFocus ifNotNil: [:m | m mouseFocusChange: false]. | ||
newFocus ifNotNil: [:m | m mouseFocusChange: true]]. |
5 changes: 5 additions & 0 deletions
5
src/ColorContextMenu-Core.package/HandMorph.extension/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"newMouseFocus:" : "ct 2/17/2021 20:24" } } |
2 changes: 2 additions & 0 deletions
2
src/ColorContextMenu-Core.package/HandMorph.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
"name" : "HandMorph" } |
3 changes: 3 additions & 0 deletions
3
src/ColorContextMenu-Core.package/Morph.extension/instance/mouseFocusChange..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*ColorContextMenu-Core-event handling-pseudo-override | ||
mouseFocusChange: aBoolean | ||
"The message is sent to a morph when its mouse focus change. The given argument indicates that the receiver is gaining mouse focus (versus losing) the mouse focus." |
5 changes: 5 additions & 0 deletions
5
src/ColorContextMenu-Core.package/Morph.extension/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"instance" : { | ||
"mouseFocusChange:" : "ct 2/17/2021 20:24" } } |
2 changes: 2 additions & 0 deletions
2
src/ColorContextMenu-Core.package/Morph.extension/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
"name" : "Morph" } |
2 changes: 1 addition & 1 deletion
2
src/ColorContextMenu-Core.package/Number.extension/instance/sinCos.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*ColorContextMenu-Core-mathematical functions-override | ||
*ColorContextMenu-Core-mathematical functions-pseudo-override | ||
sinCos | ||
|
||
^ self asPoint sinCos |
2 changes: 1 addition & 1 deletion
2
src/ColorContextMenu-Core.package/Point.extension/instance/sinCos.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*ColorContextMenu-Core-polar coordinates-override | ||
*ColorContextMenu-Core-polar coordinates-pseudo-override | ||
sinCos | ||
|
||
^ x sin @ y cos |
2 changes: 1 addition & 1 deletion
2
src/ColorContextMenu-Core.package/Point.extension/instance/squared.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*ColorContextMenu-Core-arithmetic-override | ||
*ColorContextMenu-Core-arithmetic-pseudo-override | ||
squared | ||
|
||
^ self dotProduct: self |
5 changes: 5 additions & 0 deletions
5
src/ColorContextMenu-Core.package/RadialMenuItemMorph.class/instance/baseColor..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
accessing | ||
baseColor: aColor | ||
|
||
baseColor := aColor. | ||
self interactionState: self interactionState. |
Oops, something went wrong.