Commit graph

338 commits

Author SHA1 Message Date
Cameron Cawley
7ef8da53d7 GUI: Account for the scroll bar size in ScrollContainerWidget objects 2023-05-14 22:43:57 +02:00
Miro Kropacek
6fff1690a5 GUI: Don't redraw whole dialog in Widget::setEnabled()
Until now, every (even the tiniest) widget's change of the enabled state
resulted in a redraw of a complete *dialog*. Why this was needed and how
it has been fixed requires a bit of explanation.

There are two buffers to render the widgets in: Backbuffer and Screen
(selected by ThemeEngine::drawToBackbuffer() and
ThemeEngine::drawToScreen() respectively, setting
VectorRenderer::_activeSurface). Then there are two layers/flags:
kDrawLayerBackground and kDrawLayerForeground
(selected in Dialog::drawDialog(), setting ThemeEngine::_layerToDraw).

When asked for a complete dialog rebuild in GuiManager::redraw()
(kRedrawCloseDialog, kRedrawFull) the widgets of every dialog,
regardless of their layer, are drawn into Backbuffer and then copied
into Screen.

When asked for a partial dialog rebuild (kRedrawOpenDialog,
kRedrawTopDialog) the widgets of the topmost dialog marked with
kDrawLayerBackground are drawn into Backbuffer, then copied into Screen
and finally the widgets marked with kDrawLayerForeground are drawn into
Screen *only*.

When redraw() is called just within the GuiManager's event loop the
widgets of the topmost dialog are drawn into Screen *only*. And this is
where the layers become important.

When rebuilding the dialog, it doesn't really matter which layer has
been defined for a widget: Backbuffer contains the ones with
kDrawLayerBackground and Screen will supply the rest with
kDrawLayerForeground, if needed. But which layer is taken into account
when calling Dialog::drawWidgets() ?

It is important to realize that the content of Backbuffer is
defined by the widget's initial state (idle or disabled): so Backbuffer
will contain either "idle color" or "disabled color" after dialog's
creation.

ThemeEngine::drawDD() does two checks:

1. if widget has kDrawLayerBackground set *and* _activeSurface is
  Screen, copy the widget from Backbuffer to Screen

2. if widget's layer is the same as _layerToDraw, draw the widget into
  _activeSurface

This is what happens in redraw(kRedrawDisabled) for kDrawLayerBackground
widgets:

- Backbuffer contains an idle/disabled (depending on its initial state)
  rendition of the widget
- widget is copied from Backbuffer to Screen (1st check in drawDD())
- widget is not drawn into Screen as _layerToDraw is
  kDrawLayerForeground (2nd check in drawDD())

Summary: when switching between idle/disabled state, widget's color is
not updated.

This is what happens in redraw(kRedrawDisabled) for kDrawLayerForeground
widgets:

- Backbuffer contains an idle/disabled (depending on its initial state)
  rendition of the widget
- widget is not copied from Backbuffer to Screen as widget has
  kDrawLayerForeground set (1st check in drawDD())
- widget is drawn into Screen as _layerToDraw is still
  kDrawLayerForeground from the last redraw() (2nd check in drawDD())

Summary: when switching between idle/disabled state, widget's color is
correctly updated and not restored from Backbuffer.

Initially, I set up "button idle" to be rendered in the foreground
layer, same as "button disabled". However @lephilousophe suggested a
great improvement: render "button idle" still in the background but make
"button disabled" its child (in the foreground). Worked like a charm as
it just mimics the hovering behaviour.

And this is why hovering doesn't require scheduleTopDialogRedraw():

- Backbuffer contains an idle [kDrawLayerBackground] rendition of the
  widget
- when highlighted [kDrawLayerForeground], widget is not copied from
  Backbuffer to Screen
- widget is drawn into Screen

Unhovering:

- Backbuffer contains an idle [kDrawLayerBackground] rendition of the
  widget
- when idle [kDrawLayerBackground], widget is copied from Backbuffer to
  Screen
