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
This commit is contained in:
Jonathan Gordon 2009-12-09 07:25:46 +00:00
parent 85aad9b397
commit b2eb44ce0e
24 changed files with 292 additions and 426 deletions

View file

@ -50,7 +50,6 @@ enum {
enum {
GUI_EVENT_STATUSBAR_TOGGLE = (EVENT_CLASS_GUI|1),
GUI_EVENT_ACTIONUPDATE,
GUI_EVENT_REFRESH,
GUI_EVENT_THEME_CHANGED,
};

View file

@ -2652,13 +2652,15 @@ static const struct the_menu_item menuitems[] = {
};
static int menu_action_callback(int btn, struct gui_synclist *lists)
{
int i;
if (btn == ACTION_STD_OK)
{
int oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, false, NULL);
menuitems[gui_synclist_get_sel_pos(lists)].function();
btn = ACTION_REDRAW;
send_event(GUI_EVENT_REFRESH, NULL);
viewportmanager_set_statusbar(oldbars);
FOR_NB_SCREENS(i)
viewportmanager_theme_undo(i);
}
return btn;
}

View file

@ -528,9 +528,6 @@ int ft_enter(struct tree_context* c)
splash(0, ID2P(LANG_WAIT));
if (!settings_load_config(buf,true))
break;
/* redraw the UI in case the user setting changed apparence */
send_event(GUI_EVENT_REFRESH, tree_drawlists);
splash(HZ, ID2P(LANG_SETTINGS_LOADED));
break;
@ -652,8 +649,6 @@ int ft_enter(struct tree_context* c)
}
}
send_event(GUI_EVENT_REFRESH, tree_drawlists);
if ( play ) {
/* the resume_index must always be the index in the
shuffled list in case shuffle is enabled */

View file

@ -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;
}

View file

@ -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);

View file

@ -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)

View file

@ -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,72 +102,21 @@ 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)
{
FOR_NB_SCREENS(i)
int i = screen;
if (TIME_AFTER(current_tick, next_update) || force)
{
if (sb_skin_get_state(i))
{
@ -180,13 +125,22 @@ static void sb_skin_update(void* param)
* so still update those */
if (lcd_active() || (i != SCREEN_MAIN))
#endif
skin_update(&sb_skin[i], forced_draw?
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;
}
}
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;
}
}

View file

@ -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__ */

View file

@ -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) */

View file

@ -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,25 +54,146 @@ 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;
#define VPSTACK_DEPTH 16
struct viewport_stack_item
{
struct viewport* vp;
bool enabled;
};
#ifdef HAVE_LCD_BITMAP
static struct {
struct viewport* vp;
int active[NB_SCREENS];
} ui_vp_info;
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);
static void toggle_theme(void)
{
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
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
{
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);
}
FOR_NB_SCREENS(i)
was_enabled[i] = is_theme_enabled(i);
}
void viewportmanager_theme_enable(enum screen_type screen, bool enable,
struct viewport *viewport)
{
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);
}
void viewportmanager_theme_undo(enum screen_type screen)
{
int top = --theme_stack_top[screen];
if (top < 0)
panicf("Stack underflow... viewportmanager");
toggle_theme();
}
static bool is_theme_enabled(enum screen_type screen)
{
int top = theme_stack_top[screen];
return theme_stack[screen][top].enabled;
}
static bool custom_vp_loaded_ok[NB_SCREENS];
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
static void viewportmanager_redraw(void* data);
#endif /* HAVE_LCD_BITMAP */
int viewport_get_nb_lines(const struct viewport *vp)
{
@ -86,85 +205,36 @@ int viewport_get_nb_lines(const struct viewport *vp)
#endif
}
static bool showing_bars(enum screen_type screen)
{
if (statusbar_enabled & VP_SB_ONSCREEN(screen))
{
#ifdef HAVE_LCD_BITMAP
int ignore;
ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen);
return ignore || (statusbar_position(screen) != STATUSBAR_OFF);
#else
return true;
#endif
}
return false;
}
void viewportmanager_init(void)
{
#ifdef HAVE_LCD_BITMAP
add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, statusbar_toggled);
#endif
viewportmanager_set_statusbar(VP_SB_ALLSCREENS);
}
int viewportmanager_get_statusbar(void)
{
return statusbar_enabled;
}
int viewportmanager_set_statusbar(const int enabled)
{
int old = statusbar_enabled;
int i;
statusbar_enabled = 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);
}
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
{
sb_skin_set_state(showing_bars(i)
&& statusbar_position(i) == STATUSBAR_CUSTOM, i);
}
#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,90 +247,24 @@ 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);
}
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);
/* 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);
}
}
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
@ -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)
{
@ -281,14 +285,12 @@ static unsigned viewport_init_ui_vp(void)
#endif
setting = global_settings.ui_vp_config;
ret = viewport_parse_viewport(&custom_vp[screen], screen,
setting, ',');
if (!(viewport_parse_viewport(&custom_vp[screen], screen,
setting, ',')))
viewport_set_fullscreen(&custom_vp[screen], screen);
else
ret |= BIT_N(screen);
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,

View file

@ -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);
#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__ */

