Implement GlStack, GlFlex is now child of GlStack
This commit is contained in:
parent
e7753f244c
commit
896f98476e
12 changed files with 179 additions and 55 deletions
|
|
@ -39,12 +39,14 @@ private:
|
|||
class GlComponent;
|
||||
class GlFlex;
|
||||
class GlLabel;
|
||||
class GlStack;
|
||||
class GlWindow: public GlContainer, public std::enable_shared_from_this<GlWindow>
|
||||
{
|
||||
friend class GlApplication;
|
||||
friend class GlComponent;
|
||||
friend class GlFlex;
|
||||
friend class GlLabel;
|
||||
friend class GlStack;
|
||||
|
||||
public:
|
||||
std::string title;
|
||||
|
|
@ -57,6 +59,7 @@ public:
|
|||
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);
|
||||
std::shared_ptr<GlFlex> create_flex(const position_t x, const position_t y, const Direction direction);
|
||||
std::shared_ptr<GlStack> create_stack(const position_t x, const position_t y, const Direction direction);
|
||||
|
||||
protected:
|
||||
GlApplication* app;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@
|
|||
namespace uui
|
||||
{
|
||||
class GlFlex;
|
||||
class GlStack;
|
||||
class GlComponent: public std::enable_shared_from_this<GlComponent>
|
||||
{
|
||||
friend class GlWindow;
|
||||
friend class GlFlex;
|
||||
friend class GlStack;
|
||||
|
||||
public:
|
||||
~GlComponent();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ public:
|
|||
enum Type
|
||||
{
|
||||
WINDOW,
|
||||
FLEX
|
||||
FLEX,
|
||||
STACK
|
||||
};
|
||||
std::vector<std::shared_ptr<GlComponent>> components;
|
||||
Type type;
|
||||
|
|
|
|||
|
|
@ -7,22 +7,15 @@
|
|||
#include "uui/opengl/component.hpp"
|
||||
#include "uui/opengl/container.hpp"
|
||||
#include "uui/opengl/label.hpp"
|
||||
#include "uui/opengl/stack.hpp"
|
||||
|
||||
namespace uui
|
||||
{
|
||||
class GlFlex: public GlComponent, public GlContainer
|
||||
class GlFlex: public GlStack
|
||||
{
|
||||
friend class GlWindow;
|
||||
|
||||
public:
|
||||
std::shared_ptr<GlComponent> create_component(const position_t width, const position_t height);
|
||||
std::shared_ptr<GlLabel> create_label(const std::string& text, const std::tuple<float, float, float, float>& text_color);
|
||||
|
||||
protected:
|
||||
Direction direction;
|
||||
int content_width;
|
||||
int content_height;
|
||||
|
||||
GlFlex(
|
||||
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);
|
||||
|
|
@ -30,9 +23,6 @@ protected:
|
|||
GlFlex(window, window_index, window, window_index, x, y, direction)
|
||||
{}
|
||||
|
||||
float get_width() const;
|
||||
float get_height() const;
|
||||
|
||||
std::tuple<int, int> get_child_position(const std::size_t child_index) const override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@
|
|||
namespace uui
|
||||
{
|
||||
class GlFlex;
|
||||
class GlStack;
|
||||
class GlLabel: public GlComponent
|
||||
{
|
||||
friend class GlWindow;
|
||||
friend class GlFlex;
|
||||
friend class GlStack;
|
||||
|
||||
size_t font_index;
|
||||
|
||||
|
|
|
|||
39
include/uui/opengl/stack.hpp
Normal file
39
include/uui/opengl/stack.hpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "uui/opengl/component.hpp"
|
||||
#include "uui/opengl/container.hpp"
|
||||
#include "uui/opengl/label.hpp"
|
||||
|
||||
namespace uui
|
||||
{
|
||||
class GlStack: public GlComponent, public GlContainer
|
||||
{
|
||||
friend class GlWindow;
|
||||
|
||||
public:
|
||||
std::shared_ptr<GlComponent> create_component(const position_t width, const position_t height);
|
||||
std::shared_ptr<GlLabel> create_label(const std::string& text, const std::tuple<float, float, float, float>& text_color);
|
||||
|
||||
protected:
|
||||
Direction direction;
|
||||
int content_width;
|
||||
int content_height;
|
||||
|
||||
GlStack(
|
||||
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);
|
||||
GlStack(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)
|
||||
{}
|
||||
|
||||
float get_width() const;
|
||||
float get_height() const;
|
||||
|
||||
virtual std::tuple<int, int> get_child_position(const std::size_t child_index) const;
|
||||
};
|
||||
|
||||
} // namespace uui
|
||||
Loading…
Add table
Add a link
Reference in a new issue