|
OpenTTD Source 15.0-beta1
|
Functions, definitions and such used only by the GUI. More...
#include "vehiclelist.h"#include "vehicle_type.h"#include "viewport_type.h"#include "company_type.h"#include "tile_type.h"#include "widget_type.h"#include "string_type.h"Go to the source code of this file.
Data Structures | |
| class | WidgetDimensions |
| struct | WindowDesc |
| High level window description. More... | |
| struct | ResizeInfo |
| Data structure for resizing a window. More... | |
| struct | ViewportData |
| Data structure for a window viewport. More... | |
| struct | Window |
| Data structure for an opened window. More... | |
| struct | Window::WindowIterator< TtoBack > |
| Iterator to iterate all valid Windows. More... | |
| struct | Window::AllWindows< Tfront > |
| Iterable ensemble of all valid Windows. More... | |
| class | PickerWindowBase |
| Base class for windows opened from a toolbar. More... | |
Typedefs | |
| using | WindowList = std::list< Window * > |
Enumerations | |
| enum | FrameFlags { FR_NONE = 0 , FR_TRANSPARENT = 1 << 0 , FR_BORDERONLY = 1 << 4 , FR_LOWERED = 1 << 5 , FR_DARKENED = 1 << 6 } |
| Flags to describe the look of the frame. More... | |
| enum | WindowPosition { WDP_MANUAL , WDP_AUTO , WDP_CENTER , WDP_ALIGN_TOOLBAR } |
| How do we the window to be placed? More... | |
| enum | WindowDefaultFlag { WDF_CONSTRUCTION = 1 << 0 , WDF_MODAL = 1 << 1 , WDF_NO_FOCUS = 1 << 2 , WDF_NO_CLOSE = 1 << 3 } |
| Window default widget/window handling flags. More... | |
| enum | SortButtonState { SBS_OFF , SBS_DOWN , SBS_UP } |
| State of a sort direction button. More... | |
| enum | WindowFlags { WF_TIMEOUT = 1 << 0 , WF_DRAGGING = 1 << 3 , WF_SIZING_RIGHT = 1 << 4 , WF_SIZING_LEFT = 1 << 5 , WF_SIZING = WF_SIZING_RIGHT | WF_SIZING_LEFT , WF_STICKY = 1 << 6 , WF_DISABLE_VP_SCROLL = 1 << 7 , WF_WHITE_BORDER = 1 << 8 , WF_HIGHLIGHTED = 1 << 9 , WF_CENTERED = 1 << 10 } |
| Window flags. More... | |
| enum | TooltipCloseCondition { TCC_RIGHT_CLICK , TCC_HOVER , TCC_NONE , TCC_EXIT_VIEWPORT } |
| enum | SpecialMouseMode { WSM_NONE , WSM_DRAGDROP , WSM_SIZING , WSM_PRESIZE , WSM_DRAGGING } |
| Mouse modes. More... | |
Functions | |
| void | DrawFrameRect (int left, int top, int right, int bottom, Colours colour, FrameFlags flags) |
| Draw frame rectangle. | |
| void | DrawFrameRect (const Rect &r, Colours colour, FrameFlags flags) |
| void | DrawCaption (const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs) |
| Draw a caption bar. | |
| Point | GetToolbarAlignedWindowPosition (int window_width) |
| Computer the position of the top-left corner of a window to be opened right under the toolbar. | |
| template<class It , class Pred > | |
| 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 predicate. | |
| Window * | BringWindowToFrontById (WindowClass cls, WindowNumber number) |
| Find a window and make it the relative top-window on the screen. | |
| Window * | FindWindowFromPt (int x, int y) |
| Do a search for a window at specific coordinates. | |
| template<typename T , std::enable_if_t< std::is_base_of< StrongTypedefBase, T >::value, int > = 0> | |
| Window * | BringWindowToFrontById (WindowClass cls, T number) |
| template<typename Wcls > | |
| Wcls * | AllocateWindowDescFront (WindowDesc &desc, int window_number, bool return_existing=false) |
| Open a new window. | |
| void | RelocateAllWindows (int neww, int newh) |
| Relocate all windows to fit the new size of the game application screen. | |
| void | GuiShowTooltips (Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount=0) |
| Shows a tooltip. | |
| WidgetID | GetWidgetFromPos (const Window *w, int x, int y) |
| Returns the index for the widget located at the given position relative to the window. | |
| void | SetFocusedWindow (Window *w) |
| Set the window that has the focus. | |
| void | ScrollbarClickHandler (Window *w, NWidgetCore *nw, int x, int y) |
| Special handling for the scrollbar widget type. | |
| Rect | ScrollRect (Rect r, const Scrollbar &sb, int resize_step=1) |
| Apply 'scroll' to a rect to be drawn in. | |
Variables | |
| WindowList | _z_windows |
| List of windows opened at the screen sorted from the front to back. | |
| Window * | _focused_window |
| static const int | TIMEOUT_DURATION = 7 |
| The initial timeout value for WF_TIMEOUT. | |
| static const int | WHITE_BORDER_DURATION = 3 |
| The initial timeout value for WF_WHITE_BORDER. | |
| Point | _cursorpos_drag_start |
| int | _scrollbar_start_pos |
| int | _scrollbar_size |
| uint8_t | _scroller_click_timeout |
| bool | _scrolling_viewport |
| A viewport is being scrolled with the mouse. | |
| bool | _mouse_hovering |
| The mouse is hovering over the same point. | |
| SpecialMouseMode | _special_mouse_mode |
| Mode of the mouse. | |
Functions, definitions and such used only by the GUI.
Definition in file window_gui.h.
| using WindowList = std::list<Window *> |
Definition at line 139 of file window_gui.h.
| enum FrameFlags |
Flags to describe the look of the frame.
Definition at line 24 of file window_gui.h.
| enum SortButtonState |
State of a sort direction button.
| Enumerator | |
|---|---|
| SBS_OFF | Do not sort (with this button). |
| SBS_DOWN | Sort ascending. |
| SBS_UP | Sort descending. |
Definition at line 218 of file window_gui.h.
| enum SpecialMouseMode |
Mouse modes.
| Enumerator | |
|---|---|
| WSM_NONE | No special mouse mode. |
| WSM_DRAGDROP | Drag&drop an object. |
| WSM_SIZING | Sizing mode. |
| WSM_PRESIZE | Presizing mode (docks, tunnels). |
| WSM_DRAGGING | Dragging mode (trees). |
Definition at line 1039 of file window_gui.h.
| enum TooltipCloseCondition |
Definition at line 263 of file window_gui.h.
| enum WindowDefaultFlag |
Window default widget/window handling flags.
Definition at line 202 of file window_gui.h.
| enum WindowFlags |
Window flags.
| Enumerator | |
|---|---|
| WF_TIMEOUT | Window timeout counter. |
| WF_DRAGGING | Window is being dragged. |
| WF_SIZING_RIGHT | Window is being resized towards the right. |
| WF_SIZING_LEFT | Window is being resized towards the left. |
| WF_SIZING | Window is being resized. |
| WF_STICKY | Window is made sticky by user. |
| WF_DISABLE_VP_SCROLL | Window does not do autoscroll,.
|
| WF_WHITE_BORDER | Window white border counter bit mask. |
| WF_HIGHLIGHTED | Window has a widget that has a highlight. |
| WF_CENTERED | Window is centered and shall stay centered after ReInit. |
Definition at line 227 of file window_gui.h.
| enum WindowPosition |
How do we the window to be placed?
| Enumerator | |
|---|---|
| WDP_MANUAL | Manually align the window (so no automatic location finding) |
| WDP_AUTO | Find a place automatically. |
| WDP_CENTER | Center the window. |
| WDP_ALIGN_TOOLBAR | Align toward the toolbar. |
Definition at line 145 of file window_gui.h.
|
inline |
Generic helper function that checks if all elements of the range are equal with respect to the given predicate.
| begin | The start of the range. |
| end | The end of the range. |
| pred | The predicate to use. |
Definition at line 940 of file window_gui.h.
Referenced by DepotWindow::OnVehicleSelect(), and OrdersWindow::OnVehicleSelect().
| Wcls * AllocateWindowDescFront | ( | WindowDesc & | desc, |
| int | window_number, | ||
| bool | return_existing = false |
||
| ) |
Open a new window.
| Wcls | Window class to use if the window does not exist. |
| desc | The pointer to the WindowDesc to be created |
| window_number | the window number of the new window |
| return_existing | If set, also return the window if it already existed. |
nullptr. Definition at line 1015 of file window_gui.h.
References BringWindowToFrontById(), and WindowDesc::cls.
| Window * BringWindowToFrontById | ( | WindowClass | cls, |
| T | number | ||
| ) |
Definition at line 1001 of file window_gui.h.
| Window * BringWindowToFrontById | ( | WindowClass | cls, |
| WindowNumber | number | ||
| ) |
Find a window and make it the relative top-window on the screen.
The window gets unshaded if it was shaded, and a white border is drawn at its edges for a brief period of time to visualize its "activation".
| cls | WindowClass of the window to activate |
| number | WindowNumber of the window to activate |
Definition at line 1223 of file window.cpp.
References BringWindowToFront(), FindWindowById(), Window::IsShaded(), Window::SetDirty(), Window::SetShaded(), and Window::SetWhiteBorder().
Referenced by AllocateWindowDescFront(), DoSelectCompanyManagerFace(), NetworkContentListWindow::OnClick(), ShowBuyCompanyDialog(), ShowCompanyFinances(), ShowDepotWindow(), ShowGenerateWorldProgress(), ShowIndustryCargoesWindow(), and ShowScriptDebugWindow().
| void DrawCaption | ( | const Rect & | r, |
| Colours | colour, | ||
| Owner | owner, | ||
| TextColour | text_colour, | ||
| StringID | str, | ||
| StringAlignment | align, | ||
| FontSize | fs | ||
| ) |
Draw a caption bar.
| r | Rectangle of the bar. |
| colour | Colour of the window. |
| owner | 'Owner' of the window. |
| text_colour | Colour of the text. |
| str | Text to draw in the bar. |
| align | Alignment of the text. |
| fs | Font size of the text. |
Definition at line 680 of file widget.cpp.
References _company_colours, WidgetDimensions::bevel, WidgetDimensions::captiontext, DrawFrameRect(), DrawString(), FR_BORDERONLY, FR_DARKENED, FR_LOWERED, GetAlignedPosition(), GetColourGradient(), GetStringBoundingBox(), GfxFillRect(), MAX_COMPANIES, WidgetDimensions::scaled, and Rect::Shrink().
Referenced by NWidgetLeaf::Draw(), and NewsWindow::DrawWidget().
|
inline |
Definition at line 131 of file window_gui.h.
| void DrawFrameRect | ( | int | left, |
| int | top, | ||
| int | right, | ||
| int | bottom, | ||
| Colours | colour, | ||
| FrameFlags | flags | ||
| ) |
Draw frame rectangle.
| left | Left edge of the frame |
| top | Top edge of the frame |
| right | Right edge of the frame |
| bottom | Bottom edge of the frame |
| colour | Colour table to use. |
| flags | Flags controlling how to draw the frame. |
Definition at line 283 of file widget.cpp.
References FILLRECT_RECOLOUR, FR_BORDERONLY, FR_DARKENED, FR_LOWERED, FR_TRANSPARENT, GetColourGradient(), GfxFillRect(), PALETTE_TO_TRANSPARENT, WidgetDimensions::scaled, and Rect::Shrink().
Referenced by NWidgetBackground::Draw(), NWidgetLeaf::Draw(), DrawAircraftImage(), DrawArrowButtons(), DrawBoolButton(), DrawButtonDropdown(), NetworkClientListWindow::DrawButtons(), DrawCaption(), DrawCloseBox(), DrawDropDownButton(), DrawHorizontalScrollbar(), DrawImageButtons(), DrawInset(), DrawMatrix(), DrawResizeBox(), DrawRoadVehImage(), DrawShipImage(), DrawSliderWidget(), DrawTrainImage(), NewGRFInspectWindow::DrawVehicleChainWidget(), DrawVerticalScrollbar(), GenerateProgressWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), IndustryProductionGraphWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), StoryBookWindow::DrawWidget(), TransparenciesWindow::DrawWidget(), RefitWindow::DrawWidget(), and Window::DrawWidgets().
| Window * FindWindowFromPt | ( | int | x, |
| int | y | ||
| ) |
Do a search for a window at specific coordinates.
For this we start at the topmost window, obviously and work our way down to the bottom
| x | position x to query |
| y | position y to query |
Definition at line 1768 of file window.cpp.
References Window::height, IsInsideBS(), Window::left, MayBeShown(), Window::top, and Window::width.
Referenced by HandleAutoscroll(), HandleMouseOver(), HandleViewportScroll(), and TooltipsWindow::OnMouseLoop().
| Point GetToolbarAlignedWindowPosition | ( | int | window_width | ) |
Computer the position of the top-left corner of a window to be opened right under the toolbar.
| window_width | the width of the window to get the position for |
Definition at line 1627 of file window.cpp.
References _current_text_dir, FindWindowById(), Window::height, Window::left, TD_RTL, Window::top, WC_MAIN_TOOLBAR, and Window::width.
Referenced by LocalGetWindowPlacement(), TerraformToolbarWindow::OnInitialPosition(), and TransparenciesWindow::OnInitialPosition().
Returns the index for the widget located at the given position relative to the window.
It includes all widget-corner pixels as well.
Definition at line 268 of file widget.cpp.
References NWidgetCore::index, and Window::nested_root.
Referenced by DropdownWindow::GetDropDownItem(), HandleMouseDragDrop(), and Window::OnDropdownClose().
| void GuiShowTooltips | ( | Window * | parent, |
| StringID | str, | ||
| TooltipCloseCondition | close_tooltip, | ||
| uint | paramcount | ||
| ) |
Shows a tooltip.
| parent | The window this tooltip is related to. |
| str | String to be displayed |
| close_tooltip | the condition under which the tooltip closes |
| paramcount | number of params to deal with |
Definition at line 740 of file misc_gui.cpp.
References CloseWindowById(), CursorVars::in_window, and WC_TOOLTIPS.
Referenced by DispatchHoverEvent(), DispatchRightClickEvent(), DepotWindow::OnRightClick(), ReplaceVehicleWindow::OnTooltip(), IndustryCargoesWindow::OnTooltip(), LinkGraphLegendWindow::OnTooltip(), NetworkClientListWindow::OnTooltip(), BuildRailToolbarWindow::OnTooltip(), VehicleDetailsWindow::OnTooltip(), and ShowMeasurementTooltips().
| void RelocateAllWindows | ( | int | neww, |
| int | newh | ||
| ) |
Relocate all windows to fit the new size of the game application screen.
| neww | New width of the game application screen |
| newh | New height of the game application screen. |
Definition at line 3451 of file window.cpp.
References _toolbar_width, CloseWindowByClass(), EnsureVisibleCaption(), FindWindowById(), Window::flags, Window::height, IConsoleResize(), Window::left, PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), PositionStatusbar(), ResizeWindow(), Window::top, WC_BOOTSTRAP, WC_CONSOLE, WC_DROPDOWN_MENU, WC_ENDSCREEN, WC_HIGHSCORE, WC_MAIN_TOOLBAR, WC_MAIN_WINDOW, WC_NEWS_WINDOW, WC_SEND_NETWORK_MSG, WC_STATUS_BAR, WF_CENTERED, Window::width, and Window::window_class.
Referenced by GameSizeChanged(), and ReInitAllWindows().
| void ScrollbarClickHandler | ( | Window * | w, |
| NWidgetCore * | nw, | ||
| int | x, | ||
| int | y | ||
| ) |
Special handling for the scrollbar widget type.
Handles the special scrolling buttons and other scrolling.
| w | Window on which a scroll was performed. |
| nw | Pointer to the scrollbar widget. |
| x | The X coordinate of the mouse click. |
| y | The Y coordinate of the mouse click. |
Definition at line 244 of file widget.cpp.
References NWidgetBase::current_x, NWidgetBase::current_y, NWID_HSCROLLBAR, NWidgetBase::pos_x, NWidgetBase::pos_y, ScrollbarClickPositioning(), and NWidgetBase::type.
Referenced by DispatchLeftClickEvent().
Apply 'scroll' to a rect to be drawn in.
| r | Rect to be 'scrolled'. |
| sb | The scrollbar affecting the scroll. |
| resize_step | Resize step of the widget/scrollbar (1 if the scrollbar is pixel-based.) |
Definition at line 2468 of file widget.cpp.
References _current_text_dir, Scrollbar::GetCount(), Scrollbar::GetPosition(), Scrollbar::IsVertical(), and TD_RTL.
Referenced by IndustryDirectoryWindow::DrawWidget(), TextfileWindow::DrawWidget(), and ScriptDebugWindow::DrawWidgetLog().
| void SetFocusedWindow | ( | Window * | w | ) |
Set the window that has the focus.
| w | The window to set the focus on |
Definition at line 422 of file window.cpp.
References Window::nested_focus, Window::OnFocus(), Window::OnFocusLost(), NWidgetBase::SetDirty(), WC_TOOLTIPS, and Window::window_class.
Referenced by DispatchLeftClickEvent(), Window::InitializeData(), Window::OnHotkey(), BuildVehicleWindow::OnHotkey(), IndustryDirectoryWindow::OnHotkey(), PickerWindow::OnHotkey(), SignListWindow::OnHotkey(), TownDirectoryWindow::OnHotkey(), and ShowQuery().
|
extern |
Definition at line 84 of file window.cpp.
|
extern |
Definition at line 82 of file window.cpp.
|
extern |
The mouse is hovering over the same point.
Definition at line 91 of file window.cpp.
Referenced by HandleMouseEvents(), InitWindowSystem(), and TooltipsWindow::OnMouseLoop().
|
extern |
Definition at line 87 of file window.cpp.
|
extern |
Definition at line 86 of file window.cpp.
|
extern |
Definition at line 88 of file window.cpp.
|
extern |
A viewport is being scrolled with the mouse.
Definition at line 90 of file window.cpp.
Referenced by HandleViewportScroll(), InitWindowSystem(), and SmallMapWindow::OnRightClick().
|
extern |
Mode of the mouse.
Definition at line 93 of file window.cpp.
Referenced by DeleteDepotHighlightOfVehicle(), DeleteGroupHighlightOfVehicle(), HandleMouseDragDrop(), SetObjectToPlace(), VpHandlePlaceSizingDrag(), VpStartDragging(), and VpStartPlaceSizing().
|
extern |
List of windows opened at the screen sorted from the front to back.
Definition at line 57 of file window.cpp.
Referenced by BringWindowToFront(), Window::DeleteClosedWindows(), UnInitWindowSystem(), and Window::Window().
|
static |
The initial timeout value for WF_TIMEOUT.
Definition at line 242 of file window_gui.h.
Referenced by Window::SetTimeout().
|
static |
The initial timeout value for WF_WHITE_BORDER.
Definition at line 243 of file window_gui.h.
Referenced by Window::SetWhiteBorder().