Loading...
Searching...
No Matches
InfoButton.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith.
2// Malena Framework — Licensed under PolyForm Noncommercial 1.0.0; commercial use requires a paid license. See LICENSE.
3
4#ifndef MALENA_INFOBUTTON_H
5#define MALENA_INFOBUTTON_H
6
7#pragma once
8
13#include <string>
14
15namespace ml
16{
39 class MALENA_API InfoButton : public Graphic<sf::CircleShape>
40 {
41 public:
43
44 void setText(const std::string& help); // popover body text
45 void setRadius(float r);
46 void setPopoverWidth(float w);
47
48 void open();
49 void close();
50 void toggle();
51 [[nodiscard]] bool isOpen() const { return _open; }
52
53 // ── Positionable ──────────────────────────────────────────────────────
54 void setPosition(const sf::Vector2f& pos) override;
55 [[nodiscard]] sf::Vector2f getPosition() const override;
56 [[nodiscard]] sf::FloatRect getGlobalBounds() const override; // badge only
57
58 void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
59
60 private:
61 const sf::Font* _font;
62 std::string _text;
63 float _radius = 9.f;
64 float _popWidth = 260.f;
65 sf::Vector2f _pos = { 0.f, 0.f };
66 bool _open = false;
67 bool _prevDown = false;
68 };
69
70} // namespace ml
71
72#endif // MALENA_INFOBUTTON_H
static const sf::Font & getDefault()
Return the built-in Arial font.
void setPopoverWidth(float w)
sf::Vector2f getPosition() const override
Return the current world-space position.
void setPosition(const sf::Vector2f &pos) override
Set the world-space position.
bool isOpen() const
Definition InfoButton.h:51
sf::FloatRect getGlobalBounds() const override
Return the axis-aligned bounding box in world space.
void setText(const std::string &help)
InfoButton(const sf::Font &font=FontManager<>::getDefault())
void setRadius(float r)
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
Draw this graphic to an SFML render target.
#define MALENA_API
Definition Component.h:22
Rect< float > FloatRect
Vector2< float > Vector2f