the plot:
Since we want to be able to allow the user to full customize
his or her menus and toolbars we need to be able to abstract
the following things away from the layout of the menus:
sensitivity, hiddenness, state ( such as toggledness )
Other things we want to separate are:
default labels, tips and pixmaps
So; how is this separation achieved in practice?
We have a namespace that 'commands' live in; these can either
be things like 'Save' ( a verb ) or 'Threaded View' ( a state
with an id ). Both verbs and id's are in the same space. So;
we describe the capbilities of a program in terms of the verbs
and state inputs it can handle, and provide a default UI
layout, perhaps like this:
<Root>
<commands>
<cmd name="baa" _label="Our Label" _tip="Hello World"
pixtype="stock" pixname="Open"/>
</commands>
<menu>
<menuitem name="foo" verb="baa"/>
</menu>
</Root>
Now; the user can chose to remove the 'Our Label' button, or
more creatively might decide to convert it into a toolbar and
change the label to 'MyLabel':
- <menu>
- <menuitem name="foo" verb="baa"/>
- </menu>
+ <dockitem name="fishy">
+ <toolitem name="foo" verb="baa" _label="MyLabel"/>
+ </dockitem>
But what does this mean for the programmer? .
What it means, is that when you decided to make this (
dangerous lookin ) verb insensitive, instead of setting
sensitive="0" on the item at path /menu/foo, you instead do it
on the item at path /commands/baa. This then allows the user
to have none, one or many representations of each verb/id as
either menu or toolbar items. But wait, don't you need Menu_Open for stock menu
icons? .
In this case no; since we need to be able to generate either a
menu or a toolbar item view of this verb/id. Consequently the
code will add the Menu_ prefix where needed for you.
But wait, what if the stock items are called
Foo_Open and Baa_Open for menu / toolbar items ? or ... what if I
have a non-stock toolbar icon that won't fit in a menu ? .
Sadly there was not time to implement custom widget sizing
logic, so setting a single pixmap on the verb won't
work. However, you can still set the pixmap on the individual
toolbar / menu items at the expense of customization. But what about acclerators ?
How do I get rid of '_'s in my toolbar labels. .
Since accelerators are clearly part of the widget and not the
command it is important to put labels with accelerators in
them in the widget and not the command node. _But_ it is also
important to ensure that a non-accelerated version is left in
the command for use by GUI configuration software as a default
label, it would also be wise to use this as the default
toolbar label. So this is good practice:
<Root>
<commands>
<cmd name="FileOpen" _label="Open" hidden="1"
_tip="Open a file" pixtype="stock" pixname="Open"
accel="F3"/>
</commands>
<menu>
<menuitem name="FileNew" verb="" _label="_New"/>
</menu>
</Root>
See std-ui.xml for a set of correctly organised useful cmd and
widget descriptions.
Note that 'verb=""' is shorthand for making the verb name the
same as the node name (in this example, "FileNew"). This is
not the same as leaving the verb out entirely. |