Build XCEditor menu and status shell widgets

This commit is contained in:
2026-04-07 03:51:26 +08:00
parent 5f9f3386ab
commit 8eeb7af56e
25 changed files with 3708 additions and 106 deletions

View File

@@ -4,12 +4,34 @@
#include <chrono>
#include <cctype>
#include <cstdlib>
#include <cstdio>
#include <sstream>
#include <system_error>
namespace XCEngine::UI::Editor::Host {
namespace {
bool IsAutoCaptureOnStartupEnabled() {
const char* value = std::getenv("XCUI_AUTO_CAPTURE_ON_STARTUP");
if (value == nullptr || value[0] == '\0') {
return false;
}
std::string normalized = value;
for (char& character : normalized) {
character = static_cast<char>(std::tolower(static_cast<unsigned char>(character)));
}
return normalized != "0" &&
normalized != "false" &&
normalized != "off" &&
normalized != "no";
}
} // namespace
void AutoScreenshotController::Initialize(const std::filesystem::path& captureRoot) {
m_captureRoot = captureRoot.lexically_normal();
m_historyRoot = (m_captureRoot / "history").lexically_normal();
@@ -19,6 +41,9 @@ void AutoScreenshotController::Initialize(const std::filesystem::path& captureRo
m_pendingReason.clear();
m_lastCaptureSummary.clear();
m_lastCaptureError.clear();
if (IsAutoCaptureOnStartupEnabled()) {
RequestCapture("startup");
}
}
void AutoScreenshotController::Shutdown() {
@@ -37,7 +62,11 @@ void AutoScreenshotController::CaptureIfRequested(
unsigned int width,
unsigned int height,
bool framePresented) {
if (!m_capturePending || !framePresented || drawData.Empty() || width == 0u || height == 0u) {
if (!m_capturePending) {
return;
}
if (!framePresented || drawData.Empty() || width == 0u || height == 0u) {
return;
}