summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-01-22 04:24:26 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-01-22 04:24:26 +0000
commitd3a03b679f196be076043d475b9512338fd6c8bb (patch)
treec4c57a157a46d09a7037c39e290182a8c43deb71 /apps
parentbfe740712a3513dbb4143336cbc5e9aaab09d732 (diff)
downloadrockbox-d3a03b679f196be076043d475b9512338fd6c8bb.tar.gz
rockbox-d3a03b679f196be076043d475b9512338fd6c8bb.tar.bz2
rockbox-d3a03b679f196be076043d475b9512338fd6c8bb.zip
Horizontal screen scrolling part 3 (by Shachar Liberman)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8414 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/list.c172
-rw-r--r--apps/gui/list.h45
-rw-r--r--apps/screen_access.c21
-rw-r--r--apps/screen_access.h16
-rw-r--r--apps/settings.h6
-rw-r--r--apps/settings_menu.c6
6 files changed, 129 insertions, 137 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 2ae5f995f4..ce2a3354e4 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -37,8 +37,13 @@
#define SCROLL_LIMIT 2
#endif
-static int offset_step = 15;
-static bool offset_outof_view = false;
+#ifdef HAVE_LCD_BITMAP
+static int offset_step = 16; /* pixels per screen scroll step */
+/* should lines scroll out of the screen */
+static bool offset_out_of_view = false;
+#endif
+
+
void gui_list_init(struct gui_list * gui_list,
list_get_name callback_get_item_name,
@@ -54,7 +59,9 @@ void gui_list_init(struct gui_list * gui_list,
gui_list->limit_scroll = false;
gui_list->data=data;
gui_list->cursor_flash_state=false;
- gui_list->offsetval = 0;
+#ifdef HAVE_LCD_BITMAP
+ gui_list->offset_position = 0;
+#endif
}
void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
@@ -181,47 +188,43 @@ void gui_list_draw(struct gui_list * gui_list)
entry_name = gui_list->callback_get_item_name(current_item,
gui_list->data,
entry_buffer);
-
#ifdef HAVE_LCD_BITMAP
- /* position the string at the right offset place */
- int item_offset;
- int str_width,h;
- display->getstringsize(entry_name, &str_width, &h);
+ /* position the string at the correct offset place */
+ int item_offset;
+ int item_width,h;
+ display->getstringsize(entry_name, &item_width, &h);
- if (offset_outof_view)
- item_offset = gui_list->offsetval;
- else
- /* if text is smaller then view */
- if (str_width <= display->width - text_pos)
- item_offset = 0;
+ if (offset_out_of_view)
+ item_offset = gui_list->offset_position;
else
- /* if text got out of view */
- if (gui_list->offsetval > str_width - (display->width - text_pos))
- item_offset = str_width - (display->width - text_pos);
+ /* if text is smaller then view */
+ if (item_width <= display->width - text_pos)
+ item_offset = 0;
else
- item_offset = gui_list->offsetval;
-
-#endif
+ /* if text got out of view */
+ if (gui_list->offset_position >
+ item_width - (display->width - text_pos))
+ item_offset = item_width - (display->width - text_pos);
+ else
+ item_offset = gui_list->offset_position;
+#endif
if(current_item == gui_list->selected_item) {
- /* The selected item must be displayed scrolling */
+ /* The selected item must be displayed scrolling */
#ifdef HAVE_LCD_BITMAP
- if (global_settings.invert_cursor) /* Display inverted-line-style*/
-
+ if (global_settings.invert_cursor)/* Display inverted-line-style*/
/* if text got out of view */
- if (item_offset > str_width - (display->width - text_pos))
+ if (item_offset > item_width - (display->width - text_pos))
/* don't scroll */
display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
else
display->puts_scroll_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
-
- else /* if (global_settings.invert_cursor) */
-
- if (item_offset > str_width - (display->width - text_pos))
- display->puts_offset(0, i, entry_name,item_offset);
- else
- display->puts_scroll_offset(0, i, entry_name,item_offset);
+ else /* if (!global_settings.invert_cursor) */
+ if (item_offset > item_width - (display->width - text_pos))
+ display->puts_offset(0, i, entry_name,item_offset);
+ else
+ display->puts_scroll_offset(0, i, entry_name,item_offset);
#else
display->puts_scroll(text_pos, i, entry_name);
#endif
@@ -264,40 +267,6 @@ void gui_list_draw(struct gui_list * gui_list)
gui_textarea_update(display);
}
-#ifdef HAVE_LCD_BITMAP
-void gui_list_screen_scroll_step(int ofs)
-{
- offset_step = ofs;
-}
-
-void gui_list_screen_scroll_out_of_view(bool enable)
-{
- if (enable)
- offset_outof_view = true;
- else
- offset_outof_view = false;
-}
-
-void gui_list_offset_right(struct gui_list * gui_list)
-{
- /* there should be a callback to find out what's the longest item on the list,
- * and then, by finding out the width with get_stringsize, we would stop the
- * list from scrolling at that point */
-
- gui_list->offsetval+=offset_step;
- if (gui_list->offsetval > 1000)
- gui_list->offsetval = 1000;
-}
-
-void gui_list_offset_left(struct gui_list * gui_list)
-{
- gui_list->offsetval-=offset_step;
- if (gui_list->offsetval < 0)
- gui_list->offsetval = 0;
-
-}
-#endif /* HAVE_LCD_BITMAP */
-
void gui_list_select_item(struct gui_list * gui_list, int item_number)
{
if( item_number > gui_list->nb_items-1 || item_number < 0 )
@@ -428,6 +397,37 @@ void gui_list_del_item(struct gui_list * gui_list)
}
}
+#ifdef HAVE_LCD_BITMAP
+void gui_list_scroll_right(struct gui_list * gui_list)
+{
+ /* FIXME: This is a fake right boundry limiter. there should be some
+ * callback function to find the longest item on the list in pixels,
+ * to stop the list from scrolling past that point */
+ gui_list->offset_position+=offset_step;
+ if (gui_list->offset_position > 1000)
+ gui_list->offset_position = 1000;
+}
+
+void gui_list_scroll_left(struct gui_list * gui_list)
+{
+ gui_list->offset_position-=offset_step;
+ if (gui_list->offset_position < 0)
+ gui_list->offset_position = 0;
+}
+void gui_list_screen_scroll_step(int ofs)
+{
+ offset_step = ofs;
+}
+
+void gui_list_screen_scroll_out_of_view(bool enable)
+{
+ if (enable)
+ offset_out_of_view = true;
+ else
+ offset_out_of_view = false;
+}
+#endif /* HAVE_LCD_BITMAP */
+
/*
* Synchronized lists stuffs
*/
@@ -453,7 +453,9 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
FOR_NB_SCREENS(i)
{
gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
- lists->gui_list[i].offsetval = 0;
+#ifdef HAVE_LCD_BITMAP
+ lists->gui_list[i].offset_position = 0;
+#endif
}
}
void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
@@ -502,22 +504,6 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
screens[screen].nb_lines);
}
-#ifdef HAVE_LCD_BITMAP
-void gui_synclist_offset_right(struct gui_synclist * lists)
-{
- int i;
- FOR_NB_SCREENS(i)
- gui_list_offset_right(&(lists->gui_list[i]));
-}
-
-void gui_synclist_offset_left(struct gui_synclist * lists)
-{
- int i;
- FOR_NB_SCREENS(i)
- gui_list_offset_left(&(lists->gui_list[i]));
-}
-#endif /* HAVE_LCD_BITMAP */
-
void gui_synclist_select_previous_page(struct gui_synclist * lists,
enum screen_type screen)
{
@@ -555,6 +541,22 @@ void gui_synclist_flash(struct gui_synclist * lists)
gui_list_flash(&(lists->gui_list[i]));
}
+#ifdef HAVE_LCD_BITMAP
+void gui_synclist_scroll_right(struct gui_synclist * lists)
+{
+ int i;
+ FOR_NB_SCREENS(i)
+ gui_list_scroll_right(&(lists->gui_list[i]));
+}
+
+void gui_synclist_scroll_left(struct gui_synclist * lists)
+{
+ int i;
+ FOR_NB_SCREENS(i)
+ gui_list_scroll_left(&(lists->gui_list[i]));
+}
+#endif /* HAVE_LCD_BITMAP */
+
unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
{
gui_synclist_limit_scroll(lists, true);
@@ -588,7 +590,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
gui_synclist_select_next(lists);
gui_synclist_draw(lists);
return LIST_NEXT;
-
+
#ifdef LIST_PGRIGHT
case LIST_PGRIGHT:
case LIST_PGRIGHT | BUTTON_REPEAT:
@@ -596,7 +598,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_RC_PGRIGHT:
case LIST_RC_PGRIGHT | BUTTON_REPEAT:
#endif
- gui_synclist_offset_right(lists);
+ gui_synclist_scroll_right(lists);
gui_synclist_draw(lists);
return true;
#endif
@@ -608,7 +610,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
case LIST_RC_PGLEFT:
case LIST_RC_PGLEFT | BUTTON_REPEAT:
#endif
- gui_synclist_offset_left(lists);
+ gui_synclist_scroll_left(lists);
gui_synclist_draw(lists);
return true;
#endif
diff --git a/apps/gui/list.h b/apps/gui/list.h
index e177f5ef75..8643c4d047 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -126,19 +126,20 @@ typedef void list_get_icon(int selected_item,
* a buffer when it's not necessary)
* Returns a pointer to a string that contains the text to display
*/
-
typedef char * list_get_name(int selected_item,
void * data,
char *buffer);
struct gui_list
{
- int offsetval; /* value of screen offset */
int nb_items;
int selected_item;
bool cursor_flash_state;
int start_item; /* the item that is displayed at the top of the screen */
+#ifdef HAVE_LCD_BITMAP
+ int offset_position; /* the list's screen scroll placement in pixels */
+#endif
list_get_icon *callback_get_item_icon;
list_get_name *callback_get_item_name;
@@ -234,13 +235,6 @@ extern void gui_list_draw(struct gui_list * gui_list);
* (Item 0 gets selected if the end of the list is reached)
* - gui_list : the list structure
*/
-
-extern void gui_list_screen_scroll_step(int ofs);
-/* parse global setting to static int */
-
-extern void gui_list_screen_scroll_out_of_view(bool enable);
-/* parse global setting to static bool */
-
extern void gui_list_select_next(struct gui_list * gui_list);
/*
@@ -250,27 +244,32 @@ extern void gui_list_select_next(struct gui_list * gui_list);
*/
extern void gui_list_select_previous(struct gui_list * gui_list);
-/*
- * Go to next page if any, else selects the last item in the list
- * - gui_list : the list structure
- * - nb_lines : the number of lines to try to move the cursor
- */
-
-extern void gui_list_offset_right(struct gui_list * gui_list);
-
+#ifdef HAVE_LCD_BITMAP
/*
* Makes all the item in the list scroll by one step to the right.
* Should stop increasing the value when reaching the widest item value
* in the list.
*/
-
-extern void gui_list_offset_left(struct gui_list * gui_list);
+void gui_list_scroll_right(struct gui_list * gui_list);
/*
* Makes all the item in the list scroll by one step to the left.
* stops at starting position.
- */
-
+ */
+void gui_list_scroll_left(struct gui_list * gui_list);
+
+/* parse global setting to static int */
+extern void gui_list_screen_scroll_step(int ofs);
+
+/* parse global setting to static bool */
+extern void gui_list_screen_scroll_out_of_view(bool enable);
+#endif /* HAVE_LCD_BITMAP */
+
+/*
+ * Go to next page if any, else selects the last item in the list
+ * - gui_list : the list structure
+ * - nb_lines : the number of lines to try to move the cursor
+ */
extern void gui_list_select_next_page(struct gui_list * gui_list,
int nb_lines);
@@ -347,8 +346,6 @@ extern void gui_synclist_select_item(struct gui_synclist * lists,
int item_number);
extern void gui_synclist_select_next(struct gui_synclist * lists);
extern void gui_synclist_select_previous(struct gui_synclist * lists);
-extern void gui_synclist_offset_right(struct gui_synclist * lists);
-extern void gui_synclist_offset_left(struct gui_synclist * lists);
extern void gui_synclist_select_next_page(struct gui_synclist * lists,
enum screen_type screen);
extern void gui_synclist_select_previous_page(struct gui_synclist * lists,
@@ -357,6 +354,8 @@ extern void gui_synclist_add_item(struct gui_synclist * lists);
extern void gui_synclist_del_item(struct gui_synclist * lists);
extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
extern void gui_synclist_flash(struct gui_synclist * lists);
+void gui_synclist_scroll_right(struct gui_synclist * lists);
+void gui_synclist_scroll_left(struct gui_synclist * lists);
/*
* Do the action implied by the given button,
diff --git a/apps/screen_access.c b/apps/screen_access.c
index b47bd10122..dfe2b13a46 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -67,15 +67,13 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
screen->scroll_delay=&lcd_remote_scroll_delay;
screen->scroll_step=&lcd_remote_scroll_step;
screen->invertscroll=&lcd_remote_invertscroll;
-
- screen->puts_scroll_style=&lcd_remote_puts_scroll_style;
- screen->puts_scroll_offset=&lcd_remote_puts_scroll_offset;
- screen->puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset;
-
+#endif /* LCD_REMOTE_DEPTH > 1 */
screen->puts_offset=&lcd_remote_puts_offset;
- screen->puts_style=&lcd_remote_puts_style;
screen->puts_style_offset=&lcd_remote_puts_style_offset;
-#endif /* LCD_REMOTE_DEPTH > 1 */
+ screen->puts_scroll_style=&lcd_remote_puts_scroll_style;
+ screen->puts_scroll_offset=&lcd_remote_puts_scroll_offset;
+ screen->puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset;
+
#if 0 /* no charcell remote LCDs so far */
screen->width=11;
screen->height=2;
@@ -99,7 +97,6 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
screen->backlight_on=&remote_backlight_on;
screen->backlight_off=&remote_backlight_off;
break;
-
#endif /* HAVE_REMOTE_LCD */
case SCREEN_MAIN:
@@ -136,13 +133,11 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
screen->scroll_delay=&lcd_scroll_delay;
screen->scroll_step=&lcd_scroll_step;
screen->invertscroll=&lcd_invertscroll;
-
- screen->puts_scroll_offset=&lcd_puts_scroll_offset;
- screen->puts_scroll_style_offset=&lcd_puts_scroll_style_offset;
-
screen->puts_offset=&lcd_puts_offset;
screen->puts_style_offset=&lcd_puts_style_offset;
- screen->puts_style=&lcd_puts_style;
+ screen->puts_scroll_style=&lcd_puts_scroll_offset;
+ screen->puts_scroll_offset=&lcd_puts_scroll_style;
+ screen->puts_scroll_style_offset=&lcd_puts_scroll_style_offset;
#endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 81d0675d83..1c694e8d31 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -69,23 +69,17 @@ struct screen
void (*setfont)(int newfont);
int (*getstringsize)(const unsigned char *str, int *w, int *h);
void (*putsxy)(int x, int y, const unsigned char *str);
- void (*scroll_step)(int pixels);
-
+ void (*scroll_step)(int pixels);
+ void (*puts_offset)(int x, int y, const unsigned char *str, int offset);
+ void (*puts_style_offset)(int x, int y, const unsigned char *str,
+ int style, int offset);
void (*puts_scroll_style)(int x, int y, const unsigned char *string,
int style);
void (*puts_scroll_offset)(int x, int y, const unsigned char *string,
int offset);
void (*puts_scroll_style_offset)(int x, int y, const unsigned char *string,
- int style, int offset);
-
- void (*puts_offset)(int x, int y, const unsigned char *str, int offset);
- void (*puts_style)(int x, int y, const unsigned char *string, int style);
- void (*puts_style_offset)(int x, int y, const unsigned char *str,
- int style, int offset);
-
-
-
+ int style, int offset);
void (*mono_bitmap)(const unsigned char *src,
int x, int y, int width, int height);
void (*set_drawmode)(int mode);
diff --git a/apps/settings.h b/apps/settings.h
index 97e608d3bc..ebd3ec35b0 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -319,8 +319,10 @@ struct user_settings
int bidir_limit; /* bidir scroll length limit */
int scroll_delay; /* delay (in 1/10s) before starting scroll */
int scroll_step; /* pixels to advance per update */
- bool offset_out_of_view; /* should lines scroll out of the screen */
- int screen_scroll_step; /* pixels to advance screen view*/
+#ifdef HAVE_LCD_BITMAP
+ bool offset_out_of_view;
+ int screen_scroll_step;
+#endif
/* auto bookmark settings */
int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 85d898674c..2de6d93c5c 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1515,9 +1515,9 @@ static bool scroll_settings_menu(void)
static const struct menu_item items[] = {
{ ID2P(LANG_SCROLL_SPEED), scroll_speed },
- { ID2P(LANG_SCROLL_DELAY), scroll_delay },
+ { ID2P(LANG_SCROLL_DELAY), scroll_delay },
#ifdef HAVE_LCD_BITMAP
- { ID2P(LANG_SCROLL_STEP), scroll_step },
+ { ID2P(LANG_SCROLL_STEP), scroll_step },
#endif
{ ID2P(LANG_BIDIR_SCROLL), bidir_limit },
#ifdef HAVE_LCD_CHARCELLS
@@ -1526,7 +1526,7 @@ static bool scroll_settings_menu(void)
#endif
#ifdef HAVE_LCD_BITMAP
{ ID2P(LANG_SCREEN_SCROLL_VIEW), screen_scroll },
- { ID2P(LANG_SCREEN_SCROLL_STEP), screen_scroll_step },
+ { ID2P(LANG_SCREEN_SCROLL_STEP), screen_scroll_step },
#endif
};