From 84f1052a556ca679cd09b417a16fc136d455ebf2 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 15 Feb 2022 19:33:26 +0100 Subject: [PATCH] moved code to draw "choose tree" screen to separate function --- src/screens.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/screens.c b/src/screens.c index 750aaae4..6f18bf31 100644 --- a/src/screens.c +++ b/src/screens.c @@ -4972,6 +4972,18 @@ static void drawChooseTreeCursorAndText(int y, boolean active, TreeInfo *ti) drawChooseTreeText(y, active, ti); } +static void drawChooseTreeScreen(TreeInfo *ti) +{ + int num_entries = numTreeInfoInGroup(ti); + int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN); + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti); + + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti); +} + static void HandleChooseTree(int mx, int my, int dx, int dy, int button, TreeInfo **ti_ptr) { @@ -5013,13 +5025,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (position_set_by_scrollbar) ti->cl_first = dy; - else - AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, - ti->cl_first, ti); - drawChooseTreeList(ti->cl_first, num_page_entries, ti); - drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti); + drawChooseTreeScreen(ti); return; } @@ -5127,14 +5134,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } if (redraw) - { - drawChooseTreeList(ti->cl_first, num_page_entries, ti); - drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti); - - AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, - ti->cl_first, ti); - } + drawChooseTreeScreen(ti); return; } -- 2.34.1