#!html <h1 style="text-align: left; color: red"> This Plugin is not part of the current lcd4linux. This wiki entry was created for discussion about a plugin prototype. <br><br> </h1>
The plugin Menu allows to configure and use menus.
This Plugin uses plugin Layout to switch Layouts. Therefore plugin Layout has to be configured and activated too.\
Due to this and the similar use of actions it's highly recommended to read the wiki entry of plugin Layout first.
While simple menus can be create with plugin Layout by using the change of button functions depending on the current layout, with plugin Menu menus are builded by using item selection and button functions that are depending on the current active item. So more choises can be made on a small display or with very few buttons. Its also a more natural way to build menus if controls with arrow buttons (e.g. widget Keypad) are used.
A part of a menu configured in the attached sample config file looks like this:
┌────────────────────────────────────────┐ │1.1/1.2 Main Menu 1/2 │ │ [[:SET|VALUE]] >CPU< [[:RAM]] [[:DISK]] [[:ETH]] >>│ └────────────────────────────────────────┘
In this example CPU is setected, inactive items are marked with ... to distinguish between selectable items and normal text like the title (Main Menu…).
The plugin Menu does NOT draw any item or menu itself. It only stores the current menu and item internally and provides functions to switch the current menu or item and functions to detect if a menu/item is active. Latter functions are used by visible widgets (usually the Text widget) to make the menu state visible (e.g. marks or blink). The functionality of the menus is specified by setting actions for each item. By this its very adjustable how a menu look and acts but that is paid with a more complex configuration.
\
\
===== 2.1. Structure
The structure in the config-file looks like this:
Plugin Menu { active 1 blink 150 initmenu 'M_Menu' confirm layout::confirm() cancel layout::cancel() left layout::left() right layout::right() Menu1 { name 'M_Menu' layoutgroup 'G_Menu' confirm menu::none(); layout::layout('G_Diff','L_Dummy') cancel ' ' left menu::prev(0) right menu::next(0) Item1 { name 'I_Menu_SET' layout 'L_Menu_1' confirm menu::menu('M_SET') } Item2 { name 'I_Menu_CPU' confirm menu::none(); layout::layout('G_Diff','L_CPU') } ... } Menu2 { ... } } ... Widget W_Menu_CPU { class 'text' update t_item width 5 expression menu::if('M_Menu','I_Menu_CPU','>CPU<','[[:CPU]]') } ...
“active 1” activates the plugin. If it has not been activated all of its functions will return -1.
The plugin must contain at least 1 menu - each menu at least 1 item. Menus and items have to be numbered serially starting with 1.
In the example a text widget linked to item I_Menu_CPU of menu M_Menu is shown. If this item is active, the widget will be drawn as >CPU<, else CPU Of course menu::if() could be used in the prefix and postfix expressions of the text widget too.
Widgets which are linked to a menu item that way have to poll the current menu state periodically. Using a variable to set the update parameter of the widget to a decisecond might be a good idea.
For each menu a layout group has to be set. For each menu the layout of the first item has to be set explicitly. For all other items it's assumed that it has the same layout as its previous item if no layout was set. Of course this layout should contain the widget which represents the item visually.
If the current menu/item is switched the plugin will switch to the layout which was set for this item automatically.
===== 2.2. Section Plugin Menu
Parameters:
active | Set to 1 to activate plugin, otherwise the plugin won't work and all of its functions return -1. |
initmenu* | Name of the menu that should be active initially (first item). (If not set: No menu/item is active at the start.) |
blinkblink* | Duration in milliseconds between a state change in function menu::blink(…); default: 200 |
<actions>* | see Actions |
* optional |
Subsections
Menus | see Subsection Menu |
===== menu2.3. Subsection Menu
Parameters:
name* | Unique name of the menu. Default: 'Menu1' for Menu1, … |
layoutgroup | Layout group of the menu. |
<actions>* | see Actions |
* optional |
Subsections
Items | see Subsection Item |
===== item2.4. Subsection Item
Parameters:
name | Name of the item. Default: 'Item1' for Item1, … |