From a01f9508b0ca7bd5235d98e26239ecc41e9d867c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 17 Dec 2010 13:32:43 +0000 Subject: Base treeview line height on text height, unless that's too small for the icon to fit. svn path=/trunk/netsurf/; revision=11087 --- desktop/tree.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'desktop') diff --git a/desktop/tree.c b/desktop/tree.c index 1f7d8ffc3..dd34cb64a 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -46,9 +46,9 @@ #define TREE_TEXT_SIZE_PT 11 #define TREE_ICON_SIZE 17 #define NODE_INSTEP 20 -#define TREE_LINE_HEIGHT 20 static int tree_text_size_px; +static int TREE_LINE_HEIGHT; static plot_font_style_t plot_fstyle = { .family = PLOT_FONT_FAMILY_SANS_SERIF, @@ -206,6 +206,19 @@ struct tree *tree_create(unsigned int flags, tree->callbacks = callbacks; tree->client_data = client_data; + /* Set text height in pixels */ + tree_text_size_px = + (TREE_TEXT_SIZE_PT * FIXTOINT(nscss_screen_dpi) + 36) / + 72; + /* Set line height appropriate for this text height in pixels + * Using 4/3 text height */ + TREE_LINE_HEIGHT = (tree_text_size_px * 8 + 3) / 6; + + /* But if that's too small for the icons, base the line height on + * the icon height. */ + if (TREE_LINE_HEIGHT < TREE_ICON_SIZE + 2) + TREE_LINE_HEIGHT = TREE_ICON_SIZE + 2; + return tree; } @@ -1795,10 +1808,6 @@ void tree_draw(struct tree *tree, int x, int y, if (tree->root->child == NULL || !tree->redraw) return; - tree_text_size_px = - (TREE_TEXT_SIZE_PT * FIXTOINT(nscss_screen_dpi) + 36) / - 72; - /* Set up clip rectangle */ clip.x0 = x + clip_x; clip.y0 = y + clip_y; -- cgit v1.2.3