forked from len0rd/rockbox
Use the multi-screen api in the usb and time screens
usb screen forces the status bar to display (fixes FS#700) time screen is now usable on the lcd remotes (need keymaps for the m5/x5) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13903 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f22dd51956
commit
3d73b8eb16
2 changed files with 133 additions and 100 deletions
|
|
@ -710,6 +710,14 @@ static const struct button_mapping button_context_radio_h300lcdremote[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const struct button_mapping button_context_time_remote[] = {
|
||||||
|
{ ACTION_STD_CANCEL, BUTTON_OFF, BUTTON_NONE },
|
||||||
|
{ ACTION_STD_OK, BUTTON_ON, BUTTON_NONE },
|
||||||
|
{ ACTION_SETTINGS_INC, BUTTON_RC_BITRATE, BUTTON_NONE },
|
||||||
|
{ ACTION_SETTINGS_DEC, BUTTON_RC_SOURCE, BUTTON_NONE },
|
||||||
|
LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
|
||||||
|
}; /* button_context_settings_bmark */
|
||||||
|
|
||||||
/* the actual used tables */
|
/* the actual used tables */
|
||||||
static const struct button_mapping
|
static const struct button_mapping
|
||||||
*remote_btn_ctxt_std = 0,
|
*remote_btn_ctxt_std = 0,
|
||||||
|
|
@ -878,6 +886,8 @@ static const struct button_mapping* get_context_mapping_remote(int context)
|
||||||
return remote_btn_ctxt_listtree_scroll_w_cmb;
|
return remote_btn_ctxt_listtree_scroll_w_cmb;
|
||||||
case CONTEXT_CUSTOM|CONTEXT_TREE:
|
case CONTEXT_CUSTOM|CONTEXT_TREE:
|
||||||
return remote_btn_ctxt_tree;
|
return remote_btn_ctxt_tree;
|
||||||
|
case CONTEXT_SETTINGS_TIME:
|
||||||
|
return remote_btn_ctxt_settingsgrph;
|
||||||
|
|
||||||
case CONTEXT_SETTINGS:
|
case CONTEXT_SETTINGS:
|
||||||
return remote_btn_ctxt_settings;
|
return remote_btn_ctxt_settings;
|
||||||
|
|
|
||||||
221
apps/screens.c
221
apps/screens.c
|
|
@ -86,44 +86,45 @@ void usb_screen(void)
|
||||||
/* nothing here! */
|
/* nothing here! */
|
||||||
#else
|
#else
|
||||||
int i;
|
int i;
|
||||||
|
bool statusbar = global_settings.statusbar; /* force the statusbar */
|
||||||
|
global_settings.statusbar = true;
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
show_main_backdrop();
|
show_main_backdrop();
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
||||||
show_remote_main_backdrop();
|
show_remote_main_backdrop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FOR_NB_SCREENS(i)
|
FOR_NB_SCREENS(i)
|
||||||
|
{
|
||||||
screens[i].backlight_on();
|
screens[i].backlight_on();
|
||||||
|
screens[i].clear_display();
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#if NB_SCREENS > 1
|
||||||
lcd_remote_clear_display();
|
if (i == SCREEN_REMOTE)
|
||||||
lcd_remote_bitmap(remote_usblogo,
|
{
|
||||||
|
screens[i].bitmap(remote_usblogo,
|
||||||
(LCD_REMOTE_WIDTH-BMPWIDTH_remote_usblogo),
|
(LCD_REMOTE_WIDTH-BMPWIDTH_remote_usblogo),
|
||||||
(LCD_REMOTE_HEIGHT-BMPHEIGHT_remote_usblogo)/2,
|
(LCD_REMOTE_HEIGHT-BMPHEIGHT_remote_usblogo)/2,
|
||||||
BMPWIDTH_remote_usblogo, BMPHEIGHT_remote_usblogo);
|
BMPWIDTH_remote_usblogo, BMPHEIGHT_remote_usblogo);
|
||||||
lcd_remote_update();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lcd_clear_display();
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#ifdef HAVE_LCD_COLOR
|
screens[i].transparent_bitmap(usblogo,
|
||||||
lcd_bitmap_transparent(usblogo, (LCD_WIDTH-BMPWIDTH_usblogo),
|
(LCD_WIDTH-BMPWIDTH_usblogo),
|
||||||
(LCD_HEIGHT-BMPHEIGHT_usblogo)/2,
|
|
||||||
BMPWIDTH_usblogo, BMPHEIGHT_usblogo);
|
|
||||||
#else
|
|
||||||
lcd_bitmap(usblogo, (LCD_WIDTH-BMPWIDTH_usblogo),
|
|
||||||
(LCD_HEIGHT-BMPHEIGHT_usblogo)/2,
|
(LCD_HEIGHT-BMPHEIGHT_usblogo)/2,
|
||||||
BMPWIDTH_usblogo, BMPHEIGHT_usblogo);
|
BMPWIDTH_usblogo, BMPHEIGHT_usblogo);
|
||||||
#endif /* HAVE_LCD_COLOR */
|
|
||||||
#else
|
#else
|
||||||
lcd_double_height(false);
|
screens[i].puts_scroll(0, 0, "[USB Mode]");
|
||||||
lcd_puts_scroll(0, 0, "[USB Mode]");
|
status_set_param(false);
|
||||||
status_set_param(false);
|
status_set_audio(false);
|
||||||
status_set_audio(false);
|
status_set_usb(true);
|
||||||
status_set_usb(true);
|
|
||||||
#endif /* HAVE_LCD_BITMAP */
|
#endif /* HAVE_LCD_BITMAP */
|
||||||
lcd_update();
|
#if NB_SCREENS > 1
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
screens[i].update();
|
||||||
|
}
|
||||||
|
|
||||||
gui_syncstatusbar_draw(&statusbars, true);
|
gui_syncstatusbar_draw(&statusbars, true);
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
|
|
@ -144,6 +145,7 @@ void usb_screen(void)
|
||||||
#endif /* HAVE_LCD_CHARCELLS */
|
#endif /* HAVE_LCD_CHARCELLS */
|
||||||
FOR_NB_SCREENS(i)
|
FOR_NB_SCREENS(i)
|
||||||
screens[i].backlight_on();
|
screens[i].backlight_on();
|
||||||
|
global_settings.statusbar = statusbar;
|
||||||
#endif /* USB_NONE */
|
#endif /* USB_NONE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -862,7 +864,7 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int button;
|
int button;
|
||||||
int i;
|
int i, s;
|
||||||
int cursorpos = 0;
|
int cursorpos = 0;
|
||||||
int lastcursorpos = !cursorpos;
|
int lastcursorpos = !cursorpos;
|
||||||
unsigned int julianday;
|
unsigned int julianday;
|
||||||
|
|
@ -922,10 +924,6 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
str(dayname[tm->tm_wday]), tm->tm_year+1900,
|
str(dayname[tm->tm_wday]), tm->tm_year+1900,
|
||||||
str(monthname[tm->tm_mon]), tm->tm_mday);
|
str(monthname[tm->tm_mon]), tm->tm_mday);
|
||||||
|
|
||||||
/* recalculate the positions and offsets */
|
|
||||||
lcd_getstringsize(title, &width, &prev_line_height);
|
|
||||||
lcd_getstringsize(buffer, &width, &line_height);
|
|
||||||
lcd_getstringsize(SEPARATOR, &separator_width, &height);
|
|
||||||
|
|
||||||
/* convert spaces in the buffer to \0 to make it possible to work
|
/* convert spaces in the buffer to \0 to make it possible to work
|
||||||
directly on the buffer */
|
directly on the buffer */
|
||||||
|
|
@ -935,83 +933,103 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
buffer[9 + DAYNAME_LEN] = '\0';
|
buffer[9 + DAYNAME_LEN] = '\0';
|
||||||
buffer[14 + DAYNAME_LEN] = '\0';
|
buffer[14 + DAYNAME_LEN] = '\0';
|
||||||
buffer[15 + DAYNAME_LEN + MONTHNAME_LEN] = '\0';
|
buffer[15 + DAYNAME_LEN + MONTHNAME_LEN] = '\0';
|
||||||
|
FOR_NB_SCREENS(s)
|
||||||
/* hour */
|
|
||||||
lcd_getstringsize(buffer, &width, &height);
|
|
||||||
/* cursor[0][INDEX_X] is already 0 because of the memset */
|
|
||||||
cursor[0][INDEX_Y] = prev_line_height + statusbar_height;
|
|
||||||
cursor[0][INDEX_WIDTH] = width;
|
|
||||||
|
|
||||||
/* minute */
|
|
||||||
lcd_getstringsize(buffer + 3, &width, &height);
|
|
||||||
cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width;
|
|
||||||
cursor[1][INDEX_Y] = prev_line_height + statusbar_height;
|
|
||||||
cursor[1][INDEX_WIDTH] = width;
|
|
||||||
|
|
||||||
/* second */
|
|
||||||
lcd_getstringsize(buffer + 6, &width, &height);
|
|
||||||
cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width +
|
|
||||||
cursor[1][INDEX_WIDTH] + separator_width;
|
|
||||||
cursor[2][INDEX_Y] = prev_line_height + statusbar_height;
|
|
||||||
|
|
||||||
/* weekday */
|
|
||||||
lcd_getstringsize(buffer + 9, &weekday_width, &height);
|
|
||||||
lcd_getstringsize(" ", &separator_width, &height);
|
|
||||||
|
|
||||||
/* year */
|
|
||||||
lcd_getstringsize(buffer + 10 + DAYNAME_LEN, &width, &height);
|
|
||||||
cursor[3][INDEX_X] = weekday_width + separator_width;
|
|
||||||
cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
|
||||||
cursor[3][INDEX_WIDTH] = width;
|
|
||||||
|
|
||||||
/* month */
|
|
||||||
lcd_getstringsize(buffer + 15 + DAYNAME_LEN, &width, &height);
|
|
||||||
cursor[4][INDEX_X] = weekday_width + 2 * separator_width +
|
|
||||||
cursor[3][INDEX_WIDTH];
|
|
||||||
cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
|
||||||
cursor[4][INDEX_WIDTH] = width;
|
|
||||||
|
|
||||||
/* day */
|
|
||||||
lcd_getstringsize(buffer + 16 + DAYNAME_LEN + MONTHNAME_LEN, &width, &height);
|
|
||||||
cursor[5][INDEX_X] = weekday_width + 3 * separator_width +
|
|
||||||
cursor[3][INDEX_WIDTH] +
|
|
||||||
cursor[4][INDEX_WIDTH];
|
|
||||||
cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
|
||||||
|
|
||||||
/* draw the screen */
|
|
||||||
lcd_set_drawmode(DRMODE_SOLID);
|
|
||||||
lcd_clear_display();
|
|
||||||
/* display the screen title */
|
|
||||||
lcd_puts_scroll(0, 0, title);
|
|
||||||
|
|
||||||
/* these are not selectable, so we draw them outside the loop */
|
|
||||||
lcd_putsxy(0, cursor[3][INDEX_Y], buffer + 9); /* name of the week day */
|
|
||||||
lcd_putsxy(cursor[1][INDEX_X] - separator_width, cursor[0][INDEX_Y],
|
|
||||||
SEPARATOR);
|
|
||||||
lcd_putsxy(cursor[2][INDEX_X] - separator_width, cursor[0][INDEX_Y],
|
|
||||||
SEPARATOR);
|
|
||||||
|
|
||||||
/* draw the selected item with drawmode set to
|
|
||||||
DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
|
|
||||||
items with drawmode DRMODE_SOLID */
|
|
||||||
for(i=0; i<6; i++)
|
|
||||||
{
|
{
|
||||||
if (cursorpos == i)
|
/* minimum lines needed is 2 + title line */
|
||||||
lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
gui_textarea_update_nblines(&screens[s]);
|
||||||
|
if (screens[s].nb_lines < 4)
|
||||||
|
{
|
||||||
|
screens[s].setfont(FONT_SYSFIXED);
|
||||||
|
gui_textarea_update_nblines(&screens[s]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* recalculate the positions and offsets */
|
||||||
|
if (screens[s].nb_lines >= 3)
|
||||||
|
screens[s].getstringsize(title, &width, &prev_line_height);
|
||||||
else
|
else
|
||||||
lcd_set_drawmode(DRMODE_SOLID);
|
prev_line_height = 0;
|
||||||
|
screens[s].getstringsize(buffer, &width, &line_height);
|
||||||
|
screens[s].getstringsize(SEPARATOR, &separator_width, &height);
|
||||||
|
|
||||||
lcd_putsxy(cursor[i][INDEX_X], cursor[i][INDEX_Y], ptr[i]);
|
/* hour */
|
||||||
|
screens[s].getstringsize(buffer, &width, &height);
|
||||||
|
/* cursor[0][INDEX_X] is already 0 because of the memset */
|
||||||
|
cursor[0][INDEX_Y] = prev_line_height + statusbar_height;
|
||||||
|
cursor[0][INDEX_WIDTH] = width;
|
||||||
|
|
||||||
|
/* minute */
|
||||||
|
screens[s].getstringsize(buffer + 3, &width, &height);
|
||||||
|
cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width;
|
||||||
|
cursor[1][INDEX_Y] = prev_line_height + statusbar_height;
|
||||||
|
cursor[1][INDEX_WIDTH] = width;
|
||||||
|
|
||||||
|
/* second */
|
||||||
|
screens[s].getstringsize(buffer + 6, &width, &height);
|
||||||
|
cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width +
|
||||||
|
cursor[1][INDEX_WIDTH] + separator_width;
|
||||||
|
cursor[2][INDEX_Y] = prev_line_height + statusbar_height;
|
||||||
|
|
||||||
|
/* weekday */
|
||||||
|
screens[s].getstringsize(buffer + 9, &weekday_width, &height);
|
||||||
|
screens[s].getstringsize(" ", &separator_width, &height);
|
||||||
|
|
||||||
|
/* year */
|
||||||
|
screens[s].getstringsize(buffer + 10 + DAYNAME_LEN, &width, &height);
|
||||||
|
cursor[3][INDEX_X] = weekday_width + separator_width;
|
||||||
|
cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
||||||
|
cursor[3][INDEX_WIDTH] = width;
|
||||||
|
|
||||||
|
/* month */
|
||||||
|
screens[s].getstringsize(buffer + 15 + DAYNAME_LEN, &width, &height);
|
||||||
|
cursor[4][INDEX_X] = weekday_width + 2 * separator_width +
|
||||||
|
cursor[3][INDEX_WIDTH];
|
||||||
|
cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
||||||
|
cursor[4][INDEX_WIDTH] = width;
|
||||||
|
|
||||||
|
/* day */
|
||||||
|
screens[s].getstringsize(buffer + 16 + DAYNAME_LEN + MONTHNAME_LEN,
|
||||||
|
&width, &height);
|
||||||
|
cursor[5][INDEX_X] = weekday_width + 3 * separator_width +
|
||||||
|
cursor[3][INDEX_WIDTH] +
|
||||||
|
cursor[4][INDEX_WIDTH];
|
||||||
|
cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
||||||
|
|
||||||
|
/* draw the screen */
|
||||||
|
screens[s].set_drawmode(DRMODE_SOLID);
|
||||||
|
screens[s].clear_display();
|
||||||
|
/* display the screen title */
|
||||||
|
screens[s].puts_scroll(0, 0, title);
|
||||||
|
|
||||||
|
/* these are not selectable, so we draw them outside the loop */
|
||||||
|
screens[s].putsxy(0, cursor[3][INDEX_Y], buffer + 9); /* name of the week day */
|
||||||
|
screens[s].putsxy(cursor[1][INDEX_X] - separator_width,
|
||||||
|
cursor[0][INDEX_Y], SEPARATOR);
|
||||||
|
screens[s].putsxy(cursor[2][INDEX_X] - separator_width,
|
||||||
|
cursor[0][INDEX_Y], SEPARATOR);
|
||||||
|
|
||||||
|
/* draw the selected item with drawmode set to
|
||||||
|
DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
|
||||||
|
items with drawmode DRMODE_SOLID */
|
||||||
|
for(i=0; i<6; i++)
|
||||||
|
{
|
||||||
|
if (cursorpos == i)
|
||||||
|
screens[s].set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
||||||
|
else
|
||||||
|
screens[s].set_drawmode(DRMODE_SOLID);
|
||||||
|
|
||||||
|
screens[s].putsxy(cursor[i][INDEX_X],
|
||||||
|
cursor[i][INDEX_Y], ptr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print help text */
|
||||||
|
if (screens[s].nb_lines > 4)
|
||||||
|
screens[s].puts(0, 4, str(LANG_TIME_SET));
|
||||||
|
if (screens[s].nb_lines > 5)
|
||||||
|
screens[s].puts(0, 5, str(LANG_TIME_REVERT));
|
||||||
|
screens[s].update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print help text */
|
|
||||||
lcd_puts(0, 4, str(LANG_TIME_SET));
|
|
||||||
lcd_puts(0, 5, str(LANG_TIME_REVERT));
|
|
||||||
|
|
||||||
gui_syncstatusbar_draw(&statusbars, true);
|
gui_syncstatusbar_draw(&statusbars, true);
|
||||||
|
|
||||||
lcd_update();
|
|
||||||
|
|
||||||
/* calculate the minimum and maximum for the number under cursor */
|
/* calculate the minimum and maximum for the number under cursor */
|
||||||
if(cursorpos!=lastcursorpos) {
|
if(cursorpos!=lastcursorpos) {
|
||||||
lastcursorpos=cursorpos;
|
lastcursorpos=cursorpos;
|
||||||
|
|
@ -1050,7 +1068,7 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
say_time(cursorpos, tm);
|
say_time(cursorpos, tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
button = get_action(CONTEXT_SETTINGS_TIME,HZ/2);
|
button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK);
|
||||||
switch ( button ) {
|
switch ( button ) {
|
||||||
case ACTION_STD_PREV:
|
case ACTION_STD_PREV:
|
||||||
cursorpos = (cursorpos + 6 - 1) % 6;
|
cursorpos = (cursorpos + 6 - 1) % 6;
|
||||||
|
|
@ -1090,6 +1108,11 @@ bool set_time_screen(const char* title, struct tm *tm)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FOR_NB_SCREENS(i)
|
||||||
|
{
|
||||||
|
screens[i].setfont(FONT_UI);
|
||||||
|
gui_textarea_update_nblines(&screens[i]);
|
||||||
|
}
|
||||||
action_signalscreenchange();
|
action_signalscreenchange();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue