Loading...
Searching...
No Matches
ButtonSettings.h
Go to the documentation of this file.
1//
2// ButtonSettings.h
3//
4
5#ifndef MALENA_BUTTONSETTINGS_H
6#define MALENA_BUTTONSETTINGS_H
7
8#pragma once
9
15#include <string>
16
17namespace ml
18{
28 {
29 // ── Geometry ──────────────────────────────────────────────────────────
30 sf::Vector2f size = {100.f, 36.f};
31
32 // ── Labels ────────────────────────────────────────────────────────────
33 std::string onLabel = "ON";
34 std::string offLabel = "OFF";
35
36 // ── Icons ─────────────────────────────────────────────────────────────
37 const sf::Texture* iconOn = nullptr;
38 const sf::Texture* iconOff = nullptr;
39 sf::Vector2f iconSize = {0.f, 0.f};
42
45 float iconPadding = 6.f;
46
47 // ── Assignment from parent levels ─────────────────────────────────────
48
50 {
51 static_cast<ToggleSettings&>(*this) = t;
52 return *this;
53 }
54
56 {
57 static_cast<ToggleSettings&>(*this) = c;
58 return *this;
59 }
60
62 {
63 static_cast<ToggleSettings&>(*this) = g;
64 return *this;
65 }
66
67 // ── Getters / setters ─────────────────────────────────────────────────
68
69 [[nodiscard]] sf::Vector2f getSize() const { return size; }
70 [[nodiscard]] std::string getOnLabel() const { return onLabel; }
71 [[nodiscard]] std::string getOffLabel() const { return offLabel; }
72 [[nodiscard]] const sf::Texture* getIconOn() const { return iconOn; }
73 [[nodiscard]] const sf::Texture* getIconOff() const { return iconOff; }
74 [[nodiscard]] sf::Vector2f getIconSize() const { return iconSize; }
75 [[nodiscard]] sf::IntRect getIconOnRect() const { return iconOnRect; }
76 [[nodiscard]] sf::IntRect getIconOffRect() const { return iconOffRect; }
77 [[nodiscard]] IconAlign getIconAlign() const { return iconAlign; }
78 [[nodiscard]] float getIconPadding() const { return iconPadding; }
79
80 void setSize(const sf::Vector2f& s) { size = s; }
81 void setOnLabel(const std::string& s) { onLabel = s; }
82 void setOffLabel(const std::string& s) { offLabel = s; }
83 void setLabels(const std::string& on,
84 const std::string& off) { onLabel = on; offLabel = off; }
85 void setIcons(const sf::Texture* on,
86 const sf::Texture* off = nullptr)
87 { iconOn = on; iconOff = off ? off : on; }
88 void setIconOn(const sf::Texture* t) { iconOn = t; }
89 void setIconOff(const sf::Texture* t) { iconOff = t; }
90 void setIconSize(const sf::Vector2f& s) { iconSize = s; }
91 void setIconOnRect(const sf::IntRect& r) { iconOnRect = r; }
92 void setIconOffRect(const sf::IntRect& r){ iconOffRect = r; }
94 void setIconPadding(float p) { iconPadding = p; }
95 };
96
97} // namespace ml
98
99#endif // MALENA_BUTTONSETTINGS_H
Definition Component.h:22
Rect< int > IntRect
Vector2< float > Vector2f
Layout and behaviour settings for ButtonToggle.
IconAlign getIconAlign() const
void setIconOffRect(const sf::IntRect &r)
sf::Vector2f getIconSize() const
ButtonSettings & operator=(const ToggleSettings &t)
sf::Vector2f iconSize
{0,0} = native size
const sf::Texture * getIconOn() const
void setIconAlign(IconAlign a)
const sf::Texture * getIconOff() const
void setLabels(const std::string &on, const std::string &off)
float getIconPadding() const
sf::Vector2f getSize() const
void setIconOn(const sf::Texture *t)
void setOnLabel(const std::string &s)
void setIconOff(const sf::Texture *t)
void setSize(const sf::Vector2f &s)
void setIconSize(const sf::Vector2f &s)
sf::IntRect iconOnRect
const sf::Texture * iconOff
ButtonSettings & operator=(const GraphicSettings &g)
const sf::Texture * iconOn
void setOffLabel(const std::string &s)
sf::IntRect iconOffRect
sf::IntRect getIconOnRect() const
sf::IntRect getIconOffRect() const
void setIcons(const sf::Texture *on, const sf::Texture *off=nullptr)
std::string getOnLabel() const
void setIconOnRect(const sf::IntRect &r)
ButtonSettings & operator=(const ControlSettings &c)
void setIconPadding(float p)
std::string getOffLabel() const
Settings trait for interactive UI controls — layout only.
Base settings trait for all visual components — geometry only.
Settings shared by all toggle variants — behaviour only.