View file

@ -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
@ -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
}

View file

@ -329,7 +329,7 @@ static void init(void)
storage_init();
settings_reset();
settings_load(SETTINGS_ALL);
settings_apply(true);
settings_apply(false);
init_dircache(true);
init_dircache(false);
#ifdef HAVE_TAGCACHE
@ -367,6 +367,8 @@ static void init(void)
audio_init();
button_clear_queue(); /* Empty the keyboard buffer */
settings_apply(true);
}
#else
@ -560,7 +562,7 @@ static void init(void)
#endif
}
settings_apply(true);
settings_apply(false);
init_dircache(false);
#ifdef HAVE_TAGCACHE
init_tagcache();
@ -625,6 +627,8 @@ static void init(void)
#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
check_bootfile(false); /* remember write time and filesize */
#endif
settings_apply(true);
}
#ifdef CPU_PP

View file

@ -343,8 +343,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
const struct menu_item_ex *temp, *menu;
int ret = 0, i;
bool redraw_lists;
int oldbars = viewportmanager_get_statusbar();
viewportmanager_set_statusbar(hide_bars ? VP_SB_HIDE_ALL : oldbars);
FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, true/*!hide_bars*/, NULL);
const struct menu_item_ex *menu_stack[MAX_MENUS];
int menu_stack_selected_item[MAX_MENUS];
@ -686,7 +686,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
*start_selected = get_menu_selection(
gui_synclist_get_sel_pos(&lists), menu);
}
viewportmanager_set_statusbar(oldbars);
FOR_NB_SCREENS(i)
viewportmanager_theme_undo(i);
return ret;
}

View file

@ -391,7 +391,8 @@ bool eq_menu_graphical(void)
enum eq_type current_type;
char buf[24];
int i, w, h, height, start_item, nb_eq_sliders[NB_SCREENS];
int barsenabled = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, false, NULL);
FOR_NB_SCREENS(i) {
@ -570,12 +571,13 @@ bool eq_menu_graphical(void)
}
/* Reset screen settings */
FOR_NB_SCREENS(i) {
FOR_NB_SCREENS(i)
{
screens[i].setfont(FONT_UI);
screens[i].clear_display();
screens[i].set_viewport(NULL);
viewportmanager_theme_undo(i);
}
viewportmanager_set_statusbar(barsenabled);
return result;
}

View file

@ -49,7 +49,6 @@ static int clear_main_backdrop(void)
global_settings.backdrop_file[0]=0;
backdrop_unload(BACKDROP_MAIN);
backdrop_show(BACKDROP_MAIN);
send_event(GUI_EVENT_REFRESH, NULL);
settings_save();
return 0;
}
@ -164,11 +163,6 @@ static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item
case ACTION_EXIT_MENUITEM:
send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL);
send_event(GUI_EVENT_ACTIONUPDATE, (void*)true);
if ((old_bar[screen] == STATUSBAR_CUSTOM)
|| (statusbar_position(screen) == STATUSBAR_CUSTOM))
send_event(GUI_EVENT_REFRESH, NULL);
else
gui_statusbar_changed(screen, old_bar[screen]);
break;
}
return ACTION_REDRAW;

View file

