Refactor editor rendering contracts
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
#include "Project/ProjectPanel.h"
|
||||
#include "Scene/SceneEditCommandRoute.h"
|
||||
#include "Scene/SceneViewportFeature.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Viewport/ViewportHostService.h"
|
||||
|
||||
#include <XCEditor/Panels/UIEditorHostedPanelDispatch.h>
|
||||
|
||||
@@ -219,7 +217,7 @@ public:
|
||||
}
|
||||
|
||||
void Initialize(const EditorWorkspacePanelInitializationContext& context) override {
|
||||
m_panel.SetBuiltInIcons(&context.builtInIcons);
|
||||
m_panel.SetIconService(&context.iconService);
|
||||
m_panel.SetTextMeasurer(&context.textMeasurer);
|
||||
m_panel.Initialize();
|
||||
}
|
||||
@@ -330,7 +328,7 @@ public:
|
||||
}
|
||||
|
||||
void Initialize(const EditorWorkspacePanelInitializationContext& context) override {
|
||||
m_panel.SetBuiltInIcons(&context.builtInIcons);
|
||||
m_panel.SetIconService(&context.iconService);
|
||||
m_panel.SetTextMeasurer(&context.textMeasurer);
|
||||
}
|
||||
|
||||
@@ -406,15 +404,16 @@ public:
|
||||
}
|
||||
|
||||
void Initialize(const EditorWorkspacePanelInitializationContext& context) override {
|
||||
m_feature.Initialize(
|
||||
context.repoRoot,
|
||||
context.textureHost,
|
||||
&context.builtInIcons,
|
||||
context.viewportHostService);
|
||||
if (context.sceneViewportRuntime != nullptr) {
|
||||
m_feature.Initialize(
|
||||
&context.iconService,
|
||||
*context.sceneViewportRuntime);
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown(const EditorWorkspacePanelShutdownContext& context) override {
|
||||
m_feature.Shutdown(context.textureHost, context.viewportHostService);
|
||||
(void)context;
|
||||
m_feature.Shutdown();
|
||||
m_commandRoute.BindSceneRuntime(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "HierarchyPanel.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include <XCEditor/Foundation/UIEditorPanelInputFilter.h>
|
||||
#include <XCEditor/Foundation/UIEditorTheme.h>
|
||||
#include "EditorSceneRuntime.h"
|
||||
@@ -15,13 +15,13 @@ using ::XCEngine::UI::UIColor;
|
||||
inline constexpr float kDragThreshold = 4.0f;
|
||||
inline constexpr UIColor kDragPreviewColor(0.92f, 0.92f, 0.92f, 0.42f);
|
||||
|
||||
::XCEngine::UI::UITextureHandle ResolveGameObjectIcon(const BuiltInIcons* icons);
|
||||
::XCEngine::UI::UITextureHandle ResolveGameObjectIcon(const EditorIconService* icons);
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
::XCEngine::UI::UITextureHandle ResolveGameObjectIcon(const BuiltInIcons* icons) {
|
||||
::XCEngine::UI::UITextureHandle ResolveGameObjectIcon(const EditorIconService* icons) {
|
||||
return icons != nullptr
|
||||
? icons->Resolve(BuiltInIconKind::GameObject)
|
||||
: ::XCEngine::UI::UITextureHandle {};
|
||||
@@ -80,7 +80,7 @@ void HierarchyPanel::SetCommandFocusService(
|
||||
m_commandFocusService = commandFocusService;
|
||||
}
|
||||
|
||||
void HierarchyPanel::SetBuiltInIcons(const BuiltInIcons* icons) {
|
||||
void HierarchyPanel::SetIconService(const EditorIconService* icons) {
|
||||
m_icons = icons;
|
||||
RebuildItems();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class EditorCommandFocusService;
|
||||
class EditorIconService;
|
||||
class EditorSceneRuntime;
|
||||
|
||||
class HierarchyPanel final : public EditorEditCommandRoute {
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
void Initialize();
|
||||
void SetSceneRuntime(EditorSceneRuntime* sceneRuntime);
|
||||
void SetCommandFocusService(EditorCommandFocusService* commandFocusService);
|
||||
void SetBuiltInIcons(const BuiltInIcons* icons);
|
||||
void SetIconService(const EditorIconService* icons);
|
||||
void SetTextMeasurer(const ::XCEngine::UI::Editor::UIEditorTextMeasurer* textMeasurer);
|
||||
void ResetInteractionState();
|
||||
void Update(
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
const std::vector<Widgets::UIEditorTreeViewItem>& GetPresentedTreeItems() const;
|
||||
const ::XCEngine::UI::Widgets::UIExpansionModel& GetPresentedExpansionModel() const;
|
||||
|
||||
const BuiltInIcons* m_icons = nullptr;
|
||||
const EditorIconService* m_icons = nullptr;
|
||||
EditorCommandFocusService* m_commandFocusService = nullptr;
|
||||
EditorSceneRuntime* m_sceneRuntime = nullptr;
|
||||
HierarchyModel m_model = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ProjectPanel.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include <XCEditor/Collections/UIEditorScrollView.h>
|
||||
#include <XCEditor/Collections/UIEditorTreeView.h>
|
||||
#include <XCEditor/Foundation/UIEditorTheme.h>
|
||||
@@ -71,7 +71,7 @@ float MeasureTextWidth(
|
||||
const UIEditorTextMeasurer* textMeasurer,
|
||||
std::string_view text,
|
||||
float fontSize);
|
||||
::XCEngine::UI::UITextureHandle ResolveFolderIcon(const BuiltInIcons* icons);
|
||||
::XCEngine::UI::UITextureHandle ResolveFolderIcon(const EditorIconService* icons);
|
||||
float ClampNavigationWidth(float value, float totalWidth);
|
||||
UIRect ComputeFittedTextureRect(
|
||||
const UIRect& bounds,
|
||||
@@ -129,7 +129,7 @@ float MeasureTextWidth(
|
||||
return static_cast<float>(text.size()) * fontSize * 0.56f;
|
||||
}
|
||||
|
||||
::XCEngine::UI::UITextureHandle ResolveFolderIcon(const BuiltInIcons* icons) {
|
||||
::XCEngine::UI::UITextureHandle ResolveFolderIcon(const EditorIconService* icons) {
|
||||
return icons != nullptr
|
||||
? icons->Resolve(BuiltInIconKind::Folder)
|
||||
: ::XCEngine::UI::UITextureHandle {};
|
||||
@@ -425,7 +425,7 @@ void ProjectPanel::SetSystemInteractionHost(
|
||||
m_systemInteractionHost = systemInteractionHost;
|
||||
}
|
||||
|
||||
void ProjectPanel::SetBuiltInIcons(BuiltInIcons* icons) {
|
||||
void ProjectPanel::SetIconService(EditorIconService* icons) {
|
||||
m_icons = icons;
|
||||
RebuildWindowTreeItems();
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class EditorCommandFocusService;
|
||||
class EditorIconService;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
void SetProjectRuntime(EditorProjectRuntime* projectRuntime);
|
||||
void SetCommandFocusService(EditorCommandFocusService* commandFocusService);
|
||||
void SetSystemInteractionHost(System::SystemInteractionService* systemInteractionHost);
|
||||
void SetBuiltInIcons(BuiltInIcons* icons);
|
||||
void SetIconService(EditorIconService* icons);
|
||||
void SetTextMeasurer(const ::XCEngine::UI::Editor::UIEditorTextMeasurer* textMeasurer);
|
||||
void ResetInteractionState();
|
||||
void Update(
|
||||
@@ -254,7 +254,7 @@ private:
|
||||
EditorProjectRuntime* m_projectRuntime = nullptr;
|
||||
EditorCommandFocusService* m_commandFocusService = nullptr;
|
||||
System::SystemInteractionService* m_systemInteractionHost = nullptr;
|
||||
BuiltInIcons* m_icons = nullptr;
|
||||
EditorIconService* m_icons = nullptr;
|
||||
const ::XCEngine::UI::Editor::UIEditorTextMeasurer* m_textMeasurer = nullptr;
|
||||
std::vector<Widgets::UIEditorTreeViewItem> m_windowTreeItems = {};
|
||||
::XCEngine::UI::Widgets::UISelectionModel m_folderSelection = {};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Scene/SceneViewportController.h"
|
||||
|
||||
#include "Viewport/ViewportObjectPickerService.h"
|
||||
#include "Viewport/EditorViewportPicking.h"
|
||||
#include "EditorSceneRuntime.h"
|
||||
#include "State/EditorCommandFocusService.h"
|
||||
|
||||
@@ -136,17 +136,15 @@ void ApplySceneViewportToggleButton(
|
||||
|
||||
} // namespace
|
||||
|
||||
void SceneViewportController::Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& renderer,
|
||||
const BuiltInIcons* builtInIcons) {
|
||||
m_toolOverlay.Initialize(repoRoot, renderer);
|
||||
m_sceneOverlay.SetBuiltInIcons(builtInIcons);
|
||||
void SceneViewportController::Initialize(const EditorIconService* iconService) {
|
||||
m_toolOverlay.SetIconService(iconService);
|
||||
m_sceneOverlay.SetIconService(iconService);
|
||||
ResetInteractionState();
|
||||
}
|
||||
|
||||
void SceneViewportController::Shutdown(Rendering::Host::UiTextureHost& renderer) {
|
||||
m_toolOverlay.Shutdown(renderer);
|
||||
void SceneViewportController::Shutdown() {
|
||||
m_toolOverlay.SetIconService(nullptr);
|
||||
m_sceneOverlay.SetIconService(nullptr);
|
||||
ResetInteractionState();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,32 +10,18 @@
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorCommandFocusService;
|
||||
class BuiltInIcons;
|
||||
class EditorIconService;
|
||||
class EditorSceneRuntime;
|
||||
class IViewportObjectPickerService;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class UiTextureHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class SceneViewportController {
|
||||
public:
|
||||
void Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& renderer,
|
||||
const BuiltInIcons* builtInIcons);
|
||||
void Shutdown(Rendering::Host::UiTextureHost& renderer);
|
||||
void Initialize(const EditorIconService* iconService);
|
||||
void Shutdown();
|
||||
void ResetInteractionState();
|
||||
void SetCommandFocusService(EditorCommandFocusService* commandFocusService);
|
||||
|
||||
|
||||
@@ -1,33 +1,20 @@
|
||||
#include "Scene/SceneViewportFeature.h"
|
||||
|
||||
#include "Panels/EditorPanelIds.h"
|
||||
#include "UiTextureHost.h"
|
||||
#include "Viewport/SceneViewportResourcePaths.h"
|
||||
#include "Viewport/ViewportHostService.h"
|
||||
#include "EditorSceneRuntime.h"
|
||||
#include "State/EditorCommandFocusService.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
void SceneViewportFeature::Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
const BuiltInIcons* builtInIcons,
|
||||
ViewportHostService& viewportHostService) {
|
||||
m_renderService.Initialize(BuildSceneViewportShaderPaths(repoRoot));
|
||||
viewportHostService.SetContentRenderer(
|
||||
kScenePanelId,
|
||||
&m_renderService,
|
||||
SceneViewportRenderService::GetViewportResourceRequirements());
|
||||
m_controller.Initialize(repoRoot, textureHost, builtInIcons);
|
||||
const EditorIconService* iconService,
|
||||
EditorSceneViewportRuntime& sceneViewportRuntime) {
|
||||
m_sceneViewportRuntime = &sceneViewportRuntime;
|
||||
m_controller.Initialize(iconService);
|
||||
}
|
||||
|
||||
void SceneViewportFeature::Shutdown(
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
ViewportHostService& viewportHostService) {
|
||||
viewportHostService.SetContentRenderer(kScenePanelId, nullptr, {});
|
||||
m_controller.Shutdown(textureHost);
|
||||
m_renderService.Shutdown();
|
||||
void SceneViewportFeature::Shutdown() {
|
||||
m_controller.Shutdown();
|
||||
m_sceneViewportRuntime = nullptr;
|
||||
}
|
||||
|
||||
void SceneViewportFeature::ResetInteractionState() {
|
||||
@@ -40,17 +27,23 @@ void SceneViewportFeature::SetCommandFocusService(
|
||||
}
|
||||
|
||||
void SceneViewportFeature::SyncRenderRequest(EditorSceneRuntime& sceneRuntime) {
|
||||
m_renderService.SetRenderRequest(
|
||||
sceneRuntime.BuildSceneViewportRenderRequest());
|
||||
if (m_sceneViewportRuntime != nullptr) {
|
||||
m_sceneViewportRuntime->SetRenderRequest(
|
||||
sceneRuntime.BuildSceneViewportRenderRequest());
|
||||
}
|
||||
}
|
||||
|
||||
void SceneViewportFeature::Update(
|
||||
EditorSceneRuntime& sceneRuntime,
|
||||
const UIEditorWorkspaceComposeState& composeState,
|
||||
const UIEditorWorkspaceComposeFrame& composeFrame) {
|
||||
if (m_sceneViewportRuntime == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_controller.Update(
|
||||
sceneRuntime,
|
||||
m_renderService,
|
||||
m_sceneViewportRuntime->GetObjectPicker(),
|
||||
composeState,
|
||||
composeFrame);
|
||||
SyncRenderRequest(sceneRuntime);
|
||||
|
||||
@@ -1,42 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include "Scene/SceneViewportController.h"
|
||||
#include "Viewport/SceneViewportRenderService.h"
|
||||
#include "Viewport/EditorViewportRuntimeServices.h"
|
||||
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceCompose.h>
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorCommandFocusService;
|
||||
class BuiltInIcons;
|
||||
class EditorSceneRuntime;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
namespace XCEngine::UI::Editor::Rendering::Host {
|
||||
|
||||
class UiTextureHost;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Rendering::Host
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class ViewportHostService;
|
||||
|
||||
class SceneViewportFeature {
|
||||
public:
|
||||
void Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
const BuiltInIcons* builtInIcons,
|
||||
ViewportHostService& viewportHostService);
|
||||
void Shutdown(
|
||||
Rendering::Host::UiTextureHost& textureHost,
|
||||
ViewportHostService& viewportHostService);
|
||||
const EditorIconService* iconService,
|
||||
EditorSceneViewportRuntime& sceneViewportRuntime);
|
||||
void Shutdown();
|
||||
void ResetInteractionState();
|
||||
void SetCommandFocusService(EditorCommandFocusService* commandFocusService);
|
||||
void SyncRenderRequest(EditorSceneRuntime& sceneRuntime);
|
||||
@@ -47,7 +29,7 @@ public:
|
||||
void Append(::XCEngine::UI::UIDrawList& drawList) const;
|
||||
|
||||
private:
|
||||
SceneViewportRenderService m_renderService = {};
|
||||
EditorSceneViewportRuntime* m_sceneViewportRuntime = nullptr;
|
||||
SceneViewportController m_controller = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Scene/SceneViewportSceneOverlay.h"
|
||||
|
||||
#include "Scene/SceneViewportTransformGizmoSupport.h"
|
||||
#include "Assets/BuiltInIcons.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
#include "EditorSceneRuntime.h"
|
||||
|
||||
#include <XCEngine/Components/CameraComponent.h>
|
||||
@@ -68,14 +68,14 @@ SceneViewportGizmoSupport::SceneViewportOverlayData BuildOverlayData(
|
||||
return overlay;
|
||||
}
|
||||
|
||||
::XCEngine::UI::UITextureHandle ResolveCameraIcon(const BuiltInIcons* icons) {
|
||||
::XCEngine::UI::UITextureHandle ResolveCameraIcon(const EditorIconService* icons) {
|
||||
return icons != nullptr
|
||||
? icons->Resolve(BuiltInIconKind::CameraGizmo)
|
||||
: ::XCEngine::UI::UITextureHandle();
|
||||
}
|
||||
|
||||
::XCEngine::UI::UITextureHandle ResolveLightIcon(
|
||||
const BuiltInIcons* icons,
|
||||
const EditorIconService* icons,
|
||||
const LightComponent& light) {
|
||||
if (icons == nullptr) {
|
||||
return {};
|
||||
@@ -95,7 +95,7 @@ SceneViewportGizmoSupport::SceneViewportOverlayData BuildOverlayData(
|
||||
|
||||
} // namespace
|
||||
|
||||
void SceneViewportSceneOverlay::SetBuiltInIcons(const BuiltInIcons* icons) {
|
||||
void SceneViewportSceneOverlay::SetIconService(const EditorIconService* icons) {
|
||||
m_icons = icons;
|
||||
if (m_icons == nullptr) {
|
||||
ResetFrame();
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class BuiltInIcons;
|
||||
class EditorSceneRuntime;
|
||||
class EditorIconService;
|
||||
|
||||
class SceneViewportSceneOverlay {
|
||||
public:
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void SetBuiltInIcons(const BuiltInIcons* icons);
|
||||
void SetIconService(const EditorIconService* icons);
|
||||
void ResetFrame();
|
||||
void Refresh(
|
||||
EditorSceneRuntime& sceneRuntime,
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
const BuiltInIcons* m_icons = nullptr;
|
||||
const EditorIconService* m_icons = nullptr;
|
||||
Frame m_frame = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "Scene/SceneViewportToolOverlay.h"
|
||||
|
||||
#include "UiTextureHost.h"
|
||||
|
||||
#include <XCEditor/Widgets/UIEditorTextLayout.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -39,16 +37,16 @@ constexpr float kToggleMinWidth = 60.0f;
|
||||
struct ToolButtonSpec {
|
||||
SceneToolMode mode = SceneToolMode::View;
|
||||
const char* label = "";
|
||||
const char* inactiveFile = "";
|
||||
const char* activeFile = "";
|
||||
BuiltInIconKind inactiveIcon = BuiltInIconKind::ViewMoveTool;
|
||||
BuiltInIconKind activeIcon = BuiltInIconKind::ViewMoveToolActive;
|
||||
};
|
||||
|
||||
constexpr std::array<ToolButtonSpec, 5> kToolButtonSpecs = {{
|
||||
{ SceneToolMode::View, "View", "view_move_tool.png", "view_move_tool_on.png" },
|
||||
{ SceneToolMode::Translate, "Move", "move_tool.png", "move_tool_on.png" },
|
||||
{ SceneToolMode::Rotate, "Rotate", "rotate_tool.png", "rotate_tool_on.png" },
|
||||
{ SceneToolMode::Scale, "Scale", "scale_tool.png", "scale_tool_on.png" },
|
||||
{ SceneToolMode::Transform, "Transform", "transform_tool.png", "transform_tool_on.png" }
|
||||
{ SceneToolMode::View, "View", BuiltInIconKind::ViewMoveTool, BuiltInIconKind::ViewMoveToolActive },
|
||||
{ SceneToolMode::Translate, "Move", BuiltInIconKind::MoveTool, BuiltInIconKind::MoveToolActive },
|
||||
{ SceneToolMode::Rotate, "Rotate", BuiltInIconKind::RotateTool, BuiltInIconKind::RotateToolActive },
|
||||
{ SceneToolMode::Scale, "Scale", BuiltInIconKind::ScaleTool, BuiltInIconKind::ScaleToolActive },
|
||||
{ SceneToolMode::Transform, "Transform", BuiltInIconKind::TransformTool, BuiltInIconKind::TransformToolActive }
|
||||
}};
|
||||
|
||||
bool ContainsPoint(const UIRect& rect, const UIPoint& point) {
|
||||
@@ -198,47 +196,10 @@ UIRect BuildToggleButtonRect(
|
||||
return kToggleIdle;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool SceneViewportToolOverlay::Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& renderer) {
|
||||
Shutdown(renderer);
|
||||
|
||||
const std::filesystem::path iconRoot =
|
||||
(repoRoot / "editor" / "resources" / "Icons").lexically_normal();
|
||||
bool loadedAnyTexture = false;
|
||||
for (std::size_t index = 0; index < kToolButtonSpecs.size(); ++index) {
|
||||
const ToolButtonSpec& path = kToolButtonSpecs[index];
|
||||
ToolTextureSet& textureSet = m_toolTextures[index];
|
||||
textureSet = {};
|
||||
textureSet.mode = path.mode;
|
||||
textureSet.label = path.label;
|
||||
|
||||
std::string error = {};
|
||||
loadedAnyTexture =
|
||||
renderer.LoadTextureFromFile(
|
||||
iconRoot / path.inactiveFile,
|
||||
textureSet.inactiveTexture,
|
||||
error) || loadedAnyTexture;
|
||||
error.clear();
|
||||
loadedAnyTexture =
|
||||
renderer.LoadTextureFromFile(
|
||||
iconRoot / path.activeFile,
|
||||
textureSet.activeTexture,
|
||||
error) || loadedAnyTexture;
|
||||
}
|
||||
|
||||
return loadedAnyTexture;
|
||||
}
|
||||
|
||||
void SceneViewportToolOverlay::Shutdown(Rendering::Host::UiTextureHost& renderer) {
|
||||
for (ToolTextureSet& textureSet : m_toolTextures) {
|
||||
renderer.ReleaseTexture(textureSet.inactiveTexture);
|
||||
renderer.ReleaseTexture(textureSet.activeTexture);
|
||||
textureSet = {};
|
||||
}
|
||||
|
||||
void SceneViewportToolOverlay::SetIconService(const EditorIconService* iconService) {
|
||||
m_iconService = iconService;
|
||||
ResetFrame();
|
||||
}
|
||||
|
||||
@@ -305,7 +266,6 @@ void SceneViewportToolOverlay::BuildFrame(
|
||||
|
||||
for (std::size_t index = 0; index < m_frame.buttons.size(); ++index) {
|
||||
const ToolButtonSpec& spec = kToolButtonSpecs[index];
|
||||
const ToolTextureSet& textureSet = m_toolTextures[index];
|
||||
SceneViewportToolOverlayButtonFrame& button = m_frame.buttons[index];
|
||||
button = {};
|
||||
button.mode = spec.mode;
|
||||
@@ -314,9 +274,10 @@ void SceneViewportToolOverlay::BuildFrame(
|
||||
button.active = spec.mode == activeMode;
|
||||
button.hovered = index == hoveredIndex;
|
||||
button.pressed = index == pressedIndex;
|
||||
button.texture = spec.mode == activeMode
|
||||
? textureSet.activeTexture
|
||||
: textureSet.inactiveTexture;
|
||||
if (m_iconService != nullptr) {
|
||||
button.texture = m_iconService->Resolve(
|
||||
spec.mode == activeMode ? spec.activeIcon : spec.inactiveIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "SceneToolState.h"
|
||||
#include "HostFwd.h"
|
||||
#include "Assets/EditorIconService.h"
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
@@ -57,10 +56,7 @@ struct SceneViewportToolOverlayFrame {
|
||||
|
||||
class SceneViewportToolOverlay {
|
||||
public:
|
||||
bool Initialize(
|
||||
const std::filesystem::path& repoRoot,
|
||||
Rendering::Host::UiTextureHost& renderer);
|
||||
void Shutdown(Rendering::Host::UiTextureHost& renderer);
|
||||
void SetIconService(const EditorIconService* iconService);
|
||||
void ResetFrame();
|
||||
|
||||
void BuildFrame(
|
||||
@@ -82,15 +78,8 @@ public:
|
||||
const SceneViewportToolOverlayFrame& GetFrame() const;
|
||||
|
||||
private:
|
||||
struct ToolTextureSet {
|
||||
SceneToolMode mode = SceneToolMode::View;
|
||||
const char* label = "";
|
||||
::XCEngine::UI::UITextureHandle inactiveTexture = {};
|
||||
::XCEngine::UI::UITextureHandle activeTexture = {};
|
||||
};
|
||||
|
||||
std::array<ToolTextureSet, 5> m_toolTextures = {};
|
||||
SceneViewportToolOverlayFrame m_frame = {};
|
||||
const EditorIconService* m_iconService = nullptr;
|
||||
};
|
||||
|
||||
void AppendSceneViewportToolOverlay(
|
||||
|
||||
Reference in New Issue
Block a user