freemyipod r823 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r822‎ | r823 | r824 >
Date:02:28, 4 December 2011
Author:theseven
Status:new
Tags:
Comment:
iPod Classic boot menu: Complete rework, this is ready for beta testing
Modified paths:
  • /apps/bootmenu-ipodclassic/SOURCES (modified) (history)
  • /apps/bootmenu-ipodclassic/bootoptionchooser.c (deleted) (history)
  • /apps/bootmenu-ipodclassic/bootoptionchooser.h (deleted) (history)
  • /apps/bootmenu-ipodclassic/main.c (modified) (history)
  • /apps/bootmenu-ipodclassic/mainchooser.c (modified) (history)
  • /apps/bootmenu-ipodclassic/settingchooser.c (modified) (history)
  • /apps/bootmenu-ipodclassic/settings.c (modified) (history)
  • /apps/bootmenu-ipodclassic/settings.h (modified) (history)
  • /apps/bootmenu-ipodclassic/toolchooser.c (modified) (history)
  • /apps/bootmenu-ipodclassic/util.c (modified) (history)

Diff [purge]

Index: apps/bootmenu-ipodclassic/bootoptionchooser.c
@@ -1,230 +0,0 @@
2 -//
3 -//
4 -// Copyright 2011 TheSeven
5 -//
6 -//
7 -// This file is part of emCORE.
8 -//
9 -// emCORE is free software: you can redistribute it and/or
10 -// modify it under the terms of the GNU General Public License as
11 -// published by the Free Software Foundation, either version 2 of the
12 -// License, or (at your option) any later version.
13 -//
14 -// emCORE is distributed in the hope that it will be useful,
15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 -// See the GNU General Public License for more details.
18 -//
19 -// You should have received a copy of the GNU General Public License along
20 -// with emCORE. If not, see <http://www.gnu.org/licenses/>.
21 -//
22 -//
23 -
24 -
25 -#include "emcoreapp.h"
26 -#include "libui.h"
27 -#include "bootoptionchooser.h"
28 -#include "main.h"
29 -#include "util.h"
30 -
31 -
32 -static struct chooser_renderer_list_itemdata bootoptionchooser_rparams_cancel =
33 -{
34 - .size = LIBUI_POINT(260, 10),
35 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
36 - .fill_color = 0xa0000000,
37 - .fill_color_selected = 0x60ffffff,
38 - .icon_pos = LIBUI_POINT(0, 0),
39 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
40 - LIBUI_POINT(0, 0)),
41 - .icon_opacity = 0,
42 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
43 - LIBUI_POINT(0, 0)),
44 - .icon_selected_opacity = 0,
45 - .text = "Cancel",
46 - .text_pos = LIBUI_POINT(1, 1),
47 - .text_color = 0xffffffff,
48 - .text_color_selected = 0xff7fffff
49 -};
50 -
51 -static struct chooser_renderer_list_itemdata bootoptionchooser_rparams_option_0 =
52 -{
53 - .size = LIBUI_POINT(260, 10),
54 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
55 - .fill_color = 0xa0000000,
56 - .fill_color_selected = 0x60ffffff,
57 - .icon_pos = LIBUI_POINT(0, 0),
58 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
59 - LIBUI_POINT(0, 0)),
60 - .icon_opacity = 0,
61 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
62 - LIBUI_POINT(0, 0)),
63 - .icon_selected_opacity = 0,
64 - .text = NULL,
65 - .text_pos = LIBUI_POINT(1, 1),
66 - .text_color = 0xffffffff,
67 - .text_color_selected = 0xff7fffff
68 -};
69 -
70 -static struct chooser_renderer_list_itemdata bootoptionchooser_rparams_option_1 =
71 -{
72 - .size = LIBUI_POINT(260, 10),
73 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
74 - .fill_color = 0xa0000000,
75 - .fill_color_selected = 0x60ffffff,
76 - .icon_pos = LIBUI_POINT(0, 0),
77 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
78 - LIBUI_POINT(0, 0)),
79 - .icon_opacity = 0,
80 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
81 - LIBUI_POINT(0, 0)),
82 - .icon_selected_opacity = 0,
83 - .text = NULL,
84 - .text_pos = LIBUI_POINT(1, 1),
85 - .text_color = 0xffffffff,
86 - .text_color_selected = 0xff7fffff
87 -};
88 -
89 -static struct chooser_renderer_list_itemdata bootoptionchooser_rparams_option_2 =
90 -{
91 - .size = LIBUI_POINT(260, 10),
92 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
93 - .fill_color = 0xa0000000,
94 - .fill_color_selected = 0x60ffffff,
95 - .icon_pos = LIBUI_POINT(0, 0),
96 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
97 - LIBUI_POINT(0, 0)),
98 - .icon_opacity = 0,
99 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
100 - LIBUI_POINT(0, 0)),
101 - .icon_selected_opacity = 0,
102 - .text = NULL,
103 - .text_pos = LIBUI_POINT(1, 1),
104 - .text_color = 0xffffffff,
105 - .text_color_selected = 0xff7fffff
106 -};
107 -
108 -static struct chooser_renderer_list_itemdata bootoptionchooser_rparams_option_3 =
109 -{
110 - .size = LIBUI_POINT(260, 10),
111 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
112 - .fill_color = 0xa0000000,
113 - .fill_color_selected = 0x60ffffff,
114 - .icon_pos = LIBUI_POINT(0, 0),
115 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
116 - LIBUI_POINT(0, 0)),
117 - .icon_opacity = 0,
118 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
119 - LIBUI_POINT(0, 0)),
120 - .icon_selected_opacity = 0,
121 - .text = NULL,
122 - .text_pos = LIBUI_POINT(1, 1),
123 - .text_color = 0xffffffff,
124 - .text_color_selected = 0xff7fffff
125 -};
126 -
127 -static struct chooser_renderer_list_params bootoptionchooser_rparams =
128 -{
129 - .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
130 - .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
131 - .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
132 - LIBUI_POINT(320, 240)),
133 - .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
134 - .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
135 - LIBUI_POINT(0, 0)),
136 - .bg_opacity = 0,
137 - .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
138 - LIBUI_POINT(0, 0)),
139 - .fill_color = 0,
140 - .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 50)),
141 - LIBUI_POINT(260, 160)),
142 - .blit_dest = LIBUI_POINT(0, 0),
143 - .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
144 - LIBUI_POINT(320, 240)),
145 - .preblit = update_display,
146 - .postblit = NULL
147 -};
148 -
149 -static struct chooser_action_handler_wheel_params bootoptionchooser_aparams =
150 -{
151 - .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
152 - .stepsperitem = 128,
153 - .eventfilter = NULL,
154 - .timeout_initial = TIMEOUT_BLOCK,
155 - .timeout_idle = TIMEOUT_BLOCK,
156 - .timeout_item = 0,
157 - .tick_force_redraw = false,
158 - .buttoncount = 5,
159 - .buttonmap =
160 - {
161 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
162 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NONE,
163 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
164 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
165 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
166 - }
167 -};
168 -
169 -static struct chooser_info bootoptionchooser =
170 -{
171 - .version = CHOOSER_INFO_VERSION,
172 - .actionhandler = NULL,
173 - .actionhandlerparams = &bootoptionchooser_aparams,
174 - .renderer = NULL,
175 - .rendererparams = &bootoptionchooser_rparams,
176 - .userparams = NULL,
177 - .tickinterval = 10000000,
178 - .itemcount = 5,
179 - .defaultitem = 0,
180 - .items =
181 - {
182 - {
183 - .user = (void*)-1,
184 - .actionparams = NULL,
185 - .renderparams = &bootoptionchooser_rparams_cancel
186 - },
187 - {
188 - .user = (void*)0,
189 - .actionparams = NULL,
190 - .renderparams = &bootoptionchooser_rparams_option_0
191 - },
192 - {
193 - .user = (void*)1,
194 - .actionparams = NULL,
195 - .renderparams = &bootoptionchooser_rparams_option_1
196 - },
197 - {
198 - .user = (void*)2,
199 - .actionparams = NULL,
200 - .renderparams = &bootoptionchooser_rparams_option_2
201 - },
202 - {
203 - .user = (void*)3,
204 - .actionparams = NULL,
205 - .renderparams = &bootoptionchooser_rparams_option_3
206 - }
207 - }
208 -};
209 -
210 -int run_bootoptionchooser(int selected_index, const char* n0, const char* n1,
211 - const char* n2, const char* n3)
212 -{
213 - bootoptionchooser.defaultitem = selected_index + 1;
214 - bootoptionchooser_rparams_option_0.text = n0;
215 - bootoptionchooser_rparams_option_1.text = n1;
216 - bootoptionchooser_rparams_option_2.text = n2;
217 - bootoptionchooser_rparams_option_3.text = n3;
218 - const struct chooser_item* result = ui->chooser_run(&bootoptionchooser);
219 - if (!result) return -1;
220 - return (int)result->user;
221 -}
222 -
223 -void bootoptionchooser_init()
224 -{
225 - bootoptionchooser.actionhandler = ui->chooser_action_handler_wheel;
226 - bootoptionchooser.renderer = ui->chooser_renderer_list;
227 - bootoptionchooser_rparams.copy_dest.buf.addr = framebuf;
228 - bootoptionchooser_rparams.copy_src.loc.buf.addr = bg;
229 - bootoptionchooser_rparams.viewport.loc.buf.addr = framebuf;
230 - bootoptionchooser_rparams.blit_src.loc.buf.addr = framebuf;
231 -}
Index: apps/bootmenu-ipodclassic/bootoptionchooser.h
@@ -1,36 +0,0 @@
2 -//
3 -//
4 -// Copyright 2011 TheSeven
5 -//
6 -//
7 -// This file is part of emCORE.
8 -//
9 -// emCORE is free software: you can redistribute it and/or
10 -// modify it under the terms of the GNU General Public License as
11 -// published by the Free Software Foundation, either version 2 of the
12 -// License, or (at your option) any later version.
13 -//
14 -// emCORE is distributed in the hope that it will be useful,
15 -// but WITHOUT ANY WARRANTY; without even the implied warranty of
16 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 -// See the GNU General Public License for more details.
18 -//
19 -// You should have received a copy of the GNU General Public License along
20 -// with emCORE. If not, see <http://www.gnu.org/licenses/>.
21 -//
22 -//
23 -
24 -
25 -#ifndef __APP_BOOTOPTIONCHOOSER_H__
26 -#define __APP_BOOTOPTIONCHOOSER_H__
27 -
28 -
29 -#include "emcoreapp.h"
30 -
31 -
32 -extern int run_bootoptionchooser(int selected_index, const char* n0, const char* n1,
33 - const char* n2, const char* n3);
34 -extern void bootoptionchooser_init();
35 -
36 -
37 -#endif
Index: apps/bootmenu-ipodclassic/toolchooser.c
@@ -37,17 +37,16 @@
3838 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
3939 .fill_color = 0xa0000000,
4040 .fill_color_selected = 0x60ffffff,
41 - .icon_pos = LIBUI_POINT(0, 0),
42 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
43 - LIBUI_POINT(0, 0)),
 41+ .icon_pos = LIBUI_POINT_NULL,
 42+ .icon = LIBUI_SURFACE_NULL,
4443 .icon_opacity = 0,
45 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
46 - LIBUI_POINT(0, 0)),
 44+ .icon_selected = LIBUI_SURFACE_NULL,
4745 .icon_selected_opacity = 0,
4846 .text = "Return to main menu",
4947 .text_pos = LIBUI_POINT(1, 1),
5048 .text_color = 0xffffffff,
51 - .text_color_selected = 0xff7fffff
 49+ .text_color_selected = 0xff7fffff,
 50+ .render = NULL
5251 };
5352
5453 static struct chooser_renderer_list_itemdata toolchooser_rparams_umsboot =
@@ -56,17 +55,16 @@
5756 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
5857 .fill_color = 0xa0000000,
5958 .fill_color_selected = 0x60ffffff,
60 - .icon_pos = LIBUI_POINT(0, 0),
61 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
62 - LIBUI_POINT(0, 0)),
 59+ .icon_pos = LIBUI_POINT_NULL,
 60+ .icon = LIBUI_SURFACE_NULL,
6361 .icon_opacity = 0,
64 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
65 - LIBUI_POINT(0, 0)),
 62+ .icon_selected = LIBUI_SURFACE_NULL,
6663 .icon_selected_opacity = 0,
6764 .text = "Run UMSboot",
6865 .text_pos = LIBUI_POINT(1, 1),
6966 .text_color = 0xffffffff,
70 - .text_color_selected = 0xff7fffff
 67+ .text_color_selected = 0xff7fffff,
 68+ .render = NULL
7169 };
7270
7371 static struct chooser_renderer_list_itemdata toolchooser_rparams_rockbox_fallback =
@@ -75,17 +73,16 @@
7674 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
7775 .fill_color = 0xa0000000,
7876 .fill_color_selected = 0x60ffffff,
79 - .icon_pos = LIBUI_POINT(0, 0),
80 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
81 - LIBUI_POINT(0, 0)),
 77+ .icon_pos = LIBUI_POINT_NULL,
 78+ .icon = LIBUI_SURFACE_NULL,
8279 .icon_opacity = 0,
83 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
84 - LIBUI_POINT(0, 0)),
 80+ .icon_selected = LIBUI_SURFACE_NULL,
8581 .icon_selected_opacity = 0,
8682 .text = "Run Rockbox fallback image",
8783 .text_pos = LIBUI_POINT(1, 1),
8884 .text_color = 0xffffffff,
89 - .text_color_selected = 0xff7fffff
 85+ .text_color_selected = 0xff7fffff,
 86+ .render = NULL
9087 };
9188
9289 static struct chooser_renderer_list_itemdata toolchooser_rparams_clearcfg =
@@ -94,17 +91,16 @@
9592 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
9693 .fill_color = 0xa0000000,
9794 .fill_color_selected = 0x60ffffff,
98 - .icon_pos = LIBUI_POINT(0, 0),
99 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
100 - LIBUI_POINT(0, 0)),
 95+ .icon_pos = LIBUI_POINT_NULL,
 96+ .icon = LIBUI_SURFACE_NULL,
10197 .icon_opacity = 0,
102 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
103 - LIBUI_POINT(0, 0)),
 98+ .icon_selected = LIBUI_SURFACE_NULL,
10499 .icon_selected_opacity = 0,
105100 .text = "Clear Rockbox configuration",
106101 .text_pos = LIBUI_POINT(1, 1),
107102 .text_color = 0xffffffff,
108 - .text_color_selected = 0xff7fffff
 103+ .text_color_selected = 0xff7fffff,
 104+ .render = NULL
109105 };
110106
111107 static struct chooser_renderer_list_itemdata toolchooser_rparams_cleardb =
@@ -113,17 +109,16 @@
114110 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
115111 .fill_color = 0xa0000000,
116112 .fill_color_selected = 0x60ffffff,
117 - .icon_pos = LIBUI_POINT(0, 0),
118 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
119 - LIBUI_POINT(0, 0)),
 113+ .icon_pos = LIBUI_POINT_NULL,
 114+ .icon = LIBUI_SURFACE_NULL,
120115 .icon_opacity = 0,
121 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
122 - LIBUI_POINT(0, 0)),
 116+ .icon_selected = LIBUI_SURFACE_NULL,
123117 .icon_selected_opacity = 0,
124118 .text = "Clear Rockbox database",
125119 .text_pos = LIBUI_POINT(1, 1),
126120 .text_color = 0xffffffff,
127 - .text_color_selected = 0xff7fffff
 121+ .text_color_selected = 0xff7fffff,
 122+ .render = NULL
128123 };
129124
130125 static struct chooser_renderer_list_itemdata toolchooser_rparams_reformat =
@@ -132,17 +127,16 @@
133128 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
134129 .fill_color = 0xa0000000,
135130 .fill_color_selected = 0x60ffffff,
136 - .icon_pos = LIBUI_POINT(0, 0),
137 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
138 - LIBUI_POINT(0, 0)),
 131+ .icon_pos = LIBUI_POINT_NULL,
 132+ .icon = LIBUI_SURFACE_NULL,
139133 .icon_opacity = 0,
140 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
141 - LIBUI_POINT(0, 0)),
 134+ .icon_selected = LIBUI_SURFACE_NULL,
142135 .icon_selected_opacity = 0,
143136 .text = "Reformat data partition",
144137 .text_pos = LIBUI_POINT(1, 1),
145138 .text_color = 0xffffffff,
146 - .text_color_selected = 0xff7fffff
 139+ .text_color_selected = 0xff7fffff,
 140+ .render = NULL
147141 };
148142
149143 static struct chooser_renderer_list_itemdata toolchooser_rparams_settingchooser =
@@ -151,17 +145,16 @@
152146 .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
153147 .fill_color = 0xa0000000,
154148 .fill_color_selected = 0x60ffffff,
155 - .icon_pos = LIBUI_POINT(0, 0),
156 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
157 - LIBUI_POINT(0, 0)),
 149+ .icon_pos = LIBUI_POINT_NULL,
 150+ .icon = LIBUI_SURFACE_NULL,
158151 .icon_opacity = 0,
159 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
160 - LIBUI_POINT(0, 0)),
 152+ .icon_selected = LIBUI_SURFACE_NULL,
161153 .icon_selected_opacity = 0,
162154 .text = "Settings",
163155 .text_pos = LIBUI_POINT(1, 1),
164156 .text_color = 0xffffffff,
165 - .text_color_selected = 0xff7fffff
 157+ .text_color_selected = 0xff7fffff,
 158+ .render = NULL
166159 };
167160
168161 static struct chooser_renderer_list_params toolchooser_rparams =
@@ -170,12 +163,10 @@
171164 .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
172165 .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
173166 LIBUI_POINT(320, 240)),
174 - .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
175 - .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
176 - LIBUI_POINT(0, 0)),
 167+ .bg_dest = LIBUI_LOCATION_NULL,
 168+ .bg_src = LIBUI_SURFACE_NULL,
177169 .bg_opacity = 0,
178 - .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
179 - LIBUI_POINT(0, 0)),
 170+ .fill_dest = LIBUI_SURFACE_NULL,
180171 .fill_color = 0,
181172 .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 50)),
182173 LIBUI_POINT(260, 160)),
@@ -194,7 +185,7 @@
195186 .timeout_initial = TIMEOUT_BLOCK,
196187 .timeout_idle = TIMEOUT_BLOCK,
197188 .timeout_item = 0,
198 - .tick_force_redraw = false,
 189+ .tick_force_redraw = true,
199190 .buttoncount = 5,
200191 .buttonmap =
201192 {
@@ -277,4 +268,6 @@
278269 toolchooser_rparams.copy_src.loc.buf.addr = bg;
279270 toolchooser_rparams.viewport.loc.buf.addr = framebuf;
280271 toolchooser_rparams.blit_src.loc.buf.addr = framebuf;
 272+ toolchooser_rparams_mainchooser.render = ui->chooser_renderer_list_show_arrow_left;
 273+ toolchooser_rparams_settingchooser.render = ui->chooser_renderer_list_show_arrow_right;
281274 }
Index: apps/bootmenu-ipodclassic/settings.c
@@ -28,6 +28,8 @@
2929
3030 struct settingdata settings_default =
3131 {
 32+ .magic = "emCOsett",
 33+ .app = "bootmenu",
3234 .version = SETTINGS_VERSION,
3335 .timeout_initial = 30000000,
3436 .timeout_idle = 300000000,
@@ -43,19 +45,56 @@
4446 memcpy(&settings, &settings_default, sizeof(settings));
4547 }
4648
 49+void setting_validate(void* setting)
 50+{
 51+ if (setting == &settings.timeout_initial)
 52+ {
 53+ if (settings.timeout_initial < SETTINGS_TIMEOUT_INITIAL_MIN)
 54+ settings.timeout_initial = SETTINGS_TIMEOUT_INITIAL_MIN;
 55+ if (settings.timeout_initial > SETTINGS_TIMEOUT_INITIAL_MAX)
 56+ settings.timeout_initial = SETTINGS_TIMEOUT_INITIAL_MAX;
 57+ }
 58+ else if (setting == &settings.timeout_idle)
 59+ {
 60+ if (settings.timeout_idle < SETTINGS_TIMEOUT_IDLE_MIN)
 61+ settings.timeout_idle = SETTINGS_TIMEOUT_IDLE_MIN;
 62+ if (settings.timeout_idle > SETTINGS_TIMEOUT_IDLE_MAX)
 63+ settings.timeout_idle = SETTINGS_TIMEOUT_IDLE_MAX;
 64+ }
 65+ else if (setting == &settings.timeout_item)
 66+ {
 67+ if (settings.timeout_item < SETTINGS_TIMEOUT_ITEM_MIN)
 68+ settings.timeout_item = SETTINGS_TIMEOUT_ITEM_MIN;
 69+ if (settings.timeout_item > SETTINGS_TIMEOUT_ITEM_MAX)
 70+ settings.timeout_item = SETTINGS_TIMEOUT_ITEM_MAX;
 71+ }
 72+ else if (setting == &settings.default_item)
 73+ {
 74+ if (settings.default_item < SETTINGS_DEFAULT_ITEM_MIN)
 75+ settings.default_item = SETTINGS_DEFAULT_ITEM_MIN;
 76+ if (settings.default_item > SETTINGS_DEFAULT_ITEM_MAX)
 77+ settings.default_item = SETTINGS_DEFAULT_ITEM_MAX;
 78+ }
 79+ else if (setting == &settings.fastboot_item)
 80+ {
 81+ if (settings.fastboot_item < SETTINGS_FASTBOOT_ITEM_MIN)
 82+ settings.fastboot_item = SETTINGS_FASTBOOT_ITEM_MIN;
 83+ if (settings.fastboot_item > SETTINGS_FASTBOOT_ITEM_MAX)
 84+ settings.fastboot_item = SETTINGS_FASTBOOT_ITEM_MAX;
 85+ }
 86+}
 87+
