summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-06-07 11:04:09 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-06-07 11:04:09 +0000
commit1ce70a679c645c1886eff1d96c5c9f2a630066d6 (patch)
treec8923657ef6108481f789314202ba35c4563c0fb
parent04fd0ce374ff3b7c21ec9619a9b35f796b4d9168 (diff)
downloadrockbox-1ce70a679c645c1886eff1d96c5c9f2a630066d6.tar.gz
rockbox-1ce70a679c645c1886eff1d96c5c9f2a630066d6.tar.bz2
rockbox-1ce70a679c645c1886eff1d96c5c9f2a630066d6.zip
text viewer: can selected scroll by column/scroll by screen for the horizontal screen.
Viewer Options: "Scrollbar", "Overlap Pages", "Auto-Scroll Speed" move to Scroll Settings > Vertical. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26654 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/text_viewer/readme.txt2
-rw-r--r--apps/plugins/text_viewer/text_viewer.c4
-rw-r--r--apps/plugins/text_viewer/tv_action.c14
-rw-r--r--apps/plugins/text_viewer/tv_action.h2
-rw-r--r--apps/plugins/text_viewer/tv_bookmark.c2
-rw-r--r--apps/plugins/text_viewer/tv_menu.c133
-rw-r--r--apps/plugins/text_viewer/tv_preferences.c6
-rw-r--r--apps/plugins/text_viewer/tv_preferences.h9
-rw-r--r--apps/plugins/text_viewer/tv_settings.c28
9 files changed, 131 insertions, 69 deletions
diff --git a/apps/plugins/text_viewer/readme.txt b/apps/plugins/text_viewer/readme.txt
index 0e9bd7ce49..1180965fe4 100644
--- a/apps/plugins/text_viewer/readme.txt
+++ b/apps/plugins/text_viewer/readme.txt
@@ -46,8 +46,6 @@ TODO list
- when the line_mode is reflow, allow to specify indent spaces.
- - for the horizontal scroll, allow the select scroll by screen/scroll by column for the settings menu.
-
- draw images that are linked to the text. (<img src="...">)
- play audios that are linked to the text. (<audio src="...">)
diff --git a/apps/plugins/text_viewer/text_viewer.c b/apps/plugins/text_viewer/text_viewer.c
index 452f7108a6..ea8972491b 100644
--- a/apps/plugins/text_viewer/text_viewer.c
+++ b/apps/plugins/text_viewer/text_viewer.c
@@ -111,7 +111,7 @@ enum plugin_status plugin_start(const void* file)
if (prefs->windows > 1)
{
/* Screen left */
- tv_scroll_left(TV_HORIZONTAL_SCROLL_WINDOW);
+ tv_scroll_left(TV_HORIZONTAL_SCROLL_PREFS);
}
else { /* prefs->windows == 1 */
/* scroll to previous page */
@@ -128,7 +128,7 @@ enum plugin_status plugin_start(const void* file)
if (prefs->windows > 1)
{
/* Screen right */
- tv_scroll_right(TV_HORIZONTAL_SCROLL_WINDOW);
+ tv_scroll_right(TV_HORIZONTAL_SCROLL_PREFS);
}
else { /* prefs->windows == 1 */
/* scroll to next page */
diff --git a/apps/plugins/text_viewer/tv_action.c b/apps/plugins/text_viewer/tv_action.c
index fb7fdb40e6..1f2ad78666 100644
--- a/apps/plugins/text_viewer/tv_action.c
+++ b/apps/plugins/text_viewer/tv_action.c
@@ -89,7 +89,7 @@ void tv_scroll_up(enum tv_vertical_scroll_mode mode)
int offset_line = -1;
if ((mode == TV_VERTICAL_SCROLL_PAGE) ||
- (mode == TV_VERTICAL_SCROLL_PREFS && prefs->scroll_mode == PAGE))
+ (mode == TV_VERTICAL_SCROLL_PREFS && prefs->vertical_scroll_mode == PAGE))
{
offset_page--;
#ifdef HAVE_LCD_BITMAP
@@ -105,7 +105,7 @@ void tv_scroll_down(enum tv_vertical_scroll_mode mode)
int offset_line = 1;
if ((mode == TV_VERTICAL_SCROLL_PAGE) ||
- (mode == TV_VERTICAL_SCROLL_PREFS && prefs->scroll_mode == PAGE))
+ (mode == TV_VERTICAL_SCROLL_PREFS && prefs->vertical_scroll_mode == PAGE))
{
offset_page++;
#ifdef HAVE_LCD_BITMAP
@@ -120,7 +120,8 @@ void tv_scroll_left(enum tv_horizontal_scroll_mode mode)
int offset_window = 0;
int offset_column = 0;
- if (mode == TV_HORIZONTAL_SCROLL_COLUMN)
+ if ((mode == TV_HORIZONTAL_SCROLL_COLUMN) ||
+ (mode == TV_HORIZONTAL_SCROLL_PREFS && prefs->horizontal_scroll_mode == COLUMN))
{
/* Scroll left one column */
offset_column--;
@@ -138,7 +139,8 @@ void tv_scroll_right(enum tv_horizontal_scroll_mode mode)
int offset_window = 0;
int offset_column = 0;
- if (mode == TV_HORIZONTAL_SCROLL_COLUMN)
+ if ((mode == TV_HORIZONTAL_SCROLL_COLUMN) ||
+ (mode == TV_HORIZONTAL_SCROLL_PREFS && prefs->horizontal_scroll_mode == COLUMN))
{
/* Scroll right one column */
offset_column++;
@@ -159,7 +161,7 @@ void tv_top(void)
void tv_bottom(void)
{
tv_move_screen(0, 0, SEEK_END);
- if (prefs->scroll_mode == PAGE)
+ if (prefs->vertical_scroll_mode == PAGE)
tv_move_screen(0, -tv_get_screen_pos()->line, SEEK_CUR);
}
@@ -172,7 +174,7 @@ enum tv_menu_result tv_menu(void)
res = tv_display_menu();
tv_convert_fpos(cur_file_pos, &cur_pos);
- if (prefs->scroll_mode == PAGE)
+ if (prefs->vertical_scroll_mode == PAGE)
cur_pos.line = 0;
tv_move_screen(cur_pos.page, cur_pos.line, SEEK_SET);
diff --git a/apps/plugins/text_viewer/tv_action.h b/apps/plugins/text_viewer/tv_action.h
index c5f7bd0e2f..b01079cbd1 100644
--- a/apps/plugins/text_viewer/tv_action.h
+++ b/apps/plugins/text_viewer/tv_action.h
@@ -29,7 +29,7 @@
enum tv_horizontal_scroll_mode
{
TV_HORIZONTAL_SCROLL_COLUMN, /* left/right one column */
- TV_HORIZONTAL_SCROLL_WINDOW, /* left/right one window */
+ TV_HORIZONTAL_SCROLL_SCREEN, /* left/right one screen */
TV_HORIZONTAL_SCROLL_PREFS, /* left/right follows the settings */
};
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c
index 61df02705e..78e4c60a83 100644
--- a/apps/plugins/text_viewer/tv_bookmark.c
+++ b/apps/plugins/text_viewer/tv_bookmark.c
@@ -224,7 +224,7 @@ void tv_select_bookmark(void)
}
/* move to the select position */
- if (tv_get_preferences()->scroll_mode == PAGE)
+ if (tv_get_preferences()->vertical_scroll_mode == PAGE)
select_pos.line = 0;
tv_move_screen(select_pos.page, select_pos.line, SEEK_SET);
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c
index ff2d6758a4..38c4af1f96 100644
--- a/apps/plugins/text_viewer/tv_menu.c
+++ b/apps/plugins/text_viewer/tv_menu.c
@@ -30,7 +30,10 @@
static struct tv_preferences new_prefs;
-/* scrollbar menu */
+/* */
+/* horizontal scroll settings menu */
+/* */
+
#ifdef HAVE_LCD_BITMAP
static bool tv_horizontal_scrollbar_setting(void)
{
@@ -42,7 +45,38 @@ static bool tv_horizontal_scrollbar_setting(void)
return rb->set_option("Horizontal Scrollbar", &new_prefs.horizontal_scrollbar, INT,
names, 2, NULL);
}
+#endif
+
+static bool tv_horizontal_scroll_mode_setting(void)
+{
+ static const struct opt_items names[] = {
+ {"Scroll by Screen", -1},
+ {"Scroll by Column", -1},
+ };
+
+ return rb->set_option("Scroll Mode", &new_prefs.horizontal_scroll_mode, INT,
+ names, 2, NULL);
+}
+#ifdef HAVE_LCD_BITMAP
+MENUITEM_FUNCTION(horizontal_scrollbar_item, 0, "Scrollbar",
+ tv_horizontal_scrollbar_setting,
+ NULL, NULL, Icon_NOICON);
+#endif
+MENUITEM_FUNCTION(horizontal_scroll_mode_item, 0, "Scroll Mode",
+ tv_horizontal_scroll_mode_setting, NULL, NULL, Icon_NOICON);
+
+MAKE_MENU(horizontal_scroll_menu, "Horizontal", NULL, Icon_NOICON,
+#ifdef HAVE_LCD_BITMAP
+ &horizontal_scrollbar_item,
+#endif
+ &horizontal_scroll_mode_item);
+
+/* */
+/* vertical scroll settings menu */
+/* */
+
+#ifdef HAVE_LCD_BITMAP
static bool tv_vertical_scrollbar_setting(void)
{
static const struct opt_items names[] = {
@@ -53,18 +87,64 @@ static bool tv_vertical_scrollbar_setting(void)
return rb->set_option("Vertical Scrollbar", &new_prefs.vertical_scrollbar, INT,
names, 2, NULL);
}
+#endif
-MENUITEM_FUNCTION(horizontal_scrollbar_item, 0, "Horizontal",
- tv_horizontal_scrollbar_setting,
- NULL, NULL, Icon_NOICON);
-MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Vertical",
+static bool tv_vertical_scroll_mode_setting(void)
+{
+ static const struct opt_items names[] = {
+ {"Scroll by Page", -1},
+ {"Scroll by Line", -1},
+ };
+
+ return rb->set_option("Scroll Mode", &new_prefs.vertical_scroll_mode, INT,
+ names, 2, NULL);
+}
+
+static bool tv_page_mode_setting(void)
+{
+ static const struct opt_items names[] = {
+ {"No", -1},
+ {"Yes", -1},
+ };
+
+ return rb->set_option("Overlap Pages", &new_prefs.page_mode, INT,
+ names, 2, NULL);
+}
+
+static bool tv_autoscroll_speed_setting(void)
+{
+ return rb->set_int("Auto-scroll Speed", "", UNIT_INT,
+ &new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL);
+}
+
+#ifdef HAVE_LCD_BITMAP
+MENUITEM_FUNCTION(vertical_scrollbar_item, 0, "Scrollbar",
tv_vertical_scrollbar_setting,
NULL, NULL, Icon_NOICON);
-MAKE_MENU(scrollbar_menu, "Scrollbar", NULL, Icon_NOICON,
- &horizontal_scrollbar_item, &vertical_scrollbar_item);
#endif
+MENUITEM_FUNCTION(vertical_scroll_mode_item, 0, "Scroll Mode",
+ tv_vertical_scroll_mode_setting, NULL, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", tv_page_mode_setting,
+ NULL, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
+ tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON);
+
+MAKE_MENU(vertical_scroll_menu, "Vertical", NULL, Icon_NOICON,
+#ifdef HAVE_LCD_BITMAP
+ &vertical_scrollbar_item,
+#endif
+ &vertical_scroll_mode_item, &page_mode_item, &autoscroll_speed_item);
+
+/* */
+/* scroll settings menu */
+/* */
+MAKE_MENU(scroll_menu, "Scroll Settings", NULL, Icon_NOICON,
+ &horizontal_scroll_menu, &vertical_scroll_menu);
+
+/* */
/* main menu */
+/* */
static bool tv_encoding_setting(void)
{
@@ -111,17 +191,6 @@ static bool tv_windows_setting(void)
&new_prefs.windows, NULL, 1, 1, 5, NULL);
}
-static bool tv_scroll_mode_setting(void)
-{
- static const struct opt_items names[] = {
- {"Scroll by Page", -1},
- {"Scroll by Line", -1},
- };
-
- return rb->set_option("Scroll Mode", &new_prefs.scroll_mode, INT,
- names, 2, NULL);
-}
-
static bool tv_alignment_setting(void)
{
static const struct opt_items names[] = {
@@ -134,17 +203,6 @@ static bool tv_alignment_setting(void)
}
#ifdef HAVE_LCD_BITMAP
-static bool tv_page_mode_setting(void)
-{
- static const struct opt_items names[] = {
- {"No", -1},
- {"Yes", -1},
- };
-
- return rb->set_option("Overlap Pages", &new_prefs.page_mode, INT,
- names, 2, NULL);
-}
-
static bool tv_header_setting(void)
{
int len = (rb->global_settings->statusbar == STATUSBAR_TOP)? 4 : 2;
@@ -280,12 +338,6 @@ static bool tv_font_setting(void)
}
#endif
-static bool tv_autoscroll_speed_setting(void)
-{
- return rb->set_int("Auto-scroll Speed", "", UNIT_INT,
- &new_prefs.autoscroll_speed, NULL, 1, 1, 10, NULL);
-}
-
MENUITEM_FUNCTION(encoding_item, 0, "Encoding", tv_encoding_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(word_wrap_item, 0, "Word Wrap", tv_word_wrap_setting,
@@ -297,8 +349,6 @@ MENUITEM_FUNCTION(windows_item, 0, "Screens Per Page", tv_windows_setting,
MENUITEM_FUNCTION(alignment_item, 0, "Alignment", tv_alignment_setting,
NULL, NULL, Icon_NOICON);
#ifdef HAVE_LCD_BITMAP
-MENUITEM_FUNCTION(page_mode_item, 0, "Overlap Pages", tv_page_mode_setting,
- NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(header_item, 0, "Show Header", tv_header_setting,
NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(footer_item, 0, "Show Footer", tv_footer_setting,
@@ -306,17 +356,14 @@ MENUITEM_FUNCTION(footer_item, 0, "Show Footer", tv_footer_setting,
MENUITEM_FUNCTION(font_item, 0, "Font", tv_font_setting,
NULL, NULL, Icon_NOICON);
#endif
-MENUITEM_FUNCTION(scroll_mode_item, 0, "Scroll Mode", tv_scroll_mode_setting,
- NULL, NULL, Icon_NOICON);
-MENUITEM_FUNCTION(autoscroll_speed_item, 0, "Auto-Scroll Speed",
- tv_autoscroll_speed_setting, NULL, NULL, Icon_NOICON);
+
MAKE_MENU(option_menu, "Viewer Options", NULL, Icon_NOICON,
&encoding_item, &word_wrap_item, &line_mode_item, &windows_item,
&alignment_item,
#ifdef HAVE_LCD_BITMAP
- &scrollbar_menu, &page_mode_item, &header_item, &footer_item, &font_item,
+ &header_item, &footer_item, &font_item,
#endif
- &scroll_mode_item, &autoscroll_speed_item);
+ &scroll_menu);
static enum tv_menu_result tv_options_menu(void)
{
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index ad4b0aa12b..62a700b85d 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -38,7 +38,8 @@ static void tv_notify_change_preferences(const struct tv_preferences *oldp,
/*
* the following items do not check.
* - alignment
- * - scroll_mode
+ * - horizontal_scroll_mode
+ * - vertical_scroll_mode
* - page_mode
* - font
* - autoscroll_speed
@@ -94,7 +95,8 @@ void tv_set_default_preferences(struct tv_preferences *p)
p->line_mode = NORMAL;
p->windows = 1;
p->alignment = LEFT;
- p->scroll_mode = PAGE;
+ p->horizontal_scroll_mode = SCREEN;
+ p->vertical_scroll_mode = PAGE;
p->page_mode = NO_OVERLAP;
p->horizontal_scrollbar = SB_OFF;
p->vertical_scrollbar = SB_OFF;
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index ca02c2b5c9..dc29dcae26 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -71,9 +71,14 @@ struct tv_preferences {
} footer_mode;
enum {
- PAGE=0,
+ SCREEN = 0,
+ COLUMN,
+ } horizontal_scroll_mode;
+
+ enum {
+ PAGE = 0,
LINE,
- } scroll_mode;
+ } vertical_scroll_mode;
int autoscroll_speed;
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index bf6ae1e74a..b537b3fb40 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -47,7 +47,8 @@
* scroll_mode 1
* autoscroll_speed 1
* horizontal_scrollbar 1
- * (reserved) 15
+ * horizontal_scroll_mode 1
+ * (reserved) 14
* font name MAX_PATH
*/
@@ -55,7 +56,7 @@
#define TV_GLOBAL_SETTINGS_FILE VIEWERS_DIR "/tv_global.dat"
#define TV_GLOBAL_SETTINGS_HEADER "\x54\x56\x47\x53" /* "TVGS" */
-#define TV_GLOBAL_SETTINGS_VERSION 0x34
+#define TV_GLOBAL_SETTINGS_VERSION 0x35
#define TV_GLOBAL_SETTINGS_HEADER_SIZE 5
#define TV_GLOBAL_SETTINGS_FIRST_VERSION 0x31
@@ -86,7 +87,8 @@
* scroll_mode 1
* autoscroll_speed 1
* horizontal_scrollbar 1
- * (reserved) 15
+ * horizontal_scroll_mode 1
+ * (reserved) 14
* font name MAX_PATH
* bookmark count 1
* [1st bookmark]
@@ -108,7 +110,7 @@
#define TV_SETTINGS_TMP_FILE VIEWERS_DIR "/tv_file.tmp"
#define TV_SETTINGS_HEADER "\x54\x56\x53" /* "TVS" */
-#define TV_SETTINGS_VERSION 0x35
+#define TV_SETTINGS_VERSION 0x36
#define TV_SETTINGS_HEADER_SIZE 4
#define TV_SETTINGS_FIRST_VERSION 0x32
@@ -149,17 +151,22 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
prefs->vertical_scrollbar = *p++;
/* skip need_scrollbar */
p++;
- prefs->page_mode = *p++;
- prefs->header_mode = *p++;
- prefs->footer_mode = *p++;
- prefs->scroll_mode = *p++;
- prefs->autoscroll_speed = *p++;
+ prefs->page_mode = *p++;
+ prefs->header_mode = *p++;
+ prefs->footer_mode = *p++;
+ prefs->vertical_scroll_mode = *p++;
+ prefs->autoscroll_speed = *p++;
if (version > 2)
prefs->horizontal_scrollbar = *p;
else
prefs->horizontal_scrollbar = SB_OFF;
+ if (version > 3)
+ prefs->horizontal_scroll_mode = *p++;
+ else
+ prefs->horizontal_scroll_mode = SCREEN;
+
rb->memcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
#ifdef HAVE_LCD_BITMAP
@@ -185,9 +192,10 @@ static bool tv_write_preferences(int pfd, const struct tv_preferences *prefs)
*p++ = prefs->page_mode;
*p++ = prefs->header_mode;
*p++ = prefs->footer_mode;
- *p++ = prefs->scroll_mode;
+ *p++ = prefs->vertical_scroll_mode;
*p++ = prefs->autoscroll_speed;
*p++ = prefs->horizontal_scrollbar;
+ *p++ = prefs->horizontal_scroll_mode;
rb->memcpy(buf + 28, prefs->font_name, MAX_PATH);