Velvet 0.1a
A beginner-friendly C++ GUI framework built on SFML.
Loading...
Searching...
No Matches
Widget.hpp
Go to the documentation of this file.
1#pragma once
2#include <SFML/Graphics.hpp>
3#include <SFML/System/Vector2.hpp>
4
16class Widget {
17private:
23 virtual void update(sf::RenderWindow &window) = 0;
24
28 virtual void draw(sf::RenderWindow &window);
29
30protected:
31 float x, y;
32
33public:
37 sf::Font font;
38
43
49 virtual void handleEvent(const sf::Event &event, sf::RenderWindow &window);
50
56 virtual void render(sf::RenderWindow &window);
57
61 virtual void setPosition(float x, float y) = 0;
62
67 virtual sf::Vector2<float> getDimensions() = 0;
68};
Base class for all Velvet UI elements.
Definition Widget.hpp:16
virtual void render(sf::RenderWindow &window)
Render this widget.
virtual void setPosition(float x, float y)=0
Set top-left position of widget in window coordinates.
virtual void handleEvent(const sf::Event &event, sf::RenderWindow &window)
Handle an SFML event.
virtual sf::Vector2< float > getDimensions()=0
Get widget dimensions used by layout containers.
float y
Definition Widget.hpp:31
float x
Definition Widget.hpp:31
Widget()
Construct a widget with default font loading.
sf::Font font
Shared font loaded by the base widget.
Definition Widget.hpp:37