4788 void settings_validate_all()
4889 {
49 - if (settings.version != SETTINGS_VERSION) settings_reset();
50 - if (settings.timeout_initial < 0) settings.timeout_initial = 0;
51 - if (settings.timeout_initial > 2000000000) settings.timeout_initial = 2000000000;
52 - if (settings.timeout_idle < 0) settings.timeout_idle = 0;
53 - if (settings.timeout_idle > 2000000000) settings.timeout_idle = 2000000000;
54 - if (settings.timeout_item < 0) settings.timeout_item = 0;
55 - if (settings.timeout_item > 3) settings.timeout_item = 3;
56 - if (settings.default_item < 0) settings.default_item = 0;
57 - if (settings.default_item > 3) settings.default_item = 3;
58 - if (settings.fastboot_item < 0) settings.fastboot_item = 0;
59 - if (settings.fastboot_item > 3) settings.fastboot_item = 3;
 90+ if (memcmp(settings.magic, settings_default.magic, sizeof(settings.magic))
 91+ || memcmp(settings.app, settings_default.app, sizeof(settings.app))
 92+ || settings.version != SETTINGS_VERSION)
 93+ settings_reset();
 94+ setting_validate(&settings.timeout_initial);
 95+ setting_validate(&settings.timeout_idle);
 96+ setting_validate(&settings.timeout_item);
 97+ setting_validate(&settings.default_item);
 98+ setting_validate(&settings.fastboot_item);
6099 }
61100
62101 void settings_apply()
Index: apps/bootmenu-ipodclassic/settingchooser.c
@@ -29,204 +29,158 @@
3030 #include "settings.h"
3131
3232
33 -static struct chooser_renderer_list_itemdata settingchooser_rparams_toolchooser =
 33+int settingchooser_time_to_str(char* buf, int buflen, void* setting, int value)
3434 {
35 - .size = LIBUI_POINT(260, 10),
36 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
37 - .fill_color = 0xa0000000,
38 - .fill_color_selected = 0x60ffffff,
39 - .icon_pos = LIBUI_POINT(0, 0),
40 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
41 - LIBUI_POINT(0, 0)),
42 - .icon_opacity = 0,
43 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
44 - LIBUI_POINT(0, 0)),
45 - .icon_selected_opacity = 0,
46 - .text = "Return to tools menu",
47 - .text_pos = LIBUI_POINT(1, 1),
48 - .text_color = 0xffffffff,
49 - .text_color_selected = 0xff7fffff
50 -};
 35+ if (value < SETTINGS_TIMEOUT_CUTOFF) return snprintf(buf, buflen, "%s", "Never");
 36+ return snprintf(buf, buflen, "%dsec", value / 1000000);
 37+}
5138
52 -static struct chooser_renderer_list_itemdata settingchooser_rparams_timeout_initial =
 39+static struct settingchooser_select_options settings_timeout_item_options =
