ui: Abstracting the UI on view level instead of element level
This change switches the view creation architecture from element based creation in the lib to view based creation in the app. This avoids wrapping of the Qt elements and instead defines interfaces for the different View implementations. * GuiElementFactory was renamed to GuiFactory and is now responsible for View creation instead of Element creation. * WidgetWrappers are now used on Views to access their root widget. * Removed DummyView and DummyController. * Removed GuiElement and corresponding QtElement files. * Removed ViewManager, functionality is now handled via MainView. * Added MainView, where Views are registered via the ViewLayout interface. * Added QtMainWindow, derived from QMainWindow and instantiated by QtMainView, which displays the Views as QDockWidgets. fortune cookie message = All your hard work will soon pay off.
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
#include "Application.h"
|
||||
|
||||
#include "gui/GuiCanvas.h"
|
||||
#include "component/view/MainView.h"
|
||||
#include "gui/GuiFactory.h"
|
||||
#include "utility/logging/ConsoleLogger.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
|
||||
std::shared_ptr<Application> Application::create(std::shared_ptr<GuiElementFactory> guiElementFactory, std::shared_ptr<GuiWindow> window)
|
||||
std::shared_ptr<Application> Application::create(GuiFactory* guiFactory)
|
||||
{
|
||||
std::shared_ptr<ConsoleLogger> consoleLogger = std::make_shared<ConsoleLogger>();
|
||||
LogManager::getInstance()->addLogger(consoleLogger);
|
||||
|
||||
std::shared_ptr<GuiCanvas> canvas = guiElementFactory->createCanvas(window);
|
||||
canvas->setBackgroundColor(255, 0, 0, 255);
|
||||
|
||||
std::shared_ptr<Application> ptr(new Application());
|
||||
ptr->m_viewManager = std::make_shared<ViewManager>(canvas);
|
||||
|
||||
ptr->m_codeAccess = std::make_shared<CodeAccess>();
|
||||
ptr->m_graphAccess = std::make_shared<GraphAccess>();
|
||||
|
||||
ptr->m_mainView = guiFactory->createMainView();
|
||||
ptr->m_componentManager =
|
||||
ComponentManager::create(ptr->m_viewManager, guiElementFactory, ptr->m_codeAccess, ptr->m_graphAccess);
|
||||
ComponentManager::create(guiFactory, ptr->m_mainView.get(), ptr->m_codeAccess, ptr->m_graphAccess);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,17 @@
|
||||
#include <memory>
|
||||
|
||||
#include "component/ComponentManager.h"
|
||||
#include "component/view/ViewManager.h"
|
||||
#include "data/access/CodeAccess.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
#include "gui/GuiElementFactory.h"
|
||||
#include "Project.h"
|
||||
|
||||
class GuiFactory;
|
||||
class MainView;
|
||||
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(std::shared_ptr<GuiElementFactory> guiElementFactory, std::shared_ptr<GuiWindow> window);
|
||||
static std::shared_ptr<Application> create(GuiFactory* guiFactory);
|
||||
|
||||
~Application();
|
||||
|
||||
@@ -27,9 +28,8 @@ private:
|
||||
std::shared_ptr<CodeAccess> m_codeAccess;
|
||||
std::shared_ptr<GraphAccess> m_graphAccess;
|
||||
|
||||
std::shared_ptr<MainView> m_mainView;
|
||||
std::shared_ptr<ComponentManager> m_componentManager;
|
||||
std::shared_ptr<ViewManager> m_viewManager;
|
||||
};
|
||||
|
||||
|
||||
#endif // APPLICATION_H
|
||||
|
||||
+10
-26
@@ -20,17 +20,15 @@ add_files(
|
||||
component/controller/CodeController.h
|
||||
component/controller/Controller.cpp
|
||||
component/controller/Controller.h
|
||||
component/controller/DummyController.cpp
|
||||
component/controller/DummyController.h
|
||||
|
||||
component/view/CodeView.cpp
|
||||
component/view/CodeView.h
|
||||
component/view/DummyView.cpp
|
||||
component/view/DummyView.h
|
||||
component/view/MainView.cpp
|
||||
component/view/MainView.h
|
||||
component/view/View.cpp
|
||||
component/view/View.h
|
||||
component/view/ViewManager.cpp
|
||||
component/view/ViewManager.h
|
||||
component/view/ViewLayout.cpp
|
||||
component/view/ViewLayout.h
|
||||
|
||||
component/Component.cpp
|
||||
component/Component.h
|
||||
@@ -78,27 +76,11 @@ add_files(
|
||||
data/Storage.cpp
|
||||
data/Storage.h
|
||||
|
||||
gui/GuiArea.cpp
|
||||
gui/GuiArea.h
|
||||
gui/GuiCanvas.cpp
|
||||
gui/GuiCanvas.h
|
||||
gui/GuiContainer.cpp
|
||||
gui/GuiContainer.h
|
||||
gui/GuiControl.cpp
|
||||
gui/GuiControl.h
|
||||
gui/GuiElement.cpp
|
||||
gui/GuiElement.h
|
||||
gui/GuiElementFactory.cpp
|
||||
gui/GuiElementFactory.h
|
||||
gui/GuiLayout.cpp
|
||||
gui/GuiLayout.h
|
||||
gui/GuiWindow.cpp
|
||||
gui/GuiWindow.h
|
||||
gui/WidgetWrapper.cpp
|
||||
gui/WidgetWrapper.h
|
||||
gui/GuiFactory.cpp
|
||||
gui/GuiFactory.h
|
||||
gui/GuiWidgetWrapper.cpp
|
||||
gui/GuiWidgetWrapper.h
|
||||
|
||||
utility/logging/PlainFileLogger.cpp
|
||||
utility/logging/PlainFileLogger.h
|
||||
utility/logging/ConsoleLogger.cpp
|
||||
utility/logging/ConsoleLogger.h
|
||||
utility/logging/FileLogger.cpp
|
||||
@@ -111,6 +93,8 @@ add_files(
|
||||
utility/logging/LogManagerImplementation.cpp
|
||||
utility/logging/LogManagerImplementation.h
|
||||
utility/logging/LogMessage.h
|
||||
utility/logging/PlainFileLogger.cpp
|
||||
utility/logging/PlainFileLogger.h
|
||||
|
||||
utility/math/Color.h
|
||||
utility/math/Vector2.h
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "component/ComponentFactory.h"
|
||||
|
||||
#include "component/controller/CodeController.h"
|
||||
#include "component/controller/DummyController.h"
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/DummyView.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
#include "gui/GuiFactory.h"
|
||||
|
||||
std::shared_ptr<ComponentFactory> ComponentFactory::create(
|
||||
std::shared_ptr<ViewManager> viewManager,
|
||||
std::shared_ptr<GuiElementFactory> guiElementFactory,
|
||||
GuiFactory* guiFactory,
|
||||
ViewLayout* viewLayout,
|
||||
std::shared_ptr<CodeAccess> codeAccess,
|
||||
std::shared_ptr<GraphAccess> graphAccess)
|
||||
{
|
||||
std::shared_ptr<ComponentFactory> ptr(new ComponentFactory());
|
||||
ptr->m_viewManger = viewManager;
|
||||
ptr->m_guiElementFactory = guiElementFactory;
|
||||
ptr->m_guiFactory = guiFactory;
|
||||
ptr->m_viewLayout = viewLayout;
|
||||
ptr->m_codeAccess = codeAccess;
|
||||
ptr->m_graphAccess = graphAccess;
|
||||
return ptr;
|
||||
@@ -23,18 +23,9 @@ ComponentFactory::~ComponentFactory()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createDummyComponent()
|
||||
{
|
||||
std::shared_ptr<View> view = std::make_shared<DummyView>(m_viewManger, m_guiElementFactory);
|
||||
std::shared_ptr<Controller> controller = std::make_shared<DummyController>();
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createCodeComponent()
|
||||
{
|
||||
std::shared_ptr<View> view = m_guiElementFactory->createCodeView(m_viewManger);
|
||||
std::shared_ptr<View> view = m_guiFactory->createCodeView(m_viewLayout);
|
||||
std::shared_ptr<Controller> controller = std::make_shared<CodeController>();
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
|
||||
@@ -4,31 +4,31 @@
|
||||
#include <memory>
|
||||
|
||||
#include "component/Component.h"
|
||||
#include "component/view/ViewManager.h"
|
||||
#include "data/access/CodeAccess.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
#include "gui/GuiElementFactory.h"
|
||||
|
||||
class GuiFactory;
|
||||
class ViewLayout;
|
||||
|
||||
class ComponentFactory
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ComponentFactory> create(
|
||||
std::shared_ptr<ViewManager> viewManager,
|
||||
std::shared_ptr<GuiElementFactory> guiElementFactory,
|
||||
GuiFactory* guiFactory,
|
||||
ViewLayout* viewLayout,
|
||||
std::shared_ptr<CodeAccess> codeAccess,
|
||||
std::shared_ptr<GraphAccess> graphAccess);
|
||||
|
||||
~ComponentFactory();
|
||||
|
||||
std::shared_ptr<Component> createDummyComponent();
|
||||
std::shared_ptr<Component> createCodeComponent();
|
||||
|
||||
private:
|
||||
ComponentFactory();
|
||||
ComponentFactory(const ComponentFactory&);
|
||||
|
||||
std::shared_ptr<ViewManager> m_viewManger;
|
||||
std::shared_ptr<GuiElementFactory> m_guiElementFactory;
|
||||
GuiFactory* m_guiFactory;
|
||||
ViewLayout* m_viewLayout;
|
||||
|
||||
std::shared_ptr<CodeAccess> m_codeAccess;
|
||||
std::shared_ptr<GraphAccess> m_graphAccess;
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
#include "component/ComponentManager.h"
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
std::shared_ptr<ComponentManager> ComponentManager::create(
|
||||
std::shared_ptr<ViewManager> viewManager,
|
||||
std::shared_ptr<GuiElementFactory> guiElementFactory,
|
||||
GuiFactory* guiFactory,
|
||||
ViewLayout* viewLayout,
|
||||
std::shared_ptr<CodeAccess> codeAccess,
|
||||
std::shared_ptr<GraphAccess> graphAccess)
|
||||
{
|
||||
std::shared_ptr<ComponentManager> ptr(new ComponentManager());
|
||||
ptr->m_componentFactory = ComponentFactory::create(viewManager, guiElementFactory, codeAccess, graphAccess);
|
||||
ptr->m_componentFactory = ComponentFactory::create(guiFactory, viewLayout, codeAccess, graphAccess);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ComponentManager::~ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ComponentManager::setup()
|
||||
{
|
||||
m_components.push_back(m_componentFactory->createDummyComponent());
|
||||
|
||||
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent();
|
||||
m_components.push_back(codeComponent);
|
||||
|
||||
@@ -29,7 +32,3 @@ void ComponentManager::setup()
|
||||
ComponentManager::ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
ComponentManager::~ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,19 +4,20 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "data/access/CodeAccess.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
#include "component/Component.h"
|
||||
#include "component/ComponentFactory.h"
|
||||
#include "component/view/ViewManager.h"
|
||||
#include "gui/GuiElementFactory.h"
|
||||
#include "data/access/CodeAccess.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
|
||||
class GuiFactory;
|
||||
class ViewLayout;
|
||||
|
||||
class ComponentManager
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ComponentManager> create(
|
||||
std::shared_ptr<ViewManager> viewManager,
|
||||
std::shared_ptr<GuiElementFactory> guiElementFactory,
|
||||
GuiFactory* guiFactory,
|
||||
ViewLayout* viewLayout,
|
||||
std::shared_ptr<CodeAccess> codeAccess,
|
||||
std::shared_ptr<GraphAccess> graphAccess);
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "component/controller/DummyController.h"
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef DUMMY_CONTROLLER_H
|
||||
#define DUMMY_CONTROLLER_H
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
class DummyController: public Controller
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
#endif // DUMMY_CONTROLLER_H
|
||||
@@ -1,10 +1,15 @@
|
||||
#include "component/view/CodeView.h"
|
||||
|
||||
CodeView::CodeView(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElement> rootElement)
|
||||
: View(viewManager, rootElement, Vec2i(100, 100))
|
||||
CodeView::CodeView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
{
|
||||
}
|
||||
|
||||
CodeView::~CodeView()
|
||||
{
|
||||
}
|
||||
|
||||
std::string CodeView::getName() const
|
||||
{
|
||||
return "CodeView";
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
#ifndef CODE_VIEW_H
|
||||
#define CODE_VIEW_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "component/view/View.h"
|
||||
|
||||
class GuiElementFactory;
|
||||
|
||||
class CodeView: public View
|
||||
{
|
||||
public:
|
||||
CodeView(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElement> rootElement);
|
||||
CodeView(ViewLayout* viewLayout);
|
||||
virtual ~CodeView();
|
||||
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void addCodeSnippet(std::string str) = 0;
|
||||
virtual void clearCodeSnippets() = 0;
|
||||
};
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "component/view/DummyView.h"
|
||||
|
||||
#include "gui/GuiArea.h"
|
||||
#include "gui/GuiElementFactory.h"
|
||||
|
||||
DummyView::DummyView(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElementFactory> guiElementFactory)
|
||||
: View(viewManager, guiElementFactory->createArea(), Vec2i(100, 100))
|
||||
, m_guiElementFactory(guiElementFactory)
|
||||
{
|
||||
getRootElement()->setBackgroundColor(0, 255, 0, 255);
|
||||
}
|
||||
|
||||
DummyView::~DummyView()
|
||||
{
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef DUMMY_VIEW_H
|
||||
#define DUMMY_VIEW_H
|
||||
|
||||
#include "component/view/View.h"
|
||||
|
||||
class GuiElementFactory;
|
||||
|
||||
class DummyView: public View
|
||||
{
|
||||
public:
|
||||
DummyView(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElementFactory> guiElementFactory);
|
||||
virtual ~DummyView();
|
||||
|
||||
private:
|
||||
std::shared_ptr<GuiElementFactory> m_guiElementFactory;
|
||||
};
|
||||
|
||||
|
||||
#endif // DUMMY_VIEW_H
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "component/view/MainView.h"
|
||||
|
||||
MainView::MainView()
|
||||
{
|
||||
}
|
||||
|
||||
MainView::~MainView()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef MAIN_VIEW_H
|
||||
#define MAIN_VIEW_H
|
||||
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
class MainView: public ViewLayout
|
||||
{
|
||||
public:
|
||||
MainView();
|
||||
virtual ~MainView();
|
||||
};
|
||||
|
||||
#endif // MAIN_VIEW_H
|
||||
@@ -1,22 +1,21 @@
|
||||
#include "component/view/View.h"
|
||||
#include "component/view/ViewManager.h"
|
||||
|
||||
View::View(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElement> rootElement, const Vec2i& minSize)
|
||||
: m_viewManager(viewManager)
|
||||
, m_rootElement(rootElement)
|
||||
, m_minSize(minSize)
|
||||
{
|
||||
m_viewManager->addView(this);
|
||||
}
|
||||
#include "component/view/ViewLayout.h"
|
||||
#include "gui/GuiWidgetWrapper.h"
|
||||
|
||||
View::~View()
|
||||
{
|
||||
m_viewManager->removeView(this);
|
||||
m_viewLayout->removeView(this);
|
||||
}
|
||||
|
||||
std::shared_ptr<GuiElement> View::getRootElement()
|
||||
void View::setWidgetWrapper(std::shared_ptr<GuiWidgetWrapper> widgetWrapper)
|
||||
{
|
||||
return m_rootElement;
|
||||
m_widgetWrapper = widgetWrapper;
|
||||
}
|
||||
|
||||
GuiWidgetWrapper* View::getWidgetWrapper()
|
||||
{
|
||||
return m_widgetWrapper.get();
|
||||
}
|
||||
|
||||
int View::getMinWidth() const
|
||||
@@ -33,3 +32,10 @@ Vec2i View::getMinSize() const
|
||||
{
|
||||
return m_minSize;
|
||||
}
|
||||
|
||||
View::View(ViewLayout* viewLayout, const Vec2i& minSize)
|
||||
: m_viewLayout(viewLayout)
|
||||
, m_widgetWrapper(nullptr)
|
||||
, m_minSize(minSize)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,28 +2,54 @@
|
||||
#define VIEW_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "component/view/ViewLayout.h"
|
||||
#include "utility/math/Vector2.h"
|
||||
|
||||
class GuiElement;
|
||||
class ViewManager;
|
||||
class GuiWidgetWrapper;
|
||||
class ViewLayout;
|
||||
|
||||
class View
|
||||
{
|
||||
public:
|
||||
View(std::shared_ptr<ViewManager> viewManager, std::shared_ptr<GuiElement> rootElement, const Vec2i& minSize);
|
||||
template<typename T>
|
||||
static std::shared_ptr<T> create(ViewLayout* viewLayout);
|
||||
|
||||
virtual ~View();
|
||||
|
||||
std::shared_ptr<GuiElement> getRootElement();
|
||||
virtual std::string getName() const = 0;
|
||||
|
||||
virtual void createWidgetWrapper() = 0;
|
||||
void setWidgetWrapper(std::shared_ptr<GuiWidgetWrapper> widgetWrapper);
|
||||
GuiWidgetWrapper* getWidgetWrapper();
|
||||
|
||||
virtual void initGui() = 0;
|
||||
|
||||
int getMinWidth() const;
|
||||
int getMinHeight() const;
|
||||
Vec2i getMinSize() const;
|
||||
|
||||
protected:
|
||||
View(ViewLayout* viewLayout, const Vec2i& minSize);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ViewManager> m_viewManager;
|
||||
std::shared_ptr<GuiElement> m_rootElement;
|
||||
ViewLayout* const m_viewLayout;
|
||||
std::shared_ptr<GuiWidgetWrapper> m_widgetWrapper;
|
||||
Vec2i m_minSize;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<T> View::create(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<T> ptr = std::make_shared<T>(viewLayout);
|
||||
|
||||
ptr->createWidgetWrapper();
|
||||
ptr->initGui();
|
||||
|
||||
viewLayout->addView(ptr.get());
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif // VIEW_H
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
ViewLayout::ViewLayout()
|
||||
{
|
||||
}
|
||||
|
||||
ViewLayout::~ViewLayout()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef VIEW_LAYOUT_H
|
||||
#define VIEW_LAYOUT_H
|
||||
|
||||
class View;
|
||||
|
||||
class ViewLayout
|
||||
{
|
||||
public:
|
||||
ViewLayout();
|
||||
virtual ~ViewLayout();
|
||||
|
||||
virtual void addView(View* view) = 0;
|
||||
virtual void removeView(View* view) = 0;
|
||||
};
|
||||
|
||||
#endif // VIEW_LAYOUT_H
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "component/view/ViewManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "gui/GuiCanvas.h"
|
||||
#include "View.h"
|
||||
|
||||
ViewManager::ViewManager(std::shared_ptr<GuiCanvas> canvas)
|
||||
: m_canvas(canvas)
|
||||
{
|
||||
}
|
||||
|
||||
ViewManager::~ViewManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewManager::addView(View* view)
|
||||
{
|
||||
m_views.push_back(view);
|
||||
m_canvas->addChild(view->getRootElement());
|
||||
}
|
||||
|
||||
void ViewManager::removeView(View* view)
|
||||
{
|
||||
std::vector<View*>::iterator it = std::find(m_views.begin(), m_views.end(), view);
|
||||
if (it != m_views.end())
|
||||
{
|
||||
m_canvas->removeChild((*it)->getRootElement());
|
||||
m_views.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef VIEW_MANAGER_H
|
||||
#define VIEW_MANAGER_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class GuiCanvas;
|
||||
class View;
|
||||
|
||||
class ViewManager
|
||||
{
|
||||
public:
|
||||
ViewManager(std::shared_ptr<GuiCanvas> canvas);
|
||||
~ViewManager();
|
||||
|
||||
void addView(View* view);
|
||||
void removeView(View* view);
|
||||
|
||||
private:
|
||||
std::shared_ptr<GuiCanvas> m_canvas;
|
||||
std::vector<View*> m_views;
|
||||
};
|
||||
|
||||
|
||||
#endif // VIEW_MANAGER_H
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "gui/GuiArea.h"
|
||||
|
||||
GuiArea::GuiArea(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: GuiControl(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiArea::~GuiArea()
|
||||
{
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef GUI_AREA_H
|
||||
#define GUI_AREA_H
|
||||
|
||||
#include "gui/GuiControl.h"
|
||||
|
||||
class GuiArea: public GuiControl
|
||||
{
|
||||
public:
|
||||
GuiArea(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiArea();
|
||||
|
||||
};
|
||||
|
||||
#endif // GUI_AREA_H
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "gui/GuiCanvas.h"
|
||||
|
||||
GuiCanvas::GuiCanvas(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: GuiContainer(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiCanvas::~GuiCanvas()
|
||||
{
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef GUI_CANVAS_H
|
||||
#define GUI_CANVAS_H
|
||||
|
||||
#include "gui/GuiContainer.h"
|
||||
|
||||
class GuiCanvas: public GuiContainer
|
||||
{
|
||||
public:
|
||||
GuiCanvas(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiCanvas();
|
||||
};
|
||||
|
||||
#endif // GUI_CANVAS_H
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "gui/GuiContainer.h"
|
||||
|
||||
GuiContainer::GuiContainer(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: GuiElement(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiContainer::~GuiContainer()
|
||||
{
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef GUI_CONTAINER_H
|
||||
#define GUI_CONTAINER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "gui/GuiElement.h"
|
||||
|
||||
class GuiContainer: public GuiElement
|
||||
{
|
||||
public:
|
||||
GuiContainer(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiContainer();
|
||||
|
||||
virtual void addChild(std::shared_ptr<GuiElement> element) = 0;
|
||||
virtual void removeChild(std::shared_ptr<GuiElement> element) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // GUI_CONTAINER_H
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "gui/GuiControl.h"
|
||||
|
||||
GuiControl::GuiControl(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: GuiElement(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiControl::~GuiControl()
|
||||
{
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef GUI_CONTROL_H
|
||||
#define GUI_CONTROL_H
|
||||
|
||||
#include "gui/GuiElement.h"
|
||||
|
||||
class GuiControl: public GuiElement
|
||||
{
|
||||
public:
|
||||
GuiControl(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiControl();
|
||||
|
||||
};
|
||||
|
||||
#endif // GUI_CONTROL_H
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "gui/GuiElement.h"
|
||||
|
||||
#include "gui/WidgetWrapper.h"
|
||||
|
||||
GuiElement::GuiElement(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: m_widgetWrapper(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiElement::~GuiElement()
|
||||
{
|
||||
}
|
||||
|
||||
void GuiElement::setBackgroundColor(int r, int g, int b, int a)
|
||||
{
|
||||
setBackgroundColor(Colori(r, g, b, a));
|
||||
}
|
||||
|
||||
std::shared_ptr<WidgetWrapper> GuiElement::getWidgetWrapper()
|
||||
{
|
||||
return m_widgetWrapper;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef GUI_ELEMENT_H
|
||||
#define GUI_ELEMENT_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "utility/math/Color.h"
|
||||
#include "utility/math/Vector2.h"
|
||||
|
||||
class WidgetWrapper;
|
||||
|
||||
class GuiElement
|
||||
{
|
||||
public:
|
||||
GuiElement(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiElement();
|
||||
|
||||
virtual void setPosition(Vec2i position) = 0;
|
||||
virtual Vec2i getPosition() const = 0;
|
||||
virtual void setSize(Vec2i size) = 0;
|
||||
virtual Vec2i getSize() const = 0;
|
||||
|
||||
virtual void setBackgroundColor(Colori color) = 0;
|
||||
void setBackgroundColor(int r, int g, int b, int a);
|
||||
|
||||
//protected:
|
||||
std::shared_ptr<WidgetWrapper> getWidgetWrapper();
|
||||
|
||||
private:
|
||||
std::shared_ptr<WidgetWrapper> m_widgetWrapper;
|
||||
};
|
||||
|
||||
#endif // GUI_ELEMENT_H
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "gui/GuiElementFactory.h"
|
||||
|
||||
GuiElementFactory::~GuiElementFactory()
|
||||
{
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef GUI_ELEMENT_FACTORY_H
|
||||
#define GUI_ELEMENT_FACTORY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
class CodeView;
|
||||
|
||||
class GuiArea;
|
||||
class GuiCanvas;
|
||||
class GuiLayout;
|
||||
class GuiWindow;
|
||||
|
||||
class ViewManager;
|
||||
|
||||
class GuiElementFactory
|
||||
{
|
||||
public:
|
||||
virtual ~GuiElementFactory();
|
||||
|
||||
virtual std::shared_ptr<GuiArea> createArea() const = 0;
|
||||
virtual std::shared_ptr<GuiCanvas> createCanvas(std::shared_ptr<GuiWindow> window) const = 0;
|
||||
virtual std::shared_ptr<GuiLayout> createLayout() const = 0;
|
||||
|
||||
virtual std::shared_ptr<CodeView> createCodeView(std::shared_ptr<ViewManager> viewManager) const = 0;
|
||||
};
|
||||
|
||||
#endif // GUI_ELEMENT_FACTORY_H
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "gui/GuiFactory.h"
|
||||
|
||||
GuiFactory::GuiFactory()
|
||||
{
|
||||
}
|
||||
|
||||
GuiFactory::~GuiFactory()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef GUI_FACTORY_H
|
||||
#define GUI_FACTORY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
class CodeView;
|
||||
class MainView;
|
||||
class ViewLayout;
|
||||
|
||||
class GuiFactory
|
||||
{
|
||||
public:
|
||||
GuiFactory();
|
||||
virtual ~GuiFactory();
|
||||
|
||||
virtual std::shared_ptr<MainView> createMainView() const = 0;
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
|
||||
};
|
||||
|
||||
#endif // GUI_FACTORY_H
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "gui/GuiLayout.h"
|
||||
|
||||
GuiLayout::GuiLayout(std::shared_ptr<WidgetWrapper> widgetWrapper)
|
||||
: GuiContainer(widgetWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
GuiLayout::~GuiLayout()
|
||||
{
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef GUI_LAYOUT_H
|
||||
#define GUI_LAYOUT_H
|
||||
|
||||
#include "gui/GuiContainer.h"
|
||||
|
||||
class GuiLayout: public GuiContainer
|
||||
{
|
||||
public:
|
||||
enum LayoutDirectionType
|
||||
{
|
||||
LAYOUT_DIRECTION_HORIZONTAL,
|
||||
LAYOUT_DIRECTION_VERTICAL
|
||||
};
|
||||
|
||||
GuiLayout(std::shared_ptr<WidgetWrapper> widgetWrapper);
|
||||
virtual ~GuiLayout();
|
||||
|
||||
virtual void setDirection(LayoutDirectionType direction) = 0;
|
||||
|
||||
virtual void addChild(std::shared_ptr<GuiElement> element) = 0;
|
||||
virtual void removeChild(std::shared_ptr<GuiElement> element) = 0;
|
||||
};
|
||||
|
||||
#endif // GUI_LAYOUT_H
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "gui/GuiWidgetWrapper.h"
|
||||
|
||||
GuiWidgetWrapper::GuiWidgetWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
GuiWidgetWrapper::~GuiWidgetWrapper()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef GUI_WIDGET_WRAPPER_H
|
||||
#define GUI_WIDGET_WRAPPER_H
|
||||
|
||||
class GuiWidgetWrapper
|
||||
{
|
||||
public:
|
||||
GuiWidgetWrapper();
|
||||
virtual ~GuiWidgetWrapper();
|
||||
};
|
||||
|
||||
#endif // GUI_WIDGET_WRAPPER_H
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "gui/GuiWindow.h"
|
||||
|
||||
#include "gui/GuiCanvas.h"
|
||||
|
||||
GuiWindow::GuiWindow()
|
||||
{
|
||||
}
|
||||
|
||||
GuiWindow::~GuiWindow()
|
||||
{
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef GUI_WINDOW_H
|
||||
#define GUI_WINDOW_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
class GuiCanvas;
|
||||
|
||||
class GuiWindow
|
||||
{
|
||||
public:
|
||||
GuiWindow();
|
||||
virtual ~GuiWindow();
|
||||
|
||||
virtual void setCanvas(std::shared_ptr<GuiCanvas> canvas) = 0;
|
||||
};
|
||||
|
||||
#endif // GUI_WINDOW_H
|
||||
@@ -1,9 +0,0 @@
|
||||
#include "gui/WidgetWrapper.h"
|
||||
|
||||
WidgetWrapper::WidgetWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
WidgetWrapper::~WidgetWrapper()
|
||||
{
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef WIDGET_WRAPPER_H
|
||||
#define WIDGET_WRAPPER_H
|
||||
|
||||
class WidgetWrapper
|
||||
{
|
||||
public:
|
||||
WidgetWrapper();
|
||||
virtual ~WidgetWrapper();
|
||||
};
|
||||
|
||||
#endif // WIDGET_WRAPPER_H
|
||||
Reference in New Issue
Block a user