OpenTTD Source: ButtonLine Class Reference

OpenTTD Source 15.3

Public Member Functions | Data Fields | Protected Member Functions
ButtonLine Class Referenceabstract

Base interface for a network client list line. More...

Inheritance diagram for ButtonLine:

## Public Member Functions
virtual void | Draw (Rect r) const =0
| Draw the button line.
template<typename T , typename... TArgs>
T & | AddButton (TArgs &&... args)
ButtonCommon * | GetButton (Rect r, const Point &pt) const
| Get the button at a given point on the line.
virtual std::optional< EncodedString > | GetTooltip (Rect r, const Point &pt) const
| Get tooptip for a given point on the line.

## Data Fields
std::vector< std::unique_ptr< ButtonCommon > > | buttons {}
| Buttons for this line.

## Protected Member Functions
Rect | DrawButtons (Rect r) const
| Draw the buttons for this line.

## Detailed Description

Base interface for a network client list line.

Definition at line 1387 of file network_gui.cpp.

## Member Function Documentation

## ◆ AddButton()

template<typename T , typename... TArgs>

T & ButtonLine::AddButton | ( | TArgs &&... | args | ) |
| inline

Definition at line 1400 of file network_gui.cpp.

## ◆ Draw()

virtual void ButtonLine::Draw | ( | Rect | r | ) | const
| pure virtual

Draw the button line.

Parameters

  r | Rect to draw within.

Implemented in CompanyButtonLine, and ClientButtonLine.

References buttons.

## ◆ DrawButtons()

Rect ButtonLine::DrawButtons | ( | Rect | r | ) | const
| inlineprotected

Draw the buttons for this line.

Parameters

  r | Rect to draw within.

Returns
  Rect of remaining space.

Definition at line 1441 of file network_gui.cpp.

References _current_text_dir, WidgetDimensions::bevel, buttons, Rect::CentreToHeight(), DrawFrameRect(), FILLRECT_CHECKER, GetColourGradient(), GfxFillRect(), WidgetDimensions::hsep_normal, Rect::Indent(), SA_CENTER, WidgetDimensions::scaled, Rect::Shrink(), TD_RTL, and Rect::WithWidth().

Referenced by CompanyButtonLine::Draw(), and ClientButtonLine::Draw().

## ◆ GetButton()

ButtonCommon * ButtonLine::GetButton | ( | Rect | r,
|  | const Point & | pt
| ) |  | const
| inline

Get the button at a given point on the line.

Parameters

  r | Rect of line.
  pt | Point of interest.

Returns
  Button at point, or `nullptr` if button isn't pressed.

Definition at line 1412 of file network_gui.cpp.

References _current_text_dir, buttons, Rect::Contains(), WidgetDimensions::hsep_normal, Rect::Indent(), WidgetDimensions::scaled, TD_RTL, and Rect::WithWidth().

Referenced by GetTooltip().

## ◆ GetTooltip()

virtual std::optional< EncodedString > ButtonLine::GetTooltip | ( | Rect | r,
|  | const Point & | pt
| ) |  | const
| inlinevirtual

Get tooptip for a given point on the line.

Parameters

  r | Rect of line.
  pt | Point of interest.

Returns
  EncodedString of tooltip, or `std::nullopt` if none.

Reimplemented in ClientButtonLine.

Definition at line 1428 of file network_gui.cpp.

References GetButton(), GetEncodedString(), and ButtonCommon::tooltip.

Referenced by ClientButtonLine::GetTooltip().

## Field Documentation

## ◆ buttons

std::vector<std::unique_ptr<ButtonCommon> > ButtonLine::buttons {}

Buttons for this line.

Definition at line 1389 of file network_gui.cpp.

Referenced by Draw(), DrawButtons(), and GetButton().

The documentation for this class was generated from the following file:

- src/network/network_gui.cpp