Commit Graph

544 Commits

Author SHA1 Message Date
Peter Nelson e563057478 Add: WindowDesc unit test to validate ini-key value.
ini-key must be present if WWT_DEFSIZEBOX or WWT_STICKYBOX is present.
This was previously enforced by a workflow, however that parsed the source
code with regex which turned out to be error-prone.
2023-11-02 22:25:01 +00:00
Peter Nelson 18fb8e153f Codechange: Add __FILE__/__LINE__ of WindowDesc to WindowDesc.
This is to allow unit-tests to produce more useful output.
2023-11-02 22:25:01 +00:00
Peter Nelson d3cb6e1e67
Codechange: Call Widget::SetDirty/SetLowered directly. (#11417)
In these instances we already have the widget to hand, so don't need to look it up by index again.
2023-11-01 20:12:08 +00:00
Peter Nelson f379b31e28 Add: data parameter in Window::Close method.
This allows passing data when closing a window, e.g. to indicate how it was closed.
2023-10-13 20:47:28 +01:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium 8ab0936491 Codechange: use parameter pack/folding instead of va_arg macros for widget states 2023-09-16 23:09:53 +02:00
Rubidium 8c742b456f Codechange: use Textbuf directly, instead via several virtual functions in Window 2023-09-06 23:07:04 +02:00
Peter Nelson e8015e497d Codechange: Use begin/end of nwidget parts of begin/length.
This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
2023-09-04 10:20:45 +01:00
MasonGulu 0be27778af
Add: alternative setting for right-click close window option to exclude pinned windows (#10204) 2023-07-19 23:24:22 +02:00
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
merni-ns a8a4737c5b
Fix #11096: Increase priority of error and confirmation windows (#11104) 2023-07-03 23:24:44 +02:00
Rubidium 836541b41c Codechange: use SetDParam and CopyOutDParam for tooltips 2023-06-17 10:01:19 +02:00
PeterN f51f117b00
Change: Add window description flag to disallow interactive window closing. (#11008)
This replaces/simplifies testing for a closebox to allow closing a window with right-click, and testing for specific window classes when closing all windows by hotkey.

This allows right-click closing of dropdowns and the high-score window.
2023-06-14 17:24:14 +01:00
PeterN ebc451b071
Fix #10987: Double-close of dropdown stopped land-info tool working as default. (#11000)
Clicking and releasing on the query toolbar icon is meant to select the land-info tool.

This did not work as during closing a window, OnFocusLost() is called, which then closes the window again. These two calls toggled the land-info tool one and off in the same action.

Resolve by not calling Window::Close in OnFocusLost() if the window is already closing.
2023-06-12 08:42:02 +01:00
PeterN b49bd86a46
Fix dec7ff6b0c: Dropdowns couldn't be closed by pressing the parent button. (#10954)
Since dropdowns self-close, the detection of re-clicking a dropdown
button no longer worked, as the dropdown is already closed.

Instead set (and then test) a flag on the parent widget to indicate that
the dropdown closed. This method avoids looping windows on every click.
2023-06-07 19:01:30 +01:00
PeterN 83a318edcf
Fix dec7ff6b0c: Dropdowns would close if their tooltip appeared. (#10939)
Solution is to not focus any tooltips, so that the dropdown doesn't lose focus. Tooltips don't accept any input so this does not change their behaviour.
2023-06-04 18:15:24 +00:00
Peter Nelson 2e62682f73 Codechange: Close dropdowns by class instead of id. 2023-06-03 14:17:05 +01:00
Peter Nelson dec7ff6b0c Fix: Make dropdowns self-close when losing focus. 2023-06-03 14:17:05 +01:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Peter Nelson 83f2ad500e Codechange: stdarg.h include not needed as cstdarg is included. 2023-05-17 10:14:41 +01:00
PeterN da7f431812
Cleanup: widget pos_x/y are already int. (#10809)
Remove old casts left over from when pos_x/y were unsigned.
2023-05-12 18:02:51 +01:00
Patric Stout 60399e17bd Codechange: C++-ify the Layouter and related functions
They all now access a std::string_view, instead of a "const char *"
or std::string (in some cases).

Additionally, GetCharAtPosition and friends now return an index
instead of a "const char *", as it makes for a more clear interface.
2023-05-08 19:21:42 +02:00
Peter Nelson 6202eae9d5 Codechange: Rely on Scrollbar::SetPosition to clamp.
Manually clamping scrollbar bounds before calling `SetPosition()` is doubling up work that the function already does.
2023-05-07 20:25:44 +01:00
Peter Nelson e8df28d7f3 Add: parameter for ReInit() to reposition window to default. 2023-04-25 13:27:22 +01:00
Patric Stout 1ba4dcc924 Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
2023-04-15 13:58:55 +02:00
Patric Stout 5e1bcee39b Codechange: introduce a framework for all our timers
IntervalTimer and TimeoutTimer use RAII, and can be used to replace
all the time-based timeouts, lag-detection, "execute every N" we
have.
As it uses RAII, you can safely use it as static variable, class
member, temporary variable, etc. As soon as it goes out-of-scope,
it will be safely removed.
This allows for much easier to read code when it comes to intervals.
2023-04-15 13:58:55 +02:00
glx22 b080f24bd8 Codechange: move windows common to AI and GS out of ai_gui 2023-02-05 19:27:25 +01:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
rubidium42 6ba55e663e Codechange: do not hide variables with other variables 2023-01-29 07:21:34 +01:00
Rubidium f001e84e5e Codechange: use RAII to automatically restore _cur_dpi after use 2023-01-28 20:33:02 +01:00
Rubidium bcfe0fb076 Codechange: introduce GetMainWindow() to properly account for nullptr checks
Some nullptr checks have been removed as they were not triggered with nullptr
with the null video driver and in dedicated server mode.
2023-01-14 21:15:23 +01:00
PeterN 23eec0b7b3
Fix #8971: Resize QueryStrings with interface scale change. (#10281)
* Fix: Use width of caret symbol '_' for text entry.

This replaces an arbitrary pixel width with the space actually required.

* Fix #8971: Update QueryString sizes with interface scale change.
2022-12-25 00:40:55 +00:00
PeterN a044e8e007
Fix: Scale minimum visible caption by interface scale. (#10180) 2022-11-17 22:45:15 +00:00
Peter Nelson 890b2666d3 Change: Use scaled WidgetDimensions. 2022-11-12 18:28:39 +00:00
Peter Nelson b5693becdc Add: Define scaled WidgetDimensions.
Includes RectPadding container.
2022-11-12 18:28:39 +00:00
Jonathan G Rennison 64b437fa89 Fix: Data race with mixer thread performance measurements 2022-11-11 23:48:24 +01:00
Nicolas Chappe 864771ca09 Feature: [Linkgraph] Show a tooltip with statistics when hovering a link 2022-10-18 22:03:39 +02:00
Nicolas Chappe 7c79a2a767 Change: Do not generate hover events at each frame 2022-10-18 22:03:39 +02:00
Nicolas Chappe e660860d4b Codechange: Simplify logic of mouse loop 2022-10-18 22:03:39 +02:00
Bouke Haarsma 45d98f689a Fix #9993: Handle DPI changes on macOS and Windows 2022-10-16 16:52:14 +02:00
PeterN 69527abb6f
Fix 9aef7b8c: Don't dispatch hover event if already hovering. (#10042)
This fixes the timed tooltip window being (invisibly) destroyed and
reconstructed every frame.

This also affects the unused OnHover() window event.
2022-09-22 20:38:11 +01:00
Danny de Bruijne 753b1d7e15 Feature: Add selected toolbar buttons to MacBook Pro Touch Bar 2021-09-23 21:03:00 +02:00
Patric Stout fa1e27994d Feature: allow the use of TURN to connect client and server together
TURN is a last resort, used only if all other methods failed.
TURN is a relay approach to connect client and server together, where
openttd.org (by default) is the middleman.

It is very unlikely either the client or server cannot connect to
the STUN server, as they are both already connected to the Game
Coordinator. But in the odd case it does fail, estabilishing the
connection fails without any further possibility to recover.
2021-07-20 19:57:23 +02:00
Patric Stout 66dc0ce196 Codechange: C++-ify the usage of IniFile in settings.cpp
Instead of creating the object on heap and use a pointer, create
the object on stack and use a guaranteed-not-null pointer.
The size of IniFile doesn't warrent the forcing to heap.

Additionally, use a subclass instead of a function to do some
initial bookkeeping on an IniFile meant to read a configuration.
2021-07-02 14:30:14 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
glx22 994bf19aef Fix f6d5c01: Delay deletion when closing windows 2021-05-29 21:08:25 +02:00
glx22 e66e25ff71 Fix #9269, f6d5c01: Hide windows without abusing WC_INVALID 2021-05-15 21:08:49 +02:00
Rubidium 7755f81bb8 Codechange: make explicit that virtual functions in a con/destructor are resolved statically
This as during construction the sub class has not been initialized yet, and
during destruction the sub class has already been destroyed, so the overriding
virtual function would be accessing uninitialized data.
2021-05-13 10:03:26 +02:00
frosch f6d5c0136e Codechange: make Window destruction not rely on undefined behavior. 2021-05-12 23:22:41 +02:00