expo: Support drawing of popup menus
At present only a single menu is supported. All items are shown and a
pointer object points to the current item.
Add support for multiple menus, one of which is highlighted, indicated
by the highlight_id property in the scene.
The highlighted menu item has a SCENEOF_POINT flag, indicating that it
is currently pointed to.
The popup menu is normally closed, in which case it shows only the
current menu item. When it is opened, it shows all items, allowing the
user to select one.
Rather than requiring the menu item to have a description, require it to
have a label. Use the label (only) for the popup menu.
With this, most of the drawing and layout logic is complete.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/expo.h b/include/expo.h
index ea8f389..0c55d60 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -70,6 +70,7 @@
* @action: Action selected by user. At present only one is supported, with the
* type set to EXPOACT_NONE if there is no action
* @text_mode: true to use text mode for the menu (no vidconsole)
+ * @popup: true to use popup menus, instead of showing all items
* @priv: Private data for the controller
* @theme: Information about fonts styles, etc.
* @scene_head: List of scenes
@@ -83,6 +84,7 @@
uint next_id;
struct expo_action action;
bool text_mode;
+ bool popup;
void *priv;
struct expo_theme theme;
struct list_head scene_head;
@@ -111,6 +113,7 @@
* @name: Name of the scene (allocated)
* @id: ID number of the scene
* @title_id: String ID of title of the scene (allocated)
+ * @highlight_id: ID of highlighted object, if any
* @sibling: Node to link this scene to its siblings
* @obj_head: List of objects in the scene
*/
@@ -119,6 +122,7 @@
char *name;
uint id;
uint title_id;
+ uint highlight_id;
struct list_head sibling;
struct list_head obj_head;
};
@@ -157,9 +161,14 @@
* enum scene_obj_flags_t - flags for objects
*
* @SCENEOF_HIDE: object should be hidden
+ * @SCENEOF_POINT: object should be highlighted
+ * @SCENEOF_OPEN: object should be opened (e.g. menu is opened so that an option
+ * can be selected)
*/
enum scene_obj_flags_t {
SCENEOF_HIDE = 1 << 0,
+ SCENEOF_POINT = 1 << 1,
+ SCENEOF_OPEN = 1 << 2,
};
/**