12#include <SDL3_ttf/SDL_ttf.h>
43 Dropdown(SDL_Renderer* dropdown_renderer, TTF_Font* dropdown_font,
44 const SDL_FRect& rect,
45 const std::vector<std::string>& dropdown_options);
74 void update(
float deltaTime);
110 std::function<
void(
int,
const std::string&)> callback);
115 void renderArrow(
const SDL_FRect& buttonRect)
const;
Represents a UI dropdown menu.
Definition dropdown.h:34
Dropdown & operator=(Dropdown &&)=delete
DropdownStyle style
Definition dropdown.h:122
void renderArrow(const SDL_FRect &buttonRect) const
Definition dropdown.cpp:239
std::vector< std::string > options
Definition dropdown.h:120
void render()
Renders the dropdown.
Definition dropdown.cpp:90
void setOnSelectionChanged(std::function< void(int, const std::string &)> callback)
Sets the callback invoked when the selection changes.
Definition dropdown.cpp:186
bool isDropdownOpen() const
Checks if the dropdown is currently open.
Definition dropdown.cpp:36
Dropdown(Dropdown &&)=delete
std::vector< SDL_Texture * > optionTextures
Definition dropdown.h:129
void freeTextures()
Definition dropdown.cpp:221
~Dropdown()
Destroys the Dropdown.
Definition dropdown.cpp:32
void setSelectedIndex(int index)
Sets the selected option by index.
Definition dropdown.cpp:158
int selectedIndex
Definition dropdown.h:125
TTF_Font * font
Definition dropdown.h:118
SDL_FRect mainRect
Definition dropdown.h:119
void update(float deltaTime)
Updates the dropdown logic.
Definition dropdown.cpp:145
bool handleEvent(const SDL_Event &event)
Handles SDL events for the dropdown.
Definition dropdown.cpp:38
SDL_Renderer * renderer
Definition dropdown.h:117
int getSelectedIndex() const
Gets the index of the currently selected option.
Definition dropdown.cpp:147
SDL_Texture * selectedOptionTexture
Definition dropdown.h:128
Dropdown & operator=(const Dropdown &)=delete
Dropdown(const Dropdown &)=delete
void createTextures()
Definition dropdown.cpp:192
int hoveredIndex
Definition dropdown.h:126
void close()
Closes the dropdown if it is open.
Definition dropdown.cpp:34
std::string getSelectedOption() const
Gets the text of the currently selected option.
Definition dropdown.cpp:149
std::vector< SDL_FRect > optionRects
Definition dropdown.h:121
std::function< void(int, const std::string &)> onSelectionChangedCallback
Definition dropdown.h:131
bool isOpen
Definition dropdown.h:124
int index
Definition runtime_editor.cpp:94
Style configuration for a dropdown.
Definition dropdown.h:22
SDL_Color arrowColor
Definition dropdown.h:27
SDL_Color borderColor
Definition dropdown.h:24
SDL_Color backgroundColor
Definition dropdown.h:23
SDL_Color hoverColor
Definition dropdown.h:26
SDL_Color textColor
Definition dropdown.h:25