More cleaning
This commit is contained in:
parent
02ebb9a54b
commit
6adc441e6f
37 changed files with 213 additions and 181 deletions
|
@ -9,7 +9,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Start the main app
|
// Start the main app
|
||||||
auto main_app = MainApplication::Create();
|
auto main_app = MainApplication::Create();
|
||||||
main_app->Initialize(std::move(command_line_args));
|
main_app->initialize(std::move(command_line_args));
|
||||||
|
|
||||||
main_app->Run();
|
main_app->Run();
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,42 @@
|
||||||
|
list(APPEND client_HEADERS
|
||||||
|
MediaTool.h
|
||||||
|
text_editor/TextEditorView.h
|
||||||
|
text_editor/TextEditorModel.h
|
||||||
|
text_editor/TextEditorController.h
|
||||||
|
text_editor/PlainTextDocument.h
|
||||||
|
audio_editor/AudioEditorView.h
|
||||||
|
image_editor/ImageEditorView.h
|
||||||
|
web_client/WebClientView.h)
|
||||||
|
|
||||||
|
|
||||||
|
list(APPEND client_LIB_INCLUDES
|
||||||
|
text_editor/TextEditorView.cpp
|
||||||
|
text_editor/TextEditorModel.cpp
|
||||||
|
text_editor/TextEditorController.cpp
|
||||||
|
text_editor/PlainTextDocument.cpp
|
||||||
|
audio_editor/AudioEditorView.cpp
|
||||||
|
image_editor/ImageEditorView.cpp
|
||||||
|
web_client/WebClientView.cpp
|
||||||
|
MediaTool.cpp)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_executable(sample_gui_win WIN32 gui-main-win.cpp)
|
add_executable(sample_gui WIN32 gui-main-win.cpp ${client_LIB_INCLUDES})
|
||||||
target_include_directories(sample_gui PUBLIC
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/console"
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/client"
|
|
||||||
)
|
|
||||||
target_link_libraries(sample_gui_win PUBLIC client windows console core
|
|
||||||
network database geometry audio web)
|
|
||||||
set_property(TARGET sample_gui_win PROPERTY FOLDER apps)
|
|
||||||
else()
|
else()
|
||||||
find_package(X11 QUIET)
|
find_package(X11 QUIET)
|
||||||
if(X11_FOUND)
|
if(X11_FOUND)
|
||||||
add_executable(sample_gui gui-main.cpp)
|
add_executable(sample_gui gui-main.cpp ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||||
target_include_directories(sample_gui PUBLIC
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/console"
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/client"
|
|
||||||
)
|
|
||||||
target_link_libraries(sample_gui PUBLIC client windows console core
|
|
||||||
network database geometry audio web)
|
|
||||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Skipping sample GUI as no X11 dev support")
|
message(STATUS "Skipping sample GUI as no X11 dev support")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(sample_gui PUBLIC
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/text_editor"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/audio_editor"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/image_editor"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/web_client"
|
||||||
|
)
|
||||||
|
target_link_libraries(sample_gui PUBLIC client windows console core network database geometry audio web)
|
||||||
|
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||||
|
|
||||||
|
|
||||||
|
|
54
apps/sample-gui/MediaTool.cpp
Normal file
54
apps/sample-gui/MediaTool.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include "MediaTool.h"
|
||||||
|
|
||||||
|
#include "TextEditorView.h"
|
||||||
|
#include "AudioEditorView.h"
|
||||||
|
#include "ImageEditorView.h"
|
||||||
|
#include "WebClientView.h"
|
||||||
|
#include "TabbedPanelWidget.h"
|
||||||
|
#include "TopBar.h"
|
||||||
|
#include "StatusBar.h"
|
||||||
|
#include "HorizontalSpacer.h"
|
||||||
|
|
||||||
|
#include "DesktopManager.h"
|
||||||
|
#include "MainApplication.h"
|
||||||
|
|
||||||
|
MediaTool::MediaTool(std::unique_ptr<CommandLineArgs> args)
|
||||||
|
: GuiApplication(std::move(args))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaTool::initializeViews()
|
||||||
|
{
|
||||||
|
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||||
|
mainWindow->SetSize(800, 600);
|
||||||
|
|
||||||
|
auto tabbedPanel = TabbedPanelWidget::Create();
|
||||||
|
|
||||||
|
auto textEditor = TextEditorView::Create();
|
||||||
|
auto path = mMainApplication->GetCommandLineArgs()->getLaunchPath();
|
||||||
|
path /= "out.txt";
|
||||||
|
textEditor->GetController()->SetSavePath(path);
|
||||||
|
textEditor->GetController()->SetLoadPath(path);
|
||||||
|
textEditor->Initialize();
|
||||||
|
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();
|
||||||
|
|
||||||
|
auto horizontalSpace = HorizontalSpacer::Create();
|
||||||
|
horizontalSpace->AddWidgetWithScale(std::move(topBar), 1);
|
||||||
|
horizontalSpace->AddWidgetWithScale(std::move(tabbedPanel), 20);
|
||||||
|
horizontalSpace->AddWidgetWithScale(std::move(statusBar), 1);
|
||||||
|
|
||||||
|
mainWindow->AddWidget(std::move(horizontalSpace));
|
||||||
|
}
|
12
apps/sample-gui/MediaTool.h
Normal file
12
apps/sample-gui/MediaTool.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
|
class MediaTool : public GuiApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MediaTool(std::unique_ptr<CommandLineArgs> args);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initializeViews() override;
|
||||||
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "GuiApplication.h"
|
#include "MediaTool.h"
|
||||||
#include "MainApplication.h"
|
#include "MainApplication.h"
|
||||||
#include "CommandLineArgs.h"
|
#include "CommandLineArgs.h"
|
||||||
|
|
||||||
|
@ -10,15 +10,9 @@ int main(int argc, char *argv[])
|
||||||
args->process(argc, argv);
|
args->process(argc, argv);
|
||||||
args->recordLaunchPath();
|
args->recordLaunchPath();
|
||||||
|
|
||||||
// Start the main app
|
|
||||||
auto main_app = MainApplication::Create();
|
|
||||||
main_app->Initialize(std::move(args));
|
|
||||||
|
|
||||||
// Start the gui app
|
// Start the gui app
|
||||||
auto gui_app = GuiApplication();
|
auto gui_app = GuiApplication(std::move(args));
|
||||||
gui_app.SetMainApplication(main_app);
|
gui_app.run();
|
||||||
gui_app.Run();
|
|
||||||
|
|
||||||
main_app->ShutDown();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,27 +2,13 @@ list(APPEND client_HEADERS
|
||||||
TopBar.h
|
TopBar.h
|
||||||
StatusBar.h
|
StatusBar.h
|
||||||
GuiApplication.h
|
GuiApplication.h
|
||||||
TabbedPanelWidget.h
|
TabbedPanelWidget.h)
|
||||||
text_editor/TextEditorView.h
|
|
||||||
text_editor/TextEditorModel.h
|
|
||||||
text_editor/TextEditorController.h
|
|
||||||
text_editor/PlainTextDocument.h
|
|
||||||
audio_editor/AudioEditorView.h
|
|
||||||
image_editor/ImageEditorView.h
|
|
||||||
web_client/WebClientView.h)
|
|
||||||
|
|
||||||
list(APPEND client_LIB_INCLUDES
|
list(APPEND client_LIB_INCLUDES
|
||||||
TopBar.cpp
|
TopBar.cpp
|
||||||
StatusBar.cpp
|
StatusBar.cpp
|
||||||
GuiApplication.cpp
|
GuiApplication.cpp
|
||||||
TabbedPanelWidget.cpp
|
TabbedPanelWidget.cpp)
|
||||||
text_editor/TextEditorView.cpp
|
|
||||||
text_editor/TextEditorModel.cpp
|
|
||||||
text_editor/TextEditorController.cpp
|
|
||||||
text_editor/PlainTextDocument.cpp
|
|
||||||
audio_editor/AudioEditorView.cpp
|
|
||||||
image_editor/ImageEditorView.cpp
|
|
||||||
web_client/WebClientView.cpp)
|
|
||||||
|
|
||||||
add_library(client SHARED ${client_LIB_INCLUDES} ${client_HEADERS})
|
add_library(client SHARED ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,20 @@
|
||||||
#include "GuiApplication.h"
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
#include "Widget.h"
|
|
||||||
#include "UiInterfaceFactory.h"
|
#include "UiInterfaceFactory.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "TextElement.h"
|
|
||||||
#include "WindowManager.h"
|
#include "WindowManager.h"
|
||||||
#include "TextEditorView.h"
|
#include "DesktopManager.h"
|
||||||
#include "AudioEditorView.h"
|
#include "MainApplication.h"
|
||||||
#include "ImageEditorView.h"
|
#include "AbstractUiInterface.h"
|
||||||
#include "WebClientView.h"
|
|
||||||
#include "TabbedPanelWidget.h"
|
|
||||||
#include "TopBar.h"
|
|
||||||
#include "StatusBar.h"
|
|
||||||
#include "HorizontalSpacer.h"
|
|
||||||
#include "FileLogger.h"
|
#include "FileLogger.h"
|
||||||
|
|
||||||
GuiApplication::GuiApplication()
|
GuiApplication::GuiApplication(std::unique_ptr<CommandLineArgs> args)
|
||||||
: AbstractDesktopApp(),
|
: AbstractDesktopApp(),
|
||||||
mMainApplication(),
|
mMainApplication(MainApplication::Create()),
|
||||||
mDesktopManager(DesktopManager::Create())
|
mDesktopManager(DesktopManager::Create(this))
|
||||||
{
|
{
|
||||||
|
mMainApplication->initialize(args ? std::move(args) : CommandLineArgs::Create());
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiApplication::~GuiApplication()
|
GuiApplication::~GuiApplication()
|
||||||
|
@ -28,61 +22,37 @@ GuiApplication::~GuiApplication()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiApplication::SetMainApplication(MainApplicationPtr app)
|
AbstractApp* GuiApplication::getMainApplication() const
|
||||||
{
|
{
|
||||||
mMainApplication = app;
|
return mMainApplication.get();
|
||||||
mDesktopManager->SetMainApp(app);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiApplication::SetUpWidget()
|
void GuiApplication::initializeViews()
|
||||||
{
|
{
|
||||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
|
||||||
mainWindow->SetSize(800, 600);
|
|
||||||
|
|
||||||
auto tabbedPanel = TabbedPanelWidget::Create();
|
|
||||||
|
|
||||||
auto textEditor = TextEditorView::Create();
|
|
||||||
auto path = mMainApplication->GetCommandLineArgs()->getLaunchPath();
|
|
||||||
path /= "out.txt";
|
|
||||||
textEditor->GetController()->SetSavePath(path);
|
|
||||||
textEditor->GetController()->SetLoadPath(path);
|
|
||||||
textEditor->Initialize();
|
|
||||||
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();
|
|
||||||
|
|
||||||
auto horizontalSpace = HorizontalSpacer::Create();
|
|
||||||
horizontalSpace->AddWidgetWithScale(std::move(topBar), 1);
|
|
||||||
horizontalSpace->AddWidgetWithScale(std::move(tabbedPanel), 20);
|
|
||||||
horizontalSpace->AddWidgetWithScale(std::move(statusBar), 1);
|
|
||||||
|
|
||||||
mainWindow->AddWidget(std::move(horizontalSpace));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiApplication::Run()
|
void GuiApplication::setUiInterfaceBackend(UiInterfaceFactory::Backend backend)
|
||||||
|
{
|
||||||
|
mUiInterfaceBackend = backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiApplication::run()
|
||||||
{
|
{
|
||||||
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
auto mainWindow = mDesktopManager->GetWindowManager()->GetMainWindow();
|
||||||
SetUpWidget();
|
initializeViews();
|
||||||
|
|
||||||
MLOG_INFO("Creating Window Interface");
|
MLOG_INFO("Creating Window Interface");
|
||||||
auto window_interface = UiInterfaceFactory::create(mDesktopManager.get());
|
mUiInterface = UiInterfaceFactory::create(mDesktopManager.get(), mUiInterfaceBackend);
|
||||||
|
|
||||||
window_interface->initialize();
|
mUiInterface->initialize();
|
||||||
window_interface->addWindow(mainWindow);
|
mUiInterface->addWindow(mainWindow);
|
||||||
window_interface->showWindow(mainWindow);
|
mUiInterface->showWindow(mainWindow);
|
||||||
window_interface->loop();
|
mUiInterface->loop();
|
||||||
|
|
||||||
window_interface->shutDown();
|
mUiInterface->shutDown();
|
||||||
|
|
||||||
MLOG_INFO("Window Interface Shut Down");
|
MLOG_INFO("Window Interface Shut Down");
|
||||||
|
|
||||||
|
mMainApplication->ShutDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,35 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "MainApplication.h"
|
|
||||||
#include "AbstractDesktopApp.h"
|
#include "AbstractDesktopApp.h"
|
||||||
#include "DesktopManager.h"
|
#include "UiInterfaceFactory.h"
|
||||||
|
#include "CommandLineArgs.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
class MainApplication;
|
||||||
|
class DesktopManager;
|
||||||
|
class AbstractUiInterface;
|
||||||
|
|
||||||
class GuiApplication : public AbstractDesktopApp
|
class GuiApplication : public AbstractDesktopApp
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
DesktopManagerUPtr mDesktopManager;
|
|
||||||
MainApplicationPtr mMainApplication;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
GuiApplication(std::unique_ptr<CommandLineArgs> args = nullptr);
|
||||||
GuiApplication();
|
|
||||||
|
|
||||||
~GuiApplication();
|
~GuiApplication();
|
||||||
|
|
||||||
void SetMainApplication(MainApplicationPtr app);
|
AbstractApp* getMainApplication() const override;
|
||||||
|
|
||||||
void Run();
|
void run();
|
||||||
|
|
||||||
void SetUpWidget();
|
void setUiInterfaceBackend(UiInterfaceFactory::Backend backend);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void initializeViews();
|
||||||
|
|
||||||
|
std::unique_ptr<DesktopManager> mDesktopManager;
|
||||||
|
std::unique_ptr<MainApplication> mMainApplication;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UiInterfaceFactory::Backend mUiInterfaceBackend = UiInterfaceFactory::Backend::UNSET;
|
||||||
|
std::unique_ptr<AbstractUIInterface> mUiInterface;
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ MainApplication::~MainApplication()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainApplication::Initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext)
|
void MainApplication::initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext)
|
||||||
{
|
{
|
||||||
if (applicationContext)
|
if (applicationContext)
|
||||||
{
|
{
|
||||||
|
@ -137,7 +137,7 @@ void MainApplication::ShutDown()
|
||||||
FileLogger::GetInstance().Close();
|
FileLogger::GetInstance().Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MainApplication> MainApplication::Create()
|
std::unique_ptr<MainApplication> MainApplication::Create()
|
||||||
{
|
{
|
||||||
return std::make_shared<MainApplication>();
|
return std::make_unique<MainApplication>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,11 @@
|
||||||
class MainApplication : public AbstractApp
|
class MainApplication : public AbstractApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MainApplication();
|
MainApplication();
|
||||||
|
|
||||||
~MainApplication();
|
~MainApplication();
|
||||||
|
|
||||||
void Initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext=nullptr);
|
void initialize(CommandLineArgsUPtr commandLineArgs, std::unique_ptr<IApplicationContext> applicationContext=nullptr);
|
||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ public:
|
||||||
|
|
||||||
CommandLineArgs* GetCommandLineArgs() const;
|
CommandLineArgs* GetCommandLineArgs() const;
|
||||||
|
|
||||||
static std::shared_ptr<MainApplication> Create();
|
static std::unique_ptr<MainApplication> Create();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RunServer();
|
void RunServer();
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace mt
|
||||||
{
|
{
|
||||||
|
|
||||||
Window::Window()
|
Window::Window()
|
||||||
:mWidth(400),
|
:mWidth(800),
|
||||||
mHeight(300),
|
mHeight(600),
|
||||||
mWidget()
|
mWidget(Widget::Create())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,10 @@ void Window::OnPaint(const PaintEvent* event)
|
||||||
|
|
||||||
void Window::AddWidget(WidgetUPtr widget)
|
void Window::AddWidget(WidgetUPtr widget)
|
||||||
{
|
{
|
||||||
|
if (mWidget)
|
||||||
|
{
|
||||||
|
mWidget.reset();
|
||||||
|
}
|
||||||
mWidget = std::move(widget);
|
mWidget = std::move(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "AbstractApp.h"
|
||||||
|
|
||||||
class AbstractDesktopApp
|
class AbstractDesktopApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AbstractDesktopApp() = default;
|
AbstractDesktopApp() = default;
|
||||||
virtual ~AbstractDesktopApp() = default;
|
virtual ~AbstractDesktopApp() = default;
|
||||||
|
|
||||||
|
virtual AbstractApp* getMainApplication() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
using AbstractDesktopAppPtr = std::shared_ptr<AbstractDesktopApp>;
|
using AbstractDesktopAppPtr = std::shared_ptr<AbstractDesktopApp>;
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
#include "DesktopManager.h"
|
#include "DesktopManager.h"
|
||||||
|
|
||||||
|
#include "AbstractDesktopApp.h"
|
||||||
|
|
||||||
#include "FileLogger.h"
|
#include "FileLogger.h"
|
||||||
|
|
||||||
DesktopManager::DesktopManager()
|
DesktopManager::DesktopManager(AbstractDesktopApp* application)
|
||||||
: mScreens(),
|
: mScreens(),
|
||||||
mWindowManager(WindowManager::Create()),
|
mWindowManager(WindowManager::Create()),
|
||||||
mKeyboard(Keyboard::Create()),
|
mKeyboard(Keyboard::Create()),
|
||||||
mMainApplication(),
|
mUiApplication(application),
|
||||||
mModified(false),
|
mModified(false),
|
||||||
mEventManager(EventManager::Create())
|
mEventManager(EventManager::Create())
|
||||||
{
|
{
|
||||||
|
@ -18,9 +20,9 @@ DesktopManager::~DesktopManager()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DesktopManager> DesktopManager::Create()
|
std::unique_ptr<DesktopManager> DesktopManager::Create(AbstractDesktopApp* application)
|
||||||
{
|
{
|
||||||
return std::make_unique<DesktopManager>();
|
return std::make_unique<DesktopManager>(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopManager::ClearEvents()
|
void DesktopManager::ClearEvents()
|
||||||
|
@ -100,14 +102,9 @@ void DesktopManager::SetKeyboard(KeyboardUPtr keyboard)
|
||||||
mKeyboard = std::move(keyboard);
|
mKeyboard = std::move(keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopManager::SetMainApp(std::shared_ptr<AbstractApp> mainApp)
|
AbstractApp* DesktopManager::getMainApp() const
|
||||||
{
|
{
|
||||||
mMainApplication = mainApp;
|
return mUiApplication->getMainApplication();
|
||||||
}
|
|
||||||
|
|
||||||
AbstractApp* DesktopManager::GetMainApp()
|
|
||||||
{
|
|
||||||
return mMainApplication.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopManager::AddScreen(ScreenPtr screen)
|
void DesktopManager::AddScreen(ScreenPtr screen)
|
||||||
|
|
|
@ -13,21 +13,21 @@
|
||||||
#include "AbstractApp.h"
|
#include "AbstractApp.h"
|
||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
|
|
||||||
|
class AbstractDesktopApp;
|
||||||
|
|
||||||
class DesktopManager
|
class DesktopManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DesktopManager();
|
DesktopManager(AbstractDesktopApp* application);
|
||||||
|
|
||||||
~DesktopManager();
|
~DesktopManager();
|
||||||
|
|
||||||
static std::unique_ptr<DesktopManager> Create();
|
static std::unique_ptr<DesktopManager> Create(AbstractDesktopApp* application);
|
||||||
|
|
||||||
void SetWindowManager(WindowManagerUPtr windowManager);
|
void SetWindowManager(WindowManagerUPtr windowManager);
|
||||||
|
|
||||||
void SetMainApp(std::shared_ptr<AbstractApp> mainApp);
|
AbstractApp* getMainApp() const;
|
||||||
|
|
||||||
AbstractApp* GetMainApp();
|
|
||||||
|
|
||||||
WindowManager* GetWindowManager() const;
|
WindowManager* GetWindowManager() const;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ private:
|
||||||
WindowManagerUPtr mWindowManager;
|
WindowManagerUPtr mWindowManager;
|
||||||
KeyboardUPtr mKeyboard;
|
KeyboardUPtr mKeyboard;
|
||||||
EventManagerUPtr mEventManager;
|
EventManagerUPtr mEventManager;
|
||||||
std::shared_ptr<AbstractApp> mMainApplication;
|
AbstractDesktopApp* mUiApplication;
|
||||||
bool mModified;
|
bool mModified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,18 @@ namespace mt
|
||||||
class Window;
|
class Window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DesktopManager;
|
||||||
|
|
||||||
class AbstractUIInterface
|
class AbstractUIInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
AbstractUIInterface(DesktopManager* desktopManager, bool useHardware = false)
|
||||||
|
: mDesktopManager(desktopManager),
|
||||||
|
mUseHardwareRendering(useHardware)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~AbstractUIInterface() = default;
|
virtual ~AbstractUIInterface() = default;
|
||||||
|
|
||||||
virtual void initialize() = 0;
|
virtual void initialize() = 0;
|
||||||
|
@ -26,5 +35,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
DesktopManager* mDesktopManager{nullptr};
|
||||||
bool mUseHardwareRendering{false};
|
bool mUseHardwareRendering{false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,13 +10,15 @@
|
||||||
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
|
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
if (backend == Backend::UNSET || backend == Backend::X11)
|
if (backend == Backend::UNSET || backend == Backend::X11 || backend == Backend::X11_RASTER)
|
||||||
{
|
{
|
||||||
return std::make_unique<XcbInterface>(desktopManager);
|
const bool use_hardware = (backend != Backend::X11_RASTER);
|
||||||
|
return std::make_unique<XcbInterface>(desktopManager, use_hardware);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return std::make_unique<WaylandInterface>(desktopManager);
|
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
|
||||||
|
return std::make_unique<WaylandInterface>(desktopManager, use_hardware);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return std::make_unique<Win32UiInterface>();
|
return std::make_unique<Win32UiInterface>();
|
||||||
|
|
|
@ -12,7 +12,9 @@ public:
|
||||||
enum class Backend
|
enum class Backend
|
||||||
{
|
{
|
||||||
UNSET,
|
UNSET,
|
||||||
|
X11_RASTER,
|
||||||
X11,
|
X11,
|
||||||
|
WAYLAND_RASTER,
|
||||||
WAYLAND
|
WAYLAND
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,8 @@ void WaylandInterface::registryHandleGlobalRemoveEvent(void *data, struct wl_reg
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaylandInterface::WaylandInterface(DesktopManager* desktopManager, bool useHardware)
|
||||||
WaylandInterface::WaylandInterface(DesktopManager* desktopManager)
|
: AbstractUIInterface(desktopManager, useHardware),
|
||||||
: mDesktopManager(desktopManager),
|
|
||||||
mBuffer(std::make_shared<WaylandBuffer>())
|
mBuffer(std::make_shared<WaylandBuffer>())
|
||||||
{
|
{
|
||||||
mRegistryListener.global = registryHandleGlobalEvent;
|
mRegistryListener.global = registryHandleGlobalEvent;
|
||||||
|
|
|
@ -14,13 +14,12 @@ class WaylandSurface;
|
||||||
class WaylandBuffer;
|
class WaylandBuffer;
|
||||||
class WaylandSeatInterface;
|
class WaylandSeatInterface;
|
||||||
class WaylandEglInterface;
|
class WaylandEglInterface;
|
||||||
class DesktopManager;
|
|
||||||
|
|
||||||
class WaylandInterface : public AbstractUIInterface
|
class WaylandInterface : public AbstractUIInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WaylandInterface(DesktopManager* desktopManager);
|
WaylandInterface(DesktopManager* desktopManager, bool useHardware = true);
|
||||||
|
|
||||||
~WaylandInterface();
|
~WaylandInterface();
|
||||||
|
|
||||||
|
@ -48,8 +47,6 @@ private:
|
||||||
|
|
||||||
void setXdgBase(xdg_wm_base* xdg_base);
|
void setXdgBase(xdg_wm_base* xdg_base);
|
||||||
|
|
||||||
DesktopManager* mDesktopManager{nullptr};
|
|
||||||
|
|
||||||
wl_display* mDisplay{nullptr};
|
wl_display* mDisplay{nullptr};
|
||||||
wl_compositor* mCompositor{nullptr};
|
wl_compositor* mCompositor{nullptr};
|
||||||
wl_registry_listener mRegistryListener;
|
wl_registry_listener mRegistryListener;
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#include "FileLogger.h"
|
#include "FileLogger.h"
|
||||||
|
|
||||||
|
|
||||||
XcbInterface::XcbInterface(DesktopManager* desktopManager)
|
XcbInterface::XcbInterface(DesktopManager* desktopManager, bool useHardware)
|
||||||
: mDesktopManager(desktopManager),
|
: AbstractUIInterface(desktopManager, useHardware),
|
||||||
mConnection(nullptr),
|
mConnection(nullptr),
|
||||||
mX11Display(),
|
mX11Display(),
|
||||||
mGlxInterface(),
|
mGlxInterface(),
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class DesktopManager;
|
|
||||||
class GlxInterface;
|
class GlxInterface;
|
||||||
using GlxInterfacePtr = std::unique_ptr<GlxInterface>;
|
using GlxInterfacePtr = std::unique_ptr<GlxInterface>;
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ namespace mt
|
||||||
class XcbInterface : public AbstractUIInterface
|
class XcbInterface : public AbstractUIInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XcbInterface(DesktopManager* desktopManager);
|
XcbInterface(DesktopManager* desktopManager, bool useHardware = true);
|
||||||
|
|
||||||
~XcbInterface();
|
~XcbInterface();
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ private:
|
||||||
uint32_t getEventMask();
|
uint32_t getEventMask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DesktopManager* mDesktopManager{nullptr};
|
|
||||||
xcb_connection_t* mConnection;
|
xcb_connection_t* mConnection;
|
||||||
_XDisplay* mX11Display;
|
_XDisplay* mX11Display;
|
||||||
GlxInterfacePtr mGlxInterface;
|
GlxInterfacePtr mGlxInterface;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#include "DesktopManager.h"
|
|
||||||
#include "XcbInterface.h"
|
|
||||||
|
|
||||||
#include "TestCase.h"
|
#include "TestCase.h"
|
||||||
#include "TestCaseRunner.h"
|
#include "TestCaseRunner.h"
|
||||||
|
|
||||||
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -13,18 +12,11 @@ class TestOpenGlRendering : public TestCase
|
||||||
public:
|
public:
|
||||||
bool Run() override
|
bool Run() override
|
||||||
{
|
{
|
||||||
auto desktopManager = DesktopManager::Create();
|
auto app = std::make_unique<GuiApplication>();
|
||||||
|
|
||||||
auto mainWindow = desktopManager->GetWindowManager()->GetMainWindow();
|
//app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11);
|
||||||
mainWindow->SetSize(800, 600);
|
app->setUiInterfaceBackend(UiInterfaceFactory::Backend::X11_RASTER);
|
||||||
|
app->run();
|
||||||
XcbInterface window_interface(desktopManager.get());
|
|
||||||
window_interface.setUseHardwareRendering(true);
|
|
||||||
window_interface.initialize();
|
|
||||||
window_interface.addWindow(mainWindow);
|
|
||||||
window_interface.showWindow(mainWindow);
|
|
||||||
window_interface.loop();
|
|
||||||
window_interface.shutDown();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,27 +3,18 @@
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "FileLogger.h"
|
#include "FileLogger.h"
|
||||||
|
|
||||||
#include "DesktopManager.h"
|
#include "GuiApplication.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
FileLogger::GetInstance().Open();
|
FileLogger::GetInstance().Open();
|
||||||
|
|
||||||
auto desktop_manager = DesktopManager::Create();
|
auto app = std::make_unique<GuiApplication>();
|
||||||
|
|
||||||
auto window = desktop_manager->GetWindowManager()->GetMainWindow();
|
//app->setUiInterfaceBackend(UiInterfaceFactory::Backend::WAYLAND);
|
||||||
window->SetSize(800, 600);
|
app->setUiInterfaceBackend(UiInterfaceFactory::Backend::WAYLAND_RASTER);
|
||||||
|
|
||||||
WaylandInterface window_interface(desktop_manager.get());
|
app->run();
|
||||||
window_interface.setUseHardwareRendering(true);
|
|
||||||
window_interface.initialize();
|
|
||||||
|
|
||||||
window_interface.addWindow(window);
|
|
||||||
|
|
||||||
window_interface.showWindow(window);
|
|
||||||
|
|
||||||
window_interface.loop();
|
|
||||||
|
|
||||||
window_interface.shutDown();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue