From 8fb7312650d549e200cf725a8f3863157bb5f839 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Tue, 24 Sep 2002 19:41:23 +0000 Subject: Only show scrollbar when needed. (Björn Fischer) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2406 a1c6a512-1295-4272-9138-f99709370657 --- apps/menu.c | 34 +++++++++++++++++----------------- apps/tree.c | 35 ++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/apps/menu.c b/apps/menu.c index 96b0bfdf02..a0102c0ecb 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -47,22 +47,22 @@ struct menu { #ifdef HAVE_LCD_BITMAP -#define MARGIN_X (global_settings.scrollbar ? SCROLLBAR_WIDTH : 0) + CURSOR_WIDTH /* X pixel margin */ -#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */ - -#define LINE_X 0 /* X position the entry-list starts at */ -#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ - -//FIXME remove -#define LINE_HEIGTH 8 /* pixels for each text line */ -//FIXME remove -#define MENU_LINES (LCD_HEIGHT / LINE_HEIGTH - LINE_Y) - -#define CURSOR_X (global_settings.scrollbar ? 1 : 0) -#define CURSOR_Y 0 /* the cursor is not positioned in regard to - the margins, so this is the amount of lines - we add to the cursor Y position to position - it on a line */ +/* pixel margins */ +#define MARGIN_X (global_settings.scrollbar && \ + menu_lines < menus[m].itemcount ? SCROLLBAR_WIDTH : 0) +\ + CURSOR_WIDTH +#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) + +/* position the entry-list starts at */ +#define LINE_X 0 +#define LINE_Y (global_settings.statusbar ? 1 : 0) + +#define CURSOR_X (global_settings.scrollbar && \ + menu_lines < menus[m].itemcount ? 1 : 0) +#define CURSOR_Y 0 /* the cursor is not positioned in regard to + the margins, so this is the amount of lines + we add to the cursor Y position to position + it on a line */ #define CURSOR_WIDTH 4 #define SCROLLBAR_X 0 @@ -165,7 +165,7 @@ static void menu_draw(int m) /* place the cursor */ put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); #ifdef HAVE_LCD_BITMAP - if (global_settings.scrollbar) + if (global_settings.scrollbar && menus[m].itemcount > menu_lines) scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top, menus[m].top + menu_lines, VERTICAL); diff --git a/apps/tree.c b/apps/tree.c index d433787e4b..b31d9aaf4c 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -81,21 +81,22 @@ void browse_root(void) #ifdef HAVE_LCD_BITMAP -#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH) -#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ - -#define MARGIN_X (global_settings.scrollbar ? SCROLLBAR_WIDTH : 0) + CURSOR_WIDTH + ICON_WIDTH /* X pixel margin */ -#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */ - -#define LINE_X 0 /* X position the entry-list starts at */ -#define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ -#define LINE_HEIGTH 8 /* pixels for each text line */ - -#define CURSOR_X (global_settings.scrollbar ? 1 : 0) -#define CURSOR_Y 0 /* the cursor is not positioned in regard to - the margins, so this is the amount of lines - we add to the cursor Y position to position - it on a line */ +/* pixel margins */ +#define MARGIN_X (global_settings.scrollbar && \ + filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0) + \ + CURSOR_WIDTH + ICON_WIDTH +#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) + +/* position the entry-list starts at */ +#define LINE_X 0 +#define LINE_Y (global_settings.statusbar ? 1 : 0) + +#define CURSOR_X (global_settings.scrollbar && \ + filesindir > tree_max_on_screen ? 1 : 0) +#define CURSOR_Y 0 /* the cursor is not positioned in regard to + the margins, so this is the amount of lines + we add to the cursor Y position to position + it on a line */ #define CURSOR_WIDTH 4 #define ICON_WIDTH 6 @@ -191,7 +192,7 @@ static int showdir(char *path, int start) bool dir_buffer_full; #ifdef HAVE_LCD_BITMAP - int line_height = LINE_HEIGTH; + int line_height; int fw, fh; lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); @@ -428,7 +429,7 @@ static int showdir(char *path, int start) } #ifdef HAVE_LCD_BITMAP - if (global_settings.scrollbar) + if (global_settings.scrollbar && filesindir > tree_max_on_screen) scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, start + tree_max_on_screen, VERTICAL); -- cgit v1.2.3