5340 {
54 - .size = LIBUI_POINT(260, 10),
55 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
56 - .fill_color = 0xa0000000,
57 - .fill_color_selected = 0x60ffffff,
58 - .icon_pos = LIBUI_POINT(0, 0),
59 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
60 - LIBUI_POINT(0, 0)),
61 - .icon_opacity = 0,
62 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
63 - LIBUI_POINT(0, 0)),
64 - .icon_selected_opacity = 0,
65 - .text = "Initial timeout",
66 - .text_pos = LIBUI_POINT(1, 1),
67 - .text_color = 0xffffffff,
68 - .text_color_selected = 0xff7fffff
 41+ .optioncount = 4,
 42+ .options =
 43+ {
 44+ SETTINGCHOOSER_SELECT_OPTION("Power off", "Power off", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 45+ SETTINGCHOOSER_SELECT_OPTION("Rockbox", "Rockbox", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 46+ SETTINGCHOOSER_SELECT_OPTION("UMSboot", "UMSboot", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 47+ SETTINGCHOOSER_SELECT_OPTION("Console", "emCORE console", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL)
 48+ }
6949 };
7050
71 -static struct chooser_renderer_list_itemdata settingchooser_rparams_timeout_idle =
 51+static struct settingchooser_select_options settings_default_item_options =
7252 {
73 - .size = LIBUI_POINT(260, 10),
74 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
75 - .fill_color = 0xa0000000,
76 - .fill_color_selected = 0x60ffffff,
77 - .icon_pos = LIBUI_POINT(0, 0),
78 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
79 - LIBUI_POINT(0, 0)),
80 - .icon_opacity = 0,
81 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
82 - LIBUI_POINT(0, 0)),
83 - .icon_selected_opacity = 0,
84 - .text = "Idle timeout",
85 - .text_pos = LIBUI_POINT(1, 1),
86 - .text_color = 0xffffffff,
87 - .text_color_selected = 0xff7fffff
 53+ .optioncount = 4,
 54+ .options =
 55+ {
 56+ SETTINGCHOOSER_SELECT_OPTION("Power off", "Power off", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 57+ SETTINGCHOOSER_SELECT_OPTION("Rockbox", "Rockbox", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 58+ SETTINGCHOOSER_SELECT_OPTION("Console", "emCORE console", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 59+ SETTINGCHOOSER_SELECT_OPTION("Tools", "Tools", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL)
 60+ }
8861 };
8962
90 -static struct chooser_renderer_list_itemdata settingchooser_rparams_timeout_item =
 63+static struct settingchooser_select_options settings_fastboot_item_options =
9164 {
92 - .size = LIBUI_POINT(260, 10),
93 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
94 - .fill_color = 0xa0000000,
95 - .fill_color_selected = 0x60ffffff,
96 - .icon_pos = LIBUI_POINT(0, 0),
97 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
98 - LIBUI_POINT(0, 0)),
99 - .icon_opacity = 0,
100 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
101 - LIBUI_POINT(0, 0)),
102 - .icon_selected_opacity = 0,
103 - .text = "Timeout boot option",
104 - .text_pos = LIBUI_POINT(1, 1),
105 - .text_color = 0xffffffff,
106 - .text_color_selected = 0xff7fffff
 65+ .optioncount = 4,
 66+ .options =
 67+ {
 68+ SETTINGCHOOSER_SELECT_OPTION("Disabled", "Disabled", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 69+ SETTINGCHOOSER_SELECT_OPTION("Rockbox", "Rockbox", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 70+ SETTINGCHOOSER_SELECT_OPTION("UMSboot", "UMSboot", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL),
 71+ SETTINGCHOOSER_SELECT_OPTION("Console", "emCORE console", LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL)
 72+ }
10773 };
10874
109 -static struct chooser_renderer_list_itemdata settingchooser_rparams_default_item =
 75+static struct settingchooser_info settingchooser =
11076 {
111 - .size = LIBUI_POINT(260, 10),
112 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
113 - .fill_color = 0xa0000000,
114 - .fill_color_selected = 0x60ffffff,
115 - .icon_pos = LIBUI_POINT(0, 0),
116 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
117 - LIBUI_POINT(0, 0)),
118 - .icon_opacity = 0,
119 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
 77+ .version = SETTINGCHOOSER_INFO_VERSION,
 78+ .rendererparams =
 79+ {
 80+ .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
 81+ .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
 82+ .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
 83+ LIBUI_POINT(320, 240)),
 84+ .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
 85+ .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
 86+ LIBUI_POINT(0, 0)),
 87+ .bg_opacity = 0,
 88+ .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
12089 LIBUI_POINT(0, 0)),
121 - .icon_selected_opacity = 0,
122 - .text = "Default boot option",
123 - .text_pos = LIBUI_POINT(1, 1),
124 - .text_color = 0xffffffff,
125 - .text_color_selected = 0xff7fffff
126 -};
127 -
128 -static struct chooser_renderer_list_itemdata settingchooser_rparams_fastboot_item =
129 -{
130 - .size = LIBUI_POINT(260, 10),
131 - .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
132 - .fill_color = 0xa0000000,
133 - .fill_color_selected = 0x60ffffff,
134 - .icon_pos = LIBUI_POINT(0, 0),
135 - .icon = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
136 - LIBUI_POINT(0, 0)),
137 - .icon_opacity = 0,
138 - .icon_selected = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
139 - LIBUI_POINT(0, 0)),
140 - .icon_selected_opacity = 0,
141 - .text = "Fastboot boot option",
142 - .text_pos = LIBUI_POINT(1, 1),
143 - .text_color = 0xffffffff,
144 - .text_color_selected = 0xff7fffff
145 -};
146 -
147 -static struct chooser_renderer_list_params settingchooser_rparams =
148 -{
149 - .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
150 - .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
151 - .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
152 - LIBUI_POINT(320, 240)),
153 - .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
154 - .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
155 - LIBUI_POINT(0, 0)),
156 - .bg_opacity = 0,
157 - .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
158 - LIBUI_POINT(0, 0)),
159 - .fill_color = 0,
160 - .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 50)),
161 - LIBUI_POINT(260, 160)),
162 - .blit_dest = LIBUI_POINT(0, 0),
163 - .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
164 - LIBUI_POINT(320, 240)),
165 - .preblit = update_display,
166 - .postblit = NULL
167 -};
168 -
169 -static struct chooser_action_handler_wheel_params settingchooser_aparams =
170 -{
171 - .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
172 - .stepsperitem = 128,
173 - .eventfilter = NULL,
174 - .timeout_initial = TIMEOUT_BLOCK,
175 - .timeout_idle = TIMEOUT_BLOCK,
176 - .timeout_item = 0,
177 - .tick_force_redraw = false,
178 - .buttoncount = 5,
179 - .buttonmap =
 90+ .fill_color = 0,
 91+ .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 50)),
 92+ LIBUI_POINT(260, 160)),
 93+ .blit_dest = LIBUI_POINT(0, 0),
 94+ .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
 95+ LIBUI_POINT(320, 240)),
 96+ .preblit = update_display,
 97+ .postblit = NULL
 98+ },
 99+ .itemparams =
180100 {
181 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
182 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NONE,
183 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
184 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
185 - CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
186 - }
187 -};
188 -
189 -static struct chooser_info settingchooser =
190 -{
191 - .version = CHOOSER_INFO_VERSION,
192 - .actionhandler = NULL,
193 - .actionhandlerparams = &settingchooser_aparams,
194 - .renderer = NULL,
195 - .rendererparams = &settingchooser_rparams,
196 - .userparams = NULL,
 101+ .size = LIBUI_POINT(260, 10),
 102+ .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
 103+ .fill_color = 0xa0000000,
 104+ .fill_color_selected = 0x60ffffff,
 105+ .fill_color_active = 0x60003f3f,
 106+ .icon_pos = LIBUI_POINT_NULL,
 107+ .icon_opacity = 0,
 108+ .icon_selected_opacity = 0,
 109+ .icon_active_opacity = 0,
 110+ .text_pos = LIBUI_POINT(1, 1),
 111+ .text_color = 0xffffffff,
 112+ .text_color_selected = 0xff7fffff,
 113+ .text_color_active = 0xffff7f7f
 114+ },
 115+ .returntext = "Return to tools menu",
197116 .tickinterval = 10000000,
198 - .itemcount = 6,
199 - .defaultitem = 0,
 117+ .itemcount = 5,
