feat: update editor ui framework and assets

This commit is contained in:
2026-03-28 15:07:19 +08:00
parent 4a12e26860
commit 4717b595c4
45 changed files with 2434 additions and 461 deletions

View File

@@ -5,6 +5,7 @@
#include "Core/EditorContext.h"
#include "Core/EditorEvents.h"
#include "Core/EventBus.h"
#include "UI/BuiltInIcons.h"
#include "Platform/Win32Utf8.h"
#include "Platform/WindowsProcessDiagnostics.h"
#include <windows.h>
@@ -18,7 +19,20 @@ Application& Application::Get() {
}
bool Application::InitializeWindowRenderer(HWND hwnd) {
if (m_windowRenderer.Initialize(hwnd, 1280, 720)) {
RECT clientRect = {};
if (!GetClientRect(hwnd, &clientRect)) {
MessageBoxW(hwnd, L"Failed to query editor client area", L"Error", MB_OK | MB_ICONERROR);
return false;
}
const int clientWidth = clientRect.right - clientRect.left;
const int clientHeight = clientRect.bottom - clientRect.top;
if (clientWidth <= 0 || clientHeight <= 0) {
MessageBoxW(hwnd, L"Editor client area is invalid", L"Error", MB_OK | MB_ICONERROR);
return false;
}
if (m_windowRenderer.Initialize(hwnd, clientWidth, clientHeight)) {
return true;
}
@@ -38,8 +52,20 @@ void Application::InitializeEditorContext(const std::string& projectPath) {
}
void Application::InitializeImGui(HWND hwnd) {
m_imguiSession.Initialize(m_editorContext->GetProjectPath());
m_imguiBackend.Initialize(hwnd, m_windowRenderer.GetDevice(), m_windowRenderer.GetSrvHeap());
m_imguiSession.Initialize(
m_editorContext->GetProjectPath(),
UI::ImGuiBackendBridge::GetDpiScaleForHwnd(hwnd));
m_imguiBackend.Initialize(
hwnd,
m_windowRenderer.GetDevice(),
m_windowRenderer.GetCommandQueue(),
m_windowRenderer.GetSrvHeap(),
m_windowRenderer.GetSrvDescriptorSize(),
m_windowRenderer.GetSrvDescriptorCount());
UI::InitializeBuiltInIcons(
m_imguiBackend,
m_windowRenderer.GetDevice(),
m_windowRenderer.GetCommandQueue());
}
void Application::AttachEditorLayer() {
@@ -65,7 +91,6 @@ void Application::ShutdownEditorContext() {
void Application::RenderEditorFrame() {
static constexpr float kClearColor[4] = { 0.22f, 0.22f, 0.22f, 1.0f };
m_imguiBackend.BeginFrame();
m_layerStack.onImGuiRender();
UpdateWindowTitle();
@@ -89,11 +114,14 @@ bool Application::Initialize(HWND hwnd) {
InitializeEditorContext(exeDir);
InitializeImGui(hwnd);
AttachEditorLayer();
m_renderReady = true;
return true;
}
void Application::Shutdown() {
m_renderReady = false;
DetachEditorLayer();
UI::ShutdownBuiltInIcons();
m_imguiBackend.Shutdown();
m_imguiSession.Shutdown();
ShutdownEditorContext();
@@ -101,6 +129,9 @@ void Application::Shutdown() {
}
void Application::Render() {
if (!m_renderReady) {
return;
}
RenderEditorFrame();
}