Commit Graph
190 Commits
Author SHA1 Message Date
Rubidiumandrubidium42 5cee804f98 Codechange: remove ZeroedMemoryAllocator from NWidgetBase 2025-02-22 14:38:33 +01:00
Jonathan G RennisonandGitHub 8566030c53 Cleanup: Adjustments to comments to match code changes (#13636) 2025-02-22 13:28:35 +00:00
Jonathan G Rennisonandrubidium42 d06b371254 Cleanup: Fix various spelling errors 2025-02-12 22:44:51 +01:00
Peter NelsonandPeter Nelson 693a5f42b9 Codechange: Use EnumBitSet for NWidgetDisplayFlags. 2025-02-06 19:43:35 +00:00
Peter NelsonandPeter Nelson 28eb5e05c8 Codechange: Use EnumBitSet for NWidContainerFlags. 2025-02-06 19:43:35 +00:00
Peter NelsonandPeter Nelson cea62a8399 Codechange: Use EnumBitSet for AspectFlags. 2025-01-29 21:46:39 +00:00
Peter NelsonandGitHub afc0745aa2 Codechange: Specify underlying type for all enums excluding those exposed to scripts. (#13383) 2025-01-28 22:17:34 +00:00
Rubidiumandrubidium42 532f7de1f8 Codechange: make direct access to tooltip/widget_data protected 2025-01-04 21:55:43 +01:00
Rubidiumandrubidium42 bfc8ae6c52 Codechange: use accessor for (scrollbar_)index as they are read only 2025-01-04 20:51:47 +01:00
Rubidiumandrubidium42 6d9f30c343 Codefix: prevent matrix overflows on high resolution monitors 2025-01-04 12:18:37 +01:00
Rubidiumandrubidium42 99d790c4bb Codechange: split widget_data into its actual components 2025-01-04 11:33:24 +01:00
Rubidiumandrubidium42 ef87acc1ff Codechange: make STR_NULL the default for all widget construction functions 2025-01-03 23:25:27 +01:00
Rubidiumandrubidium42 60b9eb5cc6 Codechange: replace last usage of SetDataTip with specific variant 2025-01-03 23:25:07 +01:00
Rubidiumandrubidium42 c972a9ae1f Codechange: remove (unused) tooltip from function to set matrix dimensions 2025-01-03 15:05:10 +01:00
Rubidiumandrubidium42 b60101853c Codechange: add and use SetString over directly accessing widget_data 2025-01-03 12:14:55 +01:00
Rubidiumandrubidium42 fb06ddafba Codechange: add and use SetSprite over directly accessing widget_data 2025-01-03 11:13:16 +01:00
Rubidiumandrubidium42 9ac1bad480 Codechange: add and use GetString over directly accessing widget_data 2025-01-03 11:11:01 +01:00
Rubidiumandrubidium42 56d4d3cc7a Codechange: add and use GetToolTip instead of direct access 2025-01-03 11:10:05 +01:00
Rubidiumandrubidium42 08f3fa54d1 Codechange: manual conversions to remove the global SetDataTip 2025-01-02 23:28:43 +01:00
Rubidiumandrubidium42 7d8bbd4669 Codechange: add specific variants of SetDataTip 2025-01-02 23:28:43 +01:00
Peter NelsonandPeter 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 NelsonandPeter 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 NelsonandGitHub 30bda88e97 Codefix: NWidgetStacked::AdjustPaddingForZoom duplicates inherited method. (#13135) 2024-11-30 23:15:17 +00:00
Peter NelsonandGitHub 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 NelsonandGitHub 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 NelsonandGitHub 55314513ce Codechange: Pass NWidgetParts as span instead of begin/end pointers. (#12779) 2024-06-12 23:08:35 +01:00
Peter NelsonandGitHub 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 NelsonandPeter 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
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
Rubidiumandrubidium42 d09b5aaeba Codechange: use int32_t instead of uint16_t for scroll bar position/size/capacity 2024-03-24 08:30:38 +01:00
Peter NelsonandPeter Nelson bf865dc536 Codechange: Add GetVisibleRangeIterators() to Scrollbar. 2024-02-27 17:18:53 +00:00
Peter NelsonandPeter Nelson 8c22690ce1 Codechange: Update window's widget lookup map when switching displayed plane. 2024-02-15 22:28:58 +00:00
Peter NelsonandPeter Nelson 71b7ba0daa Codechange: Allow constexpr NWidgetPart construction. 2024-01-16 21:57:05 +00:00
Loïc GuillouxandGitHub b18e78e21d Change: Redesign script debug window (#11782) 2024-01-15 21:41:44 +01:00
Rubidiumandrubidium42 3a676a5af0 Codechange: replace static inline with static for non-class functions 2024-01-06 13:37:33 +01:00
Peter NelsonandPeter Nelson 7124b4eef1 Codechange: Use std::unique_ptr for all NWidgets. 2023-12-31 15:33:56 +00:00
Peter NelsonandPeter 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 NelsonandPeter 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 NelsonandGitHub 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 NelsonandGitHub 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 NelsonandPeter 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 NelsonandPeter 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 NelsonandPeter 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 NelsonandGitHub 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 NelsonandGitHub 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 NelsonandPeter Nelson ebf299e1b4 Codechange: Make SetDisplayedPlane return whether the plane changed or not. 2023-12-10 12:01:55 +00:00
Peter NelsonandPeter 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
Peter NelsonandPeter Nelson f281525492 Codechange: Add method to resize both width and height of a widget. 2023-11-20 23:09:20 +00:00
Peter NelsonandPeter Nelson 6317967dba Codechange: Add ability to allocate PIP-space dynamically by ratio.
This can be used to space out, centre, start-align, or end-align widgets without additional spacers.
2023-11-05 20:09:45 +00:00
Peter NelsonandPeter Nelson ac54bd7e58 Codechange: Apply PIP during AssignSizePosition() instead of SetupSmallestSize(). 2023-11-05 20:09:45 +00:00