Peter Nelson
17e7dafa2a
Change: Add alternate_colour widget data for boolean button.
...
Allows boolean button to have different background and button colours.
2025-04-23 19:07:52 +01:00
Peter Nelson
d89753b88d
Codechange: Add dedicated widget for boolean toggle buttons.
2025-04-21 16:23:11 +01:00
Peter Nelson
f8478cdee4
Fix 51fd2853cb
: Different news widget layouts require different font sizes. ( #13752 )
2025-03-08 12:00:56 +00:00
Rubidium
5cee804f98
Codechange: remove ZeroedMemoryAllocator from NWidgetBase
2025-02-22 14:38:33 +01:00
Jonathan G Rennison
8566030c53
Cleanup: Adjustments to comments to match code changes ( #13636 )
2025-02-22 13:28:35 +00:00
Jonathan G Rennison
d06b371254
Cleanup: Fix various spelling errors
2025-02-12 22:44:51 +01:00
Peter Nelson
693a5f42b9
Codechange: Use EnumBitSet for NWidgetDisplayFlags.
2025-02-06 19:43:35 +00:00
Peter Nelson
28eb5e05c8
Codechange: Use EnumBitSet for NWidContainerFlags.
2025-02-06 19:43:35 +00:00
Peter Nelson
cea62a8399
Codechange: Use EnumBitSet for AspectFlags.
2025-01-29 21:46:39 +00:00
Peter Nelson
afc0745aa2
Codechange: Specify underlying type for all enums excluding those exposed to scripts. ( #13383 )
2025-01-28 22:17:34 +00:00
Rubidium
532f7de1f8
Codechange: make direct access to tooltip/widget_data protected
2025-01-04 21:55:43 +01:00
Rubidium
bfc8ae6c52
Codechange: use accessor for (scrollbar_)index as they are read only
2025-01-04 20:51:47 +01:00
Rubidium
6d9f30c343
Codefix: prevent matrix overflows on high resolution monitors
2025-01-04 12:18:37 +01:00
Rubidium
99d790c4bb
Codechange: split widget_data into its actual components
2025-01-04 11:33:24 +01:00
Rubidium
ef87acc1ff
Codechange: make STR_NULL the default for all widget construction functions
2025-01-03 23:25:27 +01:00
Rubidium
60b9eb5cc6
Codechange: replace last usage of SetDataTip with specific variant
2025-01-03 23:25:07 +01:00
Rubidium
c972a9ae1f
Codechange: remove (unused) tooltip from function to set matrix dimensions
2025-01-03 15:05:10 +01:00
Rubidium
b60101853c
Codechange: add and use SetString over directly accessing widget_data
2025-01-03 12:14:55 +01:00
Rubidium
fb06ddafba
Codechange: add and use SetSprite over directly accessing widget_data
2025-01-03 11:13:16 +01:00
Rubidium
9ac1bad480
Codechange: add and use GetString over directly accessing widget_data
2025-01-03 11:11:01 +01:00
Rubidium
56d4d3cc7a
Codechange: add and use GetToolTip instead of direct access
2025-01-03 11:10:05 +01:00
Rubidium
08f3fa54d1
Codechange: manual conversions to remove the global SetDataTip
2025-01-02 23:28:43 +01:00
Rubidium
7d8bbd4669
Codechange: add specific variants of SetDataTip
2025-01-02 23:28:43 +01:00
Peter Nelson
910dd65710
Change: Improve news window layouts.
...
* Use appropriate container widget nesting with padding, instead of single-sided padding.
* Use layer widget to allow main news message to overlay close box and date widgets, to more closely match the old fixed-pixel layout.
2024-12-01 09:44:11 +00:00
Peter Nelson
60f1618cc7
Add: Widget layer container widget type, NWID_LAYER.
...
This widget allows child widgets to be overlaid on top of each other.
Very similar to NWID_SELECTION except all layers are always visible.
2024-12-01 09:44:11 +00:00
Peter Nelson
30bda88e97
Codefix: NWidgetStacked::AdjustPaddingForZoom duplicates inherited method. ( #13135 )
2024-11-30 23:15:17 +00:00
Peter Nelson
e1697a6ad1
Codechange: Don't use enums for non-enumerated values. ( #13031 )
...
In the past we have used enums to hold an arbitrary values. These values
are not enumerated types, so make them constants instead.
2024-10-27 18:02:49 +00:00
Peter Nelson
b991a399ef
Codechange: Split MakeNWidget to improve readability. ( #12785 )
...
Split MakeNWidget() into two stages, widget-creation and attribute-applying, to reduce function size and make it clearer.
2024-06-15 20:10:52 +01:00
Peter Nelson
55314513ce
Codechange: Pass NWidgetParts as span instead of begin/end pointers. ( #12779 )
2024-06-12 23:08:35 +01:00
Peter Nelson
3814adaba8
Codechange: Simplify GetScrolledItemFromWidget() ( #12556 )
...
Return `auto`, which allows working with const containers, and use std::next instead of std::advance.
2024-04-22 19:00:14 +00:00
Peter Nelson
d43ff8dc49
Change: Ability to set aspect ratio of a widget.
...
This allows setting the shape of a widget without dealing with absolute pixel sizes.
2024-04-19 22:11:16 +01:00
Peter Nelson
a28ab8cac2
Codechange: Replace C-style casts to size_t with static_cast. ( #12455 )
...
* Codechange: Replace C-style casts to size_t with static_cast.
This touches only simple value-type casts.
* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX
Co-authored-by: Rubidium <rubidium@openttd.org>
2024-04-19 20:34:36 +01:00
Rubidium
d09b5aaeba
Codechange: use int32_t instead of uint16_t for scroll bar position/size/capacity
2024-03-24 08:30:38 +01:00
Peter Nelson
bf865dc536
Codechange: Add GetVisibleRangeIterators()
to Scrollbar
.
2024-02-27 17:18:53 +00:00
Peter Nelson
8c22690ce1
Codechange: Update window's widget lookup map when switching displayed plane.
2024-02-15 22:28:58 +00:00
Peter Nelson
71b7ba0daa
Codechange: Allow constexpr NWidgetPart construction.
2024-01-16 21:57:05 +00:00
Loïc Guilloux
b18e78e21d
Change: Redesign script debug window ( #11782 )
2024-01-15 21:41:44 +01:00
Rubidium
3a676a5af0
Codechange: replace static inline with static for non-class functions
2024-01-06 13:37:33 +01:00
Peter Nelson
7124b4eef1
Codechange: Use std::unique_ptr for all NWidgets.
2023-12-31 15:33:56 +00:00
Peter Nelson
9a3934ae23
Codechange: Use vector/unique_ptr inside widget containers.
...
This replaces a C-style double-linked-list which required all widgets
to have next/prev pointers, and removes the need for manual pointer management.
2023-12-31 15:33:56 +00:00
Peter Nelson
c2c65d66ba
Codechange: Add GetParentWidget() to widgets.
...
This allows to get parent widgets in the nested tree from bottom-up.
2023-12-30 22:02:37 +00:00
Peter Nelson
8ff0bef862
Codechange: Make widget index const to prevent changes. ( #11658 )
...
This guards against future widget index manipulation.
2023-12-30 18:55:16 +00:00
Peter Nelson
6215e9bf77
Fix #11655 : Crash due to NWidgetMatrix modifying widget->index. ( #11657 )
...
NWidgetMatrix modifies its child widget's index to indicate which element
is to be drawn, which now causes issues with code that does not know about
stuffing extra data into the index.
Instead, let NWidgetMatrix store the currently processing element, and
retrieve this information from the matrix widget while child widgets are
being drawn.
This means only widgets that are children of NWidgetMatrix need to know
anything about their extra data.
2023-12-30 18:24:26 +00:00
Peter Nelson
a0dfb76e34
Codechange: Replace mishmash of types for widget index with WidgetID.
...
Indices were stored as int, but often passed around as uint/uint8_t and casts.
Now they should all use WidgetID.
2023-12-30 00:23:57 +00:00
Peter Nelson
b86182ab84
Codechange: Use std::map to provide indexed widget access.
...
This removes the need to determine the biggest widget index and replaces C-style memory handling.
2023-12-29 18:45:43 +00:00
Peter Nelson
a12f426d69
Codechange: Rename nested array to widget lookup.
...
This changes from naming storage-type to naming functionality.
* `FillNestedArray` is renamed to `FillWidgetLookup`.
* `Window::nested_array` is renamed to `Window::widget_lookup`.
* `array` parameter renamed as well.
2023-12-29 18:45:43 +00:00
Peter Nelson
feb94d233d
Codechange: Remove deferred nested_array initialization path. ( #11640 )
...
Having two ways (`FillNestedArray` and `SetupSmallestSize`) to initialize
`Window::nested_array` introduces confusion.
Instead, make `FillNestedArray` the canonical way, always call it, and remove
init_array from `SetupSmallestSize`.
2023-12-29 14:27:04 +00:00
Peter Nelson
6e8c27b8e5
Change: Hide bevel for resizeable sparse layout windows. ( #11572 )
...
When clicked, the button is still highlighted to show that it is active.
The bevel is controlled with widget_data by RWV_SHOW_BEVEL or RWV_HIDE_BEVEL values.
2023-12-10 17:25:36 +00:00
Peter Nelson
ebf299e1b4
Codechange: Make SetDisplayedPlane return whether the plane changed or not.
2023-12-10 12:01:55 +00:00
Peter Nelson
62d4fd0572
Codechange: Add method to guess the width/height required for a multiline string.
...
This is necessary for widget layouts where a minimum width is not yet known during UpdateWidgetSize().
2023-11-20 23:09:20 +00:00