OpenTTD Source 20250529-master-g10c159a79f
window_gui.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef WINDOW_GUI_H
11#define WINDOW_GUI_H
12
13#include "vehiclelist.h"
14#include "vehicle_type.h"
15#include "viewport_type.h"
16#include "company_type.h"
17#include "tile_type.h"
18#include "widget_type.h"
19#include "string_type.h"
20
24enum class FrameFlag : uint8_t {
27 Lowered,
28 Darkened,
29};
31
33public:
56
64
65 static const WidgetDimensions unscaled;
67
68 static constexpr float ASPECT_LOCATION = 12.f / 14.f;
69 static constexpr float ASPECT_RENAME = 12.f / 14.f;
70 static constexpr float ASPECT_TOGGLE_SIZE = 12.f / 14.f;
71 static constexpr float ASPECT_LEFT_RIGHT_BUTTON = 8.f / 12.f;
72 static constexpr float ASPECT_UP_DOWN_BUTTON = 11.f / 12.f;
73 static constexpr float ASPECT_VEHICLE_ICON = 15.f / 12.f;
74 static constexpr float ASPECT_VEHICLE_FLAG = 11.f / 12.f;
75
76private:
81 static constexpr uint WD_SHADEBOX_WIDTH = 12;
82 static constexpr uint WD_STICKYBOX_WIDTH = 12;
83 static constexpr uint WD_DEBUGBOX_WIDTH = 12;
84 static constexpr uint WD_DEFSIZEBOX_WIDTH = 12;
85 static constexpr uint WD_RESIZEBOX_WIDTH = 12;
86 static constexpr uint WD_CLOSEBOX_WIDTH = 11;
87 static constexpr uint WD_CAPTION_HEIGHT = 14;
88 static constexpr uint WD_DROPDOWN_HEIGHT = 12;
89
90 friend NWidgetLeaf;
91};
92
94 .imgbtn = { .left = 1, .top = 1, .right = 1, .bottom = 1},
95 .inset = { .left = 2, .top = 1, .right = 2, .bottom = 1},
96 .vscrollbar = { .left = 2, .top = 3, .right = 2, .bottom = 3},
97 .hscrollbar = { .left = 3, .top = 2, .right = 3, .bottom = 2},
98 .bevel = { .left = 1, .top = 1, .right = 1, .bottom = 1},
99 .fullbevel = { .left = 1, .top = 1, .right = 1, .bottom = 1},
100 .framerect = { .left = 2, .top = 1, .right = 2, .bottom = 1},
101 .frametext = { .left = 6, .top = 6, .right = 6, .bottom = 6},
102 .matrix = { .left = 2, .top = 3, .right = 2, .bottom = 1},
103 .shadebox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
104 .stickybox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
105 .debugbox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
106 .defsizebox = { .left = 2, .top = 3, .right = 2, .bottom = 3},
107 .resizebox = { .left = 2, .top = 2, .right = 2, .bottom = 2},
108 .closebox = { .left = 2, .top = 2, .right = 1, .bottom = 2},
109 .captiontext = { .left = 2, .top = 2, .right = 2, .bottom = 2},
110 .dropdowntext = { .left = 2, .top = 1, .right = 2, .bottom = 1},
111 .dropdownlist = { .left = 1, .top = 2, .right = 1, .bottom = 2},
112 .modalpopup = { .left = 20, .top = 10, .right = 20, .bottom = 10},
113 .picker = { .left = 3, .top = 3, .right = 3, .bottom = 3},
114 .sparse = { .left = 10, .top = 8, .right = 10, .bottom = 8},
115 .sparse_resize = { .left = 10, .top = 8, .right = 10, .bottom = 0},
116 .vsep_picker = 1,
117 .vsep_normal = 2,
118 .vsep_sparse = 4,
119 .vsep_wide = 8,
120 .hsep_normal = 2,
121 .hsep_wide = 6,
122 .hsep_indent = 10,
123};
124
125/* widget.cpp */
126void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
127
128inline void DrawFrameRect(const Rect &r, Colours colour, FrameFlags flags)
129{
130 DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, flags);
131}
132
133void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, std::string_view str, StringAlignment align, FontSize fs);
134
135/* window.cpp */
136using WindowList = std::list<Window *>;
137extern WindowList _z_windows;
138extern Window *_focused_window;
139
140
148
152enum class WindowDefaultFlag : uint8_t {
154 Modal,
155 NoFocus,
156 NoClose,
157};
159
160Point GetToolbarAlignedWindowPosition(int window_width);
161
162struct HotkeyList;
163
168
169 WindowDesc(WindowPosition default_pos, std::string_view ini_key, int16_t def_width_trad, int16_t def_height_trad,
170 WindowClass window_class, WindowClass parent_class, WindowDefaultFlags flags,
171 const std::span<const NWidgetPart> nwid_parts, HotkeyList *hotkeys = nullptr,
172 const std::source_location location = std::source_location::current());
173
174 ~WindowDesc();
175
176 const std::source_location source_location;
180 const std::string_view ini_key;
182 const std::span<const NWidgetPart> nwid_parts;
184
185 bool pref_sticky = false;
186 int16_t pref_width = 0;
187 int16_t pref_height = 0;
188
189 int16_t GetDefaultWidth() const;
190 int16_t GetDefaultHeight() const;
191
192 static void LoadFromConfig();
193 static void SaveToConfig();
194
195private:
196 const int16_t default_width_trad;
197 const int16_t default_height_trad;
198
203 WindowDesc(const WindowDesc &) = delete;
204 WindowDesc& operator=(const WindowDesc &) = delete;
205};
206
213};
214
221
225enum class WindowFlag : uint8_t {
226 Timeout,
227
228 Dragging,
230 SizingLeft,
231
232 Sticky,
236 Centred,
237};
239
240static const int TIMEOUT_DURATION = 7;
241static const int WHITE_BORDER_DURATION = 3;
242
252 int32_t scrollpos_x;
253 int32_t scrollpos_y;
256
257 void CancelFollow(const Window &viewport_window);
258};
259
260struct QueryString;
261
262/* misc_gui.cpp */
263enum TooltipCloseCondition : uint8_t {
264 TCC_RIGHT_CLICK,
265 TCC_HOVER,
266 TCC_NONE,
267 TCC_EXIT_VIEWPORT,
268};
269
273struct Window {
274private:
275 static std::vector<Window *> closed_windows;
276
277protected:
279 void InitializePositionSize(int x, int y, int min_width, int min_height);
280 virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize);
281
282 std::vector<int> scheduled_invalidation_data{};
283 bool scheduled_resize = false;
284
285 /* Protected to prevent deletion anywhere outside Window::DeleteClosedWindows(). */
286 virtual ~Window();
287
288public:
289 Window(WindowDesc &desc);
290
297 inline void *operator new[](size_t size) = delete;
298
303
304 int scale = 0;
305
306 uint8_t timeout_timer = 0;
307 uint8_t white_border_timer = 0;
308
309 int left = 0;
310 int top = 0;
311 int width = 0;
312 int height = 0;
313
315
317
318 std::unique_ptr<ViewportData> viewport;
319 const NWidgetCore *nested_focus = nullptr;
320 std::map<WidgetID, QueryString*> querystrings{};
321 std::unique_ptr<NWidgetBase> nested_root{};
325
327
328 Window *parent = nullptr;
329 WindowList::iterator z_position{};
330
331 template <class NWID>
332 inline const NWID *GetWidget(WidgetID widnum) const;
333 template <class NWID>
334 inline NWID *GetWidget(WidgetID widnum);
335
336 const Scrollbar *GetScrollbar(WidgetID widnum) const;
338
339 const QueryString *GetQueryString(WidgetID widnum) const;
342
343 virtual const struct Textbuf *GetFocusedTextbuf() const;
344 virtual Point GetCaretPosition() const;
345 virtual Rect GetTextBoundingRect(size_t from, size_t to) const;
346 virtual ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const;
347
348 void InitNested(WindowNumber number = 0);
349 void CreateNestedTree();
351
355 inline void SetTimeout()
356 {
358 this->timeout_timer = TIMEOUT_DURATION;
359 }
360
364 inline void SetWhiteBorder()
365 {
367 this->white_border_timer = WHITE_BORDER_DURATION;
368 }
369
371 void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour);
372 bool IsWidgetHighlighted(WidgetID widget_index) const;
373
381 inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
382 {
383 NWidgetCore *nwid = this->GetWidget<NWidgetCore>(widget_index);
384 if (nwid != nullptr) nwid->SetDisabled(disab_stat);
385 }
386
391 inline void DisableWidget(WidgetID widget_index)
392 {
393 SetWidgetDisabledState(widget_index, true);
394 }
395
400 inline void EnableWidget(WidgetID widget_index)
401 {
402 SetWidgetDisabledState(widget_index, false);
403 }
404
410 inline bool IsWidgetDisabled(WidgetID widget_index) const
411 {
412 return this->GetWidget<NWidgetCore>(widget_index)->IsDisabled();
413 }
414
420 inline bool IsWidgetFocused(WidgetID widget_index) const
421 {
422 return this->nested_focus != nullptr && this->nested_focus->GetIndex() == widget_index;
423 }
424
431 inline bool IsWidgetGloballyFocused(WidgetID widget_index) const
432 {
433 return _focused_window == this && IsWidgetFocused(widget_index);
434 }
435
441 inline void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
442 {
443 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(lowered_stat);
444 }
445
450 inline void ToggleWidgetLoweredState(WidgetID widget_index)
451 {
452 bool lowered_state = this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
453 this->GetWidget<NWidgetCore>(widget_index)->SetLowered(!lowered_state);
454 }
455
460 inline void LowerWidget(WidgetID widget_index)
461 {
462 SetWidgetLoweredState(widget_index, true);
463 }
464
469 inline void RaiseWidget(WidgetID widget_index)
470 {
471 SetWidgetLoweredState(widget_index, false);
472 }
473
478 inline void RaiseWidgetWhenLowered(WidgetID widget_index)
479 {
480 if (this->IsWidgetLowered(widget_index)) {
481 this->RaiseWidget(widget_index);
482 this->SetWidgetDirty(widget_index);
483 }
484 }
485
491 inline bool IsWidgetLowered(WidgetID widget_index) const
492 {
493 return this->GetWidget<NWidgetCore>(widget_index)->IsLowered();
494 }
495
497 bool SetFocusedWidget(WidgetID widget_index);
498
499 EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode);
500 virtual void InsertTextString(WidgetID wid, std::string_view str, bool marked, std::optional<size_t> caret, std::optional<size_t> insert_location, std::optional<size_t> replacement_end);
501
502 void HandleButtonClick(WidgetID widget);
503 int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const;
504
505 void RaiseButtons(bool autoraise = false);
506
514 template <typename... Args>
515 void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
516 {
517 (SetWidgetDisabledState(widgets, disab_stat), ...);
518 }
519
525 template <typename... Args>
526 void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
527 {
528 (SetWidgetLoweredState(widgets, lowered_stat), ...);
529 }
530
535 template <typename... Args>
536 void RaiseWidgetsWhenLowered(Args... widgets)
537 {
538 (this->RaiseWidgetWhenLowered(widgets), ...);
539 }
540
541 void SetWidgetDirty(WidgetID widget_index) const;
542
543 void DrawWidgets() const;
544 void DrawViewport() const;
545 void DrawSortButtonState(WidgetID widget, SortButtonState state) const;
546 static int SortButtonWidth();
547
551 void CloseChildWindowById(WindowClass wc, WindowNumber number) const;
552 virtual void Close(int data = 0);
553 static void DeleteClosedWindows();
554
555 void SetDirty() const;
556 void ReInit(int rx = 0, int ry = 0, bool reposition = false);
557
559 inline bool IsShaded() const
560 {
561 return this->shade_select != nullptr && this->shade_select->shown_plane == SZSP_HORIZONTAL;
562 }
563
564 void SetShaded(bool make_shaded);
565
566 void ScheduleResize();
568 void InvalidateData(int data = 0, bool gui_scope = true);
571
572 /*** Event handling ***/
573
578 virtual void OnInit() { }
579
580 virtual void ApplyDefaults();
581
589 virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number);
590
595 virtual void OnPaint()
596 {
597 this->DrawWidgets();
598 }
599
606 virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const {}
607
620 virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) {}
621
630 virtual std::string GetWidgetString([[maybe_unused]] WidgetID widget, StringID stringid) const;
631
635 virtual void OnFocus();
636
641 virtual void OnFocusLost(bool closing);
642
650 virtual EventState OnKeyPress([[maybe_unused]] char32_t key, [[maybe_unused]] uint16_t keycode) { return ES_NOT_HANDLED; }
651
652 virtual EventState OnHotkey(int hotkey);
653
660
661
668 virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) {}
669
677 virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) { return false; }
678
684 virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
685
692 virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; }
693
699 virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
700
706 virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
707
712 virtual void OnScroll([[maybe_unused]] Point delta) {}
713
719 virtual void OnScrollbarScroll([[maybe_unused]] WidgetID widget) {}
720
727 virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {}
728
734 virtual void OnMouseWheel([[maybe_unused]] int wheel, [[maybe_unused]] WidgetID widget) {}
735
736
740 virtual void OnMouseLoop() {}
741
745 virtual void OnGameTick() {}
746
750 virtual void OnRealtimeTick([[maybe_unused]] uint delta_ms) {}
751
755 virtual void OnTimeout() {}
756
757
762 virtual void OnResize() {}
763
769 virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index, [[maybe_unused]] int click_result) {}
770
771 virtual void OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close);
772
777 virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget) {}
778
785 virtual void OnQueryTextFinished([[maybe_unused]] std::optional<std::string> str) {}
786
792 virtual void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) {}
793
800 virtual void OnPlaceObject([[maybe_unused]] Point pt, [[maybe_unused]] TileIndex tile) {}
801
808 virtual bool OnVehicleSelect([[maybe_unused]] const struct Vehicle *v) { return false; }
809
816 virtual bool OnVehicleSelect([[maybe_unused]] VehicleList::const_iterator begin, [[maybe_unused]] VehicleList::const_iterator end) { return false; }
817
821 virtual void OnPlaceObjectAbort() {}
822
823
831 virtual void OnPlaceDrag([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) {}
832
842 virtual void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile) {}
843
851 virtual void OnPlacePresize([[maybe_unused]] Point pt, [[maybe_unused]] TileIndex tile) {}
852
853 /*** End of the event handling ***/
854
859 virtual bool IsNewGRFInspectable() const { return false; }
860
867 virtual void ShowNewGRFInspectWindow() const { NOT_REACHED(); }
868
873 template <bool TtoBack>
875 typedef Window *value_type;
876 typedef value_type *pointer;
877 typedef value_type &reference;
878 typedef size_t difference_type;
879 typedef std::forward_iterator_tag iterator_category;
880
881 explicit WindowIterator(WindowList::iterator start) : it(start)
882 {
883 this->Validate();
884 }
885 explicit WindowIterator(const Window *w) : it(w->z_position) {}
886
887 bool operator==(const WindowIterator &other) const { return this->it == other.it; }
888 Window * operator*() const { return *this->it; }
889 WindowIterator & operator++() { this->Next(); this->Validate(); return *this; }
890
891 bool IsEnd() const { return this->it == _z_windows.end(); }
892
893 private:
894 WindowList::iterator it;
895 void Validate()
896 {
897 while (!this->IsEnd() && *this->it == nullptr) this->Next();
898 }
899 void Next()
900 {
901 if constexpr (!TtoBack) {
902 ++this->it;
903 } else if (this->it == _z_windows.begin()) {
904 this->it = _z_windows.end();
905 } else {
906 --this->it;
907 }
908 }
909 };
912
917 template <bool Tfront>
918 struct AllWindows {
919 AllWindows() {}
921 {
922 if constexpr (Tfront) {
923 auto back = _z_windows.end();
924 if (back != _z_windows.begin()) --back;
925 return WindowIterator<Tfront>(back);
926 } else {
927 return WindowIterator<Tfront>(_z_windows.begin());
928 }
929 }
931 };
935};
936
944template <class It, class Pred>
945inline bool AllEqual(It begin, It end, Pred pred)
946{
947 return std::adjacent_find(begin, end, std::not_fn(pred)) == end;
948}
949
956template <class NWID>
957inline NWID *Window::GetWidget(WidgetID widnum)
958{
959 auto it = this->widget_lookup.find(widnum);
960 if (it == std::end(this->widget_lookup)) return nullptr;
961 NWID *nwid = dynamic_cast<NWID *>(it->second);
962 assert(nwid != nullptr);
963 return nwid;
964}
965
967template <>
968inline const NWidgetBase *Window::GetWidget<NWidgetBase>(WidgetID widnum) const
969{
970 auto it = this->widget_lookup.find(widnum);
971 if (it == std::end(this->widget_lookup)) return nullptr;
972 return it->second;
973}
974
981template <class NWID>
982inline const NWID *Window::GetWidget(WidgetID widnum) const
983{
984 return const_cast<Window *>(this)->GetWidget<NWID>(widnum);
985}
986
987
991class PickerWindowBase : public Window {
992
993public:
995 {
996 this->parent = parent;
997 }
998
999 void Close([[maybe_unused]] int data = 0) override;
1000};
1001
1003Window *FindWindowFromPt(int x, int y);
1004
1014template <typename Twindow, bool Treturn_existing = false, typename... Targs>
1015Twindow *AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
1016{
1017 Twindow *w = static_cast<Twindow *>(BringWindowToFrontById(desc.cls, window_number));
1018 if (w != nullptr) return Treturn_existing ? w : nullptr;
1019 return new Twindow(desc, window_number, std::forward<Targs>(extra_arguments)...);
1020}
1021
1022void RelocateAllWindows(int neww, int newh);
1023
1024void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip);
1025
1026/* widget.cpp */
1027WidgetID GetWidgetFromPos(const Window *w, int x, int y);
1028
1029extern Point _cursorpos_drag_start;
1030
1031extern int _scrollbar_start_pos;
1032extern int _scrollbar_size;
1033extern uint8_t _scroller_click_timeout;
1034
1035extern bool _scrolling_viewport;
1036extern bool _mouse_hovering;
1037
1047
1048void SetFocusedWindow(Window *w);
1049
1050void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y);
1051Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step = 1);
1052
1053#endif /* WINDOW_GUI_H */
constexpr Timpl & Set()
Set all bits.
Container for an encoded string, created by GetEncodedString.
Enum-as-bit-set wrapper.
Baseclass for nested widgets.
Base class for a 'real' widget.
WidgetID GetIndex() const
Get the WidgetID of this nested widget.
Definition widget.cpp:1267
void SetDisabled(bool disabled)
Disable (grey-out) or enable the widget.
Leaf widget.
Stacked widgets, widgets all occupying the same space in the window.
int shown_plane
Plane being displayed (for NWID_SELECTION only).
Base class for windows opened from a toolbar.
Definition window_gui.h:991
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:3570
Scrollbar data structure.
static constexpr uint WD_CAPTION_HEIGHT
Minimum height of a title bar.
Definition window_gui.h:87
RectPadding defsizebox
Padding around image in defsizebox widget.
Definition window_gui.h:46
RectPadding closebox
Padding around image in closebox widget.
Definition window_gui.h:48
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
static constexpr uint WD_DROPDOWN_HEIGHT
Minimum height of a drop down widget.
Definition window_gui.h:88
RectPadding captiontext
Padding for text within caption widget.
Definition window_gui.h:49
RectPadding sparse_resize
Padding used for a resizeable 'sparse' widget window, usually containing multiple frames.
Definition window_gui.h:55
RectPadding debugbox
Padding around image in debugbox widget.
Definition window_gui.h:45
int vsep_sparse
Normal vertical spacing for 'sparse' widget window.
Definition window_gui.h:59
RectPadding sparse
Padding used for 'sparse' widget window, usually containing multiple frames.
Definition window_gui.h:54
RectPadding frametext
Padding inside frame with text.
Definition window_gui.h:41
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
RectPadding modalpopup
Spacing for popup warning/information windows.
Definition window_gui.h:52
RectPadding hscrollbar
Padding inside horizontal scrollbar buttons.
Definition window_gui.h:37
RectPadding shadebox
Padding around image in shadebox widget.
Definition window_gui.h:43
RectPadding resizebox
Padding around image in resizebox widget.
Definition window_gui.h:47
RectPadding vscrollbar
Padding inside vertical scrollbar buttons.
Definition window_gui.h:36
RectPadding imgbtn
Padding around image button image.
Definition window_gui.h:34
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:58
int vsep_picker
Vertical spacing of picker-window widgets.
Definition window_gui.h:57
int vsep_wide
Wide vertical spacing.
Definition window_gui.h:60
int hsep_wide
Wide horizontal spacing.
Definition window_gui.h:62
static constexpr uint WD_CLOSEBOX_WIDTH
Minimum width of a close box widget.
Definition window_gui.h:86
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
RectPadding inset
Padding inside inset container.
Definition window_gui.h:35
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
static constexpr uint WD_RESIZEBOX_WIDTH
Minimum width of a resize box widget.
Definition window_gui.h:85
RectPadding picker
Padding for a picker (dock, station, etc) window.
Definition window_gui.h:53
static constexpr uint WD_STICKYBOX_WIDTH
Minimum width of a standard sticky box widget.
Definition window_gui.h:82
RectPadding matrix
Padding of WWT_MATRIX items.
Definition window_gui.h:42
int hsep_normal
Normal horizontal spacing.
Definition window_gui.h:61
RectPadding dropdownlist
Padding of complete drop down list.
Definition window_gui.h:51
static constexpr uint WD_DEBUGBOX_WIDTH
Minimum width of a standard debug box widget.
Definition window_gui.h:83
RectPadding stickybox
Padding around image in stickybox widget.
Definition window_gui.h:44
static constexpr uint WD_DEFSIZEBOX_WIDTH
Minimum width of a standard defsize box widget.
Definition window_gui.h:84
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition window_gui.h:38
RectPadding dropdowntext
Padding of drop down list item.
Definition window_gui.h:50
static constexpr uint WD_SHADEBOX_WIDTH
Distances used in drawing widgets.
Definition window_gui.h:81
int hsep_indent
Width of indentation for tree layouts.
Definition window_gui.h:63
Types related to companies.
static constexpr Owner INVALID_OWNER
An invalid owner.
FontSize
Available font sizes.
Definition gfx_type.h:250
StringAlignment
How to align the to-be drawn text.
Definition gfx_type.h:382
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:302
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:955
Types for strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Dimensions (a width and height) of a rectangle in 2D.
List of hotkeys for a window.
Definition hotkeys.h:37
Coordinates of a point in 2D.
Data stored about a string that can be modified in the GUI.
Padding dimensions to apply to each side of a Rect.
Specification of a rectangle with absolute coordinates of all edges.
Data structure for resizing a window.
Definition window_gui.h:210
uint step_height
Step-size of height resize changes.
Definition window_gui.h:212
uint step_width
Step-size of width resize changes.
Definition window_gui.h:211
Helper/buffer for input fields.
Vehicle data structure.
Data structure for a window viewport.
Definition window_gui.h:250
void CancelFollow(const Window &viewport_window)
Cancel viewport vehicle following, and raise follow location widget if needed.
int32_t dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition window_gui.h:255
int32_t scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition window_gui.h:253
int32_t dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
Definition window_gui.h:254
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, VehicleID::Invalid() otherwise.
Definition window_gui.h:251
int32_t scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
Definition window_gui.h:252
Data structure for viewport, display of a part of the world.
High level window description.
Definition window_gui.h:167
int16_t GetDefaultWidth() const
Determine default width of window.
Definition window.cpp:136
static void SaveToConfig()
Save all WindowDesc settings to _windows_file.
Definition window.cpp:175
int16_t pref_width
User-preferred width of the window. Zero if unset.
Definition window_gui.h:186
const WindowPosition default_pos
Preferred position of the window.
Definition window_gui.h:177
bool pref_sticky
Preferred stickyness.
Definition window_gui.h:185
WindowDesc(const WindowDesc &)=delete
Delete copy constructor to prevent compilers from copying the structure, which fails due to _window_d...
int16_t pref_height
User-preferred height of the window. Zero if unset.
Definition window_gui.h:187
int16_t GetDefaultHeight() const
Determine default height of window.
Definition window.cpp:146
const int16_t default_height_trad
Preferred initial height of the window (pixels at 1x zoom).
Definition window_gui.h:197
const int16_t default_width_trad
Preferred initial width of the window (pixels at 1x zoom).
Definition window_gui.h:196
const WindowClass cls
Class of the window,.
Definition window_gui.h:178
const std::string_view ini_key
Key to store window defaults in openttd.cfg. An empty string if nothing shall be stored.
Definition window_gui.h:180
const std::source_location source_location
Source location of this definition.
Definition window_gui.h:176
const WindowDefaultFlags flags
Flags.
Definition window_gui.h:181
static void LoadFromConfig()
Load all WindowDesc settings from _windows_file.
Definition window.cpp:154
const WindowClass parent_cls
Class of the parent window.
Definition window_gui.h:179
const HotkeyList * hotkeys
Hotkeys for the window.
Definition window_gui.h:183
const std::span< const NWidgetPart > nwid_parts
Span of nested widget parts describing the window.
Definition window_gui.h:182
Number to differentiate different windows of the same class.
Iterable ensemble of all valid Windows.
Definition window_gui.h:918
Iterator to iterate all valid Windows.
Definition window_gui.h:874
Data structure for an opened window.
Definition window_gui.h:273
virtual const struct Textbuf * GetFocusedTextbuf() const
Get the current input text buffer.
Definition window.cpp:363
void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour)
Sets the highlighted status of a widget.
Definition window.cpp:240
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:967
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1091
bool IsWidgetGloballyFocused(WidgetID widget_index) const
Check if given widget has user input focus.
Definition window_gui.h:431
virtual void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize)
Update size and resize step of a widget in the window.
Definition window_gui.h:620
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition window_gui.h:792
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition widget.cpp:826
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1778
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition window_gui.h:320
virtual void ApplyDefaults()
Read default values from WindowDesc configuration an apply them to the window.
Definition window.cpp:192
uint8_t white_border_timer
Timer value of the WindowFlag::WhiteBorder for flags.
Definition window_gui.h:307
NWidgetStacked * shade_select
Selection widget (NWID_SELECTION) to use for shading the window. If nullptr, window cannot shade.
Definition window_gui.h:323
void InitializePositionSize(int x, int y, int min_width, int min_height)
Set the position and smallest size of the window.
Definition window.cpp:1444
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:777
virtual bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end)
The user clicked on a vehicle while HT_VEHICLE has been set.
Definition window_gui.h:816
Dimension unshaded_size
Last known unshaded size (only valid while shaded).
Definition window_gui.h:324
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition window.cpp:3205
virtual EventState OnKeyPress(char32_t key, uint16_t keycode)
A key has been pressed.
Definition window_gui.h:650
Window * parent
Parent window.
Definition window_gui.h:328
virtual ~Window()
Remove window and all its child windows from the window stack.
Definition window.cpp:1128
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:469
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:555
uint8_t timeout_timer
Timer value of the WindowFlag::Timeout for flags.
Definition window_gui.h:306
std::unique_ptr< ViewportData > viewport
Pointer to viewport data, if present.
Definition window_gui.h:318
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:503
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
Definition window_gui.h:326
virtual void OnGameTick()
Called once per (game) tick.
Definition window_gui.h:745
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
Definition window_gui.h:867
virtual bool OnRightClick(Point pt, WidgetID widget)
A click with the right mouse button has been made on the window.
Definition window_gui.h:677
virtual void OnScrollbarScroll(WidgetID widget)
Notify window that a scrollbar position has been updated.
Definition window_gui.h:719
void RaiseWidgetWhenLowered(WidgetID widget_index)
Marks a widget as raised and dirty (redraw), when it is marked as lowered.
Definition window_gui.h:478
virtual void OnDropdownSelect(WidgetID widget, int index, int click_result)
A dropdown option associated to this window has been selected.
Definition window_gui.h:769
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition widget.cpp:809
void ProcessScheduledInvalidations()
Process all scheduled invalidations.
Definition window.cpp:3218
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition window.cpp:1064
ResizeInfo resize
Resize information.
Definition window_gui.h:314
void UnfocusFocusedWidget()
Makes no widget on this window have focus.
Definition window.cpp:468
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition window_gui.h:391
virtual void OnMouseLoop()
Called for every mouse loop run, which is at least once per (game) tick.
Definition window_gui.h:740
void SetShaded(bool make_shaded)
Set the shaded state of the window to make_shaded.
Definition window.cpp:1010
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition window_gui.h:821
int scale
Scale of this window – used to determine how to resize.
Definition window_gui.h:304
void ScheduleResize()
Mark this window as resized and in need of OnResize() event.
Definition window.cpp:3183
virtual bool OnVehicleSelect(const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
Definition window_gui.h:808
bool IsWidgetFocused(WidgetID widget_index) const
Check if given widget is focused within this window.
Definition window_gui.h:420
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:515
virtual void OnPaint()
The window must be repainted.
Definition window_gui.h:595
virtual void OnDragDrop(Point pt, WidgetID widget)
A dragged 'object' has been released.
Definition window_gui.h:706
virtual bool IsNewGRFInspectable() const
Is the data related to this window NewGRF inspectable?
Definition window_gui.h:859
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1768
WindowDesc & window_desc
Window description.
Definition window_gui.h:299
WindowClass window_class
Window class.
Definition window_gui.h:301
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
Definition window_gui.h:750
virtual void OnMouseWheel(int wheel, WidgetID widget)
The mouse wheel has been turned.
Definition window_gui.h:734
void CloseChildWindowById(WindowClass wc, WindowNumber number) const
Close all children a window might have in a head-recursive manner.
Definition window.cpp:1079
virtual void OnQueryTextFinished(std::optional< std::string > str)
The query window opened from this window has closed.
Definition window_gui.h:785
void SetWhiteBorder()
Set the timeout flag of the window and initiate the timer.
Definition window_gui.h:364
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition window.cpp:484
virtual void OnFocusLost(bool closing)
The window has lost focus.
Definition window.cpp:520
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:491
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition window_gui.h:410
void DrawViewport() const
Draw the viewport of this window.
static std::vector< Window * > closed_windows
List of closed windows to delete.
Definition window_gui.h:275
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition window.cpp:529
virtual void DrawWidget(const Rect &r, WidgetID widget) const
Draw the contents of a nested widget.
Definition window_gui.h:606
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition window_gui.h:526
virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number)
Compute the initial position of the window.
Definition window.cpp:1756
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition window_gui.h:316
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:441
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
Definition window_gui.h:400
virtual Point GetCaretPosition() const
Get the current caret position if an edit box has the focus.
Definition window.cpp:376
virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize)
Resize window towards the default size.
Definition window.cpp:1463
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close)
A dropdown window associated to this window has been closed.
Definition window.cpp:285
virtual void InsertTextString(WidgetID wid, std::string_view str, bool marked, std::optional< size_t > caret, std::optional< size_t > insert_location, std::optional< size_t > replacement_end)
Insert a text string at the cursor position into the edit box widget.
Definition window.cpp:2690
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
Definition window_gui.h:800
int left
x position of left edge of the window
Definition window_gui.h:309
bool IsShaded() const
Is window shaded currently?
Definition window_gui.h:559
Window * FindChildWindow(WindowClass wc=WC_INVALID) const
Find the Window whose parent pointer points to this window.
Definition window.cpp:1036
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition window_gui.h:355
const NWidgetCore * nested_focus
Currently focused nested widget, or nullptr if no nested widget has focus.
Definition window_gui.h:319
virtual void OnEditboxChanged(WidgetID widget)
The text in an editbox has been edited.
Definition window_gui.h:777
void UpdateQueryStringSize()
Update size of all QueryStrings of this window.
Definition window.cpp:352
virtual void OnScroll(Point delta)
Handle the request for (viewport) scrolling.
Definition window_gui.h:712
void RaiseWidgetsWhenLowered(Args... widgets)
Raises the widgets and sets widgets dirty that are lowered.
Definition window_gui.h:536
int top
y position of top edge of the window
Definition window_gui.h:310
virtual void OnClick(Point pt, WidgetID widget, int click_count)
A click with the left mouse button has been made on the window.
Definition window_gui.h:668
const QueryString * GetQueryString(WidgetID widnum) const
Return the querystring associated to a editbox.
Definition window.cpp:332
WidgetLookup widget_lookup
Indexed access to the nested widget tree. Do not access directly, use Window::GetWidget() instead.
Definition window_gui.h:322
virtual ptrdiff_t GetTextCharacterAtPosition(const Point &pt) const
Get the character that is rendered at a position by the focused edit box.
Definition window.cpp:407
std::vector< int > scheduled_invalidation_data
Data of scheduled OnInvalidateData() calls.
Definition window_gui.h:282
void InitializeData(WindowNumber window_number)
Initializes the data (except the position and initial size) of a new Window.
Definition window.cpp:1406
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition window_gui.h:842
virtual void OnMouseOver(Point pt, WidgetID widget)
The mouse is currently moving over the window or has just moved outside of the window.
Definition window_gui.h:727
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Definition window.cpp:211
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:982
virtual bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond)
Event to display a custom tooltip.
Definition window_gui.h:692
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:460
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
Definition window_gui.h:659
void ProcessScheduledResize()
Process scheduled OnResize() event.
Definition window.cpp:3191
EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode)
Process keypress for editbox widget.
Definition window.cpp:2532
virtual void OnMouseDrag(Point pt, WidgetID widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
Definition window_gui.h:699
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition window.cpp:594
virtual void OnResize()
Called after the window got resized.
Definition window_gui.h:762
Window * FindChildWindowById(WindowClass wc, WindowNumber number) const
Find the Window whose parent pointer points to this window.
Definition window.cpp:1051
virtual void OnFocus()
The window has gained focus.
Definition window.cpp:512
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1791
virtual void OnTimeout()
Called when this window's timeout has been reached.
Definition window_gui.h:755
WindowFlags flags
Window flags.
Definition window_gui.h:300
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition window.cpp:312
void ProcessHighlightedInvalidations()
Process all invalidation of highlighted widgets.
Definition window.cpp:3230
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
The user is dragging over the map when the tile highlight mode has been set.
Definition window_gui.h:831
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition window.cpp:569
static void DeleteClosedWindows()
Delete all closed windows.
Definition window.cpp:67
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:381
std::unique_ptr< NWidgetBase > nested_root
Root of the nested tree.
Definition window_gui.h:321
bool scheduled_resize
Set if window has been resized.
Definition window_gui.h:283
virtual Rect GetTextBoundingRect(size_t from, size_t to) const
Get the bounding rectangle for a text range if an edit box has the focus.
Definition window.cpp:392
bool IsWidgetHighlighted(WidgetID widget_index) const
Gets the highlighted status of a widget.
Definition window.cpp:270
void DisableAllWidgetHighlight()
Disable the highlighted status of all widgets.
Definition window.cpp:222
virtual void OnPlacePresize(Point pt, TileIndex tile)
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition window_gui.h:851
int height
Height of the window (number of pixels down in y direction)
Definition window_gui.h:312
virtual void OnHover(Point pt, WidgetID widget)
The mouse is hovering over a widget in the window, perform an action for it.
Definition window_gui.h:684
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:311
virtual void OnInit()
Notification that the nested widget tree gets initialized.
Definition window_gui.h:578
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition window_gui.h:450
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:302
Types related to tiles.
Types related to vehicles.
Functions and type for generating vehicle lists.
Types related to viewports.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definitions about widgets.
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
std::map< WidgetID, class NWidgetBase * > WidgetLookup
Lookup between widget IDs and NWidget objects.
WindowDefaultFlag
Window default widget/window handling flags.
Definition window_gui.h:152
@ Construction
This window is used for construction; close it whenever changing company.
@ NoClose
This window can't be interactively closed.
@ NoFocus
This window won't get focus/make any other window lose focus when click.
@ Modal
The window is a modal child of some other window, meaning the parent is 'inactive'.
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:298
bool _scrolling_viewport
A viewport is being scrolled with the mouse.
Definition window.cpp:92
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
Definition misc_gui.cpp:688
bool AllEqual(It begin, It end, Pred pred)
Generic helper function that checks if all elements of the range are equal with respect to the given ...
Definition window_gui.h:945
FrameFlag
Flags to describe the look of the frame.
Definition window_gui.h:24
@ Transparent
Makes the background transparent if set.
@ BorderOnly
Draw border only, no background.
@ Darkened
If set the background is darker, allows for lowered frames with normal background colour when used wi...
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition window.cpp:420
WindowFlag
Window flags.
Definition window_gui.h:225
@ SizingLeft
Window is being resized towards the left.
@ DisableVpScroll
Window does not do autoscroll,.
@ Highlighted
Window has a widget that has a highlight.
@ Centred
Window is centered and shall stay centered after ReInit.
@ Dragging
Window is being dragged.
@ SizingRight
Window is being resized towards the right.
@ WhiteBorder
Window white border counter bit mask.
@ Timeout
Window timeout counter.
@ Sticky
Window is made sticky by user.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
Definition window.cpp:1813
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, std::string_view str, StringAlignment align, FontSize fs)
Draw a caption bar.
Definition widget.cpp:725
static const int TIMEOUT_DURATION
The initial timeout value for WindowFlag::Timeout.
Definition window_gui.h:240
WidgetID GetWidgetFromPos(const Window *w, int x, int y)
Returns the index for the widget located at the given position relative to the window.
Definition widget.cpp:283
Point GetToolbarAlignedWindowPosition(int window_width)
Computer the position of the top-left corner of a window to be opened right under the toolbar.
Definition window.cpp:1672
SortButtonState
State of a sort direction button.
Definition window_gui.h:216
@ SBS_DOWN
Sort ascending.
Definition window_gui.h:218
@ SBS_UP
Sort descending.
Definition window_gui.h:219
@ SBS_OFF
Do not sort (with this button).
Definition window_gui.h:217
SpecialMouseMode
Mouse modes.
@ WSM_DRAGDROP
Drag&drop an object.
@ WSM_DRAGGING
Dragging mode (trees).
@ WSM_PRESIZE
Presizing mode (docks, tunnels).
@ WSM_NONE
No special mouse mode.
@ WSM_SIZING
Sizing mode.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition window.cpp:1265
void RelocateAllWindows(int neww, int newh)
Relocate all windows to fit the new size of the game application screen.
Definition window.cpp:3497
void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y)
Special handling for the scrollbar widget type.
Definition widget.cpp:259
bool _mouse_hovering
The mouse is hovering over the same point.
Definition window.cpp:93
WindowPosition
How do we the window to be placed?
Definition window_gui.h:142
@ WDP_CENTER
Center the window.
Definition window_gui.h:145
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:144
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition window_gui.h:146
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
WindowList _z_windows
List of windows opened at the screen sorted from the front to back.
Definition window.cpp:59
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Definition window.cpp:95
static const int WHITE_BORDER_DURATION
The initial timeout value for WindowFlag::WhiteBorder.
Definition window_gui.h:241
Rect ScrollRect(Rect r, const Scrollbar &sb, int resize_step=1)
Apply 'scroll' to a rect to be drawn in.
Definition widget.cpp:2573
int WidgetID
Widget ID.
Definition window_type.h:20
EventState
State of handling an event.
@ ES_NOT_HANDLED
The passed event is not handled.
WindowClass
Window classes.
Definition window_type.h:46
@ WC_INVALID
Invalid window.