Rename stack to flex
This commit is contained in:
parent
2ba59d8e37
commit
e7753f244c
11 changed files with 32 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
||||||
.#.*
|
.#.*
|
||||||
*.kdev4
|
*.kdev4
|
||||||
|
*.ttf
|
||||||
|
|
||||||
.ccls-cache
|
.ccls-cache
|
||||||
.kdev4
|
.kdev4
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
* stack component
|
* stack component
|
||||||
|
|
||||||
* negative absolution position (from right/bottom)
|
* button
|
||||||
|
|
||||||
* flex component
|
|
||||||
|
|
||||||
* layout (constraint)
|
* layout (constraint)
|
||||||
|
|
||||||
* scroll
|
* scroll
|
||||||
|
|
||||||
* button
|
* Text wrap
|
||||||
|
|
||||||
* projected vertex/raw vertex mode (projection on GPU)
|
* projected vertex/raw vertex mode (projection on GPU)
|
||||||
|
|
||||||
|
* negative absolution position (from right/bottom)
|
||||||
|
|
||||||
* VAO/VBO in windows (batched)
|
* VAO/VBO in windows (batched)
|
||||||
|
|
||||||
* pool/wait mode mechanism
|
* pool/wait mode mechanism
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlComponent;
|
class GlComponent;
|
||||||
class GlStack;
|
class GlFlex;
|
||||||
class GlLabel;
|
class GlLabel;
|
||||||
class GlWindow: public GlContainer, public std::enable_shared_from_this<GlWindow>
|
class GlWindow: public GlContainer, public std::enable_shared_from_this<GlWindow>
|
||||||
{
|
{
|
||||||
friend class GlApplication;
|
friend class GlApplication;
|
||||||
friend class GlComponent;
|
friend class GlComponent;
|
||||||
friend class GlStack;
|
friend class GlFlex;
|
||||||
friend class GlLabel;
|
friend class GlLabel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
std::shared_ptr<GlComponent> create_component(const position_t x, const position_t y, const position_t width, const position_t height);
|
std::shared_ptr<GlComponent> create_component(const position_t x, const position_t y, const position_t width, const position_t height);
|
||||||
std::shared_ptr<GlLabel> create_label(
|
std::shared_ptr<GlLabel> create_label(
|
||||||
const position_t x, const position_t y, const std::string& text, const std::tuple<float, float, float, float>& text_color);
|
const position_t x, const position_t y, const std::string& text, const std::tuple<float, float, float, float>& text_color);
|
||||||
std::shared_ptr<GlStack> create_stack(const position_t x, const position_t y, const Direction direction);
|
std::shared_ptr<GlFlex> create_flex(const position_t x, const position_t y, const Direction direction);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GlApplication* app;
|
GlApplication* app;
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
namespace uui
|
namespace uui
|
||||||
{
|
{
|
||||||
class GlStack;
|
class GlFlex;
|
||||||
class GlComponent: public std::enable_shared_from_this<GlComponent>
|
class GlComponent: public std::enable_shared_from_this<GlComponent>
|
||||||
{
|
{
|
||||||
friend class GlWindow;
|
friend class GlWindow;
|
||||||
friend class GlStack;
|
friend class GlFlex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~GlComponent();
|
~GlComponent();
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
namespace uui
|
namespace uui
|
||||||
{
|
{
|
||||||
class GlComponent;
|
class GlComponent;
|
||||||
class GlStack;
|
class GlFlex;
|
||||||
class GlContainer
|
class GlContainer
|
||||||
{
|
{
|
||||||
friend class GlComponent;
|
friend class GlComponent;
|
||||||
friend class GlStack;
|
friend class GlFlex;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GlContainer() = default;
|
GlContainer() = default;
|
||||||
|
|
@ -33,7 +33,7 @@ public:
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
WINDOW,
|
WINDOW,
|
||||||
STACK
|
FLEX
|
||||||
};
|
};
|
||||||
std::vector<std::shared_ptr<GlComponent>> components;
|
std::vector<std::shared_ptr<GlComponent>> components;
|
||||||
Type type;
|
Type type;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace uui
|
namespace uui
|
||||||
{
|
{
|
||||||
class GlStack: public GlComponent, public GlContainer
|
class GlFlex: public GlComponent, public GlContainer
|
||||||
{
|
{
|
||||||
friend class GlWindow;
|
friend class GlWindow;
|
||||||
|
|
||||||
|
|
@ -23,11 +23,11 @@ protected:
|
||||||
int content_width;
|
int content_width;
|
||||||
int content_height;
|
int content_height;
|
||||||
|
|
||||||
GlStack(
|
GlFlex(
|
||||||
std::shared_ptr<GlWindow> window, std::size_t window_index, std::shared_ptr<GlContainer> parent, std::size_t parent_index,
|
std::shared_ptr<GlWindow> window, std::size_t window_index, std::shared_ptr<GlContainer> parent, std::size_t parent_index,
|
||||||
const position_t x, const position_t y, const Direction direction);
|
const position_t x, const position_t y, const Direction direction);
|
||||||
GlStack(std::shared_ptr<GlWindow> window, std::size_t window_index, const position_t x, const position_t y, const Direction direction):
|
GlFlex(std::shared_ptr<GlWindow> 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(window, window_index, window, window_index, x, y, direction)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
float get_width() const;
|
float get_width() const;
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
namespace uui
|
namespace uui
|
||||||
{
|
{
|
||||||
class GlStack;
|
class GlFlex;
|
||||||
class GlLabel: public GlComponent
|
class GlLabel: public GlComponent
|
||||||
{
|
{
|
||||||
friend class GlWindow;
|
friend class GlWindow;
|
||||||
friend class GlStack;
|
friend class GlFlex;
|
||||||
|
|
||||||
size_t font_index;
|
size_t font_index;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include "uui/config.hpp"
|
#include "uui/config.hpp"
|
||||||
#include "uui/opengl/application.hpp"
|
#include "uui/opengl/application.hpp"
|
||||||
#include "uui/opengl/component.hpp"
|
#include "uui/opengl/component.hpp"
|
||||||
|
#include "uui/opengl/flex.hpp"
|
||||||
#include "uui/opengl/label.hpp"
|
#include "uui/opengl/label.hpp"
|
||||||
#include "uui/opengl/stack.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -31,14 +31,14 @@ int main()
|
||||||
label->set_background_color(0.5f, 0.5f, 0.1f);
|
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});
|
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 = stack->create_component(100, 50);
|
||||||
comp->set_background_color(0.2f, 0.75f, 0.25f);
|
comp->set_background_color(0.2f, 0.75f, 0.25f);
|
||||||
stack->create_label("test", {0.8f, 0.2f, 0.2f, 1.0f});
|
stack->create_label("test", {0.8f, 0.2f, 0.2f, 1.0f});
|
||||||
comp = stack->create_component(100, 20);
|
comp = stack->create_component(100, 20);
|
||||||
comp->set_background_color(0.2f, 0.25f, 0.75f);
|
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 = stack->create_component(50, 100);
|
||||||
comp->set_background_color(0.2f, 0.75f, 0.25f);
|
comp->set_background_color(0.2f, 0.75f, 0.25f);
|
||||||
stack->create_label("test", {0.8f, 0.2f, 0.2f, 1.0f});
|
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()
|
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(!coord_all_relative || is_in_stack)
|
||||||
{
|
{
|
||||||
if(is_in_stack)
|
if(is_in_stack)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "uui/opengl/stack.hpp"
|
#include "uui/opengl/flex.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "uui/opengl/gl_utils.hpp"
|
#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,
|
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):
|
const position_t x, const position_t y, const Direction direction):
|
||||||
GlComponent(window, window_index, parent, parent_index, x, y, 0.0f, 0.0f),
|
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)
|
if constexpr(uui::GlApplication::debug_mode)
|
||||||
std::cout << "Creating a GlStack" << std::endl;
|
std::cout << "Creating a GlStack" << std::endl;
|
||||||
|
|
||||||
type = Type::STACK;
|
type = Type::FLEX;
|
||||||
coord_all_relative = false;
|
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)
|
if(!initialized)
|
||||||
throw std::runtime_error("GlWindow error : cannot create component while not 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;
|
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)
|
if(!initialized)
|
||||||
throw std::runtime_error("GlWindow error : cannot create component while not 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;
|
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 =
|
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));
|
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 <iostream>
|
||||||
|
|
||||||
#include "uui/opengl/component.hpp"
|
#include "uui/opengl/component.hpp"
|
||||||
|
#include "uui/opengl/flex.hpp"
|
||||||
#include "uui/opengl/gl_utils.hpp"
|
#include "uui/opengl/gl_utils.hpp"
|
||||||
#include "uui/opengl/label.hpp"
|
#include "uui/opengl/label.hpp"
|
||||||
#include "uui/opengl/stack.hpp"
|
|
||||||
#include "uui/shader.hpp"
|
#include "uui/shader.hpp"
|
||||||
|
|
||||||
static void APIENTRY
|
static void APIENTRY
|
||||||
|
|
@ -274,13 +274,13 @@ std::shared_ptr<uui::GlLabel> uui::GlWindow::create_label(
|
||||||
return 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)
|
if(!initialized)
|
||||||
throw std::runtime_error("GlWindow error : cannot create stack while not initialized");
|
throw std::runtime_error("GlWindow error : cannot create stack while not initialized");
|
||||||
|
|
||||||
glfwMakeContextCurrent(glfw_window);
|
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);
|
push_child(stack);
|
||||||
stack->init();
|
stack->init();
|
||||||
return stack;
|
return stack;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue