22#include <Common/assertion.h>
23#include <Common/primitive_type.h>
24#include <Utility/TFunction.h>
25#include <Utility/TUniquePtrVector.h>
26#include <Utility/INoCopyAndMove.h>
33namespace ph {
class Path; }
39class MainThreadUpdateContext;
40class MainThreadRenderUpdateContext;
41class RenderThreadCaller;
44class Editor final :
private INoCopyAndMove
78 std::size_t
createScene(
const Path& workingDirectory,
const std::string& name =
"");
81 const Path& workingDirectory,
82 const Path& sceneDescription,
83 const std::string& name =
"",
84 const std::string& descName =
"");
89 std::size_t
loadScene(
const Path& sceneFile);
117 struct PendingRemovalScene
119 std::unique_ptr<DesignerScene> scene;
120 bool hasRenderCleanupDone =
false;
121 bool hasCleanupDone =
false;
124 TUniquePtrVector<DesignerScene> m_scenes;
125 std::list<PendingRemovalScene> m_removingScenes;
127 bool m_isActiveScenePaused =
false;
132 std::size_t newScene();
134 void loadDefaultScene();
135 void cleanupRemovingScenes();
140 template<
typename EventType>
178 template<
typename EventType>
182 template<
typename EventType>
183 static void dispatchPostedEventToListeners(
187 void flushAllEvents();
201 std::shared_ptr<EditorSettings> m_settings;
Definition DesignerScene.h:58
Size reference of various common UI elements. Unless otherwise noted, unit is in pixel (raster coordi...
Definition DimensionHints.h:12
Definition EditContext.h:9
Definition EditorEventQueue.h:16
TEditorEventDispatcher< SceneFramebufferResizedEvent > onSceneFramebufferResized
Definition Editor.h:163
std::size_t createScene(const Path &workingDirectory, const std::string &name="")
Create a new scene. The scene will be made active automatically. This method is for a scene that is b...
Definition Editor.cpp:265
TEditorEventDispatcher< ActiveDesignerSceneChangedEvent > onActiveDesignerSceneChanged
Definition Editor.h:170
void saveScene()
Save the active scene.
Definition Editor.cpp:510
DimensionHints dimensionHints
Definition Editor.h:48
void stop()
Called once after the update loop ends.
Definition Editor.cpp:163
DesignerScene * getScene(std::size_t sceneIndex) const
Definition Editor.ipp:10
EditorSettings & getSettings() const
Definition Editor.cpp:714
void afterUpdateStage()
Definition Editor.cpp:133
TEditorEventDispatcher< DisplayClosedEvent > onDisplayClosed
Definition Editor.h:164
TEditorEventDispatcher< KeyPressedEvent > onKeyPressed
Editor events. Subscribe to editor event by adding listener to the corresponding dispatcher....
Definition Editor.h:160
void saveSettings(const Path &settingsFile) const
Definition Editor.cpp:696
void renderCleanup(RenderThreadCaller &caller)
Definition Editor.cpp:249
void loadSettings(const Path &settingsFile)
Definition Editor.cpp:679
void beforeRenderStage()
Definition Editor.cpp:143
std::size_t getSceneIndex(const DesignerScene *scene) const
Get index of the scene. Most scene operations in the editor take scene index as input,...
Definition Editor.ipp:25
void afterRenderStage()
Definition Editor.cpp:153
void beforeUpdateStage()
Definition Editor.cpp:123
void update(const MainThreadUpdateContext &ctx)
Definition Editor.cpp:80
void removeScene(std::size_t sceneIndex)
Definition Editor.cpp:636
TEditorEventDispatcher< DesignerSceneRemovalEvent > onDesignerSceneRemoval
Definition Editor.h:169
EditorStats editorStats
Definition Editor.h:49
TEditorEventDispatcher< DisplayFramebufferResizedEvent > onDisplayFramebufferResized
Definition Editor.h:162
void renderUpdate(const MainThreadRenderUpdateContext &ctx)
Definition Editor.cpp:101
void postEvent(const EventType &e, TEditorEventDispatcher< EventType > &eventDispatcher)
Specify an event that is going to be dispatched by the dispatcher. The event will not be dispatched i...
Definition Editor.ipp:37
void cleanup()
Definition Editor.cpp:257
TEditorEventDispatcher< AppModuleActionEvent > onAppModuleAction
Definition Editor.h:166
static constexpr std::size_t nullSceneIndex()
Definition Editor.ipp:31
EditContext getEditContext() const
Definition Editor.cpp:729
FileSystemExplorer fileExplorer
Definition Editor.h:50
~Editor()
Definition Editor.cpp:47
void start()
Called once before the update loop begins.
Definition Editor.cpp:54
std::size_t createSceneFromDescription(const Path &workingDirectory, const Path &sceneDescription, const std::string &name="", const std::string &descName="")
Definition Editor.cpp:299
TEditorEventDispatcher< DisplayFocusChangedEvent > onDisplayFocusChanged
Definition Editor.h:165
DesignerScene * getActiveScene() const
Definition Editor.ipp:15
void setActiveScene(std::size_t sceneIndex)
Definition Editor.cpp:598
TEditorEventDispatcher< DesignerSceneAddedEvent > onDesignerSceneAdded
Definition Editor.h:168
void createRenderCommands(RenderThreadCaller &caller)
Definition Editor.cpp:111
TEditorEventDispatcher< KeyReleasedEvent > onKeyReleased
Definition Editor.h:161
TEditorEventDispatcher< EditContextUpdatedEvent > onEditContextUpdated
Definition Editor.h:167
std::size_t loadScene(const Path &sceneFile)
Load a scene. The scene will be made active automatically.
Definition Editor.cpp:424
HelpMenu helpMenu
Definition Editor.h:47
std::size_t numScenes() const
Definition Editor.ipp:20
Definition EditorSettings.h:11
Definition EditorStats.h:9
Definition FileSystemExplorer.h:53
Definition MainThreadRenderUpdateContext.h:11
Definition MainThreadUpdateContext.h:11
Thin wrapper for render thread interactions from another thread. Mainly to hide unrelated render thre...
Definition RenderThreadCaller.h:16
Definition TClassEventDispatcher.h:13
Definition ph_editor.h:10