summaryrefslogtreecommitdiff
path: root/apps/menu.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menu.h')
-rw-r--r--apps/menu.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/apps/menu.h b/apps/menu.h
index 3555cd2de6..c7d6cdbeed 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -72,9 +72,12 @@ struct menu_func_with_param {
72}; 72};
73 73
74#define MENU_TYPE_MASK 0xF /* MT_* type */ 74#define MENU_TYPE_MASK 0xF /* MT_* type */
75/* these next two are mutually exclusive */
75#define MENU_HAS_DESC 0x10 76#define MENU_HAS_DESC 0x10
76#define MENU_COUNT_MASK (~(MENU_TYPE_MASK|MENU_HAS_DESC)) /* unless we need more flags*/ 77#define MENU_DYNAMIC_DESC 0x20
77#define MENU_COUNT_SHIFT 5 78/* unless we need more flags*/
79#define MENU_COUNT_MASK (~(MENU_TYPE_MASK|MENU_HAS_DESC|MENU_DYNAMIC_DESC))
80#define MENU_COUNT_SHIFT 6
78 81
79struct menu_item_ex { 82struct menu_item_ex {
80 int flags; /* above defines */ 83 int flags; /* above defines */
@@ -88,7 +91,9 @@ struct menu_item_ex {
88 const char **strings; /* used with MT_RETURN_ID */ 91 const char **strings; /* used with MT_RETURN_ID */
89 }; 92 };
90 union { 93 union {
94 /* For settings */
91 int (*menu_callback)(int action, const struct menu_item_ex *this_item); 95 int (*menu_callback)(int action, const struct menu_item_ex *this_item);
96 /* For everything else, except if the text is dynamic */
92 const struct menu_callback_with_desc { 97 const struct menu_callback_with_desc {
93 int (*menu_callback)(int action, 98 int (*menu_callback)(int action,
94 const struct menu_item_ex *this_item); 99 const struct menu_item_ex *this_item);
@@ -97,12 +102,23 @@ struct menu_item_ex {
97 ICON icon; /* Icon to display */ 102 ICON icon; /* Icon to display */
98#endif 103#endif
99 } *callback_and_desc; 104 } *callback_and_desc;
105 /* For when the item text is dynamic */
106 const struct menu_get_name_and_icon {
107 int (*menu_callback)(int action,
108 const struct menu_item_ex *this_item);
109 char *(*list_get_name)(int selected_item, void * data, char *buffer);
110 void *list_get_name_data;
111#ifdef HAVE_LCD_BITMAP
112 ICON icon; /* Icon to display */
113#endif
114 } *menu_get_name_and_icon;
100 }; 115 };
101}; 116};
102 117
103typedef int (*menu_callback_type)(int action, 118typedef int (*menu_callback_type)(int action,
104 const struct menu_item_ex *this_item); 119 const struct menu_item_ex *this_item);
105int do_menu(const struct menu_item_ex *menu); 120int do_menu(const struct menu_item_ex *menu);
121bool do_setting_from_menu(const struct menu_item_ex *temp);
106 122
107#define MENU_ITEM_COUNT(c) (c<<MENU_COUNT_SHIFT) 123#define MENU_ITEM_COUNT(c) (c<<MENU_COUNT_SHIFT)
108/* In all the following macros the argument names are as follows: 124/* In all the following macros the argument names are as follows:
@@ -152,6 +168,17 @@ int do_menu(const struct menu_item_ex *menu);
152 { MT_FUNCTION_WITH_PARAM|MENU_HAS_DESC, \ 168 { MT_FUNCTION_WITH_PARAM|MENU_HAS_DESC, \
153 { .func_with_param = &name##__}, \ 169 { .func_with_param = &name##__}, \
154 {.callback_and_desc = & name##_}}; 170 {.callback_and_desc = & name##_}};
171
172/* As above, except the text is dynamic */
173#define MENUITEM_FUNCTION_WPARAM_DYNTEXT(name, func, param, callback, \
174 text_callback, text_cb_data, icon) \
175 static const struct menu_get_name_and_icon name##_ \
176 = {callback,text_callback,text_cb_data,icon};\
177 static const struct menu_func_with_param name##__ = {func, param}; \
178 static const struct menu_item_ex name = \
179 { MT_FUNCTION_WITH_PARAM|MENU_DYNAMIC_DESC, \
180 { .func_with_param = &name##__}, \
181 {.menu_get_name_and_icon = & name##_}};
155 182
156/* Use this to actually create a menu. the ... argument is a list of pointers 183/* Use this to actually create a menu. the ... argument is a list of pointers
157 to any of the above macro'd variables. (It can also have other menus in the list. */ 184 to any of the above macro'd variables. (It can also have other menus in the list. */