foxygit / doom Log in
commit 61361932bf9f92deea2a97b84f8eefc8a7f0b252
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Jan 29 23:00:14 2009 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Thu Jan 29 23:00:14 2009 +0000

    Allow clicking within scroll bars to set position.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1438
---
 textscreen/txt_scrollpane.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c
index 9049413b..cfed6a3e 100644
--- a/textscreen/txt_scrollpane.c
+++ b/textscreen/txt_scrollpane.c
@@ -251,6 +251,12 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
         {
             ++scrollpane->x;
         }
+        else
+        {
+            int range = FullWidth(scrollpane) - scrollpane->w;
+
+            scrollpane->x = ((rel_x - 1) * range) / (scrollpane->w - 3);
+        }

         return;
     }
@@ -266,6 +272,12 @@ static void TXT_ScrollPaneMousePress(TXT_UNCAST_ARG(scrollpane),
         {
             ++scrollpane->y;
         }
+        else
+        {
+            int range = FullHeight(scrollpane) - scrollpane->h;
+
+            scrollpane->y = ((rel_y - 1) * range) / (scrollpane->h - 3);
+        }

         return;
     }