6 #include <unordered_map> 8 #include <SFML/Graphics/Drawable.hpp> 9 #include <SFML/Graphics/Rect.hpp> 10 #include <SFML/Graphics/Transformable.hpp> 11 #include <SFML/System/Vector2.hpp> 13 #include <NasNas/ui/Callbacks.hpp> 19 class Widget :
public sf::Drawable,
public sf::Transformable {
24 virtual auto getGlobalBounds()
const -> sf::FloatRect = 0;
25 virtual auto contains(
const sf::Vector2f& pos)
const ->
bool = 0;
27 void setCallback(CursorCallback cb_type, std::function<
void(
Widget*)> cb);
29 auto isHovered()
const ->
bool {
return m_hovered; }
30 auto isFocused()
const ->
bool {
return m_focused; }
36 void call(CursorCallback cb_type);
37 virtual void call(ClickCallback cb_type);
45 unsigned m_type = Type::None;
48 std::unordered_map<CursorCallback, std::function<void(Widget*)>> m_default_callbacks;
49 std::unordered_map<CursorCallback, std::function<void(Widget*)>> m_user_callbacks;
51 bool m_hovered =
false;
52 bool m_focused =
false;
61 m_type |= Type::Styled;
70 using Widget::setCallback;
71 void setCallback(ClickCallback cb_type, std::function<
void(
Widget*)> cb);
75 void call(ClickCallback cb_type)
override;
76 std::unordered_map<ClickCallback, std::function<void(Widget*)>> m_user_callbacks;