7 #ifndef NDK_BASEWIDGET_HPP 8 #define NDK_BASEWIDGET_HPP 10 #include <NDK/Prerequesites.hpp> 11 #include <NDK/Entity.hpp> 12 #include <NDK/EntityOwner.hpp> 13 #include <NDK/World.hpp> 14 #include <Nazara/Graphics/Sprite.hpp> 15 #include <Nazara/Platform/Event.hpp> 16 #include <Nazara/Platform/Mouse.hpp> 17 #include <Nazara/Utility/Node.hpp> 36 template<
typename T,
typename... Args> T* Add(Args&&... args);
37 inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
40 inline void CenterHorizontal();
41 inline void CenterVertical();
43 inline void Destroy();
45 void EnableBackground(
bool enable);
49 inline const Nz::Color& GetBackgroundColor()
const;
50 inline Canvas* GetCanvas();
51 inline Nz::SystemCursor GetCursor()
const;
52 inline const Padding& GetPadding()
const;
57 inline bool IsVisible()
const;
61 virtual void ResizeToContent() = 0;
63 void SetBackgroundColor(
const Nz::Color& color);
64 void SetCursor(Nz::SystemCursor systemCursor);
66 inline void SetPadding(
float left,
float top,
float right,
float bottom);
69 void Show(
bool show =
true);
84 void DestroyEntity(
Entity* entity);
85 virtual void Layout();
86 void InvalidateNode()
override;
88 virtual void OnKeyPressed(
const Nz::WindowEvent::KeyEvent& key);
89 virtual void OnKeyReleased(
const Nz::WindowEvent::KeyEvent& key);
90 virtual void OnMouseEnter();
91 virtual void OnMouseMoved(
int x,
int y,
int deltaX,
int deltaY);
92 virtual void OnMouseButtonPress(
int x,
int y, Nz::Mouse::Button button);
93 virtual void OnMouseButtonRelease(
int x,
int y, Nz::Mouse::Button button);
94 virtual void OnMouseExit();
95 virtual void OnParentResized(
const Nz::Vector2f& newSize);
96 virtual void OnTextEntered(char32_t character,
bool repeated);
102 void DestroyChildren();
103 inline bool IsRegisteredToCanvas()
const;
104 inline void NotifyParentResized(
const Nz::Vector2f& newSize);
105 void RegisterToCanvas();
106 inline void UpdateCanvasIndex(std::size_t index);
107 void UnregisterFromCanvas();
109 static constexpr std::size_t InvalidCanvasIndex = std::numeric_limits<std::size_t>::max();
111 std::size_t m_canvasIndex;
112 std::vector<EntityOwner> m_entities;
113 std::vector<std::unique_ptr<BaseWidget>> m_children;
120 Nz::SystemCursor m_cursor;
127 #include <NDK/BaseWidget.inl> 129 #endif // NDK_BASEWIDGET_HPP TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so...
Definition: Algorithm.hpp:12
NDK class that represents an entity in a world.
Definition: Entity.hpp:28
Core class that represents a color.
Definition: Color.hpp:18
NDK class that represents the owner of the entity and so its lifetime.
Definition: EntityOwner.hpp:14
Core class that represents a reference to an object.
Definition: ObjectRef.hpp:18