[Cuis-dev] WorldMenu
Hilaire Fernandes
hilaire at drgeo.eu
Fri May 27 09:37:11 PDT 2022
Hi Hernan, Luciano.
Le 27/05/2022 à 16:52, Hernan Wilkinson via Cuis-dev a écrit :
> Hi Luciano,
> adding options to menus based on packages is already solved. Look at
> the class DynamicMenuBuilder.
> In fact, it is used to create the world menu beside other menues like
> the editor menu.
> Hilaire, does the DynamicMenuBuilder satisfy your needs?
Which needs? To define a completely different World Menu?
In Cuis, AFAIK, the world menu hierarchy is both defined with a mix of
data declaration (see #worldMenuOptions) and code to build the menu by
invoking data declaration (see #openMenu), mostly to establish the
informal parent-child menus relationship.
A formal menu declaration decoupled of menu build up will make menu
understanding and extension easier.
I will use a builder instance passed along the methods defining the
menus. The menu data and relationship will be defined in these methods,
then the menu build up done by the builder object. Changing/subclassing
the builder will make possible to have different way to represent menu.
The methods used to defined the whole menu hierarchy will be identified
with a dedicated pragma.
This is more less as implemented in Pharo, it is pretty neat and make
the menu hierarchy easy to understand, you just need to search the
method with a given pragma. In Cuis you have to search for all the
methods defining the menu and submenu (different method names)
In DrGeo for example. The names of the method do not mater, only the pragma:
Main menu, is a regular menu without parent:
DrGeo>>worldMenu: aBuilder
<drgeoMenu>
(aBuilder item: 'New' translated)
action: [ DrGeo newFullScreen ];
icon: (self iconNamed: #smallNewIcon);
order: 0.
../..
(aBuilder item: #Tools translated)
icon: (self iconNamed: #tools);
order: 5.
And submenu are identified by parent argument:
DrGeo>>toolsMenuOn: aBuilder
<drgeoMenu>
(aBuilder item: #'System Browser' translated)
parent: #Tools translated;
action: [ Smalltalk tools browser openOnClass: DrGeoSketch ];
icon: (self iconNamed: #smallObjects);
help:'A source code browser to view, edit and save Dr. Geo
code. I open the browser on the DrGeoCanvas class you can study to
design your own Smalltalk sketch.' translated.
(aBuilder item: #'Workspace' translated)
parent: #Tools translated;
action: [Smalltalk tools openWorkspace bounds: RealEstateAgent
leftMaximumUsableArea];
icon: (self iconNamed: #workspace);
help: 'A window used as a scratchpad area where fragments of
Pharo code can be entered, stored, edited, and evaluated.' translated.
I wonder if pragma parameter parent: will make the menu hierarchy more
explicit and the method a bit less verbose.
Then you can change your world menu with a simple WorldMorph
desktopMenuPragma: #drgeoMenu
Just some food for thought
Hilaire
>
> Cheers!
> Hernan.
--
GNU Dr. Geo
http://drgeo.eu
http://blog.drgeo.eu
More information about the Cuis-dev
mailing list