Represents a UI dropdown menu.
More...
#include <dropdown.h>
Represents a UI dropdown menu.
◆ Dropdown() [1/3]
| Dropdown::Dropdown |
( |
SDL_Renderer * |
dropdown_renderer, |
|
|
TTF_Font * |
dropdown_font, |
|
|
const SDL_FRect & |
rect, |
|
|
const std::vector< std::string > & |
dropdown_options |
|
) |
| |
Constructs a new Dropdown.
- Parameters
-
| dropdown_renderer | The SDL renderer used for drawing. |
| dropdown_font | The font used for text. |
| rect | The rectangle defining the dropdown's position and size. |
| dropdown_options | The list of string options in the dropdown. |
◆ ~Dropdown()
◆ Dropdown() [2/3]
◆ Dropdown() [3/3]
◆ close()
Closes the dropdown if it is open.
◆ createTextures()
| void Dropdown::createTextures |
( |
| ) |
|
|
private |
◆ freeTextures()
| void Dropdown::freeTextures |
( |
| ) |
|
|
private |
◆ getSelectedIndex()
| int Dropdown::getSelectedIndex |
( |
| ) |
const |
Gets the index of the currently selected option.
- Returns
- The selected index.
◆ getSelectedOption()
| std::string Dropdown::getSelectedOption |
( |
| ) |
const |
Gets the text of the currently selected option.
- Returns
- The selected string.
◆ handleEvent()
| bool Dropdown::handleEvent |
( |
const SDL_Event & |
event | ) |
|
Handles SDL events for the dropdown.
- Parameters
-
| event | The SDL event to process. |
- Returns
- True if the event was handled by the dropdown.
◆ isDropdownOpen()
| bool Dropdown::isDropdownOpen |
( |
| ) |
const |
Checks if the dropdown is currently open.
- Returns
- True if open, false otherwise.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ render()
| void Dropdown::render |
( |
| ) |
|
◆ renderArrow()
| void Dropdown::renderArrow |
( |
const SDL_FRect & |
buttonRect | ) |
const |
|
private |
◆ setOnSelectionChanged()
| void Dropdown::setOnSelectionChanged |
( |
std::function< void(int, const std::string &)> |
callback | ) |
|
Sets the callback invoked when the selection changes.
- Parameters
-
| callback | The function to call, passing the new index and text. |
◆ setSelectedIndex()
| void Dropdown::setSelectedIndex |
( |
int |
index | ) |
|
Sets the selected option by index.
- Parameters
-
| index | The index to select. |
◆ update()
| void Dropdown::update |
( |
float |
deltaTime | ) |
|
Updates the dropdown logic.
- Parameters
-
| deltaTime | The time elapsed since the last update. |
◆ font
◆ hoveredIndex
| int Dropdown::hoveredIndex = -1 |
|
private |
◆ isOpen
| bool Dropdown::isOpen = false |
|
private |
◆ mainRect
| SDL_FRect Dropdown::mainRect |
|
private |
◆ onSelectionChangedCallback
| std::function<void(int, const std::string&)> Dropdown::onSelectionChangedCallback |
|
private |
◆ optionRects
| std::vector<SDL_FRect> Dropdown::optionRects |
|
private |
◆ options
| std::vector<std::string> Dropdown::options |
|
private |
◆ optionTextures
| std::vector<SDL_Texture*> Dropdown::optionTextures |
|
private |
◆ renderer
| SDL_Renderer* Dropdown::renderer |
|
private |
◆ selectedIndex
| int Dropdown::selectedIndex = 0 |
|
private |
◆ selectedOptionTexture
| SDL_Texture* Dropdown::selectedOptionTexture = nullptr |
|
private |
◆ style
The documentation for this class was generated from the following files: