summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-09-07 17:37:06 +0000
committerThomas Martitz <kugel@rockbox.org>2009-09-07 17:37:06 +0000
commit2eb1cb6f826a6542b3947f36a57130de235e530e (patch)
treed6ade8f11719173c858f606ad123240a72abc553 /apps
parent47611321c0adafa4125070ac83aa56817504e579 (diff)
downloadrockbox-2eb1cb6f826a6542b3947f36a57130de235e530e.tar.gz
rockbox-2eb1cb6f826a6542b3947f36a57130de235e530e.tar.bz2
rockbox-2eb1cb6f826a6542b3947f36a57130de235e530e.zip
Fix buttonbar handling/theme changed handling in lists.
The lists need to copy to a local parent if a list passes NULL as parent in the init. This was before the commit of custom ui vp, but I removed it since I (wrongly) thought using the ui vp as parent would be fine. Let the viewportmanager fire a event in case when a theme-related setting changed and simply the handling in the lists code. However the buttonbar handling didn't work before anyway, since list code didn't know if the buttonbar was active (it asked a variable which was always false....). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22651 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/appevents.h1
-rw-r--r--apps/gui/list.c61
-rw-r--r--apps/gui/list.h1
-rw-r--r--apps/gui/viewport.c13
-rw-r--r--apps/gui/viewport.h5
-rw-r--r--apps/main.c3
-rw-r--r--apps/menus/theme_menu.c19
-rw-r--r--apps/screen_access.c9
8 files changed, 78 insertions, 34 deletions
diff --git a/apps/appevents.h b/apps/appevents.h
index f7e695d4a9..d3f7a2d194 100644
--- a/apps/appevents.h
+++ b/apps/appevents.h
@@ -51,6 +51,7 @@ enum {
GUI_EVENT_STATUSBAR_TOGGLE = (EVENT_CLASS_GUI|1),
GUI_EVENT_ACTIONUPDATE,
GUI_EVENT_REFRESH,
+ GUI_EVENT_THEME_CHANGED,
};
#endif
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 9b139dd47c..284b83012a 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -38,6 +38,7 @@
#include "misc.h"
#include "talk.h"
#include "viewport.h"
+#include "appevents.h"
#ifdef HAVE_LCD_CHARCELLS
#define SCROLL_LIMIT 1
@@ -61,21 +62,41 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list,
void list_draw(struct screen *display, struct gui_synclist *list);
#ifdef HAVE_LCD_BITMAP
+static int list_need_reinit = false;
+static struct viewport parent[NB_SCREENS];
+
+static void list_force_reinit(void *param)
+{
+ (void)param;
+ list_need_reinit = true;
+}
+
+void list_init(void)
+{
+ add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit);
+}
+
static void list_init_viewports(struct gui_synclist *list)
{
- struct viewport* vp;
- int i;
- bool parent_used = (*list->parent != NULL);
+ int i, parent_used;
+
+ if (!list)
+ return;
+
+ parent_used = (*list->parent != &parent[SCREEN_MAIN]);
+
if (!parent_used)
{
- vp = viewport_get_current_vp();
FOR_NB_SCREENS(i)
- list->parent[i] = &vp[i];
- }
+ {
+ list->parent[i] = &parent[i];
+ viewport_set_defaults(&parent[i], i);
#ifdef HAVE_BUTTONBAR
- if (list && !parent_used && global_settings.buttonbar)
- list->parent[0]->height -= BUTTONBAR_HEIGHT;
+ if (screens[i].has_buttonbar && !viewport_ui_vp_get_state(i))
+ list->parent[i]->height -= BUTTONBAR_HEIGHT;
#endif
+ }
+ }
}
#else
#define list_init_viewports(a)
@@ -135,12 +156,7 @@ void gui_synclist_init(struct gui_synclist * gui_list,
if (list_parent)
gui_list->parent[i] = &list_parent[i];
else
- gui_list->parent[i] =
-#ifdef HAVE_LCD_BITMAP
- NULL;
-#else
- &parent[i];
-#endif
+ gui_list->parent[i] = &parent[i];
}
list_init_viewports(gui_list);
gui_list->limit_scroll = false;
@@ -209,26 +225,13 @@ int gui_list_get_item_offset(struct gui_synclist * gui_list,
void gui_synclist_draw(struct gui_synclist *gui_list)
{
int i;
- static struct gui_synclist *last_list = NULL;
- static int last_count = -1;
-#ifdef HAVE_BUTTONBAR
- static bool last_buttonbar = false;
-#endif
- if (
-#ifdef HAVE_BUTTONBAR
- last_buttonbar != screens[SCREEN_MAIN].has_buttonbar ||
-#endif
- last_list != gui_list ||
- gui_list->nb_items != last_count)
+#ifdef HAVE_LCD_BITMAP
+ if (list_need_reinit)
{
list_init_viewports(gui_list);
gui_synclist_select_item(gui_list, gui_list->selected_item);
}
-#ifdef HAVE_BUTTONBAR
- last_buttonbar = screens[SCREEN_MAIN].has_buttonbar;
#endif
- last_count = gui_list->nb_items;
- last_list = gui_list;
FOR_NB_SCREENS(i)
{
list_draw(&screens[i], gui_list);
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 8a36acb005..ed61889083 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -132,6 +132,7 @@ struct gui_synclist
#ifdef HAVE_LCD_BITMAP
+extern void list_init(void);
/* parse global setting to static int */
extern void gui_list_screen_scroll_step(int ofs);
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 63f0b8fc20..281c04b2c5 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -208,6 +208,13 @@ static void statusbar_toggled(void* param)
void viewportmanager_theme_changed(int which)
{
int i;
+#ifdef HAVE_BUTTONBAR
+ if (which & THEME_BUTTONBAR)
+ { /* don't handle further, the custom ui viewport ignores the buttonbar,
+ * as does viewport_set_defaults(), since only lists use it*/
+ screens[SCREEN_MAIN].has_buttonbar = global_settings.buttonbar;
+ }
+#endif
if (which & THEME_UI_VIEWPORT)
{
int retval = viewport_init_ui_vp();
@@ -245,6 +252,7 @@ void viewportmanager_theme_changed(int which)
viewport_set_fullscreen(&custom_vp[i], i);
}
}
+ send_event(GUI_EVENT_THEME_CHANGED, NULL);
}
static void viewportmanager_ui_vp_changed(void *param)
@@ -279,6 +287,11 @@ struct viewport* viewport_get_current_vp(void)
return ui_vp_info.vp;
}
+bool viewport_ui_vp_get_state(enum screen_type screen)
+{
+ return ui_vp_info.active[screen];
+}
+
#ifdef HAVE_LCD_COLOR
#define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc")
#else
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 93b5c70fc3..d431766ab5 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -58,6 +58,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen);
#define THEME_STATUSBAR (BIT_N(0))
#define THEME_UI_VIEWPORT (BIT_N(1))
+#define THEME_BUTTONBAR (BIT_N(2))
#define THEME_ALL (~(0u))
#define VP_SB_HIDE_ALL 0
@@ -116,6 +117,10 @@ struct viewport* viewport_get_current_vp(void);
*/
void viewport_set_current_vp(struct viewport* vp);
+/*
+ * returns true if the ui viewport is active on the screen
+ */
+bool viewport_ui_vp_get_state(enum screen_type screen);
#ifdef HAVE_TOUCHSCREEN
bool viewport_point_within_vp(const struct viewport *vp, int x, int y);
#endif
diff --git a/apps/main.c b/apps/main.c
index 6aa16e5cb6..c7510801d4 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -135,6 +135,9 @@ static void app_main(void)
screens[i].clear_display();
screens[i].update();
}
+#ifdef HAVE_LCD_BITMAP
+ list_init();
+#endif
tree_gui_init();
gui_syncstatusbar_init(&statusbars);
viewportmanager_init();
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index b4505de4b3..38e052b262 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -38,6 +38,7 @@
#include "backdrop.h"
#include "exported_menus.h"
#include "appevents.h"
+#include "viewport.h"
#if LCD_DEPTH > 1
/**
@@ -177,6 +178,20 @@ static int statusbar_callback(int action,const struct menu_item_ex *this_item)
{
return statusbar_callback_ex(action, this_item, SCREEN_MAIN);
}
+
+#ifdef HAVE_BUTTONBAR
+static int buttonbar_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ switch (action)
+ {
+ case ACTION_EXIT_MENUITEM:
+ viewportmanager_theme_changed(THEME_BUTTONBAR);
+ break;
+ }
+ return ACTION_REDRAW;
+}
+#endif
MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL);
MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
MENUITEM_SETTING(statusbar, &global_settings.statusbar,
@@ -185,8 +200,8 @@ MENUITEM_SETTING(statusbar, &global_settings.statusbar,
MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar,
statusbar_callback_remote);
#endif
-#if CONFIG_KEYPAD == RECORDER_PAD
-MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL);
+#ifdef HAVE_BUTTONBAR
+MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, buttonbar_callback);
#endif
MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL);
MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL);
diff --git a/apps/screen_access.c b/apps/screen_access.c
index d0b483f3f4..5b2b4724f1 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -56,7 +56,7 @@ static int screen_helper_getnblines(void)
{
int height=screens[0].lcdheight;
#ifdef HAVE_LCD_BITMAP
- if(global_settings.statusbar)
+ if(global_settings.statusbar != STATUSBAR_OFF)
height -= STATUSBAR_HEIGHT;
#ifdef HAVE_BUTTONBAR
if(global_settings.buttonbar && screens[0].has_buttonbar)
@@ -89,10 +89,10 @@ static int screen_helper_remote_getnblines(void)
{
int height=screens[1].lcdheight;
#ifdef HAVE_LCD_BITMAP
- if(global_settings.statusbar)
+ if(global_settings.statusbar != STATUSBAR_OFF)
height -= STATUSBAR_HEIGHT;
#ifdef HAVE_BUTTONBAR
- if(global_settings.buttonbar && screens[0].has_buttonbar)
+ if(global_settings.buttonbar && screens[1].has_buttonbar)
height -= BUTTONBAR_HEIGHT;
#endif
#endif
@@ -286,6 +286,9 @@ struct screen screens[NB_SCREENS] =
.backdrop_load=&remote_backdrop_load,
.backdrop_unload=&remote_backdrop_unload,
.backdrop_show=&remote_backdrop_show,
+#ifdef HAVE_BUTTONBAR
+ .has_buttonbar=false,
+#endif
}
#endif /* HAVE_REMOTE_LCD */
};