From bc087b49e2e5a9c00b5b1620b4bd289ebee5ee73 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 22 Mar 2011 21:08:04 +0000 Subject: Fix scrollbars so that clicks scroll the pane to a location that matches the clicked location. Interpret mousewheel events so that scroll panes can be scrolled. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2307 --- textscreen/txt_scrollpane.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'textscreen/txt_scrollpane.c') diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c index 17c9bcbf..903c7910 100644 --- a/textscreen/txt_scrollpane.c +++ b/textscreen/txt_scrollpane.c @@ -416,6 +416,33 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), scrollbars = NeedsScrollbars(scrollpane); + if (b == TXT_MOUSE_SCROLLUP) + { + if (scrollbars & SCROLLBAR_VERTICAL) + { + --scrollpane->y; + } + else if (scrollbars & SCROLLBAR_HORIZONTAL) + { + --scrollpane->x; + } + + return; + } + else if (b == TXT_MOUSE_SCROLLDOWN) + { + if (scrollbars & SCROLLBAR_VERTICAL) + { + ++scrollpane->y; + } + else if (scrollbars & SCROLLBAR_HORIZONTAL) + { + ++scrollpane->x; + } + + return; + } + rel_x = x - scrollpane->widget.x; rel_y = y - scrollpane->widget.y; @@ -433,14 +460,15 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), else { int range = FullWidth(scrollpane) - scrollpane->w; + int bar_max = scrollpane->w - 3; - scrollpane->x = ((rel_x - 1) * range) / (scrollpane->w - 3); + scrollpane->x = ((rel_x - 1) * range + (bar_max / 2)) / bar_max; } return; } - // Click on the horizontal scrollbar? + // Click on the vertical scrollbar? if ((scrollbars & SCROLLBAR_VERTICAL) && rel_x == scrollpane->w) { if (rel_y == 0) @@ -454,8 +482,9 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), else { int range = FullHeight(scrollpane) - scrollpane->h; + int bar_max = scrollpane->h - 3; - scrollpane->y = ((rel_y - 1) * range) / (scrollpane->h - 3); + scrollpane->y = ((rel_y - 1) * range + (bar_max / 2)) / bar_max; } return; @@ -465,7 +494,6 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), { TXT_WidgetMousePress(scrollpane->child, x, y, b); } - } static void TXT_ScrollPaneLayout(TXT_UNCAST_ARG(scrollpane)) -- cgit v1.2.3 From a69af94b58ac491c8a215ebe2f81b3a521b833f4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 27 Mar 2011 23:45:53 +0000 Subject: Scroll faster in reaction to the scroll wheel. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2310 --- textscreen/txt_scrollpane.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'textscreen/txt_scrollpane.c') diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c index 903c7910..856f6b8a 100644 --- a/textscreen/txt_scrollpane.c +++ b/textscreen/txt_scrollpane.c @@ -420,11 +420,11 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), { if (scrollbars & SCROLLBAR_VERTICAL) { - --scrollpane->y; + scrollpane->y -= 3; } else if (scrollbars & SCROLLBAR_HORIZONTAL) { - --scrollpane->x; + scrollpane->x -= 3; } return; @@ -433,11 +433,11 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane), { if (scrollbars & SCROLLBAR_VERTICAL) { - ++scrollpane->y; + scrollpane->y += 3; } else if (scrollbars & SCROLLBAR_HORIZONTAL) { - ++scrollpane->x; + scrollpane->x += 3; } return; -- cgit v1.2.3 From 9f3f6683d929d118b18e21b06a0b729586569e1a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Apr 2011 20:07:07 +0000 Subject: Change the background color when hovering over widgets. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2320 --- textscreen/txt_scrollpane.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'textscreen/txt_scrollpane.c') diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c index 856f6b8a..2fd45c55 100644 --- a/textscreen/txt_scrollpane.c +++ b/textscreen/txt_scrollpane.c @@ -557,6 +557,10 @@ txt_scrollpane_t *TXT_NewScrollPane(int w, int h, TXT_UNCAST_ARG(target)) scrollpane->expand_w = w <= 0; scrollpane->expand_h = h <= 0; + // Set parent pointer for inner widget. + + target->parent = &scrollpane->widget; + return scrollpane; } -- cgit v1.2.3