Rename stack to flex
This commit is contained in:
parent
2ba59d8e37
commit
e7753f244c
11 changed files with 32 additions and 31 deletions
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "uui/opengl/stack.hpp"
|
||||
#include "uui/opengl/flex.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "uui/opengl/gl_utils.hpp"
|
||||
|
||||
uui::GlStack::GlStack(
|
||||
uui::GlFlex::GlFlex(
|
||||
std::shared_ptr<uui::GlWindow> window, std::size_t window_index, std::shared_ptr<uui::GlContainer> 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::GlComponent> uui::GlStack::create_component(const position_t width, const position_t height)
|
||||
std::shared_ptr<uui::GlComponent> 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::GlComponent> uui::GlStack::create_component(const position_
|
|||
return component;
|
||||
}
|
||||
|
||||
std::shared_ptr<uui::GlLabel> uui::GlStack::create_label(const std::string& text, const std::tuple<float, float, float, float>& text_color)
|
||||
std::shared_ptr<uui::GlLabel> uui::GlFlex::create_label(const std::string& text, const std::tuple<float, float, float, float>& text_color)
|
||||
{
|
||||
if(!initialized)
|
||||
throw std::runtime_error("GlWindow error : cannot create component while not initialized");
|
||||
|
|
@ -51,7 +51,7 @@ std::shared_ptr<uui::GlLabel> uui::GlStack::create_label(const std::string& text
|
|||
return label;
|
||||
}
|
||||
|
||||
std::tuple<int, int> uui::GlStack::get_child_position(const std::size_t child_index) const
|
||||
std::tuple<int, int> 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<int>(std::get<1>(position_x) * static_cast<float>(window->width));
|
||||
|
|
@ -3,9 +3,9 @@
|
|||
#include <iostream>
|
||||
|
||||
#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::GlLabel> uui::GlWindow::create_label(
|
|||
return label;
|
||||
}
|
||||
|
||||
std::shared_ptr<uui::GlStack> uui::GlWindow::create_stack(const position_t x, const position_t y, const Direction direction)
|
||||
std::shared_ptr<uui::GlFlex> 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<uui::GlStack> stack(new uui::GlStack(shared_from_this(), components.size(), x, y, direction));
|
||||
std::shared_ptr<uui::GlFlex> stack(new uui::GlFlex(shared_from_this(), components.size(), x, y, direction));
|
||||
push_child(stack);
|
||||
stack->init();
|
||||
return stack;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue