diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-07 00:36:54 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-07 00:36:54 +0200 |
commit | 6e133a4bbad472dc03215acd6a22b0211c30a6f3 (patch) | |
tree | a14a5ea8c459517ee6b0b20b8d43228641e62634 | |
parent | 8a0efc9e0032fb4c0a4796ee25309a770b9fa517 (diff) |
Fix: widget alignment is uninitialized
-rw-r--r-- | include/gui/Widget.hpp | 4 | ||||
-rw-r--r-- | src/gui/List.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/gui/Widget.hpp b/include/gui/Widget.hpp index 7a04338..5b582da 100644 --- a/include/gui/Widget.hpp +++ b/include/gui/Widget.hpp @@ -51,8 +51,8 @@ namespace gsr { Widget *parent_widget = nullptr; Widget *selected_child_widget = nullptr; - Alignment horizontal_aligment; - Alignment vertical_aligment; + Alignment horizontal_aligment = Alignment::START; + Alignment vertical_aligment = Alignment::START; bool visible = true; }; diff --git a/src/gui/List.cpp b/src/gui/List.cpp index 0c5f78e..1e81b83 100644 --- a/src/gui/List.cpp +++ b/src/gui/List.cpp @@ -85,6 +85,7 @@ namespace gsr { offset.x = floor(size.x * 0.5f - widget->get_size().x * 0.5f); else offset.x = 0.0f; + widget->set_position(draw_pos + offset); if(widget.get() != selected_widget) widget->draw(window, mgl::vec2f(0.0f, 0.0f)); @@ -99,6 +100,7 @@ namespace gsr { if(content_alignment == Alignment::CENTER) offset.y = floor(size.y * 0.5f - widget->get_size().y * 0.5f); + widget->set_position(draw_pos + offset); if(widget.get() != selected_widget) widget->draw(window, mgl::vec2f(0.0f, 0.0f)); |