OpenTTD Source: CursorVars Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields
CursorVars Struct Reference

Collection of variables for cursor-display and -animation. More...

`#include <gfx_type.h>`

## Public Member Functions
void | UpdateCursorPositionRelative (int delta_x, int delta_y)
| Update cursor position based on a relative change.
bool | UpdateCursorPosition (int x, int y)
| Update cursor position on mouse movement.

## Data Fields
Point | pos
| logical mouse position
Point | delta
| relative mouse movement in this tick
int | wheel
| mouse wheel movement
bool | fix_at
| mouse is moving, but cursor is not (used for scrolling)
bool | wheel_moved
float | v_wheel
float | h_wheel
std::vector< CursorSprite > | sprites
| Sprites comprising cursor.
Point | total_offs
Point | total_size
| union of sprite properties
Point | draw_pos
Point | draw_size
| position and size bounding-box for drawing
std::span< const AnimCursor > | animate_list {}
| in case of animated cursor, list of frames
std::span< constAnimCursor >::iterator | animate_cur = std::end(animate_list)
| in case of animated cursor, current frame
uint | animate_timeout
| in case of animated cursor, number of ticks to show the current cursor
bool | visible
| cursor is visible
bool | dirty
| the rect occupied by the mouse is dirty (redraw)
bool | in_window
| mouse inside this window, determines drawing logic
bool | vehchain
| vehicle chain is dragged

## Detailed Description

Collection of variables for cursor-display and -animation.

Definition at line 123 of file gfx_type.h.

## Member Function Documentation

## ◆ UpdateCursorPosition()

bool CursorVars::UpdateCursorPosition | ( | int | x,
|  | int | y
| ) |  |

Update cursor position on mouse movement.

Parameters

  x | New X position.
  y | New Y position.

Returns
  true, if the OS cursor position should be warped back to this->pos.

Definition at line 1748 of file gfx.cpp.

References delta, dirty, fix_at, pos, Coord2D< T >::x, and Coord2D< T >::y.

Referenced by VideoDriver_SDL_Base::PollEvent().

## ◆ UpdateCursorPositionRelative()

void CursorVars::UpdateCursorPositionRelative | ( | int | delta_x,
|  | int | delta_y
| ) |  |

Update cursor position based on a relative change.

Parameters

  delta_x | How much change in the X position.
  delta_y | How much change in the Y position.

Definition at line 1734 of file gfx.cpp.

References delta, fix_at, Coord2D< T >::x, and Coord2D< T >::y.

## Field Documentation

## ◆ animate_cur

std::span<constAnimCursor>::iterator CursorVars::animate_cur = std::end(animate_list)

in case of animated cursor, current frame

Definition at line 142 of file gfx_type.h.

Referenced by SetAnimatedMouseCursor().

## ◆ animate_list

std::span<const AnimCursor> CursorVars::animate_list {}

in case of animated cursor, list of frames

Definition at line 141 of file gfx_type.h.

Referenced by SetAnimatedMouseCursor().

## ◆ animate_timeout

uint CursorVars::animate_timeout

in case of animated cursor, number of ticks to show the current cursor

Definition at line 143 of file gfx_type.h.

Referenced by SetMouseCursor().

## ◆ delta

Point CursorVars::delta

relative mouse movement in this tick

Definition at line 126 of file gfx_type.h.

Referenced by HandleActiveWidget(), HandleMouseDragDrop(), HandleMouseEvents(), HandleViewportScroll(), HandleWindowDragging(), UpdateCursorPosition(), and UpdateCursorPositionRelative().

## ◆ dirty

bool CursorVars::dirty

the rect occupied by the mouse is dirty (redraw)

Definition at line 146 of file gfx_type.h.

Referenced by UpdateCursorPosition(), and UpdateCursorSize().

## ◆ draw_pos

Point CursorVars::draw_pos

Definition at line 139 of file gfx_type.h.

## ◆ draw_size

Point CursorVars::draw_size

position and size bounding-box for drawing

Definition at line 139 of file gfx_type.h.

Referenced by NetworkUndrawChatMessage(), and RedrawScreenRect().

## ◆ fix_at

bool CursorVars::fix_at

mouse is moving, but cursor is not (used for scrolling)

Definition at line 128 of file gfx_type.h.

Referenced by HandleViewportScroll(), LoadIntroGame(), SmallMapWindow::OnScroll(), VideoDriver_SDL_Base::PollEvent(), UpdateCursorPosition(), and UpdateCursorPositionRelative().

## ◆ h_wheel

float CursorVars::h_wheel

Definition at line 133 of file gfx_type.h.

## ◆ in_window

bool CursorVars::in_window

mouse inside this window, determines drawing logic

Definition at line 147 of file gfx_type.h.

Referenced by GuiShowTooltips(), HandleMouseEvents(), TooltipsWindow::OnMouseLoop(), openttd_main(), and VideoDriver_SDL_Base::PollEvent().

## ◆ pos

Point CursorVars::pos

logical mouse position

Definition at line 125 of file gfx_type.h.

Referenced by DropdownWindow::Close(), DropdownWindow::GetDropDownItem(), HandleActiveWidget(), HandleAutoscroll(), HandleMouseDragDrop(), HandleMouseEvents(), HandleMouseOver(), HandleScrollbarScrolling(), HandleViewportScroll(), HandleWindowDragging(), OrdersWindow::OnClick(), BuildBridgeWindow::OnInitialPosition(), ErrmsgWindow::OnInitialPosition(), TooltipsWindow::OnInitialPosition(), DropdownWindow::OnMouseLoop(), TooltipsWindow::OnMouseLoop(), SmallMapWindow::OnMouseWheel(), SelectGameWindow::OnRealtimeTick(), VideoDriver_SDL_Base::PollEvent(), ScrollbarClickPositioning(), StartWindowDrag(), StartWindowSizing(), and UpdateCursorPosition().

## ◆ sprites

std::vector<CursorSprite> CursorVars::sprites

Sprites comprising cursor.

Definition at line 136 of file gfx_type.h.

Referenced by SetAnimatedMouseCursor(), SetCursorSprite(), SetMouseCursorBusy(), SetMouseCursorVehicle(), and UpdateCursorSize().

## ◆ total_offs

Point CursorVars::total_offs

Definition at line 137 of file gfx_type.h.

## ◆ total_size

Point CursorVars::total_size

union of sprite properties

Definition at line 137 of file gfx_type.h.

Referenced by TooltipsWindow::OnInitialPosition(), and UpdateCursorSize().

## ◆ v_wheel

float CursorVars::v_wheel

Definition at line 132 of file gfx_type.h.

## ◆ vehchain

bool CursorVars::vehchain

vehicle chain is dragged

Definition at line 150 of file gfx_type.h.

Referenced by DepotWindow::CountDraggedLength(), DepotWindow::DepotClick(), DrawTrainImage(), VehicleGroupWindow::OnClick(), DepotWindow::OnCTRLStateChange(), DepotWindow::OnDragDrop(), and VehicleGroupWindow::OnDragDrop().

## ◆ visible

bool CursorVars::visible

cursor is visible

Definition at line 145 of file gfx_type.h.

Referenced by NetworkUndrawChatMessage(), and RedrawScreenRect().

## ◆ wheel

int CursorVars::wheel

mouse wheel movement

Definition at line 127 of file gfx_type.h.

Referenced by HandleMouseEvents(), and VideoDriver_SDL_Base::PollEvent().

## ◆ wheel_moved

bool CursorVars::wheel_moved

Definition at line 131 of file gfx_type.h.

The documentation for this struct was generated from the following files:

- src/gfx_type.h
- src/gfx.cpp