#include "PropertiesView.hpp"

TSE::EDITOR::PropertiesView::PropertiesView() : GuiWindow("Properies", ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoCollapse) { }

void TSE::EDITOR::PropertiesView::Define()
{
    MenuBar();
    if(currentlyInspecting.type == InspectableType::None) return;

    ElementDrawer::Draw(currentlyInspecting, debugMode);
}

void TSE::EDITOR::PropertiesView::MenuBar()
{
    if(ImGui::BeginMenuBar())
    {
        if(ImGui::BeginMenu("..."))
        {
            if(ImGui::MenuItem("Debug"))
            {
                debugMode = !debugMode;
            }
            ImGui::EndMenu();
        }
        bool style = locked;
        if(style) ImGui::PushStyleColor(ImGuiCol_Text, {0,1,0,1});
        if(ImGui::MenuItem("Lock")) locked = !locked;
        if(style) ImGui::PopStyleColor();
    }
    ImGui::EndMenuBar();
}

TSE::EDITOR::InspectableType TSE::EDITOR::PropertiesView::GetCurrentInspectableType()
{
    return currentlyInspecting.type;
}

void TSE::EDITOR::PropertiesView::SetInspectorElement(InspectableType type, void *element)
{
    if(!locked)
        currentlyInspecting = Inspectable(type, element);
}

void TSE::EDITOR::PropertiesView::ClearInspectorElement()
{
    if(!locked)
        currentlyInspecting = Inspectable(InspectableType::None, nullptr);
}

void TSE::EDITOR::PropertiesView::ForceClearInspectorElement()
{
    currentlyInspecting = Inspectable(InspectableType::None, nullptr);
}
