Yoga layout working
This commit is contained in:
@@ -2,57 +2,36 @@
|
||||
#include <src/Core/Timestep.h>
|
||||
#include <src/Rendering/Framebuffer.h>
|
||||
#include <src/UI/Rect.h>
|
||||
|
||||
#include "yoga/Yoga.h"
|
||||
#include "Node.h"
|
||||
#include <src/UI/Canvas.h>
|
||||
#include "../Core/Maths.h"
|
||||
namespace UI
|
||||
{
|
||||
class UserInterface
|
||||
{
|
||||
private:
|
||||
std::vector<Ref<Rect>> m_Rects;
|
||||
Ref<FrameBuffer> m_Framebuffer; // Texture of the interface.
|
||||
std::string m_Name;
|
||||
|
||||
Ref<Canvas> Root;
|
||||
YGConfigRef yoga_config;
|
||||
YGNodeRef yoga_root;
|
||||
public:
|
||||
const int Width = 1920;
|
||||
const int Height = 1080;
|
||||
|
||||
UserInterface(const std::string& name);
|
||||
~UserInterface();
|
||||
|
||||
void Reload();
|
||||
|
||||
static Ref<UserInterface> New(const std::string& name);
|
||||
void Calculate();
|
||||
void Draw();
|
||||
void Calculate(int available_width, int available_height);
|
||||
|
||||
void CreateYogaLayout();
|
||||
void CreateYogaLayoutRecursive(Ref<Node> node, YGNodeRef yoga_node);
|
||||
void Draw(Vector2 size);
|
||||
void DrawRecursive(Ref<Node> node, float z, Vector2 offset);
|
||||
void Update(Timestep ts);
|
||||
|
||||
std::vector<Ref<Rect>> GetRects()
|
||||
{
|
||||
return m_Rects;
|
||||
}
|
||||
|
||||
void AddRect(Ref<Rect> rect)
|
||||
{
|
||||
m_Rects.push_back(rect);
|
||||
}
|
||||
|
||||
Ref<Rect> GetRectByID(const std::string& id)
|
||||
{
|
||||
for (auto r : m_Rects)
|
||||
{
|
||||
if (r->GetID() == id)
|
||||
return r;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<Ref<Rect>> GetRectsByGroup(const std::string& group)
|
||||
{
|
||||
std::vector<Ref<Rect>> rects = std::vector<Ref<Rect>>();
|
||||
for (auto r : m_Rects)
|
||||
{
|
||||
if(r->HasGroup(group))
|
||||
rects.push_back(r);
|
||||
}
|
||||
return rects;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user