- widget is not drawn into Screen
2023-05-10 22:52:48 +02:00
Cameron Cawley
fb2503d02e GUI: Only use a transparent colour for BMP images 2023-04-09 12:54:38 +02:00
Thierry Crozat
b1fcd15cad GUI: Allow scaling dialog and widget sizes in constructors
The resize() function has the option to do the scaling, but
adding it to the construtor avoids having to then call resize().
Also this makes more explicit that by default the sizes are not
scaled. The reason for not scaling by default is because values
with get from the ThemeEngine are already scaled.
2023-03-25 11:27:02 +01:00
Eugene Sandulenko
7dbdb70735
GUI: Remove unndeeded include 2023-03-16 16:14:41 +01:00
Le Philousophe
b8d56cd168 GUI: Remove visible check in theme
This slows down this time critical function and the value can never be
set anyway.
2022-10-30 12:33:53 +01:00
Le Philousophe
d21b42950a GUI: Avoid useless surface copy before scaling
By using the const rawSurface function instead of the surfacePtr one,
there is no need to create a copy of the const argument.
2022-08-25 17:57:38 +02:00
grisenti
7b53202a9e ALL: add support for --config and refactor code 2022-05-29 13:56:21 +02:00
grisenti
819f52a14d ALL: add support for --fullscreen command 2022-05-29 13:56:21 +02:00
grisenti
fa031ca1a3 ALL: add support for --themepath and --extrapath 2022-05-29 13:56:21 +02:00
grisenti
c0acb85605 ALL: add support for --savepath command 2022-05-29 13:56:21 +02:00
Die4Ever
e36d66f0e5 GUI: button widget auto size with screen width 2022-05-23 23:44:59 +02:00
Die4Ever
2296af6b1e
GUI: Move the lowres string handling logic inside the button widgets 2022-05-15 13:16:29 +03:00
Torbjörn Andersson
d057880f92 GUI: Fix unpressed state of checkboxes and radio buttons
Clicking on a checkbox (and, presumably, a radio button) would leave it
in the "pressed" state, which would inhibit tooltips for it. Now the
unpressed state is cleared along with _duringPress for both these
classes. There are other widgets that inherit from ButtonWidget, but
they either already did this, or didn't override handleMouseUp(), so
they should be fine.
2022-03-28 11:16:50 +02:00
SupSuper
57d0df273e GUI: Scale grid widget icons with filtering 2022-02-22 17:46:21 +00:00
Die4Ever
b8e4fb7380 GUI: fix RTL clip rect for tabs with scrollbars 2022-01-23 20:28:55 +02:00
Die4Ever
42a27fda40 GUI: tabs with scrollbars for more pages 2022-01-23 20:28:55 +02:00
Die4Ever
30a8d927a1 GUI: tabs with scrollbars 2022-01-23 20:28:55 +02:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
av-dx
9a9fb5ef71 GUI: Remove incorrect return condition in scaleGfx
The condition is wrong as it fails to scale image when xRatio == yRatio.
2021-11-12 14:46:34 +01:00
av-dx
33b5694a4e JANITORIAL: Formatting fixes 2021-11-12 14:46:34 +01:00
av-dx
0dea9a8096 GUI: Restore const in scaleGfx argument 2021-11-12 14:46:34 +01:00
av-dx
6a57173c5a GUI: Moved Grid widgets to separate files. 2021-11-12 14:46:34 +01:00
av-dx
f3f657bd8d GUI: Avoid double pointers 2021-11-12 14:46:34 +01:00
av-dx
8dcb3c298a GUI: Reverted scaleGfx() to return const pointer 2021-11-12 14:46:34 +01:00
av-dx
ba91762825 GUI: Reusable containers for Grid Items 2021-11-12 14:46:34 +01:00
av-dx
ac55350cb5 GUI: Scale gfx at the time of loading 2021-11-12 14:46:34 +01:00
av-dx
cf3dd4f845 GUI: Fix memory leak in thumbnail scaling. 2021-11-12 14:46:34 +01:00
av-dx
4d07dd48e3 GUI: Switch to GridItemInfo struct from LauncherEntry 2021-11-12 14:46:34 +01:00
av-dx
f09a05cbb4 GUI: Dynamically "load" thumbnails during scroll or resize 2021-11-12 14:46:34 +01:00
av-dx
823474faaf GUI: Remove gridFromList() to move code to reflowLayout() 2021-11-12 14:46:34 +01:00
av-dx
b6ccca78c0 GUI: Move Grid Initialisation to reflowLayout() 2021-11-12 14:46:34 +01:00
av-dx
64afe7a55f GUI: JANITORIAL: Fix misleading/ambigous names 2021-11-12 14:46:34 +01:00
av-dx
50611aa60b GUI: Fix transitive clipping behaviour 2021-11-12 14:46:34 +01:00
av-dx
43d864e97a GUI: Fix grid scroll going offscreen 2021-11-12 14:46:34 +01:00
av-dx
6628e1d445 GUI: Recheck visibility on reflow 2021-11-12 14:46:34 +01:00
av-dx
b931a37028 GUI: Make use of scaleGfx() to scale icons 2021-11-12 14:46:34 +01:00
av-dx
c664c77ea1 GUI: Remember scroll position on resizing window 2021-11-12 14:46:34 +01:00
av-dx
2900553a43 GUI: Reflow Grid when window size changes 2021-11-12 14:46:34 +01:00
av-dx
181fdcdb43 GUI: Use iterators instead of indexing in for loop 2021-11-12 14:46:34 +01:00
av-dx
34cb198dee GUI: Group entries by "gameid". 2021-11-12 14:46:34 +01:00
av-dx
2f2c1dae94 GUI: Use Common::FSNode for reading files. 2021-11-12 14:46:34 +01:00
av-dx
059deb0e50 MISC: Remove temporary warnings 2021-11-12 14:46:34 +01:00
av-dx
dc878846ee GUI: Create new widgets for the grid system. 2021-11-12 14:46:34 +01:00
av-dx
999c5d2bc6 GUI: Testing grid view with constraints 2021-11-12 14:46:34 +01:00
Cameron Cawley
d460f8f70a GUI: Avoid showing ellipses in smaller labels 2021-10-12 23:29:21 +01:00
Cameron Cawley
b444f53685 GUI: Specify the spacing for checkboxes and radio buttons in the theme files 2021-10-12 23:27:07 +01:00
antoniou79
0b10088110 JANITORIAL: Fix wrong spacing for return commands 2021-06-30 18:12:32 +02:00
antoniou79
8a04060c68 GUI: Increase scope of setGfx() fix to more setGfx() of relevant widgets
Fix is to not proceed with setGfx except for freeing _gfx mem, if widget or its boss is invisible
2021-06-30 18:12:32 +02:00
antoniou79
6fb05fceeb GUI: If GraphicsWidget is hidden do not proceed with GraphicsWidget::setGfx()
Removes interfering invisible thumbnail with list item selection in saveload-dialog (OpenGL, large scale)

I'm issuing this as a PR because I'm unsure if this fix is ok, since it affects all GraphicsWidget objects, not just the one for thumbnail in saveload-dialog. Also not sure if some similar check should be done in the other setGfx() methods in widget.cpp to prevent similar issues.
Note that an alternative fix, which also works, would be to only modify gui/saveload-dialog.cpp and method SaveLoadChooserSimple::updateSelection(), to check for _gfxWidget isVisible status before calling: _gfxWidget->setGfx(thumb, true);
2021-06-30 18:12:32 +02:00