added editor WIP
This commit is contained in:
35
TSE_Editor/src/UI/base/GuiWindow.cpp
Normal file
35
TSE_Editor/src/UI/base/GuiWindow.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "GuiWindow.h"
|
||||
|
||||
TSE::EDITOR::GuiWindow::GuiWindow(const string &title, const ImGuiWindowFlags &flags)
|
||||
{
|
||||
this->title = title;
|
||||
this->flags = flags;
|
||||
}
|
||||
|
||||
TSE::EDITOR::GuiWindow::GuiWindow(const string &title, const Vector2 pos, const Vector2 size, const ImGuiWindowFlags &flags)
|
||||
{
|
||||
this->title = title;
|
||||
this->pos = pos;
|
||||
this->size = size;
|
||||
this->flags = flags;
|
||||
}
|
||||
|
||||
void TSE::EDITOR::GuiWindow::Render()
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
Begin();
|
||||
Define();
|
||||
End();
|
||||
}
|
||||
}
|
||||
|
||||
void TSE::EDITOR::GuiWindow::Begin()
|
||||
{
|
||||
ImGui::Begin(title.c_str(), &enabled, flags);
|
||||
}
|
||||
|
||||
void TSE::EDITOR::GuiWindow::End()
|
||||
{
|
||||
ImGui::End();
|
||||
}
|
||||
27
TSE_Editor/src/UI/base/GuiWindow.h
Normal file
27
TSE_Editor/src/UI/base/GuiWindow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGUIElement.hpp"
|
||||
#include "Types.hpp"
|
||||
#include "Vector2.hpp"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace TSE::EDITOR
|
||||
{
|
||||
class GuiWindow : public IGUIElement
|
||||
{
|
||||
public:
|
||||
Vector2 pos = Vector2::zero;
|
||||
Vector2 size = Vector2(100,100);
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_None;
|
||||
string title = "Title";
|
||||
|
||||
GuiWindow(const string& title, const ImGuiWindowFlags& flags = ImGuiWindowFlags_None);
|
||||
GuiWindow(const string& title, const Vector2 pos, const Vector2 size, const ImGuiWindowFlags& flags = ImGuiWindowFlags_None);
|
||||
void Render() override;
|
||||
virtual void Define() = 0;
|
||||
|
||||
private:
|
||||
void Begin();
|
||||
void End();
|
||||
};
|
||||
} // namespace TSE::EDITOR
|
||||
16
TSE_Editor/src/UI/base/IGUIElement.hpp
Normal file
16
TSE_Editor/src/UI/base/IGUIElement.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
namespace TSE::EDITOR
|
||||
{
|
||||
class IGUIElement
|
||||
{
|
||||
protected:
|
||||
bool enabled = true;
|
||||
public:
|
||||
virtual void Render() = 0;
|
||||
inline void SetEnabled(bool state)
|
||||
{
|
||||
enabled = state;
|
||||
};
|
||||
};
|
||||
} // namespace TSE::EDITOR
|
||||
Reference in New Issue
Block a user