OpenTTD Source 20241224-master-gf74b0cf984
BaseSettingEntry Struct Referenceabstract

Data structure describing a single setting in a tab. More...

Inheritance diagram for BaseSettingEntry:
SettingEntry SettingsPage

Public Member Functions

virtual void Init (uint8_t level=0)
 Initialization of a setting entry.
 
virtual void FoldAll ()
 
virtual void UnFoldAll ()
 
virtual void ResetAll ()=0
 
void SetLastField (bool last_field)
 Set whether this is the last visible entry of the parent node.
 
virtual uint Length () const =0
 
virtual void GetFoldingState (bool &all_folded, bool &all_unfolded) const
 
virtual bool IsVisible (const BaseSettingEntry *item) const
 Check whether an entry is visible and not folded or filtered away.
 
virtual BaseSettingEntryFindEntry (uint row, uint *cur_row)
 Find setting entry at row row_num.
 
virtual uint GetMaxHelpHeight (int maxw)
 
bool IsFiltered () const
 Check whether an entry is hidden due to filters.
 
virtual bool UpdateFilterState (SettingFilter &filter, bool force_visible)=0
 
virtual uint Draw (GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row=0, uint parent_last=0) const
 Draw a row in the settings panel.
 

Data Fields

uint8_t flags
 Flags of the setting entry.
 
uint8_t level
 Nesting level of this setting entry.
 

Protected Member Functions

virtual void DrawSetting (GameSettings *settings_ptr, int left, int right, int y, bool highlight) const =0
 

Detailed Description

Data structure describing a single setting in a tab.

Definition at line 1242 of file settings_gui.cpp.

Constructor & Destructor Documentation

◆ BaseSettingEntry()

BaseSettingEntry::BaseSettingEntry ( )
inline

Definition at line 1246 of file settings_gui.cpp.

Member Function Documentation

◆ Draw()

uint BaseSettingEntry::Draw ( GameSettings settings_ptr,
int  left,
int  right,
int  y,
uint  first_row,
uint  max_row,
BaseSettingEntry selected,
uint  cur_row = 0,
uint  parent_last = 0 
) const
virtual

Draw a row in the settings panel.

The scrollbar uses rows of the page, while the page data structure is a tree of SettingsPage and SettingEntry objects. As a result, the drawing routing traverses the tree from top to bottom, counting rows in cur_row until it reaches first_row. Then it enables drawing rows while traversing until max_row is reached, at which point drawing is terminated.

The parent_last parameter ensures that the vertical lines at the left are only drawn when another entry follows, that it prevents output like

*  |-- setting
*  |-- (-) - Title
*  |    |-- setting
*  |    |-- setting
* 

The left-most vertical line is not wanted. It is prevented by setting the appropriate bit in the parent_last parameter.

Parameters
settings_ptrPointer to current values of all settings
leftLeft-most position in window/panel to start drawing first_row
rightRight-most x position to draw strings at.
yUpper-most position in window/panel to start drawing first_row
first_rowFirst row number to draw
max_rowRow-number to stop drawing (the row-number of the row below the last row to draw)
selectedSelected entry by the user.
cur_rowCurrent row number (internal variable)
parent_lastLast-field booleans of parent page level (page level i sets bit i to 1 if it is its last field)
Returns
Row number of the next row to draw

Reimplemented in SettingsPage.

Definition at line 1422 of file settings_gui.cpp.

References _circle_size, _current_text_dir, flags, GetColourGradient(), HasBit(), WidgetDimensions::hsep_indent, WidgetDimensions::hsep_normal, IsFiltered(), level, WidgetDimensions::scaled, SEF_LAST_FIELD, SETTING_HEIGHT, and TD_RTL.

Referenced by SettingsPage::Draw().

◆ DrawSetting()

virtual void BaseSettingEntry::DrawSetting ( GameSettings settings_ptr,
int  left,
int  right,
int  y,
bool  highlight 
) const
protectedpure virtual

Implemented in SettingEntry, and SettingsPage.

◆ FindEntry()

BaseSettingEntry * BaseSettingEntry::FindEntry ( uint  row_num,
uint *  cur_row 
)
virtual

Find setting entry at row row_num.

Parameters
row_numIndex of entry to return
cur_rowCurrent row number
Returns
The requested setting entry or nullptr if it not found (folded or filtered)

Reimplemented in SettingsPage.

Definition at line 1385 of file settings_gui.cpp.

References IsFiltered().

Referenced by SettingsContainer::FindEntry().

◆ FoldAll()

virtual void BaseSettingEntry::FoldAll ( )
inlinevirtual

Reimplemented in SettingsPage.

Definition at line 1250 of file settings_gui.cpp.

◆ GetFoldingState()

virtual void BaseSettingEntry::GetFoldingState ( bool &  all_folded,
bool &  all_unfolded 
) const
inlinevirtual

Reimplemented in SettingsPage.

Definition at line 1261 of file settings_gui.cpp.

◆ GetMaxHelpHeight()

virtual uint BaseSettingEntry::GetMaxHelpHeight ( int  maxw)
inlinevirtual

Reimplemented in SettingEntry.

Definition at line 1264 of file settings_gui.cpp.

◆ Init()

void BaseSettingEntry::Init ( uint8_t  level = 0)
virtual

Initialization of a setting entry.

Parameters
levelPage nesting level of this entry

Reimplemented in SettingEntry, and SettingsPage.

Definition at line 1362 of file settings_gui.cpp.

References level.

Referenced by SettingEntry::Init(), and SettingsPage::Init().

◆ IsFiltered()

bool BaseSettingEntry::IsFiltered ( ) const
inline

◆ IsVisible()

bool BaseSettingEntry::IsVisible ( const BaseSettingEntry item) const
virtual

Check whether an entry is visible and not folded or filtered away.

Note: This does not consider the scrolling range; it might still require scrolling to make the setting really visible.

Parameters
itemEntry to search for.
Returns
true if entry is visible.

Reimplemented in SettingsPage.

Definition at line 1373 of file settings_gui.cpp.

References IsFiltered().

◆ Length()

virtual uint BaseSettingEntry::Length ( ) const
pure virtual

Implemented in SettingEntry, and SettingsPage.

◆ ResetAll()

virtual void BaseSettingEntry::ResetAll ( )
pure virtual

Implemented in SettingsPage.

◆ SetLastField()

void BaseSettingEntry::SetLastField ( bool  last_field)
inline

Set whether this is the last visible entry of the parent node.

Parameters
last_fieldValue to set

Definition at line 1258 of file settings_gui.cpp.

References CLRBITS, SEF_LAST_FIELD, and SETBITS.

◆ UnFoldAll()

virtual void BaseSettingEntry::UnFoldAll ( )
inlinevirtual

Reimplemented in SettingsPage.

Definition at line 1251 of file settings_gui.cpp.

◆ UpdateFilterState()

virtual bool BaseSettingEntry::UpdateFilterState ( SettingFilter filter,
bool  force_visible 
)
pure virtual

Implemented in SettingEntry, and SettingsPage.

Field Documentation

◆ flags

uint8_t BaseSettingEntry::flags

◆ level

uint8_t BaseSettingEntry::level

Nesting level of this setting entry.

Definition at line 1244 of file settings_gui.cpp.

Referenced by Draw(), SettingsPage::Draw(), Init(), SettingEntry::Init(), SettingsPage::Init(), and GameSettingsWindow::OnClick().


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