Re: [hatari-devel] Little regression in hatari GUI filesystem in fullscreen mode ? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On 19.3.2024 2.09, Eero Tamminen wrote:
If scrollbar could be changed to use mouse events then the buttons
should work, but that's more changes than I'm comfortable before release.
Found an elegant solution for this. Ignore the mouse position
also for scrollbar arrows, like is done for the bar itself!
Laurent, does the attached patch fix the button issue for you?
Thomas, do you think the previous and this patch would be OK for
release, or would it better to wait until after release?
- Eero
From 38266d5cb29f1ffa69a4a7f331015ff88532a854 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Tue, 19 Mar 2024 17:37:14 +0200
Subject: [PATCH] Fix: scrollbar arrows act until mouse button is released
Regardless of whether mouse remains within the object i.e. all
interactive scrollbar elements behave now the same.
This fixes SDL2 issue of it reporting mouse _state_ coord scaled so
that their exact position in the application framebuffer cannot be
calculated in letterboxed fullscreen, unlike mouse button _events_
coords can.
---
src/gui-sdl/dlgFileSelect.c | 6 +++---
src/gui-sdl/sdlgui.c | 17 +++++++++--------
src/includes/sdlgui.h | 1 +
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/gui-sdl/dlgFileSelect.c b/src/gui-sdl/dlgFileSelect.c
index c402c805..9a72eace 100644
--- a/src/gui-sdl/dlgFileSelect.c
+++ b/src/gui-sdl/dlgFileSelect.c
@@ -104,9 +104,9 @@ static SGOBJ fsdlg[] =
{ SGTEXT, SG_EXIT, 0, 2,19, DLGFILENAMES_SIZE,1, dlgfilenames[13] },
{ SGTEXT, SG_EXIT, 0, 2,20, DLGFILENAMES_SIZE,1, dlgfilenames[14] },
{ SGTEXT, SG_EXIT, 0, 2,21, DLGFILENAMES_SIZE,1, dlgfilenames[15] },
- { SGSCROLLBAR, SG_TOUCHEXIT, 0, 62, 7, 0, 0, NULL }, /* Scrollbar */
- { SGBUTTON, SG_TOUCHEXIT, 0, 62, 6,1,1, "\x01", SG_SHORTCUT_UP },
- { SGBUTTON, SG_TOUCHEXIT, 0, 62,21,1,1, "\x02", SG_SHORTCUT_DOWN },
+ { SGSCROLLBAR, SG_TOUCHEXIT|SG_REPEAT, 0, 62, 7, 0, 0, NULL },
+ { SGBUTTON, SG_TOUCHEXIT|SG_REPEAT, 0, 62, 6,1,1, "\x01", SG_SHORTCUT_UP },
+ { SGBUTTON, SG_TOUCHEXIT|SG_REPEAT, 0, 62,21,1,1, "\x02", SG_SHORTCUT_DOWN },
{ SGCHECKBOX, SG_EXIT, 0, 2,23, 19,1, "_Show hidden files" },
{ SGBUTTON, SG_DEFAULT, 0, 32,23, 8,1, "OK" },
{ SGBUTTON, SG_CANCEL, 0, 50,23, 8,1, "Cancel" },
diff --git a/src/gui-sdl/sdlgui.c b/src/gui-sdl/sdlgui.c
index bcc29ea3..2f03943a 100644
--- a/src/gui-sdl/sdlgui.c
+++ b/src/gui-sdl/sdlgui.c
@@ -1085,10 +1085,11 @@ static void SDLGui_ScaleMouseButtonCoordinates(SDL_MouseButtonEvent *bev)
/**
* Show and process a dialog.
*
- * Dialogs using a scrollbar, must return the previous return value
- * in 'current_object' arg, as the same dialog is displayed in a loop
- * to handle scrolling. Other dialogs should give zero as 'current_object'
- * (ie no object selected at start when displaying the dialog)
+ * Dialogs using a scrollbar, or other objects with SG_REPEAT flag,
+ * must return the previous return value in 'current_object' arg, as
+ * the same dialog is displayed in a loop to handle scrolling. Other
+ * dialogs should give zero as 'current_object' (ie no object
+ * selected at start when displaying the dialog)
*
* Returns either:
* - index of the GUI item that was invoked
@@ -1168,9 +1169,10 @@ int SDLGui_DoDialogExt(SGOBJ *dlg, bool (*isEventOut)(SDL_EventType), SDL_Event
SDL_PumpEvents();
b = SDL_GetMouseState(&x, &y);
- /* If current object is the scrollbar, and mouse is still down, we can scroll it */
- /* also if the mouse pointer has left the scrollbar */
- if (current_object >= 0 && dlg[current_object].type == SGSCROLLBAR) {
+ /* Report repeat objects until mouse button is released,
+ * regardless of mouse position. Used for scrollbar
+ * object interactions */
+ if (current_object >= 0 && (dlg[current_object].flags & SG_REPEAT)) {
obj = current_object;
oldbutton = obj;
if (b & SDL_BUTTON(1))
@@ -1186,7 +1188,6 @@ int SDLGui_DoDialogExt(SGOBJ *dlg, bool (*isEventOut)(SDL_EventType), SDL_Event
SDLGui_ScaleMouseStateCoordinates(&x, &y);
obj = SDLGui_FindObj(dlg, x, y);
- current_object = obj;
if (obj != SDLGUI_NOTFOUND && (dlg[obj].flags&SG_TOUCHEXIT) )
{
oldbutton = obj;
diff --git a/src/includes/sdlgui.h b/src/includes/sdlgui.h
index 3ff3b5ab..4673433c 100644
--- a/src/includes/sdlgui.h
+++ b/src/includes/sdlgui.h
@@ -32,6 +32,7 @@ enum
#define SG_EXIT 2 /* Exit when mouse button has been pressed (and released) */
#define SG_DEFAULT 4 /* Marks a default button, selectable with Enter & Return keys */
#define SG_CANCEL 8 /* Marks a cancel button, selectable with ESC key */
+#define SG_REPEAT 16 /* (Scrollbar) buttons which repeat regardless of mouse position */
/* Object states: */
#define SG_SELECTED 1
--
2.39.2