35 enum class Flag { OPEN, DISABLED };
43 std::optional<const sf::Font*>
font;
65 const std::string&
value =
"",
92 std::vector<SelectOption> _options;
93 int _selectedIndex = -1;
98 std::string _placeholder =
"Select...";
102 float _scrollOffset = 0.f;
104 mutable int _hoveredIndex = -1;
105 mutable bool _openAbove =
false;
107 std::function<void(
const std::string&, std::size_t)> _onSelectionChanged;
110 void syncTriggerColors();
114 void commitSelection(
int index);
115 void resizePanelCanvas();
117 float panelHeight()
const;
118 float panelY()
const;
124 float itemY,
bool hovered,
bool selected)
const;
138 static_assert(std::is_base_of_v<SelectSettings, S>,
139 "applySettings() requires a type derived from SelectSettings");
147 static_assert(std::is_base_of_v<SelectTheme, T>,
148 "applyTheme() requires a type derived from SelectTheme");
153 template<
typename St>
156 static_assert(std::is_base_of_v<SelectSettings, St> &&
157 std::is_base_of_v<SelectTheme, St>,
158 "applyStyle() requires SelectSettings and SelectTheme");
167 const std::string& value =
"",
191 std::function<
void(
const std::string&, std::size_t)> callback);
213 template<
typename MANIFEST>
Virtual base class for all Malena framework objects.
static const sf::Font & getDefault()
Return the built-in Arial font.
Base class for all Malena manifests.
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
void applySettings(const S &s)
void addOption(const std::string &label, const std::string &value="", const SelectOptionStyle &style={})
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
void setPosition(const sf::Vector2f &position) override
void applyStyle(const St &s)
void selectValue(const std::string &value)
SelectManifest::State State
Select(const sf::Font &font=FontManager<>::getDefault())
std::string getSelectedValue() const
sf::FloatRect getGlobalBounds() const override
SelectManifest::Flag Flag
void applyTheme(const T &t)
std::size_t optionCount() const
std::string getSelectedLabel() const
int getSelectedIndex() const
sf::Vector2f getPosition() const override
void selectIndex(std::size_t index)
void setPlaceholder(const std::string &text)
void setEnabled(bool enabled)
void add(ml::Core &component, const std::string &value="")
void setFont(const sf::Font &f)
void setFont(const sf::Font &&)=delete
std::string getPlaceholder() const
unsigned int getCharacterSize() const
void onSelectionChanged(std::function< void(const std::string &, std::size_t)> callback)
void setOptionEnabled(std::size_t index, bool enabled)
Select(const sf::Font &font=FontManager<>::getDefault())
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
@ HOVERED
Mouse is currently over this component (set by HoverableDispatcher).
Vector2< float > Vector2f
SelectOption(const std::string &label, const std::string &value="", const SelectOptionStyle &style={})
ml::Core * customComponent
SelectOption(ml::Core &component, const std::string &value="")
std::optional< unsigned int > charSize
const sf::Texture * iconTexture
std::optional< sf::Color > color
std::optional< bool > italic
std::optional< bool > bold
std::optional< sf::Color > bgColor
std::optional< sf::Color > descColor
std::optional< const sf::Font * > font
std::optional< unsigned int > descCharSize
Layout and behaviour settings for Select.
Universal design token set applied across all Themeable components.