From e7753f244c592122578318944312402d0a50c87b Mon Sep 17 00:00:00 2001 From: Corentin Date: Thu, 22 Jul 2021 17:03:34 +0900 Subject: [PATCH] Rename stack to flex --- .gitignore | 1 + ROADMAP.md | 8 ++++---- include/uui/opengl/application.hpp | 6 +++--- include/uui/opengl/component.hpp | 4 ++-- include/uui/opengl/container.hpp | 6 +++--- include/uui/opengl/{stack.hpp => flex.hpp} | 8 ++++---- include/uui/opengl/label.hpp | 4 ++-- src/test/example_gl.cpp | 6 +++--- src/uui/opengl/component.cpp | 2 +- src/uui/opengl/{stack.cpp => flex.cpp} | 12 ++++++------ src/uui/opengl/window.cpp | 6 +++--- 11 files changed, 32 insertions(+), 31 deletions(-) rename include/uui/opengl/{stack.hpp => flex.hpp} (76%) rename src/uui/opengl/{stack.cpp => flex.cpp} (91%) diff --git a/.gitignore b/.gitignore index f6d5daf..68174dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .#.* *.kdev4 +*.ttf .ccls-cache .kdev4 diff --git a/ROADMAP.md b/ROADMAP.md index d126f8c..e4b4f52 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,17 +1,17 @@ * stack component -* negative absolution position (from right/bottom) - -* flex component +* button * layout (constraint) * scroll -* button +* Text wrap * projected vertex/raw vertex mode (projection on GPU) +* negative absolution position (from right/bottom) + * VAO/VBO in windows (batched) * pool/wait mode mechanism diff --git a/include/uui/opengl/application.hpp b/include/uui/opengl/application.hpp index ed7ab60..2488997 100644 --- a/include/uui/opengl/application.hpp +++ b/include/uui/opengl/application.hpp @@ -37,13 +37,13 @@ private: }; class GlComponent; -class GlStack; +class GlFlex; class GlLabel; class GlWindow: public GlContainer, public std::enable_shared_from_this { friend class GlApplication; friend class GlComponent; - friend class GlStack; + friend class GlFlex; friend class GlLabel; public: @@ -56,7 +56,7 @@ public: std::shared_ptr create_component(const position_t x, const position_t y, const position_t width, const position_t height); std::shared_ptr create_label( const position_t x, const position_t y, const std::string& text, const std::tuple& text_color); - std::shared_ptr create_stack(const position_t x, const position_t y, const Direction direction); + std::shared_ptr create_flex(const position_t x, const position_t y, const Direction direction); protected: GlApplication* app; diff --git a/include/uui/opengl/component.hpp b/include/uui/opengl/component.hpp index efcb31a..d6b3b2d 100644 --- a/include/uui/opengl/component.hpp +++ b/include/uui/opengl/component.hpp @@ -10,11 +10,11 @@ namespace uui { -class GlStack; +class GlFlex; class GlComponent: public std::enable_shared_from_this { friend class GlWindow; - friend class GlStack; + friend class GlFlex; public: ~GlComponent(); diff --git a/include/uui/opengl/container.hpp b/include/uui/opengl/container.hpp index 7c10116..0455201 100644 --- a/include/uui/opengl/container.hpp +++ b/include/uui/opengl/container.hpp @@ -8,11 +8,11 @@ namespace uui { class GlComponent; -class GlStack; +class GlFlex; class GlContainer { friend class GlComponent; - friend class GlStack; + friend class GlFlex; protected: GlContainer() = default; @@ -33,7 +33,7 @@ public: enum Type { WINDOW, - STACK + FLEX }; std::vector> components; Type type; diff --git a/include/uui/opengl/stack.hpp b/include/uui/opengl/flex.hpp similarity index 76% rename from include/uui/opengl/stack.hpp rename to include/uui/opengl/flex.hpp index e89fba1..1bd209b 100644 --- a/include/uui/opengl/stack.hpp +++ b/include/uui/opengl/flex.hpp @@ -10,7 +10,7 @@ namespace uui { -class GlStack: public GlComponent, public GlContainer +class GlFlex: public GlComponent, public GlContainer { friend class GlWindow; @@ -23,11 +23,11 @@ protected: int content_width; int content_height; - GlStack( + 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); - GlStack(std::shared_ptr window, std::size_t window_index, const position_t x, const position_t y, const Direction direction): - GlStack(window, window_index, window, window_index, x, y, 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) {} float get_width() const; diff --git a/include/uui/opengl/label.hpp b/include/uui/opengl/label.hpp index c24c5ba..3257da5 100644 --- a/include/uui/opengl/label.hpp +++ b/include/uui/opengl/label.hpp @@ -8,11 +8,11 @@ namespace uui { -class GlStack; +class GlFlex; class GlLabel: public GlComponent { friend class GlWindow; - friend class GlStack; + friend class GlFlex; size_t font_index; diff --git a/src/test/example_gl.cpp b/src/test/example_gl.cpp index 3d3975f..6204a78 100644 --- a/src/test/example_gl.cpp +++ b/src/test/example_gl.cpp @@ -3,8 +3,8 @@ #include "uui/config.hpp" #include "uui/opengl/application.hpp" #include "uui/opengl/component.hpp" +#include "uui/opengl/flex.hpp" #include "uui/opengl/label.hpp" -#include "uui/opengl/stack.hpp" using namespace std; @@ -31,14 +31,14 @@ int main() label->set_background_color(0.5f, 0.5f, 0.1f); label = window->create_label(0.75f, 0.75f, "Hello World!", {1.0f, 1.0f, 1.0f, 0.1f}); - auto stack = window->create_stack(200, 0.6f, uui::Direction::HORIZONTAL); + auto stack = window->create_flex(200, 0.6f, uui::Direction::HORIZONTAL); comp = stack->create_component(100, 50); comp->set_background_color(0.2f, 0.75f, 0.25f); stack->create_label("test", {0.8f, 0.2f, 0.2f, 1.0f}); comp = stack->create_component(100, 20); comp->set_background_color(0.2f, 0.25f, 0.75f); - stack = window->create_stack(50, 400, uui::Direction::VERTICAL); + stack = window->create_flex(50, 400, uui::Direction::VERTICAL); comp = stack->create_component(50, 100); comp->set_background_color(0.2f, 0.75f, 0.25f); stack->create_label("test", {0.8f, 0.2f, 0.2f, 1.0f}); diff --git a/src/uui/opengl/component.cpp b/src/uui/opengl/component.cpp index 3429f33..843a45c 100644 --- a/src/uui/opengl/component.cpp +++ b/src/uui/opengl/component.cpp @@ -148,7 +148,7 @@ void uui::GlComponent::render() void uui::GlComponent::on_resize() { - bool is_in_stack = parent->type == GlContainer::Type::STACK; + bool is_in_stack = parent->type == GlContainer::Type::FLEX; if(!coord_all_relative || is_in_stack) { if(is_in_stack) diff --git a/src/uui/opengl/stack.cpp b/src/uui/opengl/flex.cpp similarity index 91% rename from src/uui/opengl/stack.cpp rename to src/uui/opengl/flex.cpp index 25037db..73f819a 100644 --- a/src/uui/opengl/stack.cpp +++ b/src/uui/opengl/flex.cpp @@ -1,10 +1,10 @@ -#include "uui/opengl/stack.hpp" +#include "uui/opengl/flex.hpp" #include #include "uui/opengl/gl_utils.hpp" -uui::GlStack::GlStack( +uui::GlFlex::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): GlComponent(window, window_index, parent, parent_index, x, y, 0.0f, 0.0f), @@ -13,11 +13,11 @@ uui::GlStack::GlStack( if constexpr(uui::GlApplication::debug_mode) std::cout << "Creating a GlStack" << std::endl; - type = Type::STACK; + type = Type::FLEX; coord_all_relative = false; } -std::shared_ptr uui::GlStack::create_component(const position_t width, const position_t height) +std::shared_ptr uui::GlFlex::create_component(const position_t width, const position_t height) { if(!initialized) throw std::runtime_error("GlWindow error : cannot create component while not initialized"); @@ -34,7 +34,7 @@ std::shared_ptr uui::GlStack::create_component(const position_ return component; } -std::shared_ptr uui::GlStack::create_label(const std::string& text, const std::tuple& text_color) +std::shared_ptr uui::GlFlex::create_label(const std::string& text, const std::tuple& text_color) { if(!initialized) throw std::runtime_error("GlWindow error : cannot create component while not initialized"); @@ -51,7 +51,7 @@ std::shared_ptr uui::GlStack::create_label(const std::string& text return label; } -std::tuple uui::GlStack::get_child_position(const std::size_t child_index) const +std::tuple uui::GlFlex::get_child_position(const std::size_t child_index) const { const int initial_x = position_x.index() == 0 ? std::get<0>(position_x) : static_cast(std::get<1>(position_x) * static_cast(window->width)); diff --git a/src/uui/opengl/window.cpp b/src/uui/opengl/window.cpp index bb92f92..3f866c6 100644 --- a/src/uui/opengl/window.cpp +++ b/src/uui/opengl/window.cpp @@ -3,9 +3,9 @@ #include #include "uui/opengl/component.hpp" +#include "uui/opengl/flex.hpp" #include "uui/opengl/gl_utils.hpp" #include "uui/opengl/label.hpp" -#include "uui/opengl/stack.hpp" #include "uui/shader.hpp" static void APIENTRY @@ -274,13 +274,13 @@ std::shared_ptr uui::GlWindow::create_label( return label; } -std::shared_ptr uui::GlWindow::create_stack(const position_t x, const position_t y, const Direction direction) +std::shared_ptr uui::GlWindow::create_flex(const position_t x, const position_t y, const Direction direction) { if(!initialized) throw std::runtime_error("GlWindow error : cannot create stack while not initialized"); glfwMakeContextCurrent(glfw_window); - std::shared_ptr stack(new uui::GlStack(shared_from_this(), components.size(), x, y, direction)); + std::shared_ptr stack(new uui::GlFlex(shared_from_this(), components.size(), x, y, direction)); push_child(stack); stack->init(); return stack;