Rubidium
56d4d3cc7a
Codechange: add and use GetToolTip instead of direct access
2025-01-03 11:10:05 +01:00
Rubidium
f0a74fcabb
Codechange: use SetToolTip instead of accessing tool_tip directly
2025-01-03 11:09:49 +01:00
Rubidium
3196e0709d
Codechange: replace internal SetDataTips with appropriate variants
2025-01-03 11:09:49 +01:00
Rubidium
7c2668d10f
Codechange: replace SetDataTip(0x0, with SetTooltip(
2025-01-02 23:28:43 +01:00
Rubidium
4bf36e3fa6
Codechange: replace SetDataTip(STR_ with SetStringTip(STR_
2025-01-02 23:28:43 +01:00
Peter Nelson
98e980c478
Codechange: WWT_TEXT, WWT_LABEL and WWT_EMPTY don't use colour. ( #13218 )
...
Set colour for these widget types to INVALID_COLOUR to avoid giving the impression that the colour has a purpose.
A runtime exception is added to catch this the existing widget unit test.
2025-01-01 15:38:19 +00:00
Peter Nelson
aa461fca68
Codechange: A transparent FrameRect doesn't care about colours. ( #13162 )
2024-12-10 05:00:46 +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
0c04966dc3
Fix #13022 : Ensure minimum size of scrollbar slider. ( #13119 )
...
When there are many more items than fit in a list, the scrollbar slider scales to fit but there is no minimum size. It becomes too small to click on and use.
Ensure scrollbar slider is at least the same size as the buttons either end.
2024-11-24 11:50:04 +00:00
Peter Nelson
3cd1200668
Fix #12976 : Incorrect widget rect scrolling for RTL languages. ( #12978 )
...
Industry directory, AS/GS and Textfile window did not consider RTL when applying horizontal scrolling.
2024-10-05 08:02:59 +01:00
Peter Nelson
376e882a14
Codechange: Add HasFlag() to test if a value is present in a bitset enum type. ( #12959 )
...
This simplifies tests for `(x & y) != y` with enum classes by reducing repetition, similar to HasBit(), and also makes the intent of the expression clearer.
2024-09-22 14:51:37 +01: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
7e049aa2b1
Change: Use aspect ratio for common left/right buttons.
2024-04-19 22:11:16 +01:00
Peter Nelson
61c6ebaacc
Change: Automatically set aspect ratio of common window decorations.
2024-04-19 22:11:16 +01: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
de4e00c93f
Codechange: Pass by reference to UpdateWidgetSize. ( #12457 )
...
These parameters are always provided and not optional.
2024-04-09 08:34:45 +01:00
Peter Nelson
7572cfd103
Codechange: Redefine ZOOM_LVL so that ZOOM_LVL_NORMAL is 1x zoom.
...
This matches expectations of what normal zoom means.
2024-04-04 22:27:03 +01:00
Peter Nelson
9854553e10
Codechange: ZOOM_LVL_SHIFT/BASE are not actually ZOOM_LVLs.
...
Rename to ZOOM_BASE_SHIFT and ZOOM_BASE respectively, and derive from ZOOM_LVL instead of numeric value.
2024-04-04 22:27:03 +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
912d7bd80e
Codechange: Give ColourShade values names instead of numbers.
2024-02-25 12:38:07 +00:00
Peter Nelson
ae3390fe48
Codechange: Add ColourShade enum.
2024-02-25 12:38:07 +00:00
Peter Nelson
0463d4c198
Codechange: Remove direct access to _colour_gradient.
...
Access is now through GetColourGradient, which ensures parameters are in range.
2024-02-25 12:38:07 +00:00
Peter Nelson
8c22690ce1
Codechange: Update window's widget lookup map when switching displayed plane.
2024-02-15 22:28:58 +00:00
frosch
b1718478c8
Codechange: Replace old non-standard attributes with C++17/20 standard attributes.
2024-02-02 22:29:28 +01:00
Rubidium
1403f24fa9
Codechange: replace LeastCommonMultiple with std::lcm
2024-01-20 16:45:21 +01:00
Peter Nelson
68843e3a96
Codechange: Move WidgetDimensions::unscaled to header to allow const use.
2024-01-16 21:57:05 +00:00
Peter Nelson
d005e8f8bd
Fix 884b9e66: No need to include extra pixel for pressed state. ( #11803 )
2024-01-16 20:50:46 +00:00
Loïc Guilloux
b18e78e21d
Change: Redesign script debug window ( #11782 )
2024-01-15 21:41:44 +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
60565da8f9
Codechange: Add specific WidgetDimension for dropdown list window. ( #11554 )
...
This avoids contorting fullbevel dimensions.
2023-12-07 16:10:09 +00:00
Peter Nelson
90e386acaa
Codechange: Vertical spacing for caption is captiontext, not framerect. ( #11550 )
...
This does not really matter as the caption height is sized correctly later anyway, so this just avoids confusion.
2023-12-06 21:36:51 +00:00
Peter Nelson
58c252b81a
Cleanup: Remove unnecessary pressed button offset code.
2023-12-05 21:12:35 +00:00
Peter Nelson
884b9e6690
Change: Revert pressed-button content shifting introduced in r2161.
...
This restores original behaviour, and prevents all image buttons being slightly too large.
2023-12-05 21:12:35 +00:00
Peter Nelson
6f7153bf71
Codechange: Make a generic DrawRectOutline function from DrawOutline. ( #11524 )
...
This allows drawing an outline from Rect, not just constrained to a Widget's Rect. And reduces duplication a little.
2023-11-30 18:10:07 +00:00
Peter Nelson
c18a1494b7
Codechange: Remove FONT_HEIGHT_... macros. ( #11481 )
...
These make it look like we're dealing with a constant, but actually each is a call to `GetCharacterHeight(...)`.
2023-11-21 19:04:24 +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
Peter Nelson
f281525492
Codechange: Add method to resize both width and height of a widget.
2023-11-20 23:09:20 +00:00
Peter Nelson
05b55c4d43
Fix: Extra space allocated to container-within-container may not get allocated to children. ( #11471 )
...
Always derive additional length from contained widgets instead of from the container, as the container's minimal length may have been adjusted by an NC_EQUALSIZE parent container.
2023-11-19 00:36:53 +00:00