feat: overhaul editor console panel and diagnostics

This commit is contained in:
2026-03-31 21:28:16 +08:00
parent 6d3a90ef74
commit ad237cb81e
9 changed files with 1176 additions and 20 deletions

View File

@@ -4,6 +4,7 @@
#include <XCEngine/Debug/LogEntry.h>
#include <XCEngine/Debug/LogLevel.h>
#include <filesystem>
#include <string>
namespace XCEngine {
@@ -26,11 +27,77 @@ inline const char* ConsoleLogPrefix(::XCEngine::Debug::LogLevel level) {
return "[LOG] ";
}
inline const char* ConsoleSeverityLabel(::XCEngine::Debug::LogLevel level) {
switch (level) {
case ::XCEngine::Debug::LogLevel::Verbose:
case ::XCEngine::Debug::LogLevel::Debug:
case ::XCEngine::Debug::LogLevel::Info:
return "Log";
case ::XCEngine::Debug::LogLevel::Warning:
return "Warning";
case ::XCEngine::Debug::LogLevel::Error:
case ::XCEngine::Debug::LogLevel::Fatal:
return "Error";
}
return "Log";
}
inline std::string BuildConsoleSummaryText(const ::XCEngine::Debug::LogEntry& log) {
return log.message.CStr();
}
inline std::string BuildConsoleSourceText(const ::XCEngine::Debug::LogEntry& log) {
std::string source;
const char* category = ::XCEngine::Debug::LogCategoryToString(log.category);
if (category && category[0] != '\0') {
source += "[";
source += category;
source += "]";
}
const std::string filePath = log.file.CStr();
if (!filePath.empty()) {
if (!source.empty()) {
source += " ";
}
source += std::filesystem::path(filePath).filename().string();
if (log.line > 0) {
source += ":";
source += std::to_string(log.line);
}
}
return source;
}
inline std::string BuildConsoleLogText(const ::XCEngine::Debug::LogEntry& log) {
const char* category = ::XCEngine::Debug::LogCategoryToString(log.category);
return std::string(ConsoleLogPrefix(log.level)) + "[" + category + "] " + log.message.CStr();
}
inline std::string BuildConsoleCopyText(const ::XCEngine::Debug::LogEntry& log) {
std::string text = BuildConsoleLogText(log);
if (log.file.Length() > 0) {
text += "\nFile: ";
text += log.file.CStr();
if (log.line > 0) {
text += ":";
text += std::to_string(log.line);
}
}
if (log.function.Length() > 0) {
text += "\nFunction: ";
text += log.function.CStr();
}
text += "\nThread: ";
text += std::to_string(log.threadId);
text += "\nTimestamp: ";
text += std::to_string(log.timestamp);
return text;
}
} // namespace UI
} // namespace Editor
} // namespace XCEngine

View File

@@ -39,24 +39,24 @@ inline void DrawDisclosureArrow(ImDrawList* drawList, const ImVec2& min, const I
return;
}
constexpr float kSqrt3 = 1.7320508f;
const ImVec2 center(
static_cast<float>(std::floor((min.x + max.x) * 0.5f)) + 0.5f,
static_cast<float>(std::floor((min.y + max.y) * 0.5f)) + 0.5f);
const float width = max.x - min.x;
const float height = max.y - min.y;
const float radius = (std::max)(
const float halfBaseExtent = (std::max)(
3.0f,
static_cast<float>(std::floor((width < height ? width : height) * DisclosureArrowScale())));
const float baseHalfExtent = radius;
const float tipExtent = (std::max)(2.0f, static_cast<float>(std::floor(radius * 0.70f)));
if (baseHalfExtent < 1.0f || tipExtent < 1.0f) {
const float triangleHeight = kSqrt3 * halfBaseExtent;
if (halfBaseExtent < 1.0f || triangleHeight < 1.0f) {
return;
}
ImVec2 points[3] = {
ImVec2(-baseHalfExtent, -tipExtent),
ImVec2(baseHalfExtent, -tipExtent),
ImVec2(0.0f, tipExtent)
ImVec2(-halfBaseExtent, -triangleHeight / 3.0f),
ImVec2(halfBaseExtent, -triangleHeight / 3.0f),
ImVec2(0.0f, triangleHeight * 2.0f / 3.0f)
};
if (!open) {

View File

@@ -269,7 +269,7 @@ inline float NavigationTreePrefixLabelGap() {
}
inline float DisclosureArrowScale() {
return 0.28f;
return 0.18f;
}
inline ImVec4 NavigationTreePrefixColor(bool selected = false, bool hovered = false) {
@@ -704,6 +704,74 @@ inline ImVec4 ConsoleRowHoverFillColor() {
return ImVec4(1.0f, 1.0f, 1.0f, 0.03f);
}
inline ImVec4 ConsoleRowSelectedFillColor() {
return ImVec4(0.26f, 0.33f, 0.43f, 0.95f);
}
inline ImVec4 ConsoleListBackgroundColor() {
return ImVec4(0.205f, 0.205f, 0.205f, 1.0f);
}
inline ImVec4 ConsoleDetailsBackgroundColor() {
return ImVec4(0.185f, 0.185f, 0.185f, 1.0f);
}
inline ImVec4 ConsoleDetailsHeaderBackgroundColor() {
return ImVec4(0.19f, 0.19f, 0.19f, 1.0f);
}
inline ImVec4 ConsoleSecondaryTextColor() {
return ImVec4(0.57f, 0.57f, 0.57f, 1.0f);
}
inline ImVec4 ConsoleCountBadgeBackgroundColor() {
return ImVec4(0.29f, 0.29f, 0.29f, 1.0f);
}
inline ImVec4 ConsoleCountBadgeTextColor() {
return ImVec4(0.88f, 0.88f, 0.88f, 1.0f);
}
inline ImVec4 ConsoleLogColor() {
return ImVec4(0.77f, 0.77f, 0.77f, 1.0f);
}
inline ImVec4 ConsoleWarningColor() {
return ImVec4(0.93f, 0.72f, 0.26f, 1.0f);
}
inline ImVec4 ConsoleErrorColor() {
return ImVec4(0.92f, 0.37f, 0.33f, 1.0f);
}
inline float ConsoleRowHeight() {
return 22.0f;
}
inline float ConsoleSeverityButtonMinWidth() {
return 54.0f;
}
inline ImVec2 ConsoleSeverityButtonPadding() {
return ImVec2(8.0f, 4.0f);
}
inline float ConsoleBadgeRounding() {
return 3.0f;
}
inline float ConsoleDetailsDefaultHeight() {
return 168.0f;
}
inline float ConsoleDetailsMinHeight() {
return 92.0f;
}
inline float ConsoleListMinHeight() {
return 96.0f;
}
inline float MenuBarStatusRightPadding() {
return 20.0f;
}