#pragma once

#include <vector>
#include <memory>

#include "Keyboard.h"
#include "Screen.h"
#include "KeyboardEvent.h"
#include "PaintEvent.h"
#include "MouseEvent.h"
#include "WindowManager.h"
#include "UiEvent.h"
#include "AbstractApp.h"
#include "EventManager.h"

class DesktopManager
{
public:

    DesktopManager();

    ~DesktopManager();

    static std::unique_ptr<DesktopManager> Create();

    void SetWindowManager(WindowManagerUPtr windowManager);

    void SetMainApp(std::shared_ptr<AbstractApp> mainApp);

    AbstractApp* GetMainApp();

    WindowManager* GetWindowManager() const;

    Keyboard* GetKeyboard() const;

    void AddScreen(ScreenPtr screen);

    mt::Screen* GetDefaultScreen() const;

    bool IsModified() const;

    void SetIsModified(bool modified);

    void SetKeyboard(KeyboardUPtr keyboard);

    void OnUiEvent(UiEventUPtr event);

    void OnKeyboardEvent(const KeyboardEvent* keyboardEvent);

    void OnMouseEvent(const MouseEvent* mouseEvent);

    void OnPaintEvent(const PaintEvent* paintEvent);

    void ClearEvents();

private:
    std::vector<ScreenPtr> mScreens;
    WindowManagerUPtr mWindowManager;
    KeyboardUPtr mKeyboard;
    EventManagerUPtr mEventManager;
    std::shared_ptr<AbstractApp> mMainApplication;
    bool mModified;
};

using DesktopManagerUPtr = std::unique_ptr<DesktopManager>;
