diff options
Diffstat (limited to 'apps/menu.h')
-rw-r--r-- | apps/menu.h | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/apps/menu.h b/apps/menu.h index 939c17ec4e..a192df3073 100644 --- a/apps/menu.h +++ b/apps/menu.h | |||
@@ -99,34 +99,44 @@ typedef int (*menu_callback_type)(int action, | |||
99 | int do_menu(const struct menu_item_ex *menu); | 99 | int do_menu(const struct menu_item_ex *menu); |
100 | 100 | ||
101 | #define MENU_ITEM_COUNT(c) (c<<MENU_COUNT_SHIFT) | 101 | #define MENU_ITEM_COUNT(c) (c<<MENU_COUNT_SHIFT) |
102 | 102 | /* In all the following macros the argument names are as follows: | |
103 | - name: The name for the variable (so it can be used in a MAKE_MENU() | ||
104 | - str: the string to display for this menu item. use ID2P() for LANG_* id's | ||
105 | - callback: The callback function to call for this menu item. | ||
106 | */ | ||
107 | |||
108 | /* Use this to put a setting into a menu. | ||
109 | The setting must appear in settings_list.c. | ||
110 | If the setting is not configured properly, the menu will display "Not Done yet!" | ||
111 | When the user selects this item the setting select screen will load, | ||
112 | when that screen exits the user wll be back in the menu */ | ||
103 | #define MENUITEM_SETTING(name,var,callback) \ | 113 | #define MENUITEM_SETTING(name,var,callback) \ |
104 | static const struct menu_item_ex name = \ | 114 | static const struct menu_item_ex name = \ |
105 | {MT_SETTING, {.variable = (void*)var},{callback}}; | 115 | {MT_SETTING, {.variable = (void*)var},{callback}}; |
106 | 116 | ||
107 | #define MAKE_MENU( name, str, cb, ... ) \ | 117 | /* Use this To create a list of NON-XLATABLE (for the time being) Strings |
108 | static const struct menu_item_ex *name##_[] = {__VA_ARGS__}; \ | 118 | When the user enters this list and selects one, the menu will exits |
109 | static const struct menu_callback_with_desc name##__ = {cb,str}; \ | 119 | and its return value will be the index of the chosen item */ |
110 | const struct menu_item_ex name = \ | 120 | #define MENUITEM_STRINGLIST(name, str, callback, ... ) \ |
111 | {MT_MENU|MENU_HAS_DESC| \ | ||
112 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ | ||
113 | { (void*)name##_},{.callback_and_desc = & name##__}}; | ||
114 | |||
115 | #define MENUITEM_STRINGLIST(name, str, cb, ... ) \ | ||
116 | static const char *name##_[] = {__VA_ARGS__}; \ | 121 | static const char *name##_[] = {__VA_ARGS__}; \ |
117 | static const struct menu_callback_with_desc name##__ = {cb,str}; \ | 122 | static const struct menu_callback_with_desc name##__ = {callback,str}; \ |
118 | static const struct menu_item_ex name = \ | 123 | static const struct menu_item_ex name = \ |
119 | {MT_RETURN_ID|MENU_HAS_DESC| \ | 124 | {MT_RETURN_ID|MENU_HAS_DESC| \ |
120 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ | 125 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ |
121 | { .submenus = name##_},{.callback_and_desc = & name##__}}; | 126 | { .submenus = name##_},{.callback_and_desc = & name##__}}; |
127 | |||
122 | /* This one should be static'ed also, | 128 | /* This one should be static'ed also, |
123 | but cannot be done untill sound and playlist menus are done */ | 129 | but cannot be done untill settings menu is done */ |
124 | #define MENUITEM_FUNCTION(name, str, func, cb) \ | 130 | /* Use this to put a function call into the menu. |
125 | static const struct menu_callback_with_desc name##_ = {cb,str}; \ | 131 | When the user selects this item the function will be run, |
132 | when it exits the user will be back in the menu. return value is ignored */ | ||
133 | #define MENUITEM_FUNCTION(name, str, func, callback) \ | ||
134 | static const struct menu_callback_with_desc name##_ = {callback,str}; \ | ||
126 | const struct menu_item_ex name = \ | 135 | const struct menu_item_ex name = \ |
127 | { MT_FUNCTION_CALL|MENU_HAS_DESC, { .function = func}, \ | 136 | { MT_FUNCTION_CALL|MENU_HAS_DESC, { .function = func}, \ |
128 | {.callback_and_desc = & name##_}}; | 137 | {.callback_and_desc = & name##_}}; |
129 | 138 | ||
139 | /* Same as above, except the function will be called with a (void*)param. */ | ||
130 | #define MENUITEM_FUNCTION_WPARAM(name, str, func, param, callback) \ | 140 | #define MENUITEM_FUNCTION_WPARAM(name, str, func, param, callback) \ |
131 | static const struct menu_callback_with_desc name##_ = {callback,str}; \ | 141 | static const struct menu_callback_with_desc name##_ = {callback,str}; \ |
132 | static const struct menu_func_with_param name##__ = {func, param}; \ | 142 | static const struct menu_func_with_param name##__ = {func, param}; \ |
@@ -135,5 +145,13 @@ int do_menu(const struct menu_item_ex *menu); | |||
135 | { .func_with_param = &name##__}, \ | 145 | { .func_with_param = &name##__}, \ |
136 | {.callback_and_desc = & name##_}}; | 146 | {.callback_and_desc = & name##_}}; |
137 | 147 | ||
138 | 148 | /* Use this to actually create a menu. the ... argument is a list of pointers | |
149 | to any of the above macro'd variables. (It can also have other menus in the list. */ | ||
150 | #define MAKE_MENU( name, str, callback, ... ) \ | ||
151 | static const struct menu_item_ex *name##_[] = {__VA_ARGS__}; \ | ||
152 | static const struct menu_callback_with_desc name##__ = {callback,str}; \ | ||
153 | const struct menu_item_ex name = \ | ||
154 | {MT_MENU|MENU_HAS_DESC| \ | ||
155 | MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ | ||
156 | { (void*)name##_},{.callback_and_desc = & name##__}}; | ||
139 | #endif /* End __MENU_H__ */ | 157 | #endif /* End __MENU_H__ */ |