summaryrefslogtreecommitdiff
path: root/apps/plugins/mpegplayer
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-06-16 04:25:21 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-06-16 04:25:21 +0000
commitaf9f4056510f248c4c9c1335167853bb455e8cc0 (patch)
treeeff7ad7726083ee605d753bd9aa9e22213b1acf0 /apps/plugins/mpegplayer
parentcb57a568e8dc9def607dc9ab27f515309bd13841 (diff)
downloadrockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.tar.gz
rockbox-af9f4056510f248c4c9c1335167853bb455e8cc0.zip
Accept FS#10094 by Teruaki Kawashima:
Replace the old menu API with the "new" one (a very long time overdue so huge thanks for the work.) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21306 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer')
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c139
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.h2
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c2
3 files changed, 40 insertions, 103 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 8aea93b8f1..7ec1157615 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -1,7 +1,6 @@
1#include "plugin.h" 1#include "plugin.h"
2#include "lib/helper.h" 2#include "lib/helper.h"
3#include "lib/configfile.h" 3#include "lib/configfile.h"
4#include "lib/oldmenuapi.h"
5 4
6#include "mpegplayer.h" 5#include "mpegplayer.h"
7#include "mpeg_settings.h" 6#include "mpeg_settings.h"
@@ -257,7 +256,7 @@ void mpeg_menu_sysevent_clear(void)
257 mpeg_menu_sysevent_id = 0; 256 mpeg_menu_sysevent_id = 0;
258} 257}
259 258
260int mpeg_menu_sysevent_callback(int btn, int menu) 259int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu)
261{ 260{
262 switch (btn) 261 switch (btn)
263 { 262 {
@@ -283,17 +282,6 @@ void mpeg_menu_sysevent_handle(void)
283 rb->default_event_handler(id); 282 rb->default_event_handler(id);
284} 283}
285 284
286static void format_menu_item(struct menu_item *item, int bufsize,
287 const char *fmt, ...)
288{
289 va_list ap;
290 va_start(ap, fmt);
291
292 rb->vsnprintf(item->desc, bufsize, fmt, ap);
293
294 va_end(ap);
295}
296
297static bool mpeg_set_option(const char* string, 285static bool mpeg_set_option(const char* string,
298 void* variable, 286 void* variable,
299 enum optiontype type, 287 enum optiontype type,
@@ -691,7 +679,7 @@ static int get_start_time(uint32_t duration)
691 button = tmo == TIMEOUT_BLOCK ? 679 button = tmo == TIMEOUT_BLOCK ?
692 rb->button_get(true) : rb->button_get_w_tmo(tmo); 680 rb->button_get(true) : rb->button_get_w_tmo(tmo);
693 681
694 button = mpeg_menu_sysevent_callback(button, -1); 682 button = mpeg_menu_sysevent_callback(button, NULL);
695 683
696 switch (button) 684 switch (button)
697 { 685 {
@@ -822,43 +810,31 @@ static int get_start_time(uint32_t duration)
822 810
823static int show_start_menu(uint32_t duration) 811static int show_start_menu(uint32_t duration)
824{ 812{
825 int menu_id; 813 int selected = 0;
826 int result = 0; 814 int result = 0;
827 bool menu_quit = false; 815 bool menu_quit = false;
828 816
829 /* add the resume time to the menu display */ 817 /* add the resume time to the menu display */
830 char resume_str[32]; 818 static char resume_str[32];
831 char hms_str[32]; 819 char hms_str[32];
832 struct hms hms; 820 struct hms hms;
833 821
834 struct menu_item items[] = 822 MENUITEM_STRINGLIST(menu, "Mpegplayer Menu", mpeg_menu_sysevent_callback,
835 { 823 "Play from beginning", resume_str,
836 [MPEG_START_RESTART] = 824 "Set start time", "Settings",
837 { "Play from beginning", NULL }, 825 "Quit mpegplayer");
838 [MPEG_START_RESUME] =
839 { resume_str, NULL },
840 [MPEG_START_SEEK] =
841 { "Set start time", NULL },
842 [MPEG_START_SETTINGS] =
843 { "Settings", NULL },
844 [MPEG_START_QUIT] =
845 { "Quit mpegplayer", NULL },
846 };
847 826
848 ts_to_hms(settings.resume_time, &hms); 827 ts_to_hms(settings.resume_time, &hms);
849 hms_format(hms_str, sizeof(hms_str), &hms); 828 hms_format(hms_str, sizeof(hms_str), &hms);
850 format_menu_item(&items[MPEG_START_RESUME], sizeof (resume_str), 829 rb->snprintf(resume_str, sizeof (resume_str),
851 "Resume at: %s", hms_str); 830 "Resume at: %s", hms_str);
852 831
853 menu_id = menu_init(items, ARRAYLEN(items),
854 mpeg_menu_sysevent_callback, NULL, NULL, NULL);
855
856 rb->button_clear_queue(); 832 rb->button_clear_queue();
857 833
858 while (!menu_quit) 834 while (!menu_quit)
859 { 835 {
860 mpeg_menu_sysevent_clear(); 836 mpeg_menu_sysevent_clear();
861 result = menu_show(menu_id); 837 result = rb->do_menu(&menu, &selected, NULL, false);
862 838
863 switch (result) 839 switch (result)
864 { 840 {
@@ -901,8 +877,6 @@ static int show_start_menu(uint32_t duration)
901 } 877 }
902 } 878 }
903 879
904 menu_exit(menu_id);
905
906 rb->lcd_clear_display(); 880 rb->lcd_clear_display();
907 rb->lcd_update(); 881 rb->lcd_update();
908 882
@@ -934,36 +908,26 @@ int mpeg_start_menu(uint32_t duration)
934/** MPEG Menu **/ 908/** MPEG Menu **/
935static void display_options(void) 909static void display_options(void)
936{ 910{
911 int selected = 0;
937 int result; 912 int result;
938 int menu_id;
939 bool menu_quit = false; 913 bool menu_quit = false;
940 914
941 static const struct menu_item items[] = { 915 MENUITEM_STRINGLIST(menu, "Display Options", mpeg_menu_sysevent_callback,
942#if MPEG_OPTION_DITHERING_ENABLED 916#if MPEG_OPTION_DITHERING_ENABLED
943 [MPEG_OPTION_DITHERING] = 917 "Dithering",
944 { "Dithering", NULL },
945#endif 918#endif
946 [MPEG_OPTION_DISPLAY_FPS] = 919 "Display FPS", "Limit FPS", "Skip frames",
947 { "Display FPS", NULL },
948 [MPEG_OPTION_LIMIT_FPS] =
949 { "Limit FPS", NULL },
950 [MPEG_OPTION_SKIP_FRAMES] =
951 { "Skip frames", NULL },
952#ifdef HAVE_BACKLIGHT_BRIGHTNESS 920#ifdef HAVE_BACKLIGHT_BRIGHTNESS
953 [MPEG_OPTION_BACKLIGHT_BRIGHTNESS] = 921 "Backlight brightness",
954 { "Backlight brightness", NULL },
955#endif 922#endif
956 }; 923 );
957
958 menu_id = menu_init(items, ARRAYLEN(items),
959 mpeg_menu_sysevent_callback, NULL, NULL, NULL);
960 924
961 rb->button_clear_queue(); 925 rb->button_clear_queue();
962 926
963 while (!menu_quit) 927 while (!menu_quit)
964 { 928 {
965 mpeg_menu_sysevent_clear(); 929 mpeg_menu_sysevent_clear();
966 result = menu_show(menu_id); 930 result = rb->do_menu(&menu, &selected, NULL, false);
967 931
968 switch (result) 932 switch (result)
969 { 933 {
@@ -1014,38 +978,24 @@ static void display_options(void)
1014 if (mpeg_menu_sysevent() != 0) 978 if (mpeg_menu_sysevent() != 0)
1015 menu_quit = true; 979 menu_quit = true;
1016 } 980 }
1017
1018 menu_exit(menu_id);
1019} 981}
1020 982
1021static void audio_options(void) 983static void audio_options(void)
1022{ 984{
985 int selected = 0;
1023 int result; 986 int result;
1024 int menu_id;
1025 bool menu_quit = false; 987 bool menu_quit = false;
1026 988
1027 static const struct menu_item items[] = { 989 MENUITEM_STRINGLIST(menu, "Audio Options", mpeg_menu_sysevent_callback,
1028 [MPEG_AUDIO_TONE_CONTROLS] = 990 "Tone Controls", "Channel Modes", "Crossfeed",
1029 { "Tone Controls", NULL }, 991 "Equalizer", "Dithering");
1030 [MPEG_AUDIO_CHANNEL_MODES] =
1031 { "Channel Modes", NULL },
1032 [MPEG_AUDIO_CROSSFEED] =
1033 { "Crossfeed", NULL },
1034 [MPEG_AUDIO_EQUALIZER] =
1035 { "Equalizer", NULL },
1036 [MPEG_AUDIO_DITHERING] =
1037 { "Dithering", NULL },
1038 };
1039
1040 menu_id = menu_init(items, ARRAYLEN(items),
1041 mpeg_menu_sysevent_callback, NULL, NULL, NULL);
1042 992
1043 rb->button_clear_queue(); 993 rb->button_clear_queue();
1044 994
1045 while (!menu_quit) 995 while (!menu_quit)
1046 { 996 {
1047 mpeg_menu_sysevent_clear(); 997 mpeg_menu_sysevent_clear();
1048 result = menu_show(menu_id); 998 result = rb->do_menu(&menu, &selected, NULL, false);
1049 999
1050 switch (result) 1000 switch (result)
1051 { 1001 {
@@ -1087,8 +1037,6 @@ static void audio_options(void)
1087 if (mpeg_menu_sysevent() != 0) 1037 if (mpeg_menu_sysevent() != 0)
1088 menu_quit = true; 1038 menu_quit = true;
1089 } 1039 }
1090
1091 menu_exit(menu_id);
1092} 1040}
1093 1041
1094static void resume_options(void) 1042static void resume_options(void)
@@ -1121,32 +1069,23 @@ static void clear_resume_count(void)
1121 1069
1122int mpeg_menu(unsigned flags) 1070int mpeg_menu(unsigned flags)
1123{ 1071{
1124 int menu_id; 1072 int selected = 0;
1125 int result; 1073 int result;
1126 bool menu_quit = false; 1074 bool menu_quit = false;
1127 int item_count; 1075 static char clear_str[32];
1128 char clear_str[32]; 1076
1129 1077 MENUITEM_STRINGLIST(menu_with_quit, "Mpegplayer Menu",
1130 struct menu_item items[] = { 1078 mpeg_menu_sysevent_callback,
1131 [MPEG_MENU_DISPLAY_SETTINGS] = 1079 "Display Options", "Audio Options",
1132 { "Display Options", NULL }, 1080 "Resume Options", clear_str, "Quit mpegplayer");
1133 [MPEG_MENU_AUDIO_SETTINGS] = 1081 MENUITEM_STRINGLIST(menu_without_quit, "Settings",
1134 { "Audio Options", NULL }, 1082 mpeg_menu_sysevent_callback,
1135 [MPEG_MENU_ENABLE_START_MENU] = 1083 "Display Options", "Audio Options",
1136 { "Resume Options", NULL }, 1084 "Resume Options", clear_str);
1137 [MPEG_MENU_CLEAR_RESUMES] = 1085 const struct menu_item_ex *menu = &menu_with_quit;
1138 { clear_str, NULL },
1139 [MPEG_MENU_QUIT] =
1140 { "Quit mpegplayer", NULL },
1141 };
1142
1143 item_count = ARRAYLEN(items);
1144 1086
1145 if (flags & MPEG_MENU_HIDE_QUIT_ITEM) 1087 if (flags & MPEG_MENU_HIDE_QUIT_ITEM)
1146 item_count--; 1088 menu = &menu_without_quit;
1147
1148 menu_id = menu_init(items, item_count,
1149 mpeg_menu_sysevent_callback, NULL, NULL, NULL);
1150 1089
1151 rb->button_clear_queue(); 1090 rb->button_clear_queue();
1152 1091
@@ -1155,10 +1094,10 @@ int mpeg_menu(unsigned flags)
1155 mpeg_menu_sysevent_clear(); 1094 mpeg_menu_sysevent_clear();
1156 1095
1157 /* Format and add resume option to the menu display */ 1096 /* Format and add resume option to the menu display */
1158 format_menu_item(&items[MPEG_MENU_CLEAR_RESUMES], sizeof(clear_str), 1097 rb->snprintf(clear_str, sizeof(clear_str),
1159 "Clear all resumes: %u", settings.resume_count); 1098 "Clear all resumes: %u", settings.resume_count);
1160 1099
1161 result = menu_show(menu_id); 1100 result = rb->do_menu(menu, &selected, NULL, false);
1162 1101
1163 switch (result) 1102 switch (result)
1164 { 1103 {
@@ -1191,8 +1130,6 @@ int mpeg_menu(unsigned flags)
1191 } 1130 }
1192 } 1131 }
1193 1132
1194 menu_exit(menu_id);
1195
1196 rb->lcd_clear_display(); 1133 rb->lcd_clear_display();
1197 rb->lcd_update(); 1134 rb->lcd_update();
1198 1135
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h
index fc43db036b..81a43fa2d7 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.h
+++ b/apps/plugins/mpegplayer/mpeg_settings.h
@@ -100,7 +100,7 @@ enum
100int mpeg_menu(unsigned flags); 100int mpeg_menu(unsigned flags);
101void mpeg_menu_sysevent_clear(void); 101void mpeg_menu_sysevent_clear(void);
102long mpeg_menu_sysevent(void); 102long mpeg_menu_sysevent(void);
103int mpeg_menu_sysevent_callback(int btn, int menu); 103int mpeg_menu_sysevent_callback(int btn, const struct menu_item_ex *menu);
104void mpeg_menu_sysevent_handle(void); 104void mpeg_menu_sysevent_handle(void);
105 105
106void init_settings(const char* filename); 106void init_settings(const char* filename);
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 0a12a78ceb..f71b7740f3 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -1498,7 +1498,7 @@ static void button_loop(void)
1498 mpeg_menu_sysevent_clear(); 1498 mpeg_menu_sysevent_clear();
1499 button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL); 1499 button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL);
1500 1500
1501 button = mpeg_menu_sysevent_callback(button, -1); 1501 button = mpeg_menu_sysevent_callback(button, NULL);
1502 1502
1503 switch (button) 1503 switch (button)
1504 { 1504 {