Editor: rework default layout to UE5 arrangement
Panels renamed to UE semantics (docking identity change): Hierarchy -> Outliner, Inspector -> Details, Asset Browser -> Content Browser. Default DockBuilder layout now matches UE5 factory layout: Details docked right (full height), Content Browser docked bottom spanning left+center, Outliner top-left, Viewport center with Stats as a side tab. Legacy imgui.ini (old window names, no new names) is removed once at Init so the new default rebuilds cleanly; fresh or new-style ini is untouched.
This commit is contained in:
@@ -85,7 +85,7 @@ namespace {
|
|||||||
|
|
||||||
void AssetBrowserPanel::Draw(const EditorContext& ctx)
|
void AssetBrowserPanel::Draw(const EditorContext& ctx)
|
||||||
{
|
{
|
||||||
if (!ImGui::Begin("Asset Browser"))
|
if (!ImGui::Begin("Content Browser"))
|
||||||
{
|
{
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
|
|||||||
+50
-19
@@ -1,12 +1,14 @@
|
|||||||
//
|
//
|
||||||
// Editor.cpp:docking 骨架实现。
|
// Editor.cpp:docking 骨架实现。
|
||||||
//
|
//
|
||||||
// 布局方案(首帧 DockBuilder 一次,之后 imgui.ini 接管):
|
// 默认布局 = UE5 出厂布局(首帧 DockBuilder 一次,之后 imgui.ini 接管):
|
||||||
// ┌──────────────────────────────┬───────────────┐
|
// ┌──────────┬──────────────────────┬───────────┐
|
||||||
// │ Hierarchy │ │
|
// │ Outliner │ │ │
|
||||||
// ├──────────────────────────────┤ Inspector │
|
// │ │ Viewport │ Details │
|
||||||
// │ Stats │ (28%) │
|
// │ │ (+Stats tab) │ │
|
||||||
// └──────────────────────────────┴───────────────┘
|
// ├──────────┴──────────────────────┤ │
|
||||||
|
// │ Content Browser(左+中通栏) │ │
|
||||||
|
// └─────────────────────────────────┴───────────┘
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Editor.h"
|
#include "Editor.h"
|
||||||
@@ -27,6 +29,7 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
using namespace Engine; // kDisplayViewport / kDisplayDirect(SceneTypes.h)
|
using namespace Engine; // kDisplayViewport / kDisplayDirect(SceneTypes.h)
|
||||||
|
|
||||||
@@ -45,6 +48,32 @@ void Editor::Init(const EditorContext& ctx)
|
|||||||
m_Viewport = std::make_unique<ViewportPanel>();
|
m_Viewport = std::make_unique<ViewportPanel>();
|
||||||
m_Stats = std::make_unique<StatsPanel>();
|
m_Stats = std::make_unique<StatsPanel>();
|
||||||
m_AssetBrowser = std::make_unique<AssetBrowserPanel>();
|
m_AssetBrowser = std::make_unique<AssetBrowserPanel>();
|
||||||
|
|
||||||
|
// 旧布局一次性迁移:面板改名(Hierarchy→Outliner / Inspector→Details /
|
||||||
|
// Asset Browser→Content Browser)= docking 身份全变,旧 imgui.ini 对
|
||||||
|
// 新窗口名失效(新窗口首启浮动,而默认布局又因 dock node 非空不再
|
||||||
|
// 重建)。检测"有旧名无新名" → 删 ini 让 UE 默认布局重建一次。
|
||||||
|
// 此刻 ImGui 首帧 NewFrame 还未读盘(NewFrame 内才 LoadIniSettings),
|
||||||
|
// 删文件干净无副作用;新式 ini 或无 ini 不动
|
||||||
|
if (ImGui::GetCurrentContext() && ImGui::GetIO().IniFilename)
|
||||||
|
{
|
||||||
|
const char* path = ImGui::GetIO().IniFilename;
|
||||||
|
std::ifstream file(path);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
const std::string content((std::istreambuf_iterator<char>(file)),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
file.close();
|
||||||
|
if (content.find("[Window][Hierarchy]") != std::string::npos &&
|
||||||
|
content.find("[Window][Outliner]") == std::string::npos)
|
||||||
|
{
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::remove(path, ec);
|
||||||
|
ENGINE_INFO("Editor: legacy imgui.ini removed, "
|
||||||
|
"UE5 default layout will be rebuilt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- PIE(Play-In-Editor)----
|
// ---- PIE(Play-In-Editor)----
|
||||||
@@ -259,11 +288,11 @@ void Editor::DrawMenuBar()
|
|||||||
|
|
||||||
if (ImGui::BeginMenu("View"))
|
if (ImGui::BeginMenu("View"))
|
||||||
{
|
{
|
||||||
ImGui::MenuItem("Hierarchy", nullptr, &m_ShowHierarchy);
|
ImGui::MenuItem("Outliner", nullptr, &m_ShowHierarchy);
|
||||||
ImGui::MenuItem("Inspector", nullptr, &m_ShowInspector);
|
ImGui::MenuItem("Details", nullptr, &m_ShowInspector);
|
||||||
ImGui::MenuItem("Viewport", nullptr, &m_ShowViewport);
|
ImGui::MenuItem("Viewport", nullptr, &m_ShowViewport);
|
||||||
ImGui::MenuItem("Stats", nullptr, &m_ShowStats);
|
ImGui::MenuItem("Stats", nullptr, &m_ShowStats);
|
||||||
ImGui::MenuItem("Asset Browser", nullptr, &m_ShowAssetBrowser);
|
ImGui::MenuItem("Content Browser", nullptr, &m_ShowAssetBrowser);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,19 +313,21 @@ void Editor::DrawDockSpace()
|
|||||||
ImGui::DockBuilderAddNode(dockspaceId, ImGuiDockNodeFlags_DockSpace);
|
ImGui::DockBuilderAddNode(dockspaceId, ImGuiDockNodeFlags_DockSpace);
|
||||||
ImGui::DockBuilderSetNodeSize(dockspaceId, ImGui::GetMainViewport()->Size);
|
ImGui::DockBuilderSetNodeSize(dockspaceId, ImGui::GetMainViewport()->Size);
|
||||||
|
|
||||||
ImGuiID dockLeft = 0, dockRight = 0, dockCenter = 0, dockStats = 0;
|
// UE5 出厂布局:Details 右列通栏 → Content Browser 底部通栏
|
||||||
ImGui::DockBuilderSplitNode(dockspaceId, ImGuiDir_Left, 0.20f,
|
//(左+中)→ Outliner 左列 → 剩余全给 Viewport(Stats 作其 tab)
|
||||||
&dockLeft, &dockCenter);
|
ImGuiID dockRight = 0, dockBottom = 0, dockLeft = 0, dockCenter = 0;
|
||||||
ImGui::DockBuilderSplitNode(dockCenter, ImGuiDir_Right, 0.28f,
|
ImGui::DockBuilderSplitNode(dockspaceId, ImGuiDir_Right, 0.26f,
|
||||||
&dockRight, &dockCenter);
|
&dockRight, &dockCenter);
|
||||||
ImGui::DockBuilderSplitNode(dockLeft, ImGuiDir_Down, 0.38f,
|
ImGui::DockBuilderSplitNode(dockCenter, ImGuiDir_Down, 0.30f,
|
||||||
&dockStats, &dockLeft);
|
&dockBottom, &dockCenter);
|
||||||
|
ImGui::DockBuilderSplitNode(dockCenter, ImGuiDir_Left, 0.22f,
|
||||||
|
&dockLeft, &dockCenter);
|
||||||
|
|
||||||
ImGui::DockBuilderDockWindow("Hierarchy", dockLeft);
|
ImGui::DockBuilderDockWindow("Outliner", dockLeft);
|
||||||
ImGui::DockBuilderDockWindow("Stats", dockStats);
|
|
||||||
ImGui::DockBuilderDockWindow("Asset Browser", dockStats);
|
|
||||||
ImGui::DockBuilderDockWindow("Inspector", dockRight);
|
|
||||||
ImGui::DockBuilderDockWindow("Viewport", dockCenter);
|
ImGui::DockBuilderDockWindow("Viewport", dockCenter);
|
||||||
|
ImGui::DockBuilderDockWindow("Stats", dockCenter); // Viewport 旁 tab
|
||||||
|
ImGui::DockBuilderDockWindow("Content Browser", dockBottom);
|
||||||
|
ImGui::DockBuilderDockWindow("Details", dockRight);
|
||||||
|
|
||||||
ImGui::DockBuilderFinish(dockspaceId);
|
ImGui::DockBuilderFinish(dockspaceId);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -6,8 +6,9 @@
|
|||||||
// - 实体选中状态(entt::entity,Hierarchy 写 / Inspector 读)
|
// - 实体选中状态(entt::entity,Hierarchy 写 / Inspector 读)
|
||||||
// - 退出确认模态框(窗口关闭 → RequestQuit → Yes 时 Close)
|
// - 退出确认模态框(窗口关闭 → RequestQuit → Yes 时 Close)
|
||||||
//
|
//
|
||||||
// 面板窗口名(Hierarchy/Inspector/Viewport/Stats)即 docking 身份,
|
// 面板窗口名(Outliner/Details/Viewport/Stats/Content Browser)即
|
||||||
// imgui.ini 持久化布局;默认布局只在 dock node 为空时构建一次。
|
// docking 身份,imgui.ini 持久化布局;默认布局只在 dock node 为空时
|
||||||
|
// 构建一次(旧名 ini 由 Init 一次性迁移删除,见 Editor.cpp)。
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef HELLOVULKAN_EDITOR_H
|
#ifndef HELLOVULKAN_EDITOR_H
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ namespace {
|
|||||||
|
|
||||||
void HierarchyPanel::Draw(const EditorContext& ctx, entt::entity& selected)
|
void HierarchyPanel::Draw(const EditorContext& ctx, entt::entity& selected)
|
||||||
{
|
{
|
||||||
ImGui::Begin("Hierarchy");
|
ImGui::Begin("Outliner");
|
||||||
|
|
||||||
// 工具栏:创建实体(在遍历之前,不修改遍历中的注册表结构)
|
// 工具栏:创建实体(在遍历之前,不修改遍历中的注册表结构)
|
||||||
if (ImGui::Button("+ Create Entity"))
|
if (ImGui::Button("+ Create Entity"))
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace
|
|||||||
|
|
||||||
void InspectorPanel::Draw(const EditorContext& ctx, entt::entity selected)
|
void InspectorPanel::Draw(const EditorContext& ctx, entt::entity selected)
|
||||||
{
|
{
|
||||||
ImGui::Begin("Inspector");
|
ImGui::Begin("Details");
|
||||||
|
|
||||||
auto& reg = ctx.scene->GetRegistry();
|
auto& reg = ctx.scene->GetRegistry();
|
||||||
if (selected == entt::null || !reg.valid(selected))
|
if (selected == entt::null || !reg.valid(selected))
|
||||||
|
|||||||
Reference in New Issue
Block a user