X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2FWidget.hpp;h=84570a3f70ca81e32bbb21ef43ee4aae07819517;hb=d921cba26f21e4a75b22f5e9d9be988707bf6a8f;hp=ed7c84825ae0a4b3dcca098d765e34fb172d5da9;hpb=4ec93ba5186dca958be6e2a4dc2aaf3572a524cb;p=blobs.git diff --git a/src/ui/Widget.hpp b/src/ui/Widget.hpp index ed7c848..84570a3 100644 --- a/src/ui/Widget.hpp +++ b/src/ui/Widget.hpp @@ -1,8 +1,7 @@ #ifndef BLOBS_UI_WIDGET_HPP_ #define BLOBS_UI_WIDGET_HPP_ -#include "align.hpp" -#include "../graphics/glm.hpp" +#include "../math/glm.hpp" namespace blobs { @@ -27,20 +26,33 @@ public: Widget &operator =(Widget &&) = delete; public: - Widget *Position(const glm::vec3 &p) noexcept { pos = p; return this; } - const glm::vec3 &Position() const noexcept { return pos; } - glm::vec3 AlignedPosition() noexcept; - glm::vec3 TopLeft() noexcept; + void SetParent(Widget &) noexcept; + bool HasParent() const noexcept { return parent; } + Widget &GetParent() noexcept { return *parent; } + const Widget &GetParent() const noexcept { return *parent; } - Widget *Origin(Gravity o) noexcept { origin = o; return this; } - Gravity Origin() const noexcept { return origin; } + Widget *Position(const glm::vec2 &p) noexcept { pos = p; return this; } + const glm::vec2 &Position() const noexcept { return pos; } + + Widget *ZIndex(float z) noexcept { z_index = z; return this; } + float ZIndex() const noexcept { return z_index; } + + bool DirtyLayout() const noexcept { return dirty_layout; } + void BreakLayout() noexcept; + void BreakParentLayout() noexcept; + void Layout(); virtual glm::vec2 Size() = 0; virtual void Draw(app::Assets &, graphics::Viewport &) noexcept = 0; private: - glm::vec3 pos; - Gravity origin; + virtual void FixLayout() { } + +private: + Widget *parent; + glm::vec2 pos; + float z_index; + bool dirty_layout; };