Commit Graph

132 Commits

Author SHA1 Message Date
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 40f567d464
Fix #10811: Crash getting row from non-resizable widget. (#10833)
GetScrolled*FromWidget took line height from the widget's resize_y value,
however not all widgets are resizable, resulting in a division-by-zero.

Allow passing line height explicitly in cases where a widget is not
resizable.
2023-05-15 18:57:50 +01:00
Peter Nelson 941dbadf9e Codechange: Add and use GetScrolledItemFromWidget to get a list item.
This function returns an iterator, either to the selected item or the
container's end.

This makes handling the result more robust as indices are not used.
2023-05-12 21:45:32 +01:00
Peter Nelson 878c5d8d85 Codechange: Use SetPosition() to clamp after changing count/capacity. 2023-05-07 20:25:44 +01:00
Peter Nelson d2034d9c38 Codechange: Scrollbar methods now accept size_t.
This clears up a lot of casts from size_t to int.
2023-05-07 20:25:44 +01:00
Peter Nelson 35ba49bfb4 Change: Rename text colour NWidgetPart to SetTextStyle and add font size.
This allows to set both text colour and size for any widget with default
drawing.
2023-04-30 11:47:53 +01:00
Peter Nelson 55d981aec3 Add: Helper to update widget vertical size.
This avoids directly setting min_y outside widget code.
2023-04-25 13:27:22 +01:00
PeterN 2d3250923c
Fix #10554: Let Scrollbar::SetPosition clamp instead of assert. (#10555) 2023-03-09 10:19:58 -05:00
Peter Nelson b5693becdc Add: Define scaled WidgetDimensions.
Includes RectPadding container.
2022-11-12 18:28:39 +00:00
Peter Nelson 47f4fc6a70 Add: NWidgetPart SetPadding via RectPadding 2022-11-12 18:28:39 +00:00
Peter Nelson dd9f6bc803 Change: Use RectPadding Horizontal()/Vertical() helpers. 2022-11-12 18:28:39 +00:00
Peter Nelson 04cbe57d2a Change: Use RectPadding for widget padding/uz_padding. 2022-11-12 18:28:39 +00:00
Peter Nelson ba94efba87 Change: Add flag to apply resize to largest resize step first.
Resize step is normally allocated equally amongst all resizable widgets.
With this flag, we allocate as much as possible from the largest
resize step first.
2022-10-16 14:56:34 +02:00
Peter Nelson d8e06e590a Codechange: Make GetCurrentRect() conform to usual Rect bounds, and reuse it.
Similar code is already repeated in other locations.
2021-05-08 09:53:55 +01:00
Peter Nelson 52b16237ad Codechange: Don't update window contents if scrollbar position has not moved. 2021-05-08 09:52:54 +01:00
Peter Nelson 4791ff2862 Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed. 2021-04-30 17:08:15 +01:00
Peter Nelson 03a43b8247 Cleanup: Call SetMinimalSize instead of setting min_y directly. 2021-04-30 17:08:15 +01:00
Peter Nelson 5153e1b6e3 Cleanup: Horizontal widget size is commonly width rather than length. 2021-04-30 17:08:15 +01:00
Peter Nelson 51b4bd6c38 Codechange: Add widget text colour override property. 2021-04-22 16:42:04 +01:00
Peter Nelson 636e37d183 Codechange: Add internal widget alignment property, along with widget part. 2021-04-22 16:42:04 +01:00
Peter Nelson 2a0365b3d9 Cleanup: Remove unnecessary parameter of GetScrolledRowFromWidget()
Line height defaults to the resize height of the relevant widget, which is
set in all cases. Therefore it is not necessary to specify this value every time.

