[ioquake3] 95/136: Add mouse wheel support to UI list boxes
Simon McVittie
smcv at debian.org
Thu Jun 15 09:09:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository ioquake3.
commit db1198f6ea2e31769c2b3683ff25e2e973edf15c
Author: Zack Middleton <zack at cloemail.com>
Date: Sat Jun 3 13:52:38 2017 -0500
Add mouse wheel support to UI list boxes
Allows scrolling server browser list and some other lists.
---
code/q3_ui/ui_qmenu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
code/ui/ui_shared.c | 21 +++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/code/q3_ui/ui_qmenu.c b/code/q3_ui/ui_qmenu.c
index 330b6d2..90d9cb0 100644
--- a/code/q3_ui/ui_qmenu.c
+++ b/code/q3_ui/ui_qmenu.c
@@ -1034,6 +1034,50 @@ sfxHandle_t ScrollList_Key( menulist_s *l, int key )
}
return (menu_buzz_sound);
+ case K_MWHEELUP:
+ if( l->columns > 1 ) {
+ return menu_null_sound;
+ }
+
+ if (l->top > 0)
+ {
+ // if scrolling 3 lines would replace over half of the
+ // displayed items, only scroll 1 item at a time.
+ int scroll = l->height < 6 ? 1 : 3;
+ l->top -= scroll;
+ if (l->top < 0)
+ l->top = 0;
+
+ if (l->generic.callback)
+ l->generic.callback( l, QM_GOTFOCUS );
+
+ // make scrolling silent
+ return (menu_null_sound);
+ }
+ return (menu_buzz_sound);
+
+ case K_MWHEELDOWN:
+ if( l->columns > 1 ) {
+ return menu_null_sound;
+ }
+
+ if (l->top < l->numitems-l->height)
+ {
+ // if scrolling 3 items would replace over half of the
+ // displayed items, only scroll 1 item at a time.
+ int scroll = l->height < 6 ? 1 : 3;
+ l->top += scroll;
+ if (l->top > l->numitems-l->height)
+ l->top = l->numitems-l->height;
+
+ if (l->generic.callback)
+ l->generic.callback( l, QM_GOTFOCUS );
+
+ // make scrolling silent
+ return (menu_null_sound);
+ }
+ return (menu_buzz_sound);
+
case K_KP_UPARROW:
case K_UPARROW:
if( l->curvalue == 0 ) {
diff --git a/code/ui/ui_shared.c b/code/ui/ui_shared.c
index afef613..b1718e7 100644
--- a/code/ui/ui_shared.c
+++ b/code/ui/ui_shared.c
@@ -1828,6 +1828,27 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea
return qtrue;
}
}
+
+ // Use mouse wheel in vertical and horizontal menus.
+ // If scrolling 3 items would replace over half of the
+ // displayed items, only scroll 1 item at a time.
+ if ( key == K_MWHEELUP ) {
+ int scroll = viewmax < 6 ? 1 : 3;
+ listPtr->startPos -= scroll;
+ if (listPtr->startPos < 0) {
+ listPtr->startPos = 0;
+ }
+ return qtrue;
+ }
+ if ( key == K_MWHEELDOWN ) {
+ int scroll = viewmax < 6 ? 1 : 3;
+ listPtr->startPos += scroll;
+ if (listPtr->startPos > max) {
+ listPtr->startPos = max;
+ }
+ return qtrue;
+ }
+
// mouse hit
if (key == K_MOUSE1 || key == K_MOUSE2) {
if (item->window.flags & WINDOW_LB_LEFTARROW) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/ioquake3.git
More information about the Pkg-games-commits
mailing list