From ab7cb0804de68b015dcc774a4fbcc82e356d2c87 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 15 Jan 2008 16:30:08 +0000 Subject: (svn r11865) -Feature(tte): Support scrolling of drop down lists when in drag mode by moving the pointer above or below the list. --- src/widgets/dropdown.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 9488216be..bed6895ed 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -8,6 +8,7 @@ #include "../strings_type.h" #include "../gfx_func.h" #include "../window_func.h" +#include "../core/math_func.hpp" #include "dropdown_type.h" #include "dropdown_func.h" @@ -51,6 +52,7 @@ struct dropdown_d { byte selected_index; byte click_delay; bool drag_mode; + int scrolling; }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); @@ -133,6 +135,17 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e) } } break; + case WE_TICK: + if (WP(w, dropdown_d).scrolling == -1) { + w->vscroll.pos = max(0, w->vscroll.pos - 1); + SetWindowDirty(w); + } else if (WP(w, dropdown_d).scrolling == 1) { + w->vscroll.pos = min(w->vscroll.count - w->vscroll.cap, w->vscroll.pos + 1); + SetWindowDirty(w); + } + WP(w, dropdown_d).scrolling = 0; + break; + case WE_MOUSELOOP: { Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); if (w2 == NULL) { @@ -158,6 +171,16 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e) if (item < 0) return; WP(w, dropdown_d).click_delay = 2; } else { + if (_cursor.pos.y <= w->top + 2) { + /* Cursor is above the list, set scroll up */ + WP(w, dropdown_d).scrolling = -1; + return; + } else if (_cursor.pos.y >= w->top + w->height - 2) { + /* Cursor is below list, set scroll down */ + WP(w, dropdown_d).scrolling = 1; + return; + } + if (item < 0) return; } -- cgit v1.2.3-54-g00ecf