CmEditorWindowManager.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "CmEditorPrerequisites.h"
  3. #include "CmModule.h"
  4. #include <boost/function.hpp>
  5. #include <QtCore/QString>
  6. #include <QtCore/QPoint>
  7. namespace CamelotEditor
  8. {
  9. class EditorWindowManager : public Module<EditorWindowManager>
  10. {
  11. public:
  12. EditorWindowManager();
  13. void registerWidgetFactory(EditorWidgetFactory* factory);
  14. /**
  15. * @brief Opens a widget with the specified name and adds it to a window. Only one widget of a
  16. * certain type may be open at one time.
  17. *
  18. * @param name The name of the widget type. This will be used to find the widget factory.
  19. * @param parent (optional) Parent to which to attach the widget to. If null, a new window will be created.
  20. *
  21. * @return Returns the window the widget was added to.
  22. */
  23. void openWidget(const QString& name, QtEditorWindow* parent = nullptr);
  24. boost::function<void()> getOpenCallback(const QString& name);
  25. QtEditorWindow* openWindow(INT32 forcedId = -1);
  26. QtEditorWindow* getOpenWindow(INT32 id) const;
  27. QtEditorWindow* getWindowAtPosition(const QPoint& globalPos, Vector<UINT32>::type windowsToIgnore = Vector<UINT32>::type()) const;
  28. void restoreWindowsFromPrefs();
  29. void saveWindowsToPrefs();
  30. Vector<QString>::type getAvailableWindowTypes() const;
  31. private:
  32. Map<QString, EditorWidgetFactory*>::type mFactories;
  33. Map<INT32, QtEditorWindow*>::type mOpenWindows;
  34. Map<QString, QtEditorWidget*>::type mOpenWidgets;
  35. UINT32 mMaxOpenWindowId;
  36. EditorWidgetFactory* getFactory(const QString& name) const;
  37. void widgetClosed(QtEditorWidget* window);
  38. void windowClosed(QtEditorWindow* window);
  39. };
  40. EditorWindowManager& gEditorWindowManager();
  41. }