diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-10-19 15:28:15 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-10-19 15:28:15 +0000 |
commit | 1016ee4e809776619fa9e4e773ceb1523bd7bc66 (patch) | |
tree | 585cd873c118bee7c2459205e6eb54ff3e76a21b /apps/gui/viewport.c | |
parent | 00695baac0b797cbe46e7bc2999a83f73b36aae8 (diff) | |
download | rockbox-1016ee4e809776619fa9e4e773ceb1523bd7bc66.tar.gz rockbox-1016ee4e809776619fa9e4e773ceb1523bd7bc66.zip |
Initial custom statusbar commit.
The custom statusbar can be used as a WPS for the main UI, using .(r)sbs files. It's using the skin engine and knows all tags the WPS also knows.
The default folder for .sbs is the wps folder to reuse images used in the WPS.
As it can be shown in the WPS also, it's useful to move shared parts to the custom statusbar in order to save skin buffer space.
There are a few restrictions/TODOs:
*) Peak meter doesn't redraw nicely(not frequent enough), as very frequent updates would slow the UI down as hell (some targets fight with it in the WPS already: FS#10686)
*) No touchregion support as the statusbar doesn't have any action handling (it won't fail to parse though).
*) Drawing stuff into the default VP is forbidden (loading images in it is not). You *need* to use viewports for the displaying stuff (parsing fails if no viewport is used).
*) Themes that don't use a custom ui viewport can be fixed up using the new %Vi tag to avoid nasty redraw effectts (you must not draw into it as well, it's used to fix up the ui viewport). %Vi describes the viewport that the lists can use without getting in the way of the statusbar.
Otherwise, it behaves like the classic statusbar, it can be configured in the theme settings, and can be turned off in the wps using %wd.
Note to translaters: When translating LANG_STATUSBAR_CUSTOM, please consider using the same translation as for LANG_CHANNEL_CUSTOM if it's compatible. They could be combined later then.
Flyspray: FS#10566
Author: myself
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23258 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/viewport.c')
-rw-r--r-- | apps/gui/viewport.c | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index fdd06bdc46..f39a299521 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c | |||
@@ -58,6 +58,9 @@ | |||
58 | #ifdef HAVE_LCD_BITMAP | 58 | #ifdef HAVE_LCD_BITMAP |
59 | #include "language.h" | 59 | #include "language.h" |
60 | #endif | 60 | #endif |
61 | #include "statusbar-skinned.h" | ||
62 | #include "debug.h" | ||
63 | |||
61 | 64 | ||
62 | static int statusbar_enabled = 0; | 65 | static int statusbar_enabled = 0; |
63 | 66 | ||
@@ -93,8 +96,9 @@ static bool showing_bars(enum screen_type screen) | |||
93 | if (statusbar_enabled & VP_SB_ONSCREEN(screen)) | 96 | if (statusbar_enabled & VP_SB_ONSCREEN(screen)) |
94 | { | 97 | { |
95 | #ifdef HAVE_LCD_BITMAP | 98 | #ifdef HAVE_LCD_BITMAP |
96 | bool ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); | 99 | int ignore; |
97 | return ignore || (statusbar_position(screen)); | 100 | ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); |
101 | return ignore || (statusbar_position(screen) != STATUSBAR_OFF); | ||
98 | #else | 102 | #else |
99 | return true; | 103 | return true; |
100 | #endif | 104 | #endif |
@@ -109,22 +113,30 @@ void viewport_set_fullscreen(struct viewport *vp, | |||
109 | vp->width = screens[screen].lcdwidth; | 113 | vp->width = screens[screen].lcdwidth; |
110 | 114 | ||
111 | #ifdef HAVE_LCD_BITMAP | 115 | #ifdef HAVE_LCD_BITMAP |
112 | set_default_align_flags(vp); | 116 | struct viewport *sb_skin_vp = sb_skin_get_info_vp(screen); |
113 | vp->drawmode = DRMODE_SOLID; | 117 | if (sb_skin_vp && sb_skin_get_state(screen) |
114 | vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ | 118 | && statusbar_enabled & VP_SB_ONSCREEN(screen)) |
115 | 119 | { | |
116 | vp->height = screens[screen].lcdheight; | 120 | *vp = *sb_skin_vp; |
117 | if (statusbar_position(screen) != STATUSBAR_BOTTOM | 121 | } |
118 | && showing_bars(screen)) | 122 | else |
119 | vp->y = STATUSBAR_HEIGHT; | 123 | { |
120 | else | 124 | if (statusbar_position(screen) != STATUSBAR_BOTTOM && showing_bars(screen)) |
121 | vp->y = 0; | 125 | vp->y = STATUSBAR_HEIGHT; |
126 | else | ||
127 | vp->y = 0; | ||
122 | #else | 128 | #else |
123 | vp->y = 0; | 129 | { |
130 | vp->y = 0; | ||
124 | #endif | 131 | #endif |
125 | vp->height = screens[screen].lcdheight | 132 | vp->height = screens[screen].lcdheight |
126 | - (showing_bars(screen)?STATUSBAR_HEIGHT:0); | 133 | - (showing_bars(screen)?STATUSBAR_HEIGHT:0); |
134 | } | ||
127 | 135 | ||
136 | #ifdef HAVE_LCD_BITMAP | ||
137 | set_default_align_flags(vp); | ||
138 | vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ | ||
139 | vp->drawmode = DRMODE_SOLID; | ||
128 | #if LCD_DEPTH > 1 | 140 | #if LCD_DEPTH > 1 |
129 | #ifdef HAVE_REMOTE_LCD | 141 | #ifdef HAVE_REMOTE_LCD |
130 | /* We only need this test if there is a remote LCD */ | 142 | /* We only need this test if there is a remote LCD */ |
@@ -144,7 +156,7 @@ void viewport_set_fullscreen(struct viewport *vp, | |||
144 | vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; | 156 | vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; |
145 | } | 157 | } |
146 | #endif | 158 | #endif |
147 | 159 | #endif | |
148 | } | 160 | } |
149 | 161 | ||
150 | void viewport_set_defaults(struct viewport *vp, | 162 | void viewport_set_defaults(struct viewport *vp, |
@@ -180,21 +192,29 @@ int viewportmanager_get_statusbar(void) | |||
180 | int viewportmanager_set_statusbar(const int enabled) | 192 | int viewportmanager_set_statusbar(const int enabled) |
181 | { | 193 | { |
182 | int old = statusbar_enabled; | 194 | int old = statusbar_enabled; |
195 | int i; | ||
196 | |||
183 | statusbar_enabled = enabled; | 197 | statusbar_enabled = enabled; |
184 | if (enabled) | 198 | |
199 | FOR_NB_SCREENS(i) | ||
185 | { | 200 | { |
186 | int i; | 201 | if (showing_bars(i) |
187 | FOR_NB_SCREENS(i) | 202 | && statusbar_position(i) != STATUSBAR_CUSTOM) |
188 | { | 203 | { |
189 | if (showing_bars(i)) | 204 | add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); |
190 | gui_statusbar_draw(&statusbars.statusbars[i], true); | 205 | gui_statusbar_draw(&statusbars.statusbars[i], true); |
191 | } | 206 | } |
192 | add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); | 207 | else |
208 | remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); | ||
193 | } | 209 | } |
194 | else | 210 | |
211 | #ifdef HAVE_LCD_BITMAP | ||
212 | FOR_NB_SCREENS(i) | ||
195 | { | 213 | { |
196 | remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); | 214 | sb_skin_set_state(showing_bars(i) |
215 | && statusbar_position(i) == STATUSBAR_CUSTOM, i); | ||
197 | } | 216 | } |
217 | #endif | ||
198 | return old; | 218 | return old; |
199 | } | 219 | } |
200 | 220 | ||
@@ -204,7 +224,8 @@ static void viewportmanager_redraw(void* data) | |||
204 | 224 | ||
205 | FOR_NB_SCREENS(i) | 225 | FOR_NB_SCREENS(i) |
206 | { | 226 | { |
207 | if (showing_bars(i)) | 227 | if (showing_bars(i) |
228 | && statusbar_position(i) != STATUSBAR_CUSTOM) | ||
208 | gui_statusbar_draw(&statusbars.statusbars[i], NULL != data); | 229 | gui_statusbar_draw(&statusbars.statusbars[i], NULL != data); |
209 | } | 230 | } |
210 | } | 231 | } |
@@ -234,11 +255,6 @@ void viewportmanager_theme_changed(const int which) | |||
234 | /* reset the ui viewport */ | 255 | /* reset the ui viewport */ |
235 | FOR_NB_SCREENS(i) | 256 | FOR_NB_SCREENS(i) |
236 | ui_vp_info.active[i] = retval & BIT_N(i); | 257 | ui_vp_info.active[i] = retval & BIT_N(i); |
237 | |||
238 | if (retval != 0) | ||
239 | add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed); | ||
240 | else | ||
241 | remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed); | ||
242 | /* and point to it */ | 258 | /* and point to it */ |
243 | ui_vp_info.vp = custom_vp; | 259 | ui_vp_info.vp = custom_vp; |
244 | } | 260 | } |
@@ -249,18 +265,14 @@ void viewportmanager_theme_changed(const int which) | |||
249 | } | 265 | } |
250 | if (which & THEME_STATUSBAR) | 266 | if (which & THEME_STATUSBAR) |
251 | { | 267 | { |
252 | statusbar_enabled = VP_SB_HIDE_ALL; | 268 | statusbar_enabled = 0; |
253 | |||
254 | FOR_NB_SCREENS(i) | 269 | FOR_NB_SCREENS(i) |
255 | { | 270 | { |
256 | if (statusbar_position(i) != STATUSBAR_OFF) | 271 | if (statusbar_position(i) != STATUSBAR_OFF) |
257 | statusbar_enabled |= VP_SB_ONSCREEN(i); | 272 | statusbar_enabled |= VP_SB_ONSCREEN(i); |
258 | } | 273 | } |
259 | 274 | ||
260 | if (statusbar_enabled != VP_SB_HIDE_ALL) | 275 | viewportmanager_set_statusbar(statusbar_enabled); |
261 | add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); | ||
262 | else | ||
263 | remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); | ||
264 | 276 | ||
265 | /* reposition viewport to fit statusbar, only if not using the ui vp */ | 277 | /* reposition viewport to fit statusbar, only if not using the ui vp */ |
266 | 278 | ||
@@ -270,6 +282,19 @@ void viewportmanager_theme_changed(const int which) | |||
270 | viewport_set_fullscreen(&custom_vp[i], i); | 282 | viewport_set_fullscreen(&custom_vp[i], i); |
271 | } | 283 | } |
272 | } | 284 | } |
285 | |||
286 | int event_add = 0; | ||
287 | FOR_NB_SCREENS(i) | ||
288 | { | ||
289 | event_add |= ui_vp_info.active[i]; | ||
290 | event_add |= (statusbar_position(i) == STATUSBAR_CUSTOM); | ||
291 | } | ||
292 | |||
293 | if (event_add) | ||
294 | add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed); | ||
295 | else | ||
296 | remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed); | ||
297 | |||
273 | send_event(GUI_EVENT_THEME_CHANGED, NULL); | 298 | send_event(GUI_EVENT_THEME_CHANGED, NULL); |
274 | } | 299 | } |
275 | 300 | ||
@@ -283,10 +308,10 @@ static void viewportmanager_ui_vp_changed(void *param) | |||
283 | FOR_NB_SCREENS(i) | 308 | FOR_NB_SCREENS(i) |
284 | screens[i].clear_display(); | 309 | screens[i].clear_display(); |
285 | /* redraw the statusbar if it was enabled */ | 310 | /* redraw the statusbar if it was enabled */ |
286 | viewportmanager_set_statusbar(statusbar_enabled); | 311 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)true); |
287 | /* call the passed function which will redraw the content of | 312 | /* call the passed function which will redraw the content of |
288 | * the current screen */ | 313 | * the current screen */ |
289 | if (param != NULL) | 314 | if (draw_func != NULL) |
290 | draw_func(); | 315 | draw_func(); |
291 | FOR_NB_SCREENS(i) | 316 | FOR_NB_SCREENS(i) |
292 | screens[i].update(); | 317 | screens[i].update(); |