hpi-swa/vivide

New view for grouped menus

Opened this issue · 0 comments

The grouped menu is actually a simple tree at the moment. First level are icons and tooltips, second level are objects:

grouped-menu-1

script := {
[:in :out | out addAll: (in ifEmpty: [#()] ifNotEmpty: [:all |
   [:morph | { 
      { #objects -> {#submorphs. morph}.
        #object -> #dummy.
        #text -> 'Submorphs'.
        #icon -> UiSilkIcons weatherSunIcon }.
      { #objects -> {#colors. morph}.
        #object -> #dummy.
        #text -> 'Colors'.
        #icon -> UiSilkIcons weatherCloudyIcon}.
      { #objects -> {#bounds. morph}.
        #object -> #dummy.
        #text -> 'Bounds'.
        #icon -> UiSilkIcons weatherLightningIcon}.
   }] value: all first ])].
-> { #isProperty -> true }.

[:category :morph | 
   category caseOf: {
      [#submorphs] -> [morph submorphs].
      [#colors] -> [morph submorphs collect: [:ea | ea color]].
      [#bounds] -> [morph submorphs collect: [:ea | ea bounds]] }].
} asScript.

grouped-menu-2

An shorter version could be like this (using tuples):

script := {
[:pasteUpMorph | { #(
   (submorphs weatherSunIcon)
   (colors weatherCloudyIcon)
   (bounds weatherLightningIcon)).
   pasteUpMorph } asTuples ].
[:array :pasteUpMorph | 
   { #text -> array first.
     #icon -> (UiSilkIcons perform: array second) }].

[:array :morph | array first caseOf: {
   [#submorphs] -> [morph submorphs].
   [#colors] -> [morph submorphs collect: [:ea | ea color]].
   [#bounds] -> [morph submorphs collect: [:ea | ea bounds]]}].
} asScript.