#include "NotesTk.h"

#include "TextEditorView.h"
#include "AudioEditorView.h"
#include "ImageEditorView.h"
#include "WebClientView.h"
#include "CanvasView.h"
#include "MeshViewerView.h"

#include "TabbedPanelWidget.h"
#include "TopBar.h"
#include "TextNode.h"
#include "StatusBar.h"
#include "HorizontalSpacer.h"

#include "DesktopManager.h"
#include "MainApplication.h"

NotesTk::NotesTk(std::unique_ptr<CommandLineArgs> args, std::unique_ptr<MainApplication> mainApp)
    : GuiApplication(std::move(args), std::move(mainApp))
{

}

void NotesTk::initializeViews()
{
    auto mainWindow = mDesktopManager->getWindowManager()->getMainWindow();
    mainWindow->setSize(800, 600);
    mainWindow->setTitle("NotesTK");

    auto tabbedPanel = TabbedPanelWidget::Create();

    auto textEditor = TextEditorView::Create();
    auto path = mMainApplication->getCommandLineArgs()->getLaunchPath();
    path /= "out.txt";
    textEditor->setName("TextEditor");
    textEditor->getController()->SetSavePath(path);
    textEditor->getController()->SetLoadPath(path);
    textEditor->initialize();
    tabbedPanel->addPanel(std::move(textEditor), "Text Editor");

    auto audioEditor = AudioEditorView::Create();
    audioEditor->setName("audioEditor");
    tabbedPanel->addPanel(std::move(audioEditor), "Audio Editor");

    auto imageEditor = ImageEditorView::Create();
    imageEditor->setName("imageEditor");
    tabbedPanel->addPanel(std::move(imageEditor), "Image Editor");

    auto webClient = WebClientView::Create();
    webClient->setName("webClient");
    tabbedPanel->addPanel(std::move(webClient), "Web Client");

    auto canvas = CanvasView::Create();
    canvas->setName("CanvasView");
    tabbedPanel->addPanel(std::move(canvas), "Canvas");

    auto mesh = MeshViewerView::Create();
    mesh->setName("MeshViewer");
    tabbedPanel->addPanel(std::move(mesh), "Mesh Viewer");

    //auto topBar = TopBar::Create();
    //auto statusBar = StatusBar::Create();

    //auto horizontal_spacer = HorizontalSpacer::Create();
    //horizontal_spacer->addWidgetWithScale(std::move(topBar), 1);
    //horizontal_spacer->addWidgetWithScale(std::move(tabbedPanel), 20);
    //horizontal_spacer->addWidgetWithScale(std::move(statusBar), 1);

    mainWindow->setWidget(std::move(tabbedPanel));
}
