2020-05-02 07:31:03 +00:00
|
|
|
#include "GuiApplication.h"
|
|
|
|
|
|
|
|
#include "Widget.h"
|
|
|
|
#include "XcbInterface.h"
|
|
|
|
#include "XcbKeyboard.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "TextElement.h"
|
|
|
|
#include "WindowManager.h"
|
2020-06-20 18:00:06 +00:00
|
|
|
#include <iostream>
|
2020-06-27 09:47:30 +00:00
|
|
|
#include "TextEditorView.h"
|
|
|
|
#include "AudioEditorView.h"
|
|
|
|
#include "ImageEditorView.h"
|
|
|
|
#include "WebClientView.h"
|
|
|
|
#include "TabbedPanelWidget.h"
|
|
|
|
#include "TopBar.h"
|
|
|
|
#include "StatusBar.h"
|
|
|
|
#include "HorizontalSpacer.h"
|
2020-05-02 07:31:03 +00:00
|
|
|
|
|
|
|
GuiApplication::GuiApplication()
|
2020-06-20 15:34:10 +00:00
|
|
|
: AbstractDesktopApp(),
|
|
|
|
mMainApplication(),
|
|
|
|
mDesktopManager(DesktopManager::Create())
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
2020-06-20 15:34:10 +00:00
|
|
|
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GuiApplication::~GuiApplication()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiApplication::SetMainApplication(MainApplicationPtr app)
|
|
|
|
{
|
2020-06-20 15:34:10 +00:00
|
|
|
mMainApplication = app;
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-20 18:00:06 +00:00
|
|
|
void GuiApplication::SetUpWidget()
|
2020-05-02 07:31:03 +00:00
|
|
|
{
|
2020-06-20 15:34:10 +00:00
|
|
|
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
|
|
|
mainWindow->SetSize(800, 600);
|
2020-05-02 07:31:03 +00:00
|
|
|
|
2020-06-27 09:47:30 +00:00
|
|
|
auto tabbedPanel = TabbedPanelWidget::Create();
|
|
|
|
|
|
|
|
auto textEditor = TextEditorView::Create();
|
|
|
|
auto path = mMainApplication->GetCommandLineArgs()->GetLaunchPath();
|
|
|
|
path /= "out.txt";
|
|
|
|
textEditor->GetController()->SetSavePath(path);
|
|
|
|
textEditor->GetController()->SetLoadPath(path);
|
2020-06-20 18:00:06 +00:00
|
|
|
textEditor->Initialize();
|
2020-06-27 09:47:30 +00:00
|
|
|
tabbedPanel->AddPanel(std::move(textEditor), "Text Editor");
|
|
|
|
|
|
|
|
auto audioEditor = AudioEditorView::Create();
|
|
|
|
tabbedPanel->AddPanel(std::move(audioEditor), "Audio Editor");
|
|
|
|
|
|
|
|
auto imageEditor = ImageEditorView::Create();
|
|
|
|
tabbedPanel->AddPanel(std::move(imageEditor), "Image Editor");
|
|
|
|
|
|
|
|
auto webClient = WebClientView::Create();
|
|
|
|
tabbedPanel->AddPanel(std::move(webClient), "Web Client");
|
|
|
|
|
|
|
|
auto topBar = TopBar::Create();
|
|
|
|
auto statusBar = StatusBar::Create();
|
2020-06-20 18:00:06 +00:00
|
|
|
|
2020-06-27 09:47:30 +00:00
|
|
|
auto horizontalSpace = HorizontalSpacer::Create();
|
|
|
|
horizontalSpace->AddWidgetWithScale(std::move(topBar), 1);
|
|
|
|
horizontalSpace->AddWidgetWithScale(std::move(tabbedPanel), 20);
|
|
|
|
horizontalSpace->AddWidgetWithScale(std::move(statusBar), 1);
|
2020-06-20 18:00:06 +00:00
|
|
|
|
2020-06-27 09:47:30 +00:00
|
|
|
mainWindow->AddWidget(std::move(horizontalSpace));
|
2020-06-20 18:00:06 +00:00
|
|
|
}
|
2020-05-02 07:31:03 +00:00
|
|
|
|
2020-06-20 18:00:06 +00:00
|
|
|
void GuiApplication::Run()
|
|
|
|
{
|
|
|
|
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
|
|
|
SetUpWidget();
|
2020-05-02 07:31:03 +00:00
|
|
|
|
2020-06-20 15:34:10 +00:00
|
|
|
mDesktopManager->SetKeyboard(XcbKeyboard::Create());
|
2020-05-02 07:31:03 +00:00
|
|
|
|
2020-06-20 15:34:10 +00:00
|
|
|
bool useOpenGl = false;
|
|
|
|
XcbInterface window_interface;
|
|
|
|
window_interface.SetUseOpenGl(useOpenGl);
|
|
|
|
window_interface.Initialize();
|
|
|
|
window_interface.AddWindow(mainWindow);
|
|
|
|
window_interface.ShowWindow(mainWindow);
|
|
|
|
if(useOpenGl)
|
|
|
|
{
|
|
|
|
window_interface.CreateOpenGlDrawable(mainWindow);
|
|
|
|
}
|
|
|
|
window_interface.Loop(mDesktopManager.get());
|
|
|
|
window_interface.ShutDown();
|
2020-05-02 07:31:03 +00:00
|
|
|
}
|