Refactor editor rendering contracts

This commit is contained in:
2026-04-28 02:57:49 +08:00
parent 3bc0cfcf08
commit b1ae6c462d
47 changed files with 798 additions and 377 deletions

View File

@@ -1,5 +1,5 @@
#include "Project/ProjectPanel.h"
#include "Assets/BuiltInIcons.h"
#include "Assets/EditorIconService.h"
#include "SystemInteractionService.h"
#include "Panels/EditorPanelIds.h"
@@ -40,6 +40,33 @@ public:
std::filesystem::path lastRevealPath = {};
};
class FakeIconService final : public EditorIconService {
public:
void Initialize(
Rendering::Host::UiTextureHost&,
Host::EditorHostResourceService&) override {}
void Shutdown() override {}
void BeginFrame() override {}
const ::XCEngine::UI::UITextureHandle& Resolve(BuiltInIconKind) const override {
return texture;
}
const ::XCEngine::UI::UITextureHandle* ResolveAssetPreview(
const std::filesystem::path&,
const std::filesystem::path&) override {
return nullptr;
}
const std::string& GetLastError() const override {
return error;
}
private:
::XCEngine::UI::UITextureHandle texture = {};
std::string error = {};
};
class TemporaryRepo final {
public:
TemporaryRepo() {
@@ -249,13 +276,13 @@ TEST(ProjectPanelTests, InjectedRuntimeCurrentFolderDrivesRenameFallbackWithoutT
EXPECT_EQ(evaluation.message, "Rename project item 'FolderA'.");
}
TEST(ProjectPanelTests, BuiltInIconsCanBeConfiguredBeforeRuntimeInitialization) {
TEST(ProjectPanelTests, IconServiceCanBeConfiguredBeforeRuntimeInitialization) {
TemporaryRepo repo = {};
ProjectPanel panel = {};
BuiltInIcons icons = {};
FakeIconService icons = {};
panel.SetBuiltInIcons(&icons);
panel.SetIconService(&icons);
panel.Initialize(repo.Root());
const UIEditorHostCommandEvaluationResult evaluation =