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:
parent
a06f287c81
commit
daaecb987c
5 changed files with 72 additions and 43 deletions
|
@ -130,10 +130,13 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
|||
vp = list_text[screen];
|
||||
vp.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 *
|
||||
viewport_get_nb_lines(&list_text[screen]);
|
||||
vp.x = parent->x;
|
||||
if(!global_settings.scrollbar_position) /* right */
|
||||
vp.x += list_text[screen].width;
|
||||
display->set_viewport(&vp);
|
||||
gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1,
|
||||
vp.height, list->nb_items,
|
||||
|
@ -144,8 +147,11 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
|||
else if (show_title)
|
||||
{
|
||||
/* shift everything right a bit... */
|
||||
list_text[screen].width -= SCROLLBAR_WIDTH;
|
||||
list_text[screen].x += SCROLLBAR_WIDTH;
|
||||
if(global_settings.scrollbar_position) /* left */
|
||||
{
|
||||
list_text[screen].width -= SCROLLBAR_WIDTH;
|
||||
list_text[screen].x += SCROLLBAR_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
/* setup icon placement */
|
||||
|
@ -284,6 +290,35 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
|||
*/
|
||||
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)
|
||||
{
|
||||
short x, y;
|
||||
|
@ -306,33 +341,15 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
|
|||
return ACTION_NONE;
|
||||
}
|
||||
/* Scroll bar */
|
||||
else
|
||||
{
|
||||
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 if(global_settings.scrollbar_position) /* left */
|
||||
return gui_synclist_touchscreen_scrollbar(gui_list, y);
|
||||
}
|
||||
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: |
|
||||
* |--------------------------------------------------------|
|
||||
|
|
|
@ -12224,36 +12224,30 @@
|
|||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_LEFT
|
||||
desc: DEPRECATED
|
||||
desc: Generic use of 'left'
|
||||
user: core
|
||||
<source>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Left"
|
||||
</source>
|
||||
<dest>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Left"
|
||||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Left"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
id: LANG_RIGHT
|
||||
desc: DEPRECATED
|
||||
desc: Generic use of 'right
|
||||
user: core
|
||||
<source>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Right"
|
||||
</source>
|
||||
<dest>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Right"
|
||||
</dest>
|
||||
<voice>
|
||||
*: none
|
||||
quickscreen: ""
|
||||
*: "Right"
|
||||
</voice>
|
||||
</phrase>
|
||||
<phrase>
|
||||
|
@ -12685,3 +12679,17 @@
|
|||
*: "Scroll bar width"
|
||||
</voice>
|
||||
</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>
|
||||
|
|
|
@ -320,6 +320,8 @@ static int statusbar_callback(int action,const struct menu_item_ex *this_item)
|
|||
return action;
|
||||
}
|
||||
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);
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, statusbar_callback);
|
||||
|
@ -329,9 +331,8 @@ MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL);
|
|||
#endif
|
||||
MENUITEM_SETTING(volume_type, &global_settings.volume_type, 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,
|
||||
&scrollbar_item, &scrollbar_width, &statusbar,
|
||||
&scrollbar_item, &scrollbar_width, &scrollbar_position, &statusbar,
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
&remote_statusbar,
|
||||
#endif
|
||||
|
|
|
@ -770,6 +770,7 @@ struct user_settings
|
|||
#endif
|
||||
#endif
|
||||
int scrollbar_width;
|
||||
bool scrollbar_position; /* true=left false=right */
|
||||
};
|
||||
|
||||
/** global variables **/
|
||||
|
|
|
@ -607,6 +607,8 @@ const struct settings_list settings[] = {
|
|||
OFFON_SETTING(0,scrollbar, LANG_SCROLL_BAR, true, "scrollbar", NULL),
|
||||
INT_SETTING(0, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, "scrollbar width",
|
||||
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
|
||||
OFFON_SETTING(0,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue