OpenTTD Source: ViewportSign Struct Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields
ViewportSign Struct Reference

Location information about a sign as seen on the viewport. More...

`#include <viewport_type.h>`

Inheritance diagram for ViewportSign:

## Public Member Functions
auto | operator<=> (const ViewportSign &) const =default
void | UpdatePosition (int center, int top, std::string_view str, std::string_view str_small={})
| Update the position of the viewport sign.
void | MarkDirty (ZoomLevel maxzoom=ZoomLevel::Max) const
| Mark the sign dirty in all viewports.

## Data Fields
int32_t | center = 0
| The center position of the sign.
int32_t | top = 0
| The top of the sign.
uint16_t | width_normal = 0
| The width when not zoomed out (normal font)
uint16_t | width_small = 0
| The width when zoomed out (small font)

## Detailed Description

Location information about a sign as seen on the viewport.

Definition at line 47 of file viewport_type.h.

## Member Function Documentation

## ◆ UpdatePosition()

void ViewportSign::UpdatePosition | ( | int | center,
|  | int | top,
|  | std::string_view | str,
|  | std::string_view | str_small = `{}`
| ) |  |

Update the position of the viewport sign.

Parameters

  center | the (preferred) center of the viewport sign
  top | the new top of the sign
  str | the string to show in the sign
  str_small | the string to show when zoomed out. If the string is empty then the str is used.

Definition at line 1533 of file viewport.cpp.

References Align(), center, FS_SMALL, WidgetDimensions::fullbevel, GetStringBoundingBox(), MarkDirty(), WidgetDimensions::scaled, top, width_normal, and width_small.

## Field Documentation

## ◆ center

int32_t ViewportSign::center = 0

The center position of the sign.

Definition at line 48 of file viewport_type.h.

Referenced by CheckClickOnViewportSign(), MarkDirty(), UpdatePosition(), and ViewportAddString().

## ◆ top

int32_t ViewportSign::top = 0

The top of the sign.

Definition at line 49 of file viewport_type.h.

Referenced by CheckClickOnViewportSign(), UpdatePosition(), and ViewportAddString().

## ◆ width_normal

uint16_t ViewportSign::width_normal = 0

The width when not zoomed out (normal font)

Definition at line 50 of file viewport_type.h.

Referenced by CheckClickOnViewportSign(), MarkDirty(), TextEffect::Reset(), UpdatePosition(), and ViewportAddString().

## ◆ width_small

uint16_t ViewportSign::width_small = 0

The width when zoomed out (small font)

Definition at line 51 of file viewport_type.h.

Referenced by CheckClickOnViewportSign(), MarkDirty(), UpdatePosition(), and ViewportAddString().

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

- src/viewport_type.h
- src/viewport.cpp