Additionally fixes scrolled padding for the framerate window.
2021-04-21 23:12:10 +02:00
Rubidium bf4fe19a66 Codechange: merge duplicated logic to scroll in lists by key into a single function 2021-04-21 21:12:08 +02:00
Niels Martin Hansen 64c9af0991 Add: NWidgetBase::GetCurrentRect function 2021-04-09 12:18:52 +02:00
Tyler Trahan de891238d6
Change: Recolour graph windows to brown (#8700) 2021-03-11 15:30:29 +01:00
Patric Stout af22a4f2cd Add: show in the tooltip of disabled toolbar buttons why they are disabled 2021-01-08 16:43:51 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
glx 1f418555a1 Fix #7742, 66dd7c3: widget position can be negative 2019-09-17 20:11:34 +02:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Henry Wilson af7d9020a1 Codechange: Use override specifer for overriding member declarations
This is a C++11 feature that allows the compiler to check that a virtual
member declaration overrides a base-class member with the same signature.

Also src/blitter/32bpp_anim_sse4.hpp +38 is no longer erroneously marked
as virtual despite being a template.
2019-03-24 16:10:04 +01:00
Charles Pigott f5b1115039 Doc: Lots and lots of doxymentation fixes 2018-10-31 12:35:54 +01:00
frosch 80dffae130 (svn r27900) -Change [FS#6568]: Remove the gap between windows when positioning them after opening.
-Fix: Make automatic window-positioning RTL-aware.
-Fix: Automatic window-positioning now uses GUI-scale/style dependent sizes/distances instead of fixed pixel values.
2017-08-27 11:48:38 +00:00
rubidium 0af26b8a37 (svn r26971) -Fix: widget_data was sometimes uint16 and sometimes uint32; make it always be uint32 2014-10-06 19:16:29 +00:00
frosch 12ddbb7cb1 (svn r25864) -Fix: Use the actual sprite dimensions for sizing the dropdown arrow of dropdown widgets. 2013-10-13 19:18:30 +00:00
frosch 59b7125563 (svn r25727) -Fix [FS#5686]: NWidgetMatrix used pip_pre and pip_post inconsistently and incorrectly, causing misalignment for RTL. (spotted by sbr) 2013-08-18 15:32:45 +00:00
frosch 43ec0bf0c1 (svn r25537) -Codechange: Optionally make WWT_MATRIX compute the number of rows and columns from the resize step size. 2013-06-30 14:36:31 +00:00
frosch 98fdd20f84 (svn r25531) -Codechange: Use separate function to set data of WWT_MATRIX widgets. 2013-06-30 14:32:31 +00:00
frosch 4e4e635916 (svn r25294) -Feature: Add another button to window title bars to resize the window to its default size. 2013-05-26 19:30:07 +00:00
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 2013-01-08 22:46:42 +00:00
peter1138 1ef4f7712d (svn r24853) -Fix: Extend widget data member to 32 bits so that sprite IDs >= 2^16 can be used. 2012-12-25 22:10:43 +00:00
frosch cfccaff645 (svn r24696) -Doc: Improve documentation for button widget types. 2012-11-11 16:01:34 +00:00
michi_cc 6a70abbd99 (svn r24136) -Feature [FS#4465]: Autoreplace vehicles only when they get old. (Vikthor) 2012-04-17 19:44:02 +00:00
truebrain 1c9bec1999 (svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC) 2011-12-20 17:57:56 +00:00
truebrain 403cd3acdb (svn r23631) -Add: ScriptWindow, to manipulate windows on the client (GameScript only) 2011-12-19 21:05:14 +00:00
peter1138 50d1541270 (svn r23017) -Codechange: Add support for resized scrollbars. 2011-10-11 08:07:47 +00:00
rubidium d89095b3ec (svn r21843) -Codechange: move documentation towards the code to make it more likely to be updates [t-z]. 2011-01-18 21:58:22 +00:00
terkhen 679cd3c21b (svn r21803) -Cleanup: Remove unnecessary semicolons. 2011-01-15 15:36:58 +00:00
frosch da09ebc59a (svn r21763) -Codechange: Pass the distance to Scrollbar::UpdatePosition() in units of small or big steps. 2011-01-09 20:39:06 +00:00
rubidium b91ae2483e (svn r21448) -Add: generic widget for creating a scrollable (one direction) and resizable (both directions) area with same sized widgets 2010-12-10 17:47:11 +00:00