From 77431369a7c975dc50cb32010bc031b66feabee0 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 20 Aug 2010 18:32:41 +0200 Subject: [PATCH] Improve a lot list browsing with the mouse not allowing screenshots previews to be loaded immediately while scrolling the list. --- qcsrc/menu/xonotic/screenshotlist.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/qcsrc/menu/xonotic/screenshotlist.c b/qcsrc/menu/xonotic/screenshotlist.c index 0a8575dc0..97469227b 100644 --- a/qcsrc/menu/xonotic/screenshotlist.c +++ b/qcsrc/menu/xonotic/screenshotlist.c @@ -27,6 +27,9 @@ CLASS(XonoticScreenshotList) EXTENDS(XonoticListBox) ATTRIB(XonoticScreenshotList, filterBox, entity, NULL) ATTRIB(XonoticScreenshotList, filterTime, float, 0) + ATTRIB(XonoticScreenshotList, newScreenshotTime, float, 0) + ATTRIB(XonoticScreenshotList, prevSelectedItem, float, 0) + ATTRIB(XonoticScreenshotList, screenshotBrowserDialog, entity, NULL) ATTRIB(XonoticScreenshotList, screenshotPreview, entity, NULL) ATTRIB(XonoticScreenshotList, screenshotViewerDialog, entity, NULL) @@ -128,8 +131,19 @@ void XonoticScreenshotList_resizeNotify(entity me, vector relOrigin, vector relS void XonoticScreenshotList_setSelected(entity me, float i) { + me.prevSelectedItem = me.selectedItem; SUPER(XonoticScreenshotList).setSelected(me, i); - me.previewScreenshot(me); // load the preview on selection change + if (me.pressed && me.selectedItem != me.prevSelectedItem) + { + // while dragging the scrollbar (or an item) + // for a smooth mouse movement do not load immediately the new selected images + me.newScreenshotTime = time + 0.2; + } + else if (time > me.newScreenshotTime) + { + me.newScreenshotTime = 0; + me.previewScreenshot(me); // load the preview on selection change + } } void XonoticScreenshotList_drawListBoxItem(entity me, float i, vector absSize, float isSelected) @@ -186,6 +200,11 @@ void XonoticScreenshotList_draw(entity me) ScreenshotList_Filter_Change(me.filterBox, me); me.filterTime = 0; } + if (me.newScreenshotTime && time > me.newScreenshotTime) + { + me.previewScreenshot(me); + me.newScreenshotTime = 0; + } SUPER(XonoticScreenshotList).draw(me); } @@ -239,7 +258,8 @@ float XonoticScreenshotList_keyDown(entity me, float scan, float ascii, float sh me.startScreenshot(me); return 1; } - else - return SUPER(XonoticScreenshotList).keyDown(me, scan, ascii, shift); + if(scan == K_MWHEELUP || scan == K_MWHEELDOWN) + me.newScreenshotTime = time + 0.2; + return SUPER(XonoticScreenshotList).keyDown(me, scan, ascii, shift); } #endif -- 2.39.2