200118 .items =
201119 {
202120 {
203 - .user = (void*)0,
204 - .actionparams = NULL,
205 - .renderparams = &settingchooser_rparams_toolchooser
 121+ .text = "Initial timeout",
 122+ .icon = LIBUI_SURFACE_NULL,
 123+ .icon_selected = LIBUI_SURFACE_NULL,
 124+ .type = SETTINGCHOOSER_TYPE_INTEGER,
 125+ .setting = &settings.timeout_initial,
 126+ .validator = setting_validate,
 127+ .config.integer =
 128+ {
 129+ .min = SETTINGS_TIMEOUT_INITIAL_MIN,
 130+ .max = SETTINGS_TIMEOUT_INITIAL_MAX,
 131+ .step = SETTINGS_TIMEOUT_INITIAL_STEP,
 132+ .tostring = settingchooser_time_to_str
 133+ }
206134 },
207135 {
208 - .user = (void*)1,
209 - .actionparams = NULL,
210 - .renderparams = &settingchooser_rparams_timeout_initial
 136+ .text = "Idle timeout",
 137+ .icon = LIBUI_SURFACE_NULL,
 138+ .icon_selected = LIBUI_SURFACE_NULL,
 139+ .type = SETTINGCHOOSER_TYPE_INTEGER,
 140+ .setting = &settings.timeout_idle,
 141+ .validator = setting_validate,
 142+ .config.integer =
 143+ {
 144+ .min = SETTINGS_TIMEOUT_IDLE_MIN,
 145+ .max = SETTINGS_TIMEOUT_IDLE_MAX,
 146+ .step = SETTINGS_TIMEOUT_IDLE_STEP,
 147+ .tostring = settingchooser_time_to_str
 148+ }
211149 },
212150 {
213 - .user = (void*)2,
214 - .actionparams = NULL,
215 - .renderparams = &settingchooser_rparams_timeout_idle
 151+ .text = "Timeout action",
 152+ .icon = LIBUI_SURFACE_NULL,
 153+ .icon_selected = LIBUI_SURFACE_NULL,
 154+ .type = SETTINGCHOOSER_TYPE_SELECT,
 155+ .setting = &settings.timeout_item,
 156+ .validator = setting_validate,
 157+ .config.select =
 158+ {
 159+ .options = &settings_timeout_item_options
 160+ }
216161 },
217162 {
218 - .user = (void*)3,
219 - .actionparams = NULL,
220 - .renderparams = &settingchooser_rparams_timeout_item
 163+ .text = "Default action",
 164+ .icon = LIBUI_SURFACE_NULL,
 165+ .icon_selected = LIBUI_SURFACE_NULL,
 166+ .type = SETTINGCHOOSER_TYPE_SELECT,
 167+ .setting = &settings.default_item,
 168+ .validator = setting_validate,
 169+ .config.select =
 170+ {
 171+ .options = &settings_default_item_options
 172+ }
221173 },
222174 {
223 - .user = (void*)4,
224 - .actionparams = NULL,
225 - .renderparams = &settingchooser_rparams_default_item
226 - },
227 - {
228 - .user = (void*)5,
229 - .actionparams = NULL,
230 - .renderparams = &settingchooser_rparams_fastboot_item
 175+ .text = "Fastboot action",
 176+ .icon = LIBUI_SURFACE_NULL,
 177+ .icon_selected = LIBUI_SURFACE_NULL,
 178+ .type = SETTINGCHOOSER_TYPE_SELECT,
 179+ .setting = &settings.fastboot_item,
 180+ .validator = setting_validate,
 181+ .config.select =
 182+ {
 183+ .options = &settings_fastboot_item_options
 184+ }
231185 }
232186 }
233187 };
@@ -233,45 +187,21 @@
234188
235189 void run_settingchooser(void** firmware, void** app, int* size)
236190 {
237 - while (true)
 191+ bool changes = ui->settingchooser_run(&settingchooser);
 192+ if (changes)
238193 {
239 - const struct chooser_item* result = ui->chooser_run(&settingchooser);
240 - if (!result || !result->user)
241 - {
242 - rendertext(framebuf, 106, 140, 320, 0xff33ffff, 0xa0000000, "Saving settings...");
243 - displaylcd(0, 0, 320, 240, framebuf, 0, 0, 320);
244 - settings_validate_all();
245 - settings_save();
246 - settings_apply();
247 - return;
248 - }
249 - int new;
250 - switch ((int)result->user)
251 - {
252 - case 3:
253 - new = run_bootoptionchooser(settings.timeout_item, "Power off", "Rockbox", "UMSboot", "emCORE console");
254 - if (new != -1) settings.timeout_item = new;
255 - break;
256 -
257 - case 4:
258 - new = run_bootoptionchooser(settings.default_item, "Power off", "Rockbox", "emCORE console", "Tools");
259 - if (new != -1) settings.default_item = new;
260 - break;
261 -
262 - case 5:
263 - new = run_bootoptionchooser(settings.fastboot_item, "Disabled", "Rockbox", "UMSboot", "emCORE console");
264 - if (new != -1) settings.fastboot_item = new;
265 - break;
266 - }
 194+ rendertext(framebuf, 106, 140, 320, 0xff33ffff, 0xa0000000, "Saving settings...");
 195+ displaylcd(0, 0, 320, 240, framebuf, 0, 0, 320);
 196+ settings_validate_all();
 197+ settings_save();
 198+ settings_apply();
267199 }
268200 }
269201
270202 void settingchooser_init()
271203 {
272 - settingchooser.actionhandler = ui->chooser_action_handler_wheel;
273 - settingchooser.renderer = ui->chooser_renderer_list;
274 - settingchooser_rparams.copy_dest.buf.addr = framebuf;
275 - settingchooser_rparams.copy_src.loc.buf.addr = bg;
276 - settingchooser_rparams.viewport.loc.buf.addr = framebuf;
277 - settingchooser_rparams.blit_src.loc.buf.addr = framebuf;
 204+ settingchooser.rendererparams.copy_dest.buf.addr = framebuf;
 205+ settingchooser.rendererparams.copy_src.loc.buf.addr = bg;
 206+ settingchooser.rendererparams.viewport.loc.buf.addr = framebuf;
 207+ settingchooser.rendererparams.blit_src.loc.buf.addr = framebuf;
278208 }
Index: apps/bootmenu-ipodclassic/SOURCES
@@ -2,7 +2,6 @@
33 mainchooser.c
44 toolchooser.c
55 settingchooser.c
6 -bootoptionchooser.c
76 boot.c
87 tools.c
98 util.c
Index: apps/bootmenu-ipodclassic/settings.h
@@ -31,6 +31,8 @@
3232 #define SETTINGS_VERSION 1
3333 struct settingdata
3434 {
 35+ char magic[8];
 36+ char app[8];
3537 uint32_t version;
3638 long timeout_initial;
3739 long timeout_idle;
@@ -39,7 +41,22 @@
4042 int fastboot_item;
4143 };
4244
 45+#define SETTINGS_TIMEOUT_INITIAL_MIN 0
 46+#define SETTINGS_TIMEOUT_INITIAL_MAX 2000000000
 47+#define SETTINGS_TIMEOUT_INITIAL_STEP 1000000
 48+#define SETTINGS_TIMEOUT_IDLE_MIN 0
 49+#define SETTINGS_TIMEOUT_IDLE_MAX 2000000000
 50+#define SETTINGS_TIMEOUT_IDLE_STEP 1000000
 51+#define SETTINGS_TIMEOUT_ITEM_MIN 0
 52+#define SETTINGS_TIMEOUT_ITEM_MAX 3
 53+#define SETTINGS_DEFAULT_ITEM_MIN 0
 54+#define SETTINGS_DEFAULT_ITEM_MAX 3
 55+#define SETTINGS_FASTBOOT_ITEM_MIN 0
 56+#define SETTINGS_FASTBOOT_ITEM_MAX 3
4357
 58+#define SETTINGS_TIMEOUT_CUTOFF 3000000
 59+
 60+
4461 extern struct settingdata settings_default;
4562 extern struct settingdata settings;
4663
@@ -46,6 +63,7 @@
4764
4865 extern void settings_init();
4966 extern void settings_reset();
 67+extern void setting_validate(void* setting);
5068 extern void settings_validate_all();
5169 extern void settings_apply();
5270 extern void settings_save();
Index: apps/bootmenu-ipodclassic/mainchooser.c
@@ -53,6 +53,7 @@
5454 LIBUI_POINT(80, 80)),
5555 .text = "Power off",
5656 .text_color = 0xffffcccc,
 57+ .render = NULL
5758 };
5859
5960 static struct chooser_renderer_iconflow_itemdata mainchooser_rparams_rockbox =
@@ -63,6 +64,7 @@
6465 LIBUI_POINT(80, 80)),
6566 .text = "Rockbox",
6667 .text_color = 0xffffcccc,
 68+ .render = NULL
6769 };
6870
6971 static struct chooser_renderer_iconflow_itemdata mainchooser_rparams_console =
@@ -73,6 +75,7 @@
7476 LIBUI_POINT(80, 80)),
7577 .text = "emCORE console",
7678 .text_color = 0xffffcccc,
 79+ .render = NULL
7780 };
7881
7982 static struct chooser_renderer_iconflow_itemdata mainchooser_rparams_toolchooser =
@@ -83,6 +86,7 @@
8487 LIBUI_POINT(80, 80)),
8588 .text = "Tools",
8689 .text_color = 0xffffcccc,
 90+ .render = NULL
8791 };
8892
8993 static struct chooser_renderer_iconflow_params mainchooser_rparams =
@@ -91,12 +95,10 @@
9296 .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
9397 .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
9498 LIBUI_POINT(320, 240)),
95 - .bg_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
96 - .bg_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
97 - LIBUI_POINT(0, 0)),
 99+ .bg_dest = LIBUI_LOCATION_NULL,
 100+ .bg_src = LIBUI_SURFACE_NULL,
98101 .bg_opacity = 0,
99 - .fill_dest = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 0), LIBUI_POINT(0, 0)),
100 - LIBUI_POINT(0, 0)),
 102+ .fill_dest = LIBUI_SURFACE_NULL,
101103 .fill_color = 0,
102104 .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 30)),
103105 LIBUI_POINT(320, 130)),
@@ -216,8 +218,10 @@
217219 void mainchooser_apply_settings()
218220 {
219221 mainchooser.defaultitem = settings.default_item;
220 - if (settings.timeout_initial < 3000000) mainchooser_aparams.timeout_initial = TIMEOUT_BLOCK;
 222+ if (settings.timeout_initial < SETTINGS_TIMEOUT_CUTOFF)
 223+ mainchooser_aparams.timeout_initial = TIMEOUT_BLOCK;
221224 else mainchooser_aparams.timeout_initial = settings.timeout_initial + 500000;
222 - if (settings.timeout_idle < 3000000) mainchooser_aparams.timeout_idle = TIMEOUT_BLOCK;
 225+ if (settings.timeout_idle < SETTINGS_TIMEOUT_CUTOFF)
 226+ mainchooser_aparams.timeout_idle = TIMEOUT_BLOCK;
223227 else mainchooser_aparams.timeout_idle = settings.timeout_idle + 500000;
224228 }
Index: apps/bootmenu-ipodclassic/util.c
@@ -68,7 +68,8 @@
6969 // remaining battery level
7070 ui->blendcolor(batt_level, 6, 0xc0ffcccc, framebuf, 5, 5, 320, framebuf, 5, 5, 320);
7171 // background of the rest space
72 - ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level, 5, 320, framebuf, 5 + batt_level, 5, 320);
 72+ ui->blendcolor(22 - batt_level, 6, 0x40000000, framebuf, 5 + batt_level,
 73+ 5, 320, framebuf, 5 + batt_level, 5, 320);
7374 return false;
7475 }
7576
Index: apps/bootmenu-ipodclassic/main.c
@@ -87,9 +87,9 @@
8888 mainchooser_init();
8989 toolchooser_init();
9090 settingchooser_init();
91 - bootoptionchooser_init();
9291
9392 run_mainchooser(&firmware, &app, &size);
 93+
9494 free(framebuf);
9595 free(rbxlogo);
9696 free(icons);