#include "SceneView.hpp"

TSE::EDITOR::SceneView::SceneView(TSE::IRenderTexture *frameBuffer) : GuiWindow("Scene", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
{ 
    fb = frameBuffer;
}

void TSE::EDITOR::SceneView::Define()
{
    ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
    if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
    {
        ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
        auto vec2 = ImGui::GetWindowSize();
        if(fb->Width() != vec2.x || fb->Height() != vec2.y)
        {
            fb->SetSize({vec2.x, vec2.y});
        }
    }
    ImGui::EndChild();
}
