Public Member Functions | Data Fields

# SettingsPage Struct Reference

Data structure describing one page of settings in the settings window. More...

## Public Member Functions
void | Init (byte level=0)
| Initialization of an entire setting page.
void | FoldAll ()
| Recursively close all folds of sub-pages.
void | UnFoldAll ()
| Recursively open all folds of sub-pages.
uint | Length () const
| Return number of rows needed to display the whole page.
void | GetFoldingState (bool &all_folded, bool &all_unfolded) const
| Recursively accumulate the folding state of the tree.
bool | IsVisible (const SettingEntry *item) const
| Check whether an entry is visible and not folded or filtered away.
SettingEntry * | FindEntry (uint row, uint *cur_row) const
| Find the setting entry at row number row_num.
uint | GetMaxHelpHeight (int maxw)
| Get the biggest height of the help texts, if the width is at least maxw.
bool | UpdateFilterState (SettingFilter &filter, bool force_visible)
| Update the filter state.
uint | Draw (GameSettings *settings_ptr, int base_x, int base_y, int max_x, uint first_row, uint max_row, SettingEntry *selected, uint cur_row=0, uint parent_last=0) const
| Draw a selected part of the settings page.
## Data Fields
SettingEntry * | entries
| Array of setting entries of the page.
byte | num
| Number of entries on the page (statically filled).

## Detailed Description

Data structure describing one page of settings in the settings window.

Definition at line 785 of file settings_gui.cpp.

## Member Function Documentation

uint SettingsPage::Draw | ( | GameSettings * | settings_ptr,
|  | int | left,
|  | int | right,
|  | int | base_y,
|  | uint | first_row,
|  | uint | max_row,
|  | SettingEntry * | selected,
|  | uint | cur_row = `0`,
|  | uint | parent_last = `0` |
| ) |  |  | const

Draw a selected part of the settings page.

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.

Parameters:

  | settings_ptr | Pointer to current values of all settings
  | left | Left-most position in window/panel to start drawing of each setting row
  | right | Right-most position in window/panel to draw at
  | base_y | Upper-most position in window/panel to start drawing of row number first_row
  | first_row | Number of first row to draw
  | max_row | Row-number to stop drawing (the row-number of the row below the last row to draw)
  | cur_row | Current row number (internal variable)
  | parent_last | Last-field booleans of parent page level (page level i sets bit i to 1 if it is its last field)
  | selected | Selected entry by the user.

Returns:
  Row number of the next row to draw

Definition at line 1402 of file settings_gui.cpp.

References SettingEntry::Draw(), entries, and num.

Referenced by GameSettingsWindow::DrawWidget().

SettingEntry * SettingsPage::FindEntry | ( | uint | row_num,
|  | uint * | cur_row |
| ) |  |  | const

Find the setting entry at row number row_num.

Parameters:

  | row_num | Index of entry to return
  | cur_row | Variable used for keeping track of the current row number. Should point to memory initialized to `0` when first called.

Returns:
  The requested setting entry or `NULL` if it does not exist

Definition at line 1357 of file settings_gui.cpp.

References entries, SettingEntry::FindEntry(), and num.

Referenced by GameSettingsWindow::OnClick().

void SettingsPage::GetFoldingState | ( | bool & | all_folded,
|  | bool & | all_unfolded |
| ) |  |  | const

Recursively accumulate the folding state of the tree.

Parameters:

  `[in,out]` | all_folded | Set to false, if one entry is not folded.
  `[in,out]` | all_unfolded | Set to false, if one entry is folded.

Definition at line 1301 of file settings_gui.cpp.

References entries, SettingEntry::GetFoldingState(), and num.

Referenced by GameSettingsWindow::OnInvalidateData().

uint SettingsPage::GetMaxHelpHeight | ( | int | maxw | ) |

Get the biggest height of the help texts, if the width is at least maxw.

Help text gets wrapped if needed.

Parameters:

  | maxw | Maximal width of a line help text.

Returns:
  Biggest height needed to display any help text of this (sub-)tree.

Definition at line 1375 of file settings_gui.cpp.

References entries, max(), and num.

Referenced by GameSettingsWindow::UpdateWidgetSize().

void SettingsPage::Init | ( | byte | level = `0` | ) |

Initialization of an entire setting page.

Parameters:

  | level | Nesting level of this page (internal variable, do not provide a value for it when calling)

Definition at line 1273 of file settings_gui.cpp.

References entries, SettingEntry::Init(), and num.

bool SettingsPage::IsVisible | ( | const SettingEntry * | item | ) | const

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 ot make the setting really visible.

Parameters:

  | item | Entry to search for.

Returns:
  true if entry is visible.

Definition at line 1333 of file settings_gui.cpp.

References entries, and num.

Referenced by GameSettingsWindow::OnInvalidateData().

bool SettingsPage::UpdateFilterState | ( | SettingFilter & | filter,
|  | bool | force_visible |
| ) |  |  |

Update the filter state.

Parameters:

  | filter | Filter
  | force_visible | Whether to force all items visible, no matter what

Returns:
  true if item remains visible

Definition at line 1314 of file settings_gui.cpp.

References entries, num, SettingEntry::SetLastField(), and SettingEntry::UpdateFilterState().

Referenced by GameSettingsWindow::OnDropdownSelect(), and GameSettingsWindow::OnInvalidateData().

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

- src/settings_gui.cpp