@ -230,7 +230,6 @@ static const struct plugin_api rockbox_api = {
lcd_remote_bitmap,
#endif
viewport_set_defaults,
viewportmanager_set_statusbar,
/* list */
gui_synclist_init,
@ -680,8 +679,7 @@ static const struct plugin_api rockbox_api = {
int plugin_load(const char* plugin, const void* parameter)
{
int rc;
int oldbars;
int rc, i;
struct plugin_header *hdr;
#ifdef SIMULATOR
void *pd;
@ -787,7 +785,8 @@ int plugin_load(const char* plugin, const void* parameter)
lcd_remote_update();
#endif
oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, false, NULL);
cpucache_invalidate();
@ -834,12 +833,8 @@ int plugin_load(const char* plugin, const void* parameter)
#endif
#endif
viewportmanager_set_statusbar(oldbars);
if (rc != PLUGIN_GOTO_WPS)
{
send_event(GUI_EVENT_REFRESH, NULL);
}
FOR_NB_SCREENS(i)
viewportmanager_theme_undo(i);
if (pfn_tsr_exit == NULL)
plugin_loaded = false;

View file

@ -135,12 +135,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 175
#define PLUGIN_API_VERSION 176
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 173
#define PLUGIN_MIN_API_VERSION 176
/* plugin return codes */
enum plugin_status {
@ -335,7 +335,6 @@ struct plugin_api {
int height);
#endif
void (*viewport_set_defaults)(struct viewport *vp, enum screen_type screen);
int (*viewportmanager_set_statusbar)(int enable_status);
/* list */
void (*gui_synclist_init)(struct gui_synclist * lists,
list_get_name callback_get_item_name, void * data,

View file

@ -291,10 +291,10 @@ int kbd_input(char* text, int buflen)
unsigned char morse_code = 0;
int morse_tick = 0;
#endif
int oldbars = viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
FOR_NB_SCREENS(l)
{
struct keyboard_parameters *pm = &param[l];
viewportmanager_theme_enable(l, false, NULL);
#if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96
struct screen *sc = &screens[l];
@ -1126,9 +1126,9 @@ int kbd_input(char* text, int buflen)
#endif /* HAVE_MORSE_INPUT && KBD_TOGGLE_INPUT */
FOR_NB_SCREENS(l)
{
screens[l].setfont(FONT_UI);
viewportmanager_set_statusbar(oldbars);
send_event(GUI_EVENT_REFRESH, NULL);
viewportmanager_theme_undo(l);
}
return ret;
}

View file

@ -494,7 +494,6 @@ int radio_screen(void)
int button_timeout = current_tick + (2*HZ);
#endif
struct viewport vp[NB_SCREENS];
int oldbars = 0, fmbars = VP_SB_ALLSCREENS;
#ifdef HAVE_BUTTONBAR
struct gui_buttonbar buttonbar;
gui_buttonbar_init(&buttonbar);
@ -505,9 +504,6 @@ int radio_screen(void)
in_screen = true;
/* always display status bar in radio screen for now */
FOR_NB_SCREENS(i)
fmbars |= VP_SB_IGNORE_SETTING(i);
oldbars = viewportmanager_set_statusbar(fmbars);
FOR_NB_SCREENS(i)
{
viewport_set_defaults(&vp[i], i);
@ -761,12 +757,12 @@ int radio_screen(void)
break;
case ACTION_FM_MENU:
viewportmanager_set_statusbar(oldbars);
FOR_NB_SCREENS(i)
{
screens[i].scroll_stop(&vp[i]);
}
radio_menu();
curr_preset = find_preset(curr_freq);
viewportmanager_set_statusbar(fmbars);
FOR_NB_SCREENS(i)
{
screens[i].set_viewport(&vp[i]);
@ -798,9 +794,7 @@ int radio_screen(void)
break;
}
viewportmanager_set_statusbar(oldbars);
handle_radio_presets();
viewportmanager_set_statusbar(fmbars);
FOR_NB_SCREENS(i)
{
screens[i].set_viewport(&vp[i]);
@ -932,11 +926,8 @@ int radio_screen(void)
FOR_NB_SCREENS(i)
{
screens[i].set_viewport(&vp[i]);
peak_meter_screen(&screens[i],0,
STATUSBAR_HEIGHT + fh*(top_of_screen + 4),
fh);
screens[i].update_rect(0,
STATUSBAR_HEIGHT + fh*(top_of_screen + 4),
peak_meter_screen(&screens[i],0, fh*(top_of_screen + 4),fh);
screens[i].update_rect(0, fh*(top_of_screen + 4),
screens[i].getwidth(), fh);
screens[i].set_viewport(NULL);
}
@ -1134,8 +1125,9 @@ int radio_screen(void)
cpu_idle_mode(false);
#endif
FOR_NB_SCREENS(i)
{
screens[i].scroll_stop(&vp[i]);
viewportmanager_set_statusbar(oldbars);
}
in_screen = false;
#if CONFIG_CODEC != SWCODEC
return have_recorded;

View file

@ -1019,7 +1019,6 @@ bool recording_screen(bool no_source)
int peak_l, peak_r;
int balance = 0;
#endif
int oldbars, recbars = VP_SB_ALLSCREENS;
int i;
int pm_x[NB_SCREENS]; /* peakmeter (and trigger bar) x pos */
int pm_y[NB_SCREENS]; /* peakmeter y pos */
@ -1081,9 +1080,6 @@ bool recording_screen(bool no_source)
#endif
/* viewport init and calculations that only needs to be done once */
FOR_NB_SCREENS(i)
recbars |= VP_SB_IGNORE_SETTING(i);
oldbars = viewportmanager_set_statusbar(recbars);
FOR_NB_SCREENS(i)
{
struct viewport *v;
@ -1123,6 +1119,9 @@ bool recording_screen(bool no_source)
gui_synclist_init(&lists, reclist_get_name, NULL, false, 1, vp_list);
gui_synclist_set_title(&lists, NULL, Icon_NOICON);
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
/* start of the loop: we stay in this loop until user quits recscreen */
while(done <= 0)
{
@ -1576,7 +1575,6 @@ bool recording_screen(bool no_source)
/* led is restored at begin of loop / end of function */
led(false);
#endif
viewportmanager_set_statusbar(oldbars);
if (recording_menu(no_source))
{
done = 1;
@ -1590,7 +1588,6 @@ bool recording_screen(bool no_source)
done = -1;
/* the init is now done at the beginning of the loop */
}
viewportmanager_set_statusbar(recbars);
}
break;
@ -1602,7 +1599,6 @@ bool recording_screen(bool no_source)
/* led is restored at begin of loop / end of function */
led(false);
#endif
viewportmanager_set_statusbar(oldbars);
if (f2_rec_screen())
{
rec_status |= RCSTAT_HAVE_RECORDED;
@ -1610,7 +1606,6 @@ bool recording_screen(bool no_source)
}
else
update_countdown = 0; /* Update immediately */
viewportmanager_set_statusbar(recbars);
}
break;
@ -1626,7 +1621,6 @@ bool recording_screen(bool no_source)
/* led is restored at begin of loop / end of function */
led(false);
#endif
viewportmanager_set_statusbar(oldbars);
if (f3_rec_screen())
{
rec_status |= RCSTAT_HAVE_RECORDED;
@ -1634,7 +1628,6 @@ bool recording_screen(bool no_source)
}
else
update_countdown = 0; /* Update immediately */
viewportmanager_set_statusbar(recbars);
}
break;
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
@ -1920,8 +1913,6 @@ rec_abort:
FOR_NB_SCREENS(i)
screens[i].setfont(FONT_UI);
viewportmanager_set_statusbar(oldbars);
send_event(GUI_EVENT_REFRESH, NULL);
/* if the directory was created or recording happened, make sure the
browser is updated */

View file

@ -235,7 +235,6 @@ static int browser(void* param)
}
}
}
send_event(GUI_EVENT_REFRESH, NULL);
if (!tagcache_is_usable())
return GO_TO_PREVIOUS;
filter = SHOW_ID3DB;

View file

@ -905,8 +905,7 @@ int calibrate(void)
int i, ret = 0;
/* hide the statusbar */
int old_statusbar = viewportmanager_get_statusbar();
viewportmanager_set_statusbar(VP_SB_HIDE_ALL);
viewportmanager_theme_enable(SCREEN_MAIN, false, NULL);
touchscreen_disable_mapping(); /* set raw mode */
touchscreen_set_mode(TOUCHSCREEN_POINT);
@ -931,7 +930,7 @@ int calibrate(void)
sizeof(struct touchscreen_parameter));
touchscreen_set_mode(old_mode);
viewportmanager_set_statusbar(old_statusbar);
viewportmanager_theme_undo(SCREEN_MAIN);
settings_save();
return ret;

View file

@ -788,7 +788,6 @@ static int dirbrowse()
}
onplay_result = onplay(buf, attr, curr_context);
}
send_event(GUI_EVENT_REFRESH, tree_drawlists);
switch (onplay_result)
{
case ONPLAY_MAINMENU: