From 6427c7aeb73483fd1c8d38f3017fe1db8df5d41d Mon Sep 17 00:00:00 2001 From: Corentin Date: Thu, 6 Oct 2022 23:18:29 +0900 Subject: [PATCH] Add parameters structures * Changed C++ version from 17 to 20 (using designated initializers) --- include/uui/component.hpp | 4 +- include/uui/opengl/component.hpp | 10 ++-- include/uui/opengl/flex.hpp | 8 ++- include/uui/opengl/label.hpp | 9 ++-- include/uui/opengl/stack.hpp | 14 ++---- include/uui/opengl/window.hpp | 13 ++--- include/uui/stack.hpp | 6 +-- include/uui/types.hpp | 35 +++++++++++++ include/uui/window.hpp | 15 ++---- make.py | 2 +- src/test/benchmark_text.cpp | 3 +- src/test/example_gl.cpp | 85 ++++++++++++++++++-------------- src/test/sample.cpp | 21 ++------ src/uui/opengl/component.cpp | 10 ++-- src/uui/opengl/flex.cpp | 6 +-- src/uui/opengl/font_manager.cpp | 2 +- src/uui/opengl/label.cpp | 7 ++- src/uui/opengl/stack.cpp | 17 +++---- src/uui/opengl/window.cpp | 24 +++------ 19 files changed, 142 insertions(+), 149 deletions(-) diff --git a/include/uui/component.hpp b/include/uui/component.hpp index 7bd2c39..a9ad0bb 100644 --- a/include/uui/component.hpp +++ b/include/uui/component.hpp @@ -22,8 +22,8 @@ protected: uui::position_t position_x; uui::position_t position_y; - uui::position_t size_width; - uui::position_t size_height; + uui::size_t size_width; + uui::size_t size_height; bool coord_all_relative; diff --git a/include/uui/opengl/component.hpp b/include/uui/opengl/component.hpp index 24230df..441e322 100644 --- a/include/uui/opengl/component.hpp +++ b/include/uui/opengl/component.hpp @@ -34,13 +34,9 @@ protected: GlComponent( std::shared_ptr window, std::size_t window_index, std::shared_ptr parent, - std::size_t parent_index, const position_t x, const position_t y, const position_t width, - const position_t height); - GlComponent( - std::shared_ptr window, std::size_t window_index, const position_t x, const position_t y, - const position_t width, const position_t height): - GlComponent( - window, window_index, std::static_pointer_cast(window), window_index, x, y, width, height) + std::size_t parent_index, const ComponentParams& params); + GlComponent(std::shared_ptr window, std::size_t window_index, const ComponentParams& params): + GlComponent(window, window_index, std::static_pointer_cast(window), window_index, params) {} GlComponent(const GlComponent&) = delete; GlComponent(GlComponent&&) = default; diff --git a/include/uui/opengl/flex.hpp b/include/uui/opengl/flex.hpp index b73fac3..e0bcdc5 100644 --- a/include/uui/opengl/flex.hpp +++ b/include/uui/opengl/flex.hpp @@ -18,11 +18,9 @@ class GlFlex: virtual public GlStack, virtual public Flex protected: GlFlex( std::shared_ptr window, std::size_t window_index, std::shared_ptr parent, - std::size_t parent_index, const position_t x, const position_t y, const Direction direction); - GlFlex( - std::shared_ptr window, std::size_t window_index, const position_t x, const position_t y, - const Direction direction): - GlFlex(window, window_index, window, window_index, x, y, direction) + std::size_t parent_index, const StackParams& params); + GlFlex(std::shared_ptr window, std::size_t window_index, const StackParams& params): + GlFlex(window, window_index, window, window_index, params) {} std::tuple get_child_position(const std::size_t child_index) const override; diff --git a/include/uui/opengl/label.hpp b/include/uui/opengl/label.hpp index bbcb296..4570717 100644 --- a/include/uui/opengl/label.hpp +++ b/include/uui/opengl/label.hpp @@ -26,12 +26,9 @@ protected: GlLabel( std::shared_ptr window, std::size_t window_index, std::shared_ptr parent, - std::size_t parent_index, const position_t x, const position_t y, const std::string& text, - const std::tuple& text_color); - GlLabel( - std::shared_ptr window, std::size_t window_index, const position_t x, const position_t y, - const std::string& text, const std::tuple& text_color): - GlLabel(window, window_index, window, window_index, x, y, text, text_color) + std::size_t parent_index, const LabelParams& params); + GlLabel(std::shared_ptr window, std::size_t window_index, const LabelParams& params): + GlLabel(window, window_index, window, window_index, params) {} void render() final; diff --git a/include/uui/opengl/stack.hpp b/include/uui/opengl/stack.hpp index 97d58de..b625314 100644 --- a/include/uui/opengl/stack.hpp +++ b/include/uui/opengl/stack.hpp @@ -15,19 +15,15 @@ class GlStack: virtual public GlComponent, virtual public GlContainer, virtual p friend class GlWindow; public: - void create_component(const position_t width, const position_t height, InitFunction init) override; - void create_label( - const std::string& text, const std::tuple& text_color, - InitFunction