diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c index bc058b7251..3c3ed3de39 100644 --- a/apps/alarm_menu.c +++ b/apps/alarm_menu.c @@ -193,7 +193,6 @@ bool alarm_screen(void) break; case ACTION_NONE: - gui_syncstatusbar_draw(&statusbars, false); hour_wrapped = false; break; diff --git a/apps/appevents.h b/apps/appevents.h index 36990f9768..48d578de25 100644 --- a/apps/appevents.h +++ b/apps/appevents.h @@ -49,6 +49,7 @@ enum { enum { GUI_EVENT_THEME_CHANGED = (EVENT_CLASS_GUI|1), GUI_EVENT_STATUSBAR_TOGGLE, + GUI_EVENT_FOURHERTZ, }; #endif diff --git a/apps/bookmark.c b/apps/bookmark.c index 524de5aff4..52599519a3 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -198,7 +198,6 @@ bool bookmark_autobookmark(void) #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif - gui_syncstatusbar_draw(&statusbars, false); if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) { if (global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_ASK) @@ -680,11 +679,9 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu gui_synclist_set_voice_callback(&list, bookmark_list_voice_cb); gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK), Icon_Bookmark); - gui_syncstatusbar_draw(&statusbars, true); while (!exit) { - gui_syncstatusbar_draw(&statusbars, false); if (refresh) { diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 8878e29c3a..92eb245249 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -47,6 +47,7 @@ #include "misc.h" #include "splash.h" #include "dircache.h" +#include "viewport.h" #ifdef HAVE_TAGCACHE #include "tagcache.h" #endif @@ -232,6 +233,7 @@ static bool dbg_audio_thread(void) struct audio_debug d; lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(1) { @@ -269,6 +271,7 @@ static bool dbg_audio_thread(void) lcd_update(); } + viewportmanager_set_statusbar(true); return false; } #endif /* !SIMULATOR */ @@ -304,6 +307,7 @@ static bool dbg_buffering_thread(void) tick_add_task(dbg_audio_task); lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(!done) { button = get_action(CONTEXT_STD,HZ/5); @@ -394,6 +398,7 @@ static bool dbg_buffering_thread(void) } tick_remove_task(dbg_audio_task); + viewportmanager_set_statusbar(true); return false; } @@ -526,6 +531,7 @@ static bool dbg_hw_info(void) lcd_setfont(FONT_SYSFIXED); lcd_clear_display(); + viewportmanager_set_statusbar(false); lcd_puts(0, 0, "[Hardware info]"); @@ -564,6 +570,7 @@ static bool dbg_hw_info(void) int got_id; /* flag if we managed to get the flash IDs */ int oldmode; /* saved memory guard mode */ int line = 0; + viewportmanager_set_statusbar(false); oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ @@ -626,6 +633,7 @@ static bool dbg_hw_info(void) lcd_setfont(FONT_SYSFIXED); lcd_clear_display(); + viewportmanager_set_statusbar(false); lcd_puts(0, line++, "[Hardware info]"); @@ -679,10 +687,12 @@ static bool dbg_hw_info(void) lcd_update(); while (!(action_userabort(TIMEOUT_BLOCK))); + #else /* Define this function in your target tree */ return __dbg_hw_info(); #endif /* CONFIG_CPU */ + viewportmanager_set_statusbar(true); return false; } #else /* !HAVE_LCD_BITMAP */ @@ -824,6 +834,7 @@ static bool dbg_spdif(void) lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); #ifdef HAVE_SPDIF_POWER spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */ @@ -976,6 +987,7 @@ static bool dbg_spdif(void) spdif_power_enable(global_settings.spdif_enable); #endif + viewportmanager_set_statusbar(true); return false; } #endif /* CPU_COLDFIRE */ @@ -1033,6 +1045,7 @@ bool dbg_ports(void) lcd_setfont(FONT_SYSFIXED); lcd_clear_display(); + viewportmanager_set_statusbar(false); while(1) { @@ -1057,7 +1070,10 @@ bool dbg_ports(void) lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) + { + viewportmanager_set_statusbar(true); return false; + } } #elif defined(CPU_COLDFIRE) unsigned int gpio_out; @@ -1075,6 +1091,7 @@ bool dbg_ports(void) lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(1) { @@ -1140,7 +1157,10 @@ bool dbg_ports(void) lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) + { + viewportmanager_set_statusbar(true); return false; + } } #elif defined(CPU_PP502x) @@ -1150,6 +1170,7 @@ bool dbg_ports(void) lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(1) { @@ -1247,7 +1268,10 @@ extern unsigned char serbuf[]; #endif lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) + { + viewportmanager_set_statusbar(true); return false; + } } #elif CONFIG_CPU == PP5002 @@ -1256,6 +1280,7 @@ extern unsigned char serbuf[]; lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(1) { @@ -1286,8 +1311,12 @@ extern unsigned char serbuf[]; lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) + { + viewportmanager_set_statusbar(true); return false; + } } + viewportmanager_set_statusbar(true); #else return __dbg_ports(); #endif /* CPU */ @@ -1302,6 +1331,7 @@ bool dbg_ports(void) int currval = 0; lcd_clear_display(); + viewportmanager_set_statusbar(false); while(1) { @@ -1337,7 +1367,6 @@ bool dbg_ports(void) case 9: snprintf(buf, 32, "AN7: %03x", adc_read(7)); break; - break; } lcd_puts(0, 0, buf); @@ -1367,6 +1396,7 @@ bool dbg_ports(void) break; } } + viewportmanager_set_statusbar(true); return false; } #endif /* !HAVE_LCD_BITMAP */ @@ -1382,6 +1412,7 @@ static bool dbg_pcf(void) lcd_setfont(FONT_SYSFIXED); #endif lcd_clear_display(); + viewportmanager_set_statusbar(false); while(1) { @@ -1417,10 +1448,12 @@ static bool dbg_pcf(void) lcd_update(); if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) { + viewportmanager_set_statusbar(true); return false; } } + viewportmanager_set_statusbar(true); return false; } #endif @@ -1436,6 +1469,7 @@ static bool dbg_cpufreq(void) lcd_setfont(FONT_SYSFIXED); #endif lcd_clear_display(); + viewportmanager_set_statusbar(false); while(1) { @@ -1467,10 +1501,11 @@ static bool dbg_cpufreq(void) break; case ACTION_STD_CANCEL: + viewportmanager_set_statusbar(true); return false; } } - + viewportmanager_set_statusbar(true); return false; } #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ @@ -1563,6 +1598,7 @@ static bool view_battery(void) char buf[32]; lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while(1) { @@ -1803,9 +1839,11 @@ static bool view_battery(void) break; case ACTION_STD_CANCEL: + viewportmanager_set_statusbar(true); return false; } } + viewportmanager_set_statusbar(true); return false; } @@ -2434,6 +2472,7 @@ static bool cpu_boost_log(void) bool done; lcd_setfont(FONT_SYSFIXED); str = cpu_boost_log_getlog_first(); + viewportmanager_set_statusbar(false); while (i < count) { lcd_clear_display(); @@ -2467,6 +2506,7 @@ static bool cpu_boost_log(void) } get_action(CONTEXT_STD,TIMEOUT_BLOCK); lcd_setfont(FONT_UI); + viewportmanager_set_statusbar(true); return false; } #endif @@ -2485,11 +2525,12 @@ static bool dbg_scrollwheel(void) unsigned int speed; lcd_setfont(FONT_SYSFIXED); + viewportmanager_set_statusbar(false); while (1) { if (action_userabort(HZ/10)) - return false; + break; lcd_clear_display(); @@ -2514,6 +2555,7 @@ static bool dbg_scrollwheel(void) lcd_update(); } + viewportmanager_set_statusbar(true); return false; } #endif diff --git a/apps/enc_config.c b/apps/enc_config.c index 2368c9e065..8f3237d2e6 100644 --- a/apps/enc_config.c +++ b/apps/enc_config.c @@ -295,7 +295,6 @@ static int enc_menuitem_callback(int action, encoder_config_to_global(data->cfg); } - gui_syncstatusbar_draw(&statusbars, true); } return action; } diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index a3f5da92ea..3b2f16db8c 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -45,19 +45,13 @@ #define SCROLLBAR_WIDTH 6 #define ICON_PADDING 1 -static struct viewport title_text[NB_SCREENS], title_icons[NB_SCREENS], - list_text[NB_SCREENS], list_icons[NB_SCREENS]; +/* these are static to make scrolling work */ +static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS]; -/* should probably be moved somewhere else */ -int list_title_height(struct gui_synclist *list, struct viewport *vp) -{ - (void)list; - return font_get(vp->font)->height; -} int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, int text_pos, struct screen * display, struct viewport *vp); -bool list_display_title(struct gui_synclist *list, struct viewport *vp); +bool list_display_title(struct gui_synclist *list, enum screen_type screen); /* Draw the list... internal screen layout: @@ -70,47 +64,51 @@ bool list_display_title(struct gui_synclist *list, struct viewport *vp); | | | | ------------------ */ -static bool draw_title(struct screen *display, struct viewport *parent, - struct gui_synclist *list) +static bool draw_title(struct screen *display, struct gui_synclist *list) { - struct viewport *vp_icons = &title_icons[display->screen_type]; - struct viewport *vp_text = &title_text[display->screen_type]; - if (!list_display_title(list, parent)) + const int screen = display->screen_type; + if (!list_display_title(list, screen)) return false; - *vp_text = *parent; - vp_text->height = list_title_height(list, parent); + title_text[screen] = *(list->parent[screen]); + title_text[screen].height + = font_get(title_text[screen].font)->height; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { - *vp_icons = *vp_text; - vp_icons->width = get_icon_width(display->screen_type) + struct viewport title_icon = *(list->parent[screen]); + title_icon = title_text[screen]; + title_icon.width = get_icon_width(screen) + ICON_PADDING*2; - vp_icons->x += ICON_PADDING; - - vp_text->width -= vp_icons->width + vp_icons->x; - vp_text->x += vp_icons->width + vp_icons->x; - - display->set_viewport(vp_icons); + title_icon.x += ICON_PADDING; + + title_text[screen].width -= title_icon.width + title_icon.x; + title_text[screen].x += title_icon.width + title_icon.x; + + display->set_viewport(&title_icon); screen_put_icon(display, 0, 0, list->title_icon); } - display->set_viewport(vp_text); - vp_text->drawmode = STYLE_DEFAULT; + title_text[screen].drawmode = STYLE_DEFAULT; #ifdef HAVE_LCD_COLOR if (list->title_color >= 0) { - vp_text->drawmode |= (STYLE_COLORED|list->title_color);} + title_text[screen].drawmode + |= (STYLE_COLORED|list->title_color); + } #endif - display->puts_scroll_style_offset(0, 0, list->title, - vp_text->drawmode, 0); + display->set_viewport(&title_text[screen]); + display->puts_scroll_style(0, 0, list->title, + title_text[screen].drawmode); return true; } -void list_draw(struct screen *display, struct viewport *parent, - struct gui_synclist *list) +void list_draw(struct screen *display, struct gui_synclist *list) { + struct viewport list_icons; int start, end, line_height, i; - int icon_width = get_icon_width(display->screen_type) + ICON_PADDING; - bool show_cursor = !global_settings.cursor_style && + const int screen = display->screen_type; + const int icon_width = get_icon_width(screen) + ICON_PADDING; + const bool show_cursor = !global_settings.cursor_style && list->show_selection_marker; + struct viewport *parent = (list->parent[screen]); #ifdef HAVE_LCD_COLOR unsigned char cur_line = 0; #endif @@ -120,55 +118,55 @@ void list_draw(struct screen *display, struct viewport *parent, display->set_viewport(parent); display->clear_viewport(); display->stop_scroll(); - list_text[display->screen_type] = *parent; - if ((show_title = draw_title(display, parent, list))) + list_text[screen] = *parent; + if ((show_title = draw_title(display, list))) { - list_text[display->screen_type].y += list_title_height(list, parent); - list_text[display->screen_type].height -= list_title_height(list, parent); + list_text[screen].y += line_height; + list_text[screen].height -= line_height; } - - start = list->start_item[display->screen_type]; - end = start + viewport_get_nb_lines(&list_text[display->screen_type]); + + start = list->start_item[screen]; + end = start + viewport_get_nb_lines(&list_text[screen]); /* draw the scrollbar if its needed */ if (global_settings.scrollbar && - viewport_get_nb_lines(&list_text[display->screen_type]) < list->nb_items) + viewport_get_nb_lines(&list_text[screen]) < list->nb_items) { struct viewport vp; - vp = list_text[display->screen_type]; + vp = list_text[screen]; vp.width = SCROLLBAR_WIDTH; - list_text[display->screen_type].width -= SCROLLBAR_WIDTH; - list_text[display->screen_type].x += SCROLLBAR_WIDTH; + list_text[screen].width -= SCROLLBAR_WIDTH; + list_text[screen].x += SCROLLBAR_WIDTH; vp.height = line_height * - viewport_get_nb_lines(&list_text[display->screen_type]); + viewport_get_nb_lines(&list_text[screen]); vp.x = parent->x; display->set_viewport(&vp); gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, - list->start_item[display->screen_type], - list->start_item[display->screen_type] + end-start, + list->start_item[screen], + list->start_item[screen] + end-start, VERTICAL); } else if (show_title) { /* shift everything right a bit... */ - list_text[display->screen_type].width -= SCROLLBAR_WIDTH; - list_text[display->screen_type].x += SCROLLBAR_WIDTH; + list_text[screen].width -= SCROLLBAR_WIDTH; + list_text[screen].x += SCROLLBAR_WIDTH; } /* setup icon placement */ - list_icons[display->screen_type] = list_text[display->screen_type]; + list_icons = list_text[screen]; int icon_count = global_settings.show_icons && (list->callback_get_item_icon != NULL) ? 1 : 0; if (show_cursor) icon_count++; if (icon_count) { - list_icons[display->screen_type].width = icon_width * icon_count; - list_text[display->screen_type].width -= - list_icons[display->screen_type].width + ICON_PADDING; - list_text[display->screen_type].x += - list_icons[display->screen_type].width + ICON_PADDING; + list_icons.width = icon_width * icon_count; + list_text[screen].width -= + list_icons.width + ICON_PADDING; + list_text[screen].x += + list_icons.width + ICON_PADDING; } for (i=start; inb_items; i++) @@ -181,14 +179,14 @@ void list_draw(struct screen *display, struct viewport *parent, s = list->callback_get_item_name(i, list->data, entry_buffer, sizeof(entry_buffer)); entry_name = P2STR(s); - display->set_viewport(&list_text[display->screen_type]); - list_text[display->screen_type].drawmode = STYLE_DEFAULT; + display->set_viewport(&list_text[screen]); + list_text[screen].drawmode = STYLE_DEFAULT; /* position the string at the correct offset place */ int item_width,h; display->getstringsize(entry_name, &item_width, &h); item_offset = gui_list_get_item_offset(list, item_width, text_pos, display, - &list_text[display->screen_type]); + &list_text[screen]); #ifdef HAVE_LCD_COLOR /* if the list has a color callback */ @@ -198,73 +196,75 @@ void list_draw(struct screen *display, struct viewport *parent, /* if color selected */ if (color >= 0) { - list_text[display->screen_type].drawmode |= STYLE_COLORED|color; + list_text[screen].drawmode |= STYLE_COLORED|color; } } #endif - if(i >= list->selected_item && - i < list->selected_item + list->selected_size && list->show_selection_marker) + if(i >= list->selected_item && i < list->selected_item + + list->selected_size && list->show_selection_marker) {/* The selected item must be displayed scrolling */ if (global_settings.cursor_style == 1 #ifdef HAVE_REMOTE_LCD - /* the global_settings.cursor_style check is here to make sure - if they want the cursor instead of bar it will work */ + /* the global_settings.cursor_style check is here to make + * sure if they want the cursor instead of bar it will work + */ || (display->depth < 16 && global_settings.cursor_style) #endif ) { /* Display inverted-line-style */ - list_text[display->screen_type].drawmode = STYLE_INVERT; + list_text[screen].drawmode = STYLE_INVERT; } #ifdef HAVE_LCD_COLOR else if (global_settings.cursor_style == 2) { /* Display colour line selector */ - list_text[display->screen_type].drawmode = STYLE_COLORBAR; + list_text[screen].drawmode = STYLE_COLORBAR; } else if (global_settings.cursor_style == 3) { /* Display gradient line selector */ - list_text[display->screen_type].drawmode = STYLE_GRADIENT; + list_text[screen].drawmode = STYLE_GRADIENT; /* Make the lcd driver know how many lines the gradient should cover and current line number */ /* number of selected lines */ - list_text[display->screen_type].drawmode |= NUMLN_PACK(list->selected_size); + list_text[screen].drawmode |= NUMLN_PACK(list->selected_size); /* current line number, zero based */ - list_text[display->screen_type].drawmode |= CURLN_PACK(cur_line); + list_text[screen].drawmode |= CURLN_PACK(cur_line); cur_line++; } #endif /* if the text is smaller than the viewport size */ - if (item_offset > item_width - (list_text[display->screen_type].width - text_pos)) + if (item_offset> item_width + - (list_text[screen].width - text_pos)) { /* don't scroll */ display->puts_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } else { display->puts_scroll_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } } else { if (list->scroll_all) display->puts_scroll_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); else display->puts_style_offset(0, i-start, entry_name, - list_text[display->screen_type].drawmode, item_offset); + list_text[screen].drawmode, item_offset); } /* do the icon */ if (list->callback_get_item_icon && global_settings.show_icons) { - display->set_viewport(&list_icons[display->screen_type]); + display->set_viewport(&list_icons); screen_put_icon_with_offset(display, show_cursor?1:0, - (i-start),show_cursor?ICON_PADDING:0,0, - list->callback_get_item_icon(i, list->data)); + (i-start),show_cursor?ICON_PADDING:0,0, + list->callback_get_item_icon(i, list->data)); if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { @@ -274,14 +274,12 @@ void list_draw(struct screen *display, struct viewport *parent, else if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { - display->set_viewport(&list_icons[display->screen_type]); + display->set_viewport(&list_icons); screen_put_icon(display, 0, (i-start), Icon_Cursor); } } - display->set_viewport(parent); display->update_viewport(); - display->set_viewport(NULL); } @@ -292,10 +290,10 @@ void list_draw(struct screen *display, struct viewport *parent, */ static bool scrolling=false; -unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct viewport *parent) +unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) { short x, y; - unsigned button = action_get_touchscreen_press(&x, &y); + int button = action_get_touchscreen_press(&x, &y); int line; struct screen *display = &screens[SCREEN_MAIN]; if (button == BUTTON_NONE) @@ -315,13 +313,15 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view /* Scroll bar */ else { - int nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); + int nb_lines = viewport_get_nb_lines(&list_text[screen]); if (nb_lines < gui_list->nb_items) { - int scrollbar_size = nb_lines * font_get(parent->font)->height; - int actual_y = y - list_text[SCREEN_MAIN].y; + int scrollbar_size = nb_lines* + font_get(gui_list->parent[screen]->font)->height; + int actual_y = y - list_text[screen].y; - int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size; + int new_selection = (actual_y * gui_list->nb_items) + / scrollbar_size; int start_item = new_selection - nb_lines/2; if(start_item < 0) @@ -329,7 +329,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view else if(start_item > gui_list->nb_items - nb_lines) start_item = gui_list->nb_items - nb_lines; - gui_list->start_item[SCREEN_MAIN] = start_item; + gui_list->start_item[screen] = start_item; gui_synclist_select_item(gui_list, new_selection); return ACTION_REDRAW; @@ -350,27 +350,31 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view * | will bring up the context menu of it. | * |--------------------------------------------------------| */ - if (y > list_text[SCREEN_MAIN].y) + if (y > list_text[screen].y) { int line_height, actual_y; static int last_y = 0; - actual_y = y - list_text[SCREEN_MAIN].y; - line_height = font_get(parent->font)->height; + actual_y = y - list_text[screen].y; + line_height = font_get(gui_list->parent[screen]->font)->height; line = actual_y / line_height; if(actual_y%line_height == 0) /* Pressed a border */ return ACTION_NONE; - if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) /* Pressed below the list*/ + if (gui_list->start_item[screen]+line > gui_list->nb_items) + { + /* Pressed below the list*/ return ACTION_NONE; - + } last_y = actual_y; - if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button ^ BUTTON_REL) + if (line != gui_list->selected_item + - gui_list->start_item[screen] && button ^ BUTTON_REL) { if(button & BUTTON_REPEAT) scrolling = true; - gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); + gui_synclist_select_item(gui_list, gui_list->start_item[screen] + + line); return ACTION_REDRAW; } @@ -378,15 +382,17 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view { if(!scrolling) { - /* Pen was hold on the same line as the previously selected one - * => simulate long button press + /* Pen was hold on the same line as the + * previously selected one + * => simulate long button press */ return ACTION_STD_CONTEXT; } else { - /* Pen was moved across several lines and then released on this one - * => do nothing + /* Pen was moved across several lines and then released on + * this one + * => do nothing */ scrolling = false; return ACTION_NONE; @@ -394,8 +400,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view } else if(button == BUTTON_REL) { - /* Pen was released on either the same line as the previously selected one - * or an other one + /* Pen was released on either the same line as the previously + * selected one or an other one * => simulate short press */ return ACTION_STD_OK; @@ -404,11 +410,16 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct view return ACTION_NONE; } /* Title goes up one level (only on BUTTON_REL&~BUTTON_REPEAT) */ - else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL) + else if (y > title_text[screen].y && draw_title(display, gui_list) + && button == BUTTON_REL) + { return ACTION_STD_CANCEL; + } /* Title or statusbar is cancel (only on BUTTON_REL&~BUTTON_REPEAT) */ else if (global_settings.statusbar && button == BUTTON_REL) + { return ACTION_STD_CANCEL; + } } return ACTION_NONE; } diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c index b1d0adcdd6..198026e44c 100644 --- a/apps/gui/charcell/list.c +++ b/apps/gui/charcell/list.c @@ -40,10 +40,8 @@ #include "misc.h" #include "talk.h" -void list_draw(struct screen *display, struct viewport *parent, - struct gui_synclist *gui_list) +void list_draw(struct screen *display, struct gui_synclist *gui_list) { - (void)parent; int text_pos; bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 46453dc4c9..5e134b5fa3 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -61,6 +61,7 @@ #include "playback.h" #endif #include "backdrop.h" +#include "viewport.h" #define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */ /* 3% of 30min file == 54s step size */ @@ -78,17 +79,17 @@ #ifdef HAVE_LCD_BITMAP static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) { + (void)force; bool draw = global_settings.statusbar; if (wps->data->wps_sb_tag) draw = wps->data->show_sb_on_wps; - if (draw) - gui_statusbar_draw(wps->statusbar, force); + if (!draw) + viewportmanager_set_statusbar(false); } #else -#define gui_wps_statusbar_draw(wps, force) \ - gui_statusbar_draw((wps)->statusbar, (force)) +#define gui_wps_statusbar_draw(wps, force) #endif #include "pcmbuf.h" @@ -335,9 +336,6 @@ bool gui_wps_display(void) if (!wps_state.id3 && !(audio_status() & AUDIO_STATUS_PLAY)) { global_status.resume_index = -1; -#ifdef HAVE_LCD_BITMAP - gui_syncstatusbar_draw(&statusbars, true); -#endif splash(HZ, ID2P(LANG_END_PLAYLIST)); return true; } diff --git a/apps/gui/list.c b/apps/gui/list.c index 00d84cb446..b70cf424ee 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -61,7 +61,7 @@ static int force_list_reinit = false; static void gui_list_select_at_offset(struct gui_synclist * gui_list, int offset); -void list_draw(struct screen *display, struct viewport *parent, struct gui_synclist *list); +void list_draw(struct screen *display, struct gui_synclist *list); #ifdef HAVE_LCD_BITMAP static struct viewport parent[NB_SCREENS]; @@ -106,12 +106,13 @@ void list_init_viewports(struct gui_synclist *list) #endif #ifdef HAVE_LCD_BITMAP -bool list_display_title(struct gui_synclist *list, struct viewport *vp) +bool list_display_title(struct gui_synclist *list, enum screen_type screen) { - return list->title != NULL && viewport_get_nb_lines(vp)>2; + return list->title != NULL && + viewport_get_nb_lines(list->parent[screen])>2; } #else -#define list_display_title(l,v) false +#define list_display_title(l, i) false #endif /* @@ -180,10 +181,11 @@ void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide) #ifdef HAVE_LCD_BITMAP -int list_title_height(struct gui_synclist *list, struct viewport *vp); - -int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, - int text_pos, struct screen * display, struct viewport *vp) +int gui_list_get_item_offset(struct gui_synclist * gui_list, + int item_width, + int text_pos, + struct screen * display, + struct viewport *vp) { int item_offset; @@ -241,7 +243,7 @@ void gui_synclist_draw(struct gui_synclist *gui_list) last_list = gui_list; FOR_NB_SCREENS(i) { - list_draw(&screens[i], gui_list->parent[i], gui_list); + list_draw(&screens[i], gui_list); } } @@ -253,8 +255,8 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, int difference = gui_list->selected_item - gui_list->start_item[screen]; struct viewport vp = *gui_list->parent[screen]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(gui_list, gui_list->parent[screen])) - vp.height -= list_title_height(gui_list,gui_list->parent[screen]); + if (list_display_title(gui_list, screen)) + vp.height -= font_get(gui_list->parent[screen]->font)->height; #endif nb_lines = viewport_get_nb_lines(&vp); @@ -273,7 +275,10 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, if (global_settings.scroll_paginated) { if (gui_list->start_item[screen] > gui_list->selected_item) - gui_list->start_item[screen] = (gui_list->selected_item/nb_lines)*nb_lines; + { + gui_list->start_item[screen] = (gui_list->selected_item/nb_lines) + *nb_lines; + } if (gui_list->nb_items <= nb_lines) gui_list->start_item[screen] = 0; } @@ -293,7 +298,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, if (bottom < 0) bottom = 0; gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] + - 2*gui_list->selected_size); + 2*gui_list->selected_size); } else if (global_settings.scroll_paginated) { @@ -351,8 +356,8 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list, { struct viewport vp = *gui_list->parent[i]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(gui_list, gui_list->parent[i])) - vp.height -= list_title_height(gui_list,gui_list->parent[i]); + if (list_display_title(gui_list, i)) + vp.height -= font_get(gui_list->parent[i]->font)->height; #endif nb_lines = viewport_get_nb_lines(&vp); if (offset > 0) @@ -578,11 +583,11 @@ void gui_synclist_speak_item(struct gui_synclist * lists) extern intptr_t get_action_data(void); #if defined(HAVE_TOUCHSCREEN) /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ -unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list, struct viewport *parent); +unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list); #endif bool gui_synclist_do_button(struct gui_synclist * lists, - unsigned *actionptr, enum list_wrap wrap) + int *actionptr, enum list_wrap wrap) { int action = *actionptr; #ifdef HAVE_LCD_BITMAP @@ -621,7 +626,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, #if defined(HAVE_TOUCHSCREEN) if (action == ACTION_TOUCHSCREEN) - action = *actionptr = gui_synclist_do_touchscreen(lists, &parent[SCREEN_MAIN]); + action = *actionptr = gui_synclist_do_touchscreen(lists); #endif switch (wrap) @@ -791,8 +796,8 @@ bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, { struct viewport vp = *lists->parent[screen]; #ifdef HAVE_LCD_BITMAP - if (list_display_title(lists, lists->parent[screen])) - vp.height -= list_title_height(lists, lists->parent[screen]); + if (list_display_title(lists, screen)) + vp.height -= font_get(lists->parent[screen]->font)->height; #endif return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp)); } @@ -888,7 +893,6 @@ bool simplelist_show_list(struct simplelist_info *info) while(1) { - gui_syncstatusbar_draw(&statusbars, true); list_do_action(CONTEXT_STD, info->timeout, &lists, &action, wrap); @@ -900,14 +904,16 @@ bool simplelist_show_list(struct simplelist_info *info) { bool stdok = action==ACTION_STD_OK; action = info->action_callback(action, &lists); - if (stdok && action == ACTION_STD_CANCEL) /* callback asked us to exit */ + if (stdok && action == ACTION_STD_CANCEL) { + /* callback asked us to exit */ info->selection = gui_synclist_get_sel_pos(&lists); break; } if (info->get_name == NULL) - gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); + gui_synclist_set_nb_items(&lists, + simplelist_line_count*info->selection_size); } if (action == ACTION_STD_CANCEL) { @@ -918,7 +924,10 @@ bool simplelist_show_list(struct simplelist_info *info) (old_line_count != simplelist_line_count)) { if (info->get_name == NULL) - gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); + { + gui_synclist_set_nb_items(&lists, + simplelist_line_count*info->selection_size); + } gui_synclist_draw(&lists); old_line_count = simplelist_line_count; } diff --git a/apps/gui/list.h b/apps/gui/list.h index 643f662f63..c1126f257f 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -179,7 +179,7 @@ extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, * NOTE: *action may be changed regardless of return value */ extern bool gui_synclist_do_button(struct gui_synclist * lists, - unsigned *action, + int *action, enum list_wrap); /* If the list has a pending postponed scheduled announcement, that diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 570a41a78d..30df8ea6ec 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -508,7 +508,6 @@ bool option_screen(const struct settings_list *setting, gui_synclist_draw(&lists); /* talk the item */ gui_synclist_speak_item(&lists); - gui_syncstatusbar_draw(&statusbars, false); while (!done) { if (list_do_action(CONTEXT_LIST, TIMEOUT_BLOCK, @@ -562,7 +561,6 @@ bool option_screen(const struct settings_list *setting, } else if(default_event_handler(action) == SYS_USB_CONNECTED) return true; - gui_syncstatusbar_draw(&statusbars, false); /* callback */ if ( function ) function(*variable); diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c index 7a05a57743..568bbf4aee 100644 --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c @@ -286,7 +286,6 @@ int gui_syncpitchscreen_run(void) FOR_NB_SCREENS(i) pitchscreen_draw(&screens[i], max_lines[i], pitch_viewports[i], pitch); - gui_syncstatusbar_draw(&statusbars, true); button = get_action(CONTEXT_PITCHSCREEN,HZ); switch (button) { case ACTION_PS_INC_SMALL: diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 3880940ae3..a77453cf66 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -278,7 +278,6 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) * - an action taken while pressing the enter button, * then release the enter button*/ bool can_quit = false; - gui_syncstatusbar_draw(&statusbars, true); FOR_NB_SCREENS(i) { screens[i].set_viewport(NULL); @@ -315,8 +314,6 @@ bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) if(button==ACTION_STD_CANCEL) break; - - gui_syncstatusbar_draw(&statusbars, false); } /* Notify that we're exiting this screen */ cond_talk_ids_fq(VOICE_OK); diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index fc0b9637cf..29b80112f7 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -43,6 +43,7 @@ #include "recording.h" #include "pcm_record.h" #endif +#include "appevents.h" /* FIXME: should be removed from icon.h to avoid redefinition, but still needed for compatibility with old system */ @@ -817,3 +818,8 @@ int gui_statusbar_height(void) return global_settings.statusbar ? STATUSBAR_HEIGHT : 0; } +void gui_statusbar_changed(bool enabled) +{ + (void)enabled; + send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL); +} diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index f36d609bad..99acf9d006 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -99,4 +99,6 @@ struct gui_syncstatusbar extern void gui_syncstatusbar_init(struct gui_syncstatusbar * bars); extern void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, bool force_redraw); extern int gui_statusbar_height(void); +void gui_statusbar_changed(bool enabled); + #endif /*_GUI_STATUSBAR_H_*/ diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index ef61494b71..9cd905fa14 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -33,6 +33,9 @@ #include "viewport.h" #include "statusbar.h" #include "screen_access.h" +#include "appevents.h" + +static bool statusbar_enabled = true; int viewport_get_nb_lines(struct viewport *vp) { @@ -50,7 +53,7 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen) vp->x = 0; vp->width = screens[screen].lcdwidth; - vp->y = gui_statusbar_height(); + vp->y = statusbar_enabled?gui_statusbar_height():0; vp->height = screens[screen].lcdheight - vp->y; #ifdef HAVE_LCD_BITMAP vp->drawmode = DRMODE_SOLID; @@ -82,3 +85,31 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen) } #endif } + + +void viewportmanager_set_statusbar(bool enabled) +{ + if (enabled && global_settings.statusbar) + { + add_event(GUI_EVENT_FOURHERTZ, false, viewportmanager_draw_statusbars); + gui_syncstatusbar_draw(&statusbars, true); + } + else + { + remove_event(GUI_EVENT_FOURHERTZ, viewportmanager_draw_statusbars); + } + statusbar_enabled = enabled; +} + +void viewportmanager_draw_statusbars(void* data) +{ + (void)data; + if (statusbar_enabled) + gui_syncstatusbar_draw(&statusbars, false); +} + +void viewportmanager_statusbar_changed(void* data) +{ + (void)data; + viewportmanager_set_statusbar(statusbar_enabled); +} diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index 3605dbe711..cdb481017a 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h @@ -40,3 +40,9 @@ int viewport_get_nb_lines(struct viewport *vp); int viewport_load_config(const char *config, struct viewport *vp); void viewport_set_defaults(struct viewport *vp, enum screen_type screen); + +void viewportmanager_set_statusbar(bool enabled); +/* callbacks for GUI_EVENT_* events */ +void viewportmanager_draw_statusbars(void*data); +void viewportmanager_statusbar_changed(void* data); + diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 297f7f8987..756d267c63 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -131,7 +131,7 @@ enum yesno_res gui_syncyesno_run(const struct text_message * main_message, const struct text_message * no_message) { int i; - unsigned button; + int button; int result=-1; bool result_displayed; struct gui_yesno yn[NB_SCREENS]; diff --git a/apps/main.c b/apps/main.c index 45e6c77801..c62ee080b3 100644 --- a/apps/main.c +++ b/apps/main.c @@ -121,6 +121,16 @@ const char appsversion[]=APPSVERSION; static void init(void); +void fourhertz_tick_task(void) +{ + static long last_fire = 0; + if (TIME_AFTER(current_tick, last_fire+HZ/4)) + { + queue_post(&button_queue, SYS_FOURHERTZ, 0); + last_fire = current_tick; + } +} + #ifdef SIMULATOR void app_main(void) #else @@ -138,6 +148,10 @@ static void app_main(void) #ifdef HAVE_TOUCHSCREEN touchscreen_set_mode(TOUCHSCREEN_BUTTON); #endif + tick_add_task(fourhertz_tick_task); + viewportmanager_set_statusbar(true); + add_event(GUI_EVENT_STATUSBAR_TOGGLE, false, + viewportmanager_statusbar_changed); root_menu(); } diff --git a/apps/menu.c b/apps/menu.c index a0317e4a84..b5309a047e 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -283,29 +283,6 @@ static int talk_menu_item(int selected_item, void *data) } return 0; } -/* this is used to reload the default menu viewports when the - theme changes. nothing happens if the menu is using a supplied parent vp */ -static void init_default_menu_viewports(struct viewport parent[NB_SCREENS], bool hide_bars) -{ - int i; - FOR_NB_SCREENS(i) - { - viewport_set_defaults(&parent[i], i); - /* viewport_set_defaults() fixes the vp for the bars, so resize */ - if (hide_bars) - { - if (global_settings.statusbar) - { - parent[i].y -= STATUSBAR_HEIGHT; - parent[i].height += STATUSBAR_HEIGHT; - } - } - } -#ifdef HAVE_BUTTONBAR - if (!hide_bars && global_settings.buttonbar) - parent[0].height -= BUTTONBAR_HEIGHT; -#endif -} bool do_setting_from_menu(const struct menu_item_ex *temp, struct viewport parent[NB_SCREENS]) @@ -383,8 +360,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, int menu_stack_selected_item[MAX_MENUS]; int stack_top = 0; bool in_stringlist, done = false; - - struct viewport *vps, menu_vp[NB_SCREENS]; /* menu_vp will hopefully be phased out */ + struct viewport *vps = NULL; #ifdef HAVE_BUTTONBAR struct gui_buttonbar buttonbar; gui_buttonbar_init(&buttonbar); @@ -396,27 +372,12 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, if (start_menu == NULL) menu = &main_menu_; else menu = start_menu; - - init_default_menu_viewports(menu_vp, hide_bars); - - if (parent) - { - vps = parent; - /* if hide_bars == true we assume the viewport is correctly sized */ - } - else - { - vps = menu_vp; - } - FOR_NB_SCREENS(i) - { - screens[i].set_viewport(&vps[i]); - screens[i].clear_viewport(); - screens[i].set_viewport(NULL); - } - init_menu_lists(menu, &lists, selected, true, vps); + + /* if hide_bars is true, assume parent has been fixed before passed into + * this function, e.g. with viewport_set_defaults(parent, screen, true) */ + init_menu_lists(menu, &lists, selected, true, parent); + vps = *(lists.parent); in_stringlist = ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID); - /* load the callback, and only reload it if menu changes */ get_menu_callback(menu, &menu_callback); @@ -436,7 +397,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, #ifdef HAVE_BUTTONBAR gui_buttonbar_draw(&buttonbar); #endif - gui_syncstatusbar_draw(&statusbars, true); } action = get_action(CONTEXT_MAINMENU, list_do_action_timeout(&lists, HZ)); @@ -496,7 +456,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, else if (!in_stringlist) { int type; - selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); + selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu); temp = menu->submenus[selected]; type = (temp->flags&MENU_TYPE_MASK); if ((type == MT_SETTING_W_TEXT || type == MT_SETTING)) @@ -640,9 +600,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, temp->function->param); else return_value = temp->function->function(); - if (!(menu->flags&MENU_EXITAFTERTHISMENU) || (temp->flags&MENU_EXITAFTERTHISMENU)) + if (!(menu->flags&MENU_EXITAFTERTHISMENU) || + (temp->flags&MENU_EXITAFTERTHISMENU)) { - init_default_menu_viewports(menu_vp, hide_bars); init_menu_lists(menu, &lists, selected, true, vps); } if (temp->flags&MENU_FUNC_CHECK_RETVAL) @@ -658,9 +618,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, case MT_SETTING: case MT_SETTING_W_TEXT: { - if (do_setting_from_menu(temp, menu_vp)) + if (do_setting_from_menu(temp, vps)) { - init_default_menu_viewports(menu_vp, hide_bars); init_menu_lists(menu, &lists, selected, true,vps); redraw_lists = false; /* above does the redraw */ } diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index b22824d8bd..8611a66397 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -117,7 +117,8 @@ static bool show_credits(void) { /* show the rockbox logo and version untill a button is pressed */ show_logo(); - get_action(CONTEXT_STD, TIMEOUT_BLOCK); + while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK))) + ; } return false; } diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index 3b5a25ebc0..b9f5f7be78 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c @@ -537,7 +537,6 @@ int rectrigger(void) if (changed) { gui_synclist_draw(&lists); - gui_syncstatusbar_draw(&statusbars, true); peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); settings_apply_trigger(); changed = false; diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index cb1a93c28e..6d5abed622 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c @@ -295,9 +295,7 @@ int time_screen(void* ignored) if (global_settings.buttonbar) menu[i].height -= BUTTONBAR_HEIGHT; #endif - screens[i].clear_display(); draw_timedate(&clock[i], &screens[i]); - screens[i].update(); } ret = do_menu(&time_menu, NULL, menu, false); /* see comments above in the button callback */ diff --git a/apps/misc.c b/apps/misc.c index 8b73411549..894b0c2cc4 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -33,6 +33,7 @@ #endif #else #include "sprintf.h" +#include "appevents.h" #include "lang.h" #include "string.h" #include "dir.h" @@ -60,6 +61,7 @@ #include "sound.h" #include "playlist.h" #include "yesno.h" +#include "viewport.h" #ifdef IPOD_ACCESSORY_PROTOCOL #include "iap.h" @@ -904,6 +906,9 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame { switch(event) { + case SYS_FOURHERTZ: + send_event(GUI_EVENT_FOURHERTZ, NULL); + break; case SYS_BATTERY_UPDATE: if(global_settings.talk_battery_level) { diff --git a/apps/onplay.c b/apps/onplay.c index 42924a18a0..7c89e6320f 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -212,7 +212,6 @@ static bool add_to_playlist(int position, bool queue) if (global_settings.playlist_shuffle) playlist_shuffle(current_tick, -1); playlist_start(0,0); - gui_syncstatusbar_draw(&statusbars, false); onplay_result = ONPLAY_START_PLAY; } diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 7daae15552..105c3e0e83 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -295,10 +295,6 @@ static int display_playlists(char* playlist, bool view) } break; - case ACTION_NONE: - gui_syncstatusbar_draw(&statusbars, false); - break; - default: if(default_event_handler(button) == SYS_USB_CONNECTED) { diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 2acc02abe4..30dcfd0a1c 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -746,10 +746,6 @@ bool playlist_viewer_ex(const char* filename) gui_synclist_draw(&playlist_lists); break; - case ACTION_NONE: - gui_syncstatusbar_draw(&statusbars, false); - break; - default: if(default_event_handler(button) == SYS_USB_CONNECTED) { @@ -834,7 +830,6 @@ bool search_playlist(void) gui_synclist_draw(&playlist_lists); while (!exit) { - gui_syncstatusbar_draw(&statusbars, false); button = get_action(CONTEXT_LIST, HZ/4); if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD)) continue; diff --git a/apps/plugin.c b/apps/plugin.c index f78b6bf4e1..5e02d33a95 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -621,6 +621,7 @@ static const struct plugin_api rockbox_api = { appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ + viewportmanager_set_statusbar, }; int plugin_load(const char* plugin, const void* parameter) @@ -731,8 +732,11 @@ int plugin_load(const char* plugin, const void* parameter) #endif invalidate_icache(); + viewportmanager_set_statusbar(false); rc = hdr->entry_point(&rockbox_api, parameter); + + viewportmanager_set_statusbar(true); button_clear_queue(); diff --git a/apps/plugin.h b/apps/plugin.h index 81c069666a..440541d510 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 Björn Stenberg + * Copyright (C) 2002 Bj�rn Stenberg * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -132,7 +132,7 @@ 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 131 +#define PLUGIN_API_VERSION 132 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any @@ -334,7 +334,7 @@ struct plugin_api { void (*gui_synclist_del_item)(struct gui_synclist * lists); void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); bool (*gui_synclist_do_button)(struct gui_synclist * lists, - unsigned *action, enum list_wrap wrap); + int *action, enum list_wrap wrap); void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon); enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message, const struct text_message * yes_message, @@ -785,6 +785,7 @@ struct plugin_api { const char *appsversion; /* new stuff at the end, sort into place next time the API gets incompatible */ + void (*viewportmanager_set_statusbar)(bool enabled); }; /* plugin header */ diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 17b98c7f56..55771de919 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -674,7 +674,6 @@ static bool view_events(int selected, struct shown *shown) while (!exit) { - rb->gui_syncstatusbar_draw(rb->statusbars, true); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); rb->gui_synclist_do_button(&gui_memos,&button,LIST_WRAP_UNLESS_HELD); diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index 1aff214332..8c92573b75 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c @@ -640,7 +640,6 @@ struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api, rb->gui_synclist_select_item(&games_list, 0); while (true) { - rb->gui_syncstatusbar_draw(rb->statusbars, true); rb->gui_synclist_draw(&games_list); curr_selection = rb->gui_synclist_get_sel_pos(&games_list); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index dae413ccbc..6ec86f6950 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c @@ -556,7 +556,6 @@ static int keybox(void) while (!done) { - rb->gui_syncstatusbar_draw(rb->statusbars, true); rb->gui_synclist_draw(&kb_list); button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); if (rb->gui_synclist_do_button(&kb_list, &button, LIST_WRAP_ON)) diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c index b83f926532..a48a61bca6 100644 --- a/apps/plugins/lib/oldmenuapi.c +++ b/apps/plugins/lib/oldmenuapi.c @@ -98,7 +98,6 @@ int menu_show(int m) int key; rb->gui_synclist_draw(&(menus[m].synclist)); - rb->gui_syncstatusbar_draw(rb->statusbars, true); while (!exit) { key = rb->get_action(CONTEXT_MAINMENU,HZ/2); /* @@ -126,7 +125,6 @@ int menu_show(int m) return MENU_ATTACHED_USB; break; } - rb->gui_syncstatusbar_draw(rb->statusbars, false); } return MENU_SELECTED_EXIT; } @@ -149,7 +147,6 @@ bool menu_run(int m) if (menus[m].items[selected].function && menus[m].items[selected].function()) return true; - rb->gui_syncstatusbar_draw(rb->statusbars, true); } } } diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index 09b25480e8..eb3cb9506c 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c @@ -58,8 +58,6 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc) rb->gui_synclist_draw(&gui_sc); while (true) { - /* draw the statusbar, should be done often */ - rb->gui_syncstatusbar_draw(rb->statusbars, true); /* user input */ button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); if (rb->gui_synclist_do_button(&gui_sc, &button, diff --git a/apps/plugins/star.c b/apps/plugins/star.c index f358755e2a..c217fb922f 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c @@ -1008,9 +1008,6 @@ static int star_menu(void) FOR_NB_SCREENS(selection) { rb->viewport_set_defaults(&vp[selection], selection); - /* we are hiding the statusbar so fix the height also */ - vp[selection].y = 0; - vp[selection].height = rb->screens[selection]->lcdheight; #if LCD_DEPTH > 1 if (rb->screens[selection]->depth > 1) { @@ -1112,7 +1109,6 @@ static int star_menu(void) level--; star_run_game(level); } - return PLUGIN_OK; } diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c index 7ae3862fc2..36f1d519d9 100644 --- a/apps/plugins/zxbox/zxbox_keyb.c +++ b/apps/plugins/zxbox/zxbox_keyb.c @@ -443,8 +443,6 @@ int zx_kbd_input(char* text/*, int buflen*/) rb->screens[l]->set_drawmode(DRMODE_SOLID); } - -/* gui_syncstatusbar_draw(&statusbars, true);*/ FOR_NB_SCREENS(l) rb->screens[l]->update(); @@ -554,10 +552,6 @@ int zx_kbd_input(char* text/*, int buflen*/) } break; - case BUTTON_NONE: - /*gui_syncstatusbar_draw(&statusbars, false);*/ - - break; default: if(rb->default_event_handler(button) == SYS_USB_CONNECTED) diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index f72def6a8a..26413e99da 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -743,7 +743,6 @@ int kbd_input(char* text, int buflen) sc->set_drawmode(DRMODE_SOLID); } - gui_syncstatusbar_draw(&statusbars, true); FOR_NB_SCREENS(l) screens[l].update(); @@ -1190,7 +1189,6 @@ int kbd_input(char* text, int buflen) #endif /* !defined (KBD_MODES) || defined (KBD_CURSOR_KEYS) */ case BUTTON_NONE: - gui_syncstatusbar_draw(&statusbars, false); #ifdef KBD_MORSE_INPUT if (morse_reading) { diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index a6213abfb1..d01d24ccf2 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -489,7 +489,6 @@ int radio_screen(void) /* always display status bar in radio screen for now */ global_status.statusbar_forced = statusbar?0:1; global_settings.statusbar = true; - gui_syncstatusbar_draw(&statusbars,true); FOR_NB_SCREENS(i) { viewport_set_defaults(&vp[i], i); @@ -986,8 +985,6 @@ int radio_screen(void) gui_buttonbar_draw(&buttonbar); #endif } - /* Only force the redraw if update_screen is true */ - gui_syncstatusbar_draw(&statusbars,true); } update_screen = false; @@ -1027,7 +1024,6 @@ int radio_screen(void) if(audio_status() & AUDIO_STATUS_ERROR) { splash(0, str(LANG_DISK_FULL)); - gui_syncstatusbar_draw(&statusbars,true); FOR_NB_SCREENS(i) { screens[i].set_viewport(&vp[i]); @@ -1397,7 +1393,6 @@ static int handle_radio_presets(void) while (result == 0) { gui_synclist_draw(&lists); - gui_syncstatusbar_draw(&statusbars, true); list_do_action(CONTEXT_STD, TIMEOUT_BLOCK, &lists, &action, LIST_WRAP_UNLESS_HELD); switch (action) diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index a8586b9735..bdf30212f7 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -1038,7 +1038,6 @@ bool recording_screen(bool no_source) bool statusbar = global_settings.statusbar; global_status.statusbar_forced = statusbar?0:1; global_settings.statusbar = true; - gui_syncstatusbar_draw(&statusbars,true); #endif static const unsigned char *byte_units[] = { @@ -1102,7 +1101,7 @@ bool recording_screen(bool no_source) /* top vp, 4 lines, force sys font if total screen < 6 lines NOTE: one could limit the list to 1 line and get away with 5 lines */ v = &vp_top[i]; - viewport_set_defaults(v, i); /*already takes care of statusbar*/ + viewport_set_defaults(v, i); if (viewport_get_nb_lines(v) < 4) { /* compact needs 4 lines total */ @@ -1864,7 +1863,6 @@ bool recording_screen(bool no_source) /* draw peakmeter again (check if this can be removed) */ FOR_NB_ACTIVE_SCREENS(i) { - screens[i].set_viewport(NULL); gui_statusbar_draw(&(statusbars.statusbars[i]), true); screens[i].set_viewport(&vp_top[i]); peak_meter_screen(&screens[i], pm_x[i], pm_y[i], pm_h[i]); @@ -1882,7 +1880,6 @@ bool recording_screen(bool no_source) if (audio_stat & AUDIO_STATUS_ERROR) { splash(0, str(LANG_DISK_FULL)); - gui_syncstatusbar_draw(&statusbars, true); FOR_NB_SCREENS(i) screens[i].update(); diff --git a/apps/root_menu.c b/apps/root_menu.c index 9d4f256370..3b0907f00a 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -46,6 +46,7 @@ #include "buttonbar.h" #include "action.h" #include "yesno.h" +#include "viewport.h" #include "tree.h" #if CONFIG_TUNER @@ -117,7 +118,6 @@ static int browser(void* param) /* Now display progress until it's ready or the user exits */ while(!tagcache_is_usable()) { - gui_syncstatusbar_draw(&statusbars, false); struct tagcache_stat *stat = tagcache_get_stat(); /* Allow user to exit */ @@ -262,6 +262,8 @@ static int wpsscrn(void* param) #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif + /* always re-enable the statusbar after the WPS */ + viewportmanager_set_statusbar(true); return ret_val; } #if CONFIG_TUNER diff --git a/apps/screens.c b/apps/screens.c index 230e9ae53c..8a787a5ca1 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -138,7 +138,6 @@ void usb_screen(void) screens[i].update(); } - gui_syncstatusbar_draw(&statusbars, true); #ifdef SIMULATOR while (button_get(true) & BUTTON_REL); #else @@ -355,7 +354,6 @@ int charging_screen(void) remote_backlight_set_timeout(global_settings.remote_backlight_timeout); #endif backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); - gui_syncstatusbar_draw(&statusbars, true); #ifdef HAVE_LCD_CHARCELLS logo_lock_patterns(true); @@ -584,7 +582,6 @@ bool set_time_screen(const char* title, struct tm *tm) screens[s].update_viewport(); screens[s].set_viewport(NULL); } - gui_syncstatusbar_draw(&statusbars, true); /* set the most common numbers */ min = 0; @@ -841,9 +838,7 @@ bool browse_id3(void) gui_synclist_init(&id3_lists, &id3_get_info, &info, true, 2, NULL); gui_synclist_set_nb_items(&id3_lists, info.count*2); gui_synclist_draw(&id3_lists); - gui_syncstatusbar_draw(&statusbars, true); while (true) { - gui_syncstatusbar_draw(&statusbars, false); key = get_action(CONTEXT_LIST,HZ/2); if(key!=ACTION_NONE && key!=ACTION_UNKNOWN && !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD)) @@ -916,7 +911,6 @@ bool view_runtime(void) } lasttime = current_tick; gui_synclist_draw(&lists); - gui_syncstatusbar_draw(&statusbars, true); list_do_action(CONTEXT_STD, HZ, &lists, &action, LIST_WRAP_UNLESS_HELD); if(action == ACTION_STD_CANCEL) diff --git a/apps/settings.c b/apps/settings.c index b6c721ca32..dcd68b6a9c 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -273,7 +273,7 @@ bool settings_load_config(const char* file, bool apply) while (read_line(fd, line, sizeof line) > 0) { if (!settings_parseline(line, &name, &value)) - continue; + continue; for(i=0; ioption_callback) + settings[i].bool_setting->option_callback(temp==0?false:true); break; } case F_T_CHARPTR: diff --git a/apps/settings_list.c b/apps/settings_list.c index e3874566ac..18bcb8ea2c 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -52,6 +52,7 @@ #ifdef IPOD_ACCESSORY_PROTOCOL #include "iap.h" #endif +#include "statusbar.h" #define NVRAM(bytes) (bytes<