summaryrefslogtreecommitdiffstats
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-12-09 07:25:46 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-12-09 07:25:46 +0000
commitb2eb44ce0eb24632a46b0ea8c8c46a8f2ba35e24 (patch)
treeff3c0e14e9a53c08749ee1f233a5b1e887d3561a /apps/gui
parent85aad9b3972208b0e34ba0241ebb5314118ae05e (diff)
downloadrockbox-b2eb44ce0eb24632a46b0ea8c8c46a8f2ba35e24.tar.gz
rockbox-b2eb44ce0eb24632a46b0ea8c8c46a8f2ba35e24.tar.bz2
rockbox-b2eb44ce0eb24632a46b0ea8c8c46a8f2ba35e24.zip
FS#10824 - viewport/statusbar API rework.
Hopefully the only user visible changes are: - fm and recording screens go by the statusbar setting (sbs or inbuilt) - plugins go back to using the theme as they should for menus and lists - splash screens might get cut a bit... entirely theme and splash dependant.. if there is a problematic one we can look at it later. - hopefully nothing more than very minor screen flickerings... let me know exactly where they are so they can be fixed New GUI screen rules: * Screens assume that the theme (sbs+ui viewport+ maybe background image) are always enabled. They may be disabled on a per display basis, but MUST be re-enabled on exit * Screens must not be coded in a way that requires a statusbar of any type.. the inbuilt bar will be removed shortly. ALWAYS RESPECT THE USERS SETTINGS unless the screen requires the full display to fit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23904 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c10
-rw-r--r--apps/gui/skin_engine/skin_display.c5
-rw-r--r--apps/gui/splash.c3
-rw-r--r--apps/gui/statusbar-skinned.c97
-rw-r--r--apps/gui/statusbar-skinned.h3
-rw-r--r--apps/gui/usb_screen.c13
-rw-r--r--apps/gui/viewport.c347
-rw-r--r--apps/gui/viewport.h48
-rw-r--r--apps/gui/wps.c55
9 files changed, 238 insertions, 343 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 340175c0d0..eacebb5c30 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -822,14 +822,17 @@ static const char* simplelist_static_getname(int item,
bool simplelist_show_list(struct simplelist_info *info)
{
struct gui_synclist lists;
- int action, old_line_count = simplelist_line_count;
- int oldbars = viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
+ int action, old_line_count = simplelist_line_count, i;
const char* (*getname)(int item, void * data, char *buffer, size_t buffer_len);
int wrap = LIST_WRAP_UNLESS_HELD;
if (info->get_name)
getname = info->get_name;
else
getname = simplelist_static_getname;
+
+ FOR_NB_SCREENS(i)
+ viewportmanager_theme_enable(i, true, NULL);
+
gui_synclist_init(&lists, getname, info->callback_data,
info->scroll_all, info->selection_size, NULL);
@@ -904,7 +907,8 @@ bool simplelist_show_list(struct simplelist_info *info)
return true;
}
talk_shutup();
- viewportmanager_set_statusbar(oldbars);
+ FOR_NB_SCREENS(i)
+ viewportmanager_theme_undo(i);
return false;
}
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 4f33910beb..362e5078f5 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -1084,11 +1084,6 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
#ifdef HAVE_LCD_BITMAP
data->peak_meter_enabled = enable_pm;
#endif
-
- if (refresh_mode & WPS_REFRESH_STATUSBAR)
- {
- viewportmanager_set_statusbar(gwps->sync_data->statusbars);
- }
/* Restore the default viewport */
display->set_viewport(NULL);
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index 4ddd22aba2..39d224a742 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -204,12 +204,15 @@ void splashf(int ticks, const char *fmt, ...)
fmt = P2STR((unsigned char *)fmt);
FOR_NB_SCREENS(i)
{
+ viewportmanager_theme_enable(i, false, NULL);
va_start(ap, fmt);
splash_internal(&(screens[i]), fmt, ap);
va_end(ap);
}
if (ticks)
sleep(ticks);
+ FOR_NB_SCREENS(i)
+ viewportmanager_theme_undo(i);
}
void splash(int ticks, const char *str)
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 4ef739929a..8bdecef692 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -41,7 +41,7 @@ static struct wps_data sb_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
static struct wps_sync_data sb_skin_sync_data = { .do_full_update = false };
/* initial setup of wps_data */
-static void sb_skin_update(void*);
+
static bool loaded_ok[NB_SCREENS] = { false };
static int update_delay = DEFAULT_UPDATE_DELAY;
@@ -68,9 +68,6 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile)
vp->hidden_flags = VP_NEVER_VISIBLE;
}
- if (!success)
- remove_event(GUI_EVENT_ACTIONUPDATE, sb_skin_update);
-
loaded_ok[screen] = success;
}
@@ -96,7 +93,6 @@ struct viewport *sb_skin_get_info_vp(enum screen_type screen)
inline bool sb_skin_get_state(enum screen_type screen)
{
- int skinbars = sb_skin[screen].sync_data->statusbars;
/* Temp fix untill the hardcoded bar is removed */
int bar_setting = global_settings.statusbar;
#if NB_SCREENS > 1
@@ -106,87 +102,45 @@ inline bool sb_skin_get_state(enum screen_type screen)
switch (bar_setting)
{
case STATUSBAR_CUSTOM:
- return loaded_ok[screen] && (skinbars & VP_SB_ONSCREEN(screen));
+ return loaded_ok[screen];
case STATUSBAR_TOP:
case STATUSBAR_BOTTOM:
+ return true;
case STATUSBAR_OFF:
- return (viewportmanager_get_statusbar()&VP_SB_ONSCREEN(screen));
+ return false;
}
return false; /* Should never actually get here */
}
-
-static void do_update_callback(void *param)
-{
- (void)param;
- /* the WPS handles changing the actual id3 data in the id3 pointers
- * we imported, we just want a full update */
- sb_skin_sync_data.do_full_update = true;
- /* force timeout in wps main loop, so that the update is instantly */
- queue_post(&button_queue, BUTTON_NONE, 0);
-}
-
-
-void sb_skin_set_state(int state, enum screen_type screen)
-{
- sb_skin[screen].sync_data->do_full_update = true;
- int skinbars = sb_skin[screen].sync_data->statusbars;
- if (state && loaded_ok[screen])
- {
- skinbars |= VP_SB_ONSCREEN(screen);
- }
- else
- {
- skinbars &= ~VP_SB_ONSCREEN(screen);
- }
-
- if (skinbars)
- {
-#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- add_event(LCD_EVENT_ACTIVATION, false, do_update_callback);
-#endif
- add_event(PLAYBACK_EVENT_TRACK_CHANGE, false,
- do_update_callback);
- add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false,
- do_update_callback);
- add_event(GUI_EVENT_ACTIONUPDATE, false, sb_skin_update);
- }
- else
- {
-#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- remove_event(LCD_EVENT_ACTIVATION, do_update_callback);
-#endif
- remove_event(PLAYBACK_EVENT_TRACK_CHANGE, do_update_callback);
- remove_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, do_update_callback);
- remove_event(GUI_EVENT_ACTIONUPDATE, sb_skin_update);
- }
-
- sb_skin[screen].sync_data->statusbars = skinbars;
-}
-
-static void sb_skin_update(void* param)
+void sb_skin_update(enum screen_type screen, bool force)
{
static long next_update = 0;
- int i;
- int forced_draw = param || sb_skin[SCREEN_MAIN].sync_data->do_full_update;
- if (TIME_AFTER(current_tick, next_update) || forced_draw)
+ int i = screen;
+ if (TIME_AFTER(current_tick, next_update) || force)
{
- FOR_NB_SCREENS(i)
+ if (sb_skin_get_state(i))
{
- if (sb_skin_get_state(i))
- {
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- /* currently, all remotes are readable without backlight
- * so still update those */
- if (lcd_active() || (i != SCREEN_MAIN))
+ /* currently, all remotes are readable without backlight
+ * so still update those */
+ if (lcd_active() || (i != SCREEN_MAIN))
#endif
- skin_update(&sb_skin[i], forced_draw?
- WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
- }
+ skin_update(&sb_skin[i], force?
+ WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC);
}
- next_update = current_tick + update_delay; /* don't update too often */
- sb_skin[SCREEN_MAIN].sync_data->do_full_update = false;
}
+ next_update = current_tick + update_delay; /* don't update too often */
+ sb_skin[SCREEN_MAIN].sync_data->do_full_update = false;
+}
+
+void do_sbs_update_callback(void *param)
+{
+ (void)param;
+ /* the WPS handles changing the actual id3 data in the id3 pointers
+ * we imported, we just want a full update */
+ sb_skin_sync_data.do_full_update = true;
+ /* force timeout in wps main loop, so that the update is instantly */
+ queue_post(&button_queue, BUTTON_NONE, 0);
}
void sb_skin_set_update_delay(int delay)
@@ -209,7 +163,6 @@ void sb_skin_init(void)
/* Currently no seperate wps_state needed/possible
so use the only available ( "global" ) one */
sb_skin[i].state = &wps_state;
- sb_skin_sync_data.statusbars = VP_SB_HIDE_ALL;
sb_skin[i].sync_data = &sb_skin_sync_data;
}
}
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h
index 7c81eb8d01..6016c293b0 100644
--- a/apps/gui/statusbar-skinned.h
+++ b/apps/gui/statusbar-skinned.h
@@ -35,9 +35,9 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile);
/* probably temporary, to shut the classic statusbar up */
bool sb_skin_get_state(enum screen_type screen);
-void sb_skin_set_state(int state, enum screen_type screen);
void sb_skin_init(void);
struct viewport *sb_skin_get_info_vp(enum screen_type screen);
+void sb_skin_update(enum screen_type screen, bool force);
void sb_skin_set_update_delay(int delay);
@@ -48,4 +48,5 @@ void sb_skin_set_update_delay(int delay);
#define sb_skin_set_state(a,b)
#define sb_skin_get_state(a)
#endif
+void do_sbs_update_callback(void *param);
#endif /* __STATUSBAR_SKINNED_H__ */
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index f6285f995e..29d88daf06 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -150,7 +150,7 @@ static void usb_screen_fix_viewports(struct screen *screen,
viewport_set_defaults(parent, screen->screen_type);
if (parent->width < logo_width || parent->height < logo_height)
- viewport_set_fullscreen(parent, screen->screen_type);
+ viewportmanager_theme_enable(screen->screen_type, false, parent);
*logo = *parent;
logo->x = parent->x + parent->width - logo_width;
@@ -180,8 +180,6 @@ static void usb_screen_fix_viewports(struct screen *screen,
static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
{
int i;
- int usb_bars = VP_SB_ALLSCREENS; /* force statusbars */
-
lcd_clear_display();
#ifdef HAVE_LCD_REMOTE
lcd_remote_clear_display();
@@ -236,18 +234,12 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
screen->update_viewport();
screen->set_viewport(NULL);
-
- /* force statusbar by ignoring the setting */
- usb_bars |= VP_SB_IGNORE_SETTING(i);
}
-
- viewportmanager_set_statusbar(usb_bars);
}
void gui_usb_screen_run(void)
{
int i;
- int old_bars = viewportmanager_get_statusbar();
struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS];
#if defined HAVE_TOUCHSCREEN
enum touchscreen_mode old_mode = touchscreen_get_mode();
@@ -319,9 +311,8 @@ void gui_usb_screen_run(void)
FOR_NB_SCREENS(i)
{
screens[i].backlight_on();
+ viewportmanager_theme_undo(i);
}
- viewportmanager_set_statusbar(old_bars);
- send_event(GUI_EVENT_REFRESH, NULL);
}
#endif /* !defined(USB_NONE) */
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 9a7cfbd3cb..fbf5ea82ad 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -28,6 +28,8 @@
#include "screen_access.h"
#include "settings.h"
#include "misc.h"
+#include "panic.h"
+#include "viewport.h"
/*some short cuts for fg/bg/line selector handling */
#ifdef HAVE_LCD_COLOR
@@ -38,10 +40,6 @@
#define BG_FALLBACK LCD_DEFAULT_BG
#endif
-#ifdef HAVE_LCD_BITMAP
-static void set_default_align_flags(struct viewport *vp);
-#endif
-
/* all below isn't needed for pc tools (i.e. checkwps/wps editor)
* only viewport_parse_viewport() is */
#ifndef __PCTOOL__
@@ -56,115 +54,187 @@ static void set_default_align_flags(struct viewport *vp);
#endif
#include "statusbar-skinned.h"
#include "debug.h"
+#include "viewport.h"
-
-static int statusbar_enabled = 0;
-
-#ifdef HAVE_LCD_BITMAP
-static struct {
+#define VPSTACK_DEPTH 16
+struct viewport_stack_item
+{
struct viewport* vp;
- int active[NB_SCREENS];
-} ui_vp_info;
+ bool enabled;
+};
-static struct viewport custom_vp[NB_SCREENS];
-
-/* callbacks for GUI_EVENT_* events */
-static void viewportmanager_ui_vp_changed(void *param);
-static void viewportmanager_call_draw_func(void *param);
-static void statusbar_toggled(void* param);
-static unsigned viewport_init_ui_vp(void);
-#endif
+#ifdef HAVE_LCD_BITMAP
static void viewportmanager_redraw(void* data);
+
+static int theme_stack_top[NB_SCREENS]; /* the last item added */
+static struct viewport_stack_item theme_stack[NB_SCREENS][VPSTACK_DEPTH];
+static bool is_theme_enabled(enum screen_type screen);
-int viewport_get_nb_lines(const struct viewport *vp)
+static void toggle_theme(void)
{
-#ifdef HAVE_LCD_BITMAP
- return vp->height/font_get(vp->font)->height;
-#else
- (void)vp;
- return 2;
+ bool enable_event = false;
+ static bool was_enabled[NB_SCREENS] = {false};
+ int i;
+ FOR_NB_SCREENS(i)
+ {
+ enable_event = enable_event || is_theme_enabled(i);
+ }
+ if (enable_event)
+ {
+ add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw);
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+ add_event(LCD_EVENT_ACTIVATION, false, do_sbs_update_callback);
#endif
-}
-
-static bool showing_bars(enum screen_type screen)
-{
- if (statusbar_enabled & VP_SB_ONSCREEN(screen))
+ add_event(PLAYBACK_EVENT_TRACK_CHANGE, false,
+ do_sbs_update_callback);
+ add_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, false,
+ do_sbs_update_callback);
+
+ /* remove the left overs from the previous screen.
+ * could cause a tiny flicker. Redo your screen code if that happens */
+ FOR_NB_SCREENS(i)
+ {
+ if (!was_enabled[i])
+ {
+ struct viewport deadspace, user;
+ viewport_set_defaults(&user, i);
+ deadspace = user; /* get colours and everything */
+ /* above */
+ deadspace.x = 0;
+ deadspace.y = 0;
+ deadspace.width = screens[i].lcdwidth;
+ deadspace.height = user.y;
+ if (deadspace.width && deadspace.height)
+ {
+ screens[i].set_viewport(&deadspace);
+ screens[i].clear_viewport();
+ screens[i].update_viewport();
+ }
+ /* below */
+ deadspace.y = user.y + user.height;
+ deadspace.height = screens[i].lcdheight - deadspace.y;
+ if (deadspace.width && deadspace.height)
+ {
+ screens[i].set_viewport(&deadspace);
+ screens[i].clear_viewport();
+ screens[i].update_viewport();
+ }
+ /* left */
+ deadspace.x = 0;
+ deadspace.y = 0;
+ deadspace.width = user.x;
+ deadspace.height = screens[i].lcdheight;
+ if (deadspace.width && deadspace.height)
+ {
+ screens[i].set_viewport(&deadspace);
+ screens[i].clear_viewport();
+ screens[i].update_viewport();
+ }
+ /* below */
+ deadspace.x = user.x + user.width;
+ deadspace.width = screens[i].lcdwidth - deadspace.x;
+ if (deadspace.width && deadspace.height)
+ {
+ screens[i].set_viewport(&deadspace);
+ screens[i].clear_viewport();
+ screens[i].update_viewport();
+ }
+ }
+ }
+ send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
+ }
+ else
{
-#ifdef HAVE_LCD_BITMAP
- int ignore;
- ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen);
- return ignore || (statusbar_position(screen) != STATUSBAR_OFF);
-#else
- return true;
+ FOR_NB_SCREENS(i)
+ screens[i].stop_scroll();
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+ remove_event(LCD_EVENT_ACTIVATION, do_sbs_update_callback);
#endif
+ remove_event(PLAYBACK_EVENT_TRACK_CHANGE, do_sbs_update_callback);
+ remove_event(PLAYBACK_EVENT_NEXTTRACKID3_AVAILABLE, do_sbs_update_callback);
+ remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw);
}
- return false;
+
+ FOR_NB_SCREENS(i)
+ was_enabled[i] = is_theme_enabled(i);
}
-
-void viewportmanager_init(void)
+void viewportmanager_theme_enable(enum screen_type screen, bool enable,
+ struct viewport *viewport)
{
-#ifdef HAVE_LCD_BITMAP
- add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggled);
-#endif
- viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
+ int top = ++theme_stack_top[screen];
+ if (top >= VPSTACK_DEPTH-1)
+ panicf("Stack overflow... viewportmanager");
+ theme_stack[screen][top].enabled = enable;
+ theme_stack[screen][top].vp = viewport;
+ toggle_theme();
+ /* then be nice and set the viewport up */
+ if (viewport)
+ viewport_set_defaults(viewport, screen);
}
-int viewportmanager_get_statusbar(void)
+void viewportmanager_theme_undo(enum screen_type screen)
{
- return statusbar_enabled;
+ int top = --theme_stack_top[screen];
+ if (top < 0)
+ panicf("Stack underflow... viewportmanager");
+
+ toggle_theme();
}
-int viewportmanager_set_statusbar(const int enabled)
+
+static bool is_theme_enabled(enum screen_type screen)
{
- int old = statusbar_enabled;
- int i;
-
- statusbar_enabled = enabled;
+ int top = theme_stack_top[screen];
+ return theme_stack[screen][top].enabled;
+}
- FOR_NB_SCREENS(i)
- {
- if (showing_bars(i)
- && statusbar_position(i) != STATUSBAR_CUSTOM)
- {
- add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw);
- gui_statusbar_draw(&statusbars.statusbars[i], true);
- }
- else
- remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw);
- }
+static bool custom_vp_loaded_ok[NB_SCREENS];
+static struct viewport custom_vp[NB_SCREENS];
+static unsigned viewport_init_ui_vp(void);
+#endif /* HAVE_LCD_BITMAP */
+
+int viewport_get_nb_lines(const struct viewport *vp)
+{
#ifdef HAVE_LCD_BITMAP
- FOR_NB_SCREENS(i)
- {
- sb_skin_set_state(showing_bars(i)
- && statusbar_position(i) == STATUSBAR_CUSTOM, i);
- }
+ return vp->height/font_get(vp->font)->height;
+#else
+ (void)vp;
+ return 2;
#endif
- return old;
}
static void viewportmanager_redraw(void* data)
{
int i;
-
FOR_NB_SCREENS(i)
{
- if (showing_bars(i)
- && statusbar_position(i) != STATUSBAR_CUSTOM)
+#ifdef HAVE_LCD_BITMAP
+ if (statusbar_position(i) == STATUSBAR_CUSTOM)
+ sb_skin_update(i, NULL != data);
+ else if (statusbar_position(i) != STATUSBAR_OFF)
+#endif
gui_statusbar_draw(&statusbars.statusbars[i], NULL != data);
}
}
-#ifdef HAVE_LCD_BITMAP
-static void statusbar_toggled(void* param)
+void viewportmanager_init()
{
- (void)param;
- /* update vp manager for the new setting and reposition vps
- * if necessary */
- viewportmanager_theme_changed(THEME_STATUSBAR);
+#ifdef HAVE_LCD_BITMAP
+ int i;
+ FOR_NB_SCREENS(i)
+ {
+ theme_stack_top[i] = -1; /* the next call fixes this to 0 */
+ /* We always want the theme enabled by default... */
+ viewportmanager_theme_enable(i, true, NULL);
+ }
+#else
+ add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw);
+#endif
}
+#ifdef HAVE_LCD_BITMAP
void viewportmanager_theme_changed(const int which)
{
int i;
@@ -177,91 +247,25 @@ void viewportmanager_theme_changed(const int which)
#endif
if (which & THEME_UI_VIEWPORT)
{
- int retval = viewport_init_ui_vp();
- /* reset the ui viewport */
- FOR_NB_SCREENS(i)
- ui_vp_info.active[i] = retval & BIT_N(i);
- /* and point to it */
- ui_vp_info.vp = custom_vp;
+ viewport_init_ui_vp();
}
- else if (which & THEME_LANGUAGE)
- { /* THEME_UI_VIEWPORT handles rtl already */
- FOR_NB_SCREENS(i)
- set_default_align_flags(&custom_vp[i]);
+ if (which & THEME_LANGUAGE)
+ {
}
if (which & THEME_STATUSBAR)
{
- statusbar_enabled = 0;
FOR_NB_SCREENS(i)
{
- if (statusbar_position(i) != STATUSBAR_OFF)
- statusbar_enabled |= VP_SB_ONSCREEN(i);
+ /* This can probably be done better...
+ * disable the theme so it's forced to do a full redraw */
+ viewportmanager_theme_enable(i, false, NULL);
+ viewportmanager_theme_undo(i);
}
-
- viewportmanager_set_statusbar(statusbar_enabled);
-
- /* reposition viewport to fit statusbar, only if not using the ui vp */
-
- FOR_NB_SCREENS(i)
- {
- if (!ui_vp_info.active[i])
- viewport_set_fullscreen(&custom_vp[i], i);
- }
- }
-
- int event_add = 0;
- FOR_NB_SCREENS(i)
- {
- event_add |= ui_vp_info.active[i];
- event_add |= (statusbar_position(i) == STATUSBAR_CUSTOM);
- }
-
- /* add one of those to ensure the draw function is called always */
- if (event_add)
- {
- add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed);
- remove_event(GUI_EVENT_REFRESH, viewportmanager_call_draw_func);
- }
- else
- {
- add_event(GUI_EVENT_REFRESH, false, viewportmanager_call_draw_func);
- remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed);
}
-
send_event(GUI_EVENT_THEME_CHANGED, NULL);
}
/*
- * simply calls a function that draws stuff, this exists to ensure the
- * drawing function call in the GUI_EVENT_REFRESH event
- *
- * param should be 'void func(void)' */
-static void viewportmanager_call_draw_func(void *param)
-{
- /* cast param to a function */
- void (*draw_func)(void) = ((void(*)(void))param);
- /* call the passed function which will redraw the content of
- * the current screen */
- if (draw_func != NULL)
- draw_func();
-}
-
-static void viewportmanager_ui_vp_changed(void *param)
-{
- /* if the user changed the theme, we need to initiate a full redraw */
- int i;
- /* start with clearing the screen */
- FOR_NB_SCREENS(i)
- screens[i].clear_display();
- /* redraw the statusbar if it was enabled */
- send_event(GUI_EVENT_ACTIONUPDATE, (void*)true);
- /* call redraw function */
- viewportmanager_call_draw_func(param);
- FOR_NB_SCREENS(i)
- screens[i].update();
-}
-
-/*
* (re)parse the UI vp from the settings
* - Returns
* 0 if no UI vp is used at all
@@ -270,7 +274,7 @@ static void viewportmanager_ui_vp_changed(void *param)
static unsigned viewport_init_ui_vp(void)
{
int screen;
- unsigned ret = 0;
+ const char *ret = NULL;
char *setting;
FOR_NB_SCREENS(screen)
{
@@ -280,15 +284,13 @@ static unsigned viewport_init_ui_vp(void)
else
#endif
setting = global_settings.ui_vp_config;
-
- if (!(viewport_parse_viewport(&custom_vp[screen], screen,
- setting, ',')))
- viewport_set_fullscreen(&custom_vp[screen], screen);
- else
- ret |= BIT_N(screen);
+ ret = viewport_parse_viewport(&custom_vp[screen], screen,
+ setting, ',');
+
+ custom_vp_loaded_ok[screen] = ret?true:false;
}
- return ret;
+ return true; /* meh fixme */
}
#ifdef HAVE_TOUCHSCREEN
@@ -301,6 +303,16 @@ bool viewport_point_within_vp(const struct viewport *vp,
return (is_x && is_y);
}
#endif /* HAVE_TOUCHSCREEN */
+
+static void set_default_align_flags(struct viewport *vp)
+{
+ vp->flags &= ~VP_FLAG_ALIGNMENT_MASK;
+#ifndef __PCTOOL__
+ if (UNLIKELY(lang_is_rtl()))
+ vp->flags |= VP_FLAG_ALIGN_RIGHT;
+#endif
+}
+
#endif /* HAVE_LCD_BITMAP */
#endif /* __PCTOOL__ */
@@ -363,11 +375,17 @@ void viewport_set_defaults(struct viewport *vp,
#if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__)
struct viewport *sbs_area = NULL, *user_setting = NULL;
+ if (!is_theme_enabled(screen))
+ {
+ viewport_set_fullscreen(vp, screen);
+ return;
+ }
/* get the two viewports */
- if (ui_vp_info.active[screen])
- user_setting = &ui_vp_info.vp[screen];
+ if (custom_vp_loaded_ok[screen])
+ user_setting = &custom_vp[screen];
if (sb_skin_get_state(screen))
sbs_area = sb_skin_get_info_vp(screen);
+
/* have both? get their intersection */
if (sbs_area && user_setting)
{
@@ -380,6 +398,7 @@ void viewport_set_defaults(struct viewport *vp,
{
/* copy from ui vp first (for other field),fix coordinates after */
*vp = *user_setting;
+ set_default_align_flags(vp);
vp->x = MAX(a->x, b->x);
vp->y = MAX(a->y, b->y);
vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x;
@@ -405,16 +424,6 @@ void viewport_set_defaults(struct viewport *vp,
#ifdef HAVE_LCD_BITMAP
-
-static void set_default_align_flags(struct viewport *vp)
-{
- vp->flags &= ~VP_FLAG_ALIGNMENT_MASK;
-#ifndef __PCTOOL__
- if (UNLIKELY(lang_is_rtl()))
- vp->flags |= VP_FLAG_ALIGN_RIGHT;
-#endif
-}
-
const char* viewport_parse_viewport(struct viewport *vp,
enum screen_type screen,
const char *bufptr,
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 54424339ca..6cb8d1f574 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -31,60 +31,30 @@
/* return the number of text lines in the vp viewport */
int viewport_get_nb_lines(const struct viewport *vp);
-void viewport_set_defaults(struct viewport *vp,
- const enum screen_type screen);
-
-/* Used to specify which screens the statusbar (SB) should be displayed on.
- *
- * The parameter is a bit OR'ed combination of the following (screen is
- * SCREEN_MAIN or SCREEN_REMOTE from screen_access.h):
- *
- * VP_SB_HIDE_ALL means "hide the SB on all screens"
- * VP_SB_ONSCREEN(screen) means "display the SB on the given screen
- * as specified by the SB setting for that screen"
- * VP_SB_IGNORE_SETTING(screen) means "ignore the SB setting for that screen"
- * VP_SB_ALLSCREENS means "VP_SB_ONSCREEN for all screens"
- *
- * In most cases, VP_SB_ALLSCREENS should be used which means display the SB
- * as specified by the settings.
- * For the WPS (and other possible exceptions) use VP_SB_IGNORE_SETTING() to
- * FORCE the statusbar on for the given screen (i.e it will show regardless
- * of the setting)
- *
- * Returns the status before the call. This value can be used to restore the
- * SB "displaying rules".
- */
-
-
#define THEME_STATUSBAR (BIT_N(0))
#define THEME_UI_VIEWPORT (BIT_N(1))
#define THEME_BUTTONBAR (BIT_N(2))
#define THEME_LANGUAGE (BIT_N(3))
#define THEME_ALL (~(0u))
-#define VP_SB_HIDE_ALL 0
-#define VP_SB_ONSCREEN(screen) BIT_N(screen)
-#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen)
-#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1))
-
#ifndef __PCTOOL__
/*
* Initialize the viewportmanager, which in turns initializes the UI vp and
* statusbar stuff
*/
void viewportmanager_init(void);
-int viewportmanager_get_statusbar(void);
-int viewportmanager_set_statusbar(const int enabled);
-/*
- * Initializes the given viewport with maximum dimensions minus status- and
- * buttonbar
- */
+void viewport_set_defaults(struct viewport *vp,
+ const enum screen_type screen);
void viewport_set_fullscreen(struct viewport *vp,
- const enum screen_type screen);
+ const enum screen_type screen);
#ifdef HAVE_LCD_BITMAP
+void viewportmanager_theme_enable(enum screen_type screen, bool enable,
+ struct viewport *viewport);
+
+void viewportmanager_theme_undo(enum screen_type screen);
/* call this when a theme changed */
void viewportmanager_theme_changed(const int);
@@ -95,9 +65,9 @@ bool viewport_point_within_vp(const struct viewport *vp,
#endif
#else /* HAVE_LCD_CHARCELL */
-#define viewport_set_current_vp(a)
-#define viewport_get_current_vp() NULL
#define viewportmanager_theme_changed(a)
+#define viewportmanager_theme_enable(...)
+#define viewportmanager_theme_undo(...)
#endif
#endif /* __PCTOOL__ */
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 757160a586..e500f1c2d9 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -88,9 +88,6 @@ static struct wps_sync_data wps_sync_data = { .do_full_update = false
static void wps_state_init(void);
static void track_changed_callback(void *param);
static void nextid3available_callback(void* param);
-#ifdef HAVE_LCD_BITMAP
-static void statusbar_toggle_handler(void *data);
-#endif
#define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
#ifdef HAVE_REMOTE_LCD
@@ -562,24 +559,21 @@ static void wps_lcd_activation_hook(void *param)
static void gwps_leave_wps(void)
{
- int i, oldbars = VP_SB_HIDE_ALL;
+ int i;
FOR_NB_SCREENS(i)
{
gui_wps[i].display->stop_scroll();
gui_wps[i].display->backdrop_show(BACKDROP_MAIN);
- if (statusbar_position(i) != STATUSBAR_OFF)
- oldbars |= VP_SB_ONSCREEN(i);
+ viewportmanager_theme_undo(i);
}
- viewportmanager_set_statusbar(oldbars);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Play safe and unregister the hook */
remove_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook);
#endif
/* unhandle statusbar update delay */
sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY);
- send_event(GUI_EVENT_REFRESH, NULL);
}
/*
@@ -591,6 +585,14 @@ static void gwps_enter_wps(void)
{
struct gui_wps *gwps = &gui_wps[i];
struct screen *display = gwps->display;
+#ifdef HAVE_LCD_BITMAP
+ bool draw = false;
+ if (gui_wps[i].data->wps_sb_tag)
+ draw = gui_wps[i].data->show_sb_on_wps;
+ else if (statusbar_position(i) != STATUSBAR_OFF)
+ draw = true;
+#endif
+ viewportmanager_theme_enable(i, draw, NULL);
display->stop_scroll();
/* Update the values in the first (default) viewport - in case the user
@@ -725,8 +727,6 @@ long gui_wps_show(void)
#ifdef HAVE_LCD_CHARCELLS
status_set_audio(true);
status_set_param(false);
-#else
- statusbar_toggle_handler(NULL);
#endif
#ifdef AB_REPEAT_ENABLE
@@ -734,7 +734,7 @@ long gui_wps_show(void)
ab_reset_markers();
#endif
wps_state_init();
-
+
while ( 1 )
{
bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false;
@@ -1176,8 +1176,8 @@ long gui_wps_show(void)
sb_skin_set_update_delay(0);
FOR_NB_SCREENS(i)
gui_wps[i].display->backdrop_show(BACKDROP_SKIN_WPS);
- send_event(GUI_EVENT_REFRESH, gwps_enter_wps);
wps_sync_data.do_full_update = update = false;
+ gwps_enter_wps();
}
else if (wps_sync_data.do_full_update || update)
{
@@ -1271,33 +1271,6 @@ static void wps_state_init(void)
}
-#ifdef HAVE_LCD_BITMAP
-static void statusbar_toggle_handler(void *data)
-{
- (void)data;
- int i;
-
- int *wpsbars = &wps_sync_data.statusbars;
- *wpsbars = VP_SB_HIDE_ALL;
- FOR_NB_SCREENS(i)
- { /* fix viewports if needed */
- skin_statusbar_changed(&gui_wps[i]);
-
- bool draw = false;
-
- /* fix up gui_wps::statusbars, so that the viewportmanager accepts it*/
- if (gui_wps[i].data->wps_sb_tag)
- draw = gui_wps[i].data->show_sb_on_wps;
- else if (statusbar_position(i) != STATUSBAR_OFF)
- draw = true;
- if (draw)
- *wpsbars |=
- (VP_SB_ONSCREEN(i) | VP_SB_IGNORE_SETTING(i));
- }
-}
-#endif
-
-
void gui_sync_wps_init(void)
{
int i;
@@ -1315,11 +1288,7 @@ void gui_sync_wps_init(void)
gui_wps[i].display->backdrop_unload(BACKDROP_SKIN_WPS);
/* must point to the same struct for both screens */
gui_wps[i].sync_data = &wps_sync_data;
- gui_wps[i].sync_data->statusbars = VP_SB_ALLSCREENS;
}
-#ifdef HAVE_LCD_BITMAP
- add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggle_handler);
-#endif
}