Add setting to position the scrollbar on the left or right

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22390 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Maurus Cuelenaere 2009-08-17 23:36:49 +00:00
parent a06f287c81
commit daaecb987c
5 changed files with 72 additions and 43 deletions

View file

@ -130,10 +130,13 @@ void list_draw(struct screen *display, struct gui_synclist *list)
vp = list_text[screen]; vp = list_text[screen];
vp.width = SCROLLBAR_WIDTH; vp.width = SCROLLBAR_WIDTH;
list_text[screen].width -= SCROLLBAR_WIDTH; list_text[screen].width -= SCROLLBAR_WIDTH;
list_text[screen].x += SCROLLBAR_WIDTH; if(global_settings.scrollbar_position) /* left */
list_text[screen].x += SCROLLBAR_WIDTH;
vp.height = line_height * vp.height = line_height *
viewport_get_nb_lines(&list_text[screen]); viewport_get_nb_lines(&list_text[screen]);
vp.x = parent->x; vp.x = parent->x;
if(!global_settings.scrollbar_position) /* right */
vp.x += list_text[screen].width;
display->set_viewport(&vp); display->set_viewport(&vp);
gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1,
vp.height, list->nb_items, vp.height, list->nb_items,
@ -144,8 +147,11 @@ void list_draw(struct screen *display, struct gui_synclist *list)
else if (show_title) else if (show_title)
{ {
/* shift everything right a bit... */ /* shift everything right a bit... */
list_text[screen].width -= SCROLLBAR_WIDTH; if(global_settings.scrollbar_position) /* left */
list_text[screen].x += SCROLLBAR_WIDTH; {
list_text[screen].width -= SCROLLBAR_WIDTH;
list_text[screen].x += SCROLLBAR_WIDTH;
}
} }
/* setup icon placement */ /* setup icon placement */
@ -284,6 +290,35 @@ void list_draw(struct screen *display, struct gui_synclist *list)
*/ */
static bool scrolling=false; static bool scrolling=false;
static int gui_synclist_touchscreen_scrollbar(struct gui_synclist * gui_list,
int y)
{
int screen = screens[SCREEN_MAIN].screen_type;
int nb_lines = viewport_get_nb_lines(&list_text[screen]);
if (nb_lines < gui_list->nb_items)
{
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 start_item = new_selection - nb_lines/2;
if(start_item < 0)
start_item = 0;
else if(start_item > gui_list->nb_items - nb_lines)
start_item = gui_list->nb_items - nb_lines;
gui_list->start_item[screen] = start_item;
gui_synclist_select_item(gui_list, new_selection);
return ACTION_REDRAW;
}
return ACTION_NONE;
}
unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
{ {
short x, y; short x, y;
@ -306,33 +341,15 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
return ACTION_NONE; return ACTION_NONE;
} }
/* Scroll bar */ /* Scroll bar */
else else if(global_settings.scrollbar_position) /* left */
{ return gui_synclist_touchscreen_scrollbar(gui_list, y);
int nb_lines = viewport_get_nb_lines(&list_text[screen]);
if (nb_lines < gui_list->nb_items)
{
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 start_item = new_selection - nb_lines/2;
if(start_item < 0)
start_item = 0;
else if(start_item > gui_list->nb_items - nb_lines)
start_item = gui_list->nb_items - nb_lines;
gui_list->start_item[screen] = start_item;
gui_synclist_select_item(gui_list, new_selection);
return ACTION_REDRAW;
}
}
} }
else else
{ {
if(x>list_text[screen].x+list_text[screen].width &&
!global_settings.scrollbar_position) /* right*/
return gui_synclist_touchscreen_scrollbar(gui_list, y);
/* |--------------------------------------------------------| /* |--------------------------------------------------------|
* | Description of the touchscreen list interface: | * | Description of the touchscreen list interface: |
* |--------------------------------------------------------| * |--------------------------------------------------------|

View file

@ -12224,36 +12224,30 @@
</phrase> </phrase>
<phrase> <phrase>
id: LANG_LEFT id: LANG_LEFT
desc: DEPRECATED desc: Generic use of 'left'
user: core user: core
<source> <source>
*: none *: "Left"
quickscreen: ""
</source> </source>
<dest> <dest>
*: none *: "Left"
quickscreen: ""
</dest> </dest>
<voice> <voice>
*: none *: "Left"
quickscreen: ""
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
id: LANG_RIGHT id: LANG_RIGHT
desc: DEPRECATED desc: Generic use of 'right
user: core user: core
<source> <source>
*: none *: "Right"
quickscreen: ""
</source> </source>
<dest> <dest>
*: none *: "Right"
quickscreen: ""
</dest> </dest>
<voice> <voice>
*: none *: "Right"
quickscreen: ""
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -12685,3 +12679,17 @@
*: "Scroll bar width" *: "Scroll bar width"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_SCROLLBAR_POSITION
desc: in Settings -> General -> Display -> Status-/Scrollbar
user: core
<source>
*: "Scroll Bar Position"
</source>
<dest>
*: "Scroll Bar Position"
</dest>
<voice>
*: "Scroll bar position"
</voice>
</phrase>

View file

@ -320,6 +320,8 @@ static int statusbar_callback(int action,const struct menu_item_ex *this_item)
return action; return action;
} }
MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL); MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL);
MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
MENUITEM_SETTING(scrollbar_position, &global_settings.scrollbar_position, NULL);
MENUITEM_SETTING(statusbar, &global_settings.statusbar, statusbar_callback); MENUITEM_SETTING(statusbar, &global_settings.statusbar, statusbar_callback);
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, statusbar_callback); MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, statusbar_callback);
@ -329,9 +331,8 @@ MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL);
#endif #endif
MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL); MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL);
MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL); MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL);
MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, Icon_NOICON, MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, Icon_NOICON,
&scrollbar_item, &scrollbar_width, &statusbar, &scrollbar_item, &scrollbar_width, &scrollbar_position, &statusbar,
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
&remote_statusbar, &remote_statusbar,
#endif #endif

View file

@ -770,6 +770,7 @@ struct user_settings
#endif #endif
#endif #endif
int scrollbar_width; int scrollbar_width;
bool scrollbar_position; /* true=left false=right */
}; };
/** global variables **/ /** global variables **/

View file

@ -607,6 +607,8 @@ const struct settings_list settings[] = {
OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true, "scrollbar", NULL), OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true, "scrollbar", NULL),
INT_SETTING(0, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, "scrollbar width", INT_SETTING(0, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, "scrollbar width",
UNIT_INT, 3, LCD_WIDTH/10, 1, NULL, NULL, NULL), UNIT_INT, 3, LCD_WIDTH/10, 1, NULL, NULL, NULL),
BOOL_SETTING(0, scrollbar_position, LANG_SCROLLBAR_POSITION, true,
"scrollbar pos", "left,right", LANG_LEFT, LANG_RIGHT, NULL),
#if CONFIG_KEYPAD == RECORDER_PAD #if CONFIG_KEYPAD == RECORDER_PAD
OFFON_SETTING(0,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL), OFFON_SETTING(0,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
#endif #endif