2026-03-25 01:23:08 +08:00
|
|
|
#include "EditorLayer.h"
|
2026-03-25 16:20:21 +08:00
|
|
|
#include "Core/EditorContext.h"
|
2026-03-25 01:23:08 +08:00
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
|
|
EditorLayer::EditorLayer() : Layer("Editor") {}
|
|
|
|
|
|
2026-03-25 15:35:00 +08:00
|
|
|
void EditorLayer::SetContext(std::shared_ptr<IEditorContext> context) {
|
|
|
|
|
m_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 01:23:08 +08:00
|
|
|
void EditorLayer::onAttach() {
|
2026-03-25 15:35:00 +08:00
|
|
|
if (!m_context) {
|
2026-03-25 16:20:21 +08:00
|
|
|
m_context = std::make_shared<EditorContext>();
|
2026-03-25 15:35:00 +08:00
|
|
|
}
|
2026-03-26 21:18:33 +08:00
|
|
|
|
2026-03-26 23:52:05 +08:00
|
|
|
m_workspace.Attach(*m_context);
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorLayer::onDetach() {
|
2026-03-26 21:18:33 +08:00
|
|
|
if (m_context) {
|
2026-03-26 23:52:05 +08:00
|
|
|
m_workspace.Detach(*m_context);
|
2026-03-26 01:26:26 +08:00
|
|
|
}
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorLayer::onUpdate(float dt) {
|
2026-03-26 23:52:05 +08:00
|
|
|
m_workspace.Update(dt);
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorLayer::onEvent(void* event) {
|
2026-03-26 23:52:05 +08:00
|
|
|
m_workspace.DispatchEvent(event);
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-05 01:25:09 +08:00
|
|
|
void EditorLayer::onUIRender() {
|
2026-03-26 23:52:05 +08:00
|
|
|
m_workspace.Render();
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|