5#ifndef MALENA_TOGGLEGROUP_H
6#define MALENA_TOGGLEGROUP_H
67 enum class ItemType { PILL, SEGMENT, BUTTON };
86 std::vector<std::unique_ptr<Item>> _items;
87 std::vector<std::unique_ptr<PillToggle>> _ownedPills;
88 std::vector<std::unique_ptr<SegmentToggle>> _ownedSegments;
89 std::vector<std::unique_ptr<ButtonToggle>> _ownedButtons;
92 float _spacing = 12.f;
95 PillSettings _defaultPillSettings;
96 PillTheme _defaultPillTheme;
97 SegmentSettings _defaultSegmentSettings;
98 SegmentTheme _defaultSegmentTheme;
99 ButtonSettings _defaultButtonSettings;
100 ButtonTheme _defaultButtonTheme;
102 std::function<void(
const std::string&,
bool)> _onAnyToggled;
105 void attach(Item& item);
126 const std::string& key,
134 const std::string& onLabel,
135 const std::string& key,
143 const std::string& key,
156 [[nodiscard]]
bool isOn(
const std::string& key)
const;
157 void setOn(
const std::string& key,
bool on);
160 [[nodiscard]] std::vector<std::string>
getOnKeys()
const;
164 void onAnyToggled(std::function<
void(
const std::string&,
bool)> callback);
215 template<
typename MANIFEST>
Base class for all Malena manifests.
iOS-style oval pill switch with animated sliding thumb.
Two-option segmented selector with animated sliding pill.
void applyStyleToAll(const ButtonStyle &s)
sf::FloatRect getGlobalBounds() const override
void setDefaultStyle(const ButtonStyle &s)
void setFont(const sf::Font &&)=delete
SegmentToggle & addSegmentToggle(const std::string &offLabel, const std::string &onLabel, const std::string &key, bool on=false)
Create and add a new SegmentToggle.
void onAnyToggled(std::function< void(const std::string &, bool)> callback)
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
void setFont(const sf::Font &font)
Set font on the default pill theme and all owned pills.
void setOn(const std::string &key, bool on)
void applyThemeToAll(const ButtonTheme &t)
void setPosition(const sf::Vector2f &position) override
void setCharacterSize(unsigned int size)
Set character size on the default pill theme and all owned pills.
void setSpacing(float spacing)
void add(PillToggle &toggle, const std::string &key)
void setDefaultStyle(const PillStyle &s)
Set default settings and theme together.
void add(SegmentToggle &toggle, const std::string &key)
ToggleGroup(const ToggleGroup &)=delete
void setDefaultTheme(const SegmentTheme &t)
void applySettingsToAll(const SegmentSettings &s)
void setDefaultTheme(const PillTheme &t)
Set the default theme applied to new owned PillToggles.
void applyStyleToAll(const SegmentStyle &s)
void setDefaultSettings(const SegmentSettings &s)
sf::Vector2f getPosition() const override
ToggleGroupManifest::Flag Flag
bool isOn(const std::string &key) const
void applySettingsToAll(const PillSettings &s)
void applySettingsToAll(const ButtonSettings &s)
ToggleGroupManifest::State State
ToggleGroup & operator=(const ToggleGroup &)=delete
PillToggle & addToggle(const std::string &label, const std::string &key, bool on=false)
Create and add a new PillToggle with a right label.
void applyThemeToAll(const PillTheme &t)
void add(ButtonToggle &toggle, const std::string &key)
void setDefaultTheme(const ButtonTheme &t)
void applyThemeToAll(const SegmentTheme &t)
void setDefaultSettings(const PillSettings &s)
Set the default settings applied to new owned PillToggles.
void setDefaultStyle(const SegmentStyle &s)
void setDefaultSettings(const ButtonSettings &s)
void applyStyleToAll(const PillStyle &s)
ButtonToggle & addButtonToggle(const std::string &label, const std::string &key, bool on=false)
Create and add a new ButtonToggle.
std::vector< std::string > getOnKeys() const
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
Layout and behaviour settings for PillToggle.
Complete style descriptor for PillToggle.
Theme tokens for the PillToggle (iOS-style oval switch).
Layout and behaviour settings for SegmentToggle.
Complete style descriptor for SegmentToggle.
Theme tokens for the SegmentToggle (Hotels/Apartments style).