Split utility window contracts from feature factories
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include "Core/UtilityWindows/EditorUtilityWindowRegistry.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::XCEngine::UI::UISize;
|
||||
|
||||
constexpr EditorWindowChromePolicy kUtilityWindowChromePolicy = {
|
||||
.allowDetachedTitleBarTabStrip = false,
|
||||
.showFrameStats = false,
|
||||
.showTopmostButton = true,
|
||||
.topmostByDefault = true,
|
||||
};
|
||||
|
||||
constexpr EditorWindowNativeHostPolicy kUtilityWindowNativeHostPolicy = {
|
||||
.shellRole = EditorWindowNativeShellRole::ToolWindow,
|
||||
};
|
||||
|
||||
constexpr EditorUtilityWindowDescriptor kColorPickerUtilityWindowDescriptor = {
|
||||
.kind = EditorUtilityWindowKind::ColorPicker,
|
||||
.windowId = "utility.color-picker",
|
||||
.title = L"Color Picker",
|
||||
.chromePolicy = kUtilityWindowChromePolicy,
|
||||
.nativeHostPolicy = kUtilityWindowNativeHostPolicy,
|
||||
.preferredOuterSize = UISize(400.0f, 600.0f),
|
||||
.minimumOuterSize = UISize(360.0f, 560.0f),
|
||||
};
|
||||
|
||||
constexpr EditorUtilityWindowDescriptor kAddComponentUtilityWindowDescriptor = {
|
||||
.kind = EditorUtilityWindowKind::AddComponent,
|
||||
.windowId = "utility.add-component",
|
||||
.title = L"Add Component",
|
||||
.chromePolicy = kUtilityWindowChromePolicy,
|
||||
.nativeHostPolicy = kUtilityWindowNativeHostPolicy,
|
||||
.preferredOuterSize = UISize(352.0f, 500.0f),
|
||||
.minimumOuterSize = UISize(320.0f, 460.0f),
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
const EditorUtilityWindowDescriptor* ResolveEditorUtilityWindowDescriptor(
|
||||
EditorUtilityWindowKind kind) {
|
||||
switch (kind) {
|
||||
case EditorUtilityWindowKind::ColorPicker:
|
||||
return &kColorPickerUtilityWindowDescriptor;
|
||||
case EditorUtilityWindowKind::AddComponent:
|
||||
return &kAddComponentUtilityWindowDescriptor;
|
||||
case EditorUtilityWindowKind::None:
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
11
editor/app/Core/UtilityWindows/EditorUtilityWindowRegistry.h
Normal file
11
editor/app/Core/UtilityWindows/EditorUtilityWindowRegistry.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/UtilityWindows/EditorUtilityWindowRuntime.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
const EditorUtilityWindowDescriptor* ResolveEditorUtilityWindowDescriptor(
|
||||
EditorUtilityWindowKind kind);
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
65
editor/app/Core/UtilityWindows/EditorUtilityWindowRuntime.h
Normal file
65
editor/app/Core/UtilityWindows/EditorUtilityWindowRuntime.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/Windowing/EditorWindowTypes.h"
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorContext;
|
||||
|
||||
enum class EditorUtilityWindowKind : std::uint8_t {
|
||||
None = 0,
|
||||
ColorPicker,
|
||||
AddComponent,
|
||||
};
|
||||
|
||||
enum class EditorUtilityWindowReusePolicy {
|
||||
SingleInstance = 0,
|
||||
};
|
||||
|
||||
struct EditorUtilityWindowDescriptor {
|
||||
EditorUtilityWindowKind kind = EditorUtilityWindowKind::None;
|
||||
std::string_view windowId = {};
|
||||
const wchar_t* title = L"";
|
||||
EditorUtilityWindowReusePolicy reusePolicy =
|
||||
EditorUtilityWindowReusePolicy::SingleInstance;
|
||||
EditorWindowChromePolicy chromePolicy = {};
|
||||
EditorWindowNativeHostPolicy nativeHostPolicy = {};
|
||||
::XCEngine::UI::UISize preferredOuterSize = {};
|
||||
::XCEngine::UI::UISize minimumOuterSize = {};
|
||||
};
|
||||
|
||||
struct EditorUtilityWindowHostContext {
|
||||
bool mounted = false;
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
bool allowInteraction = false;
|
||||
bool focused = false;
|
||||
bool focusGained = false;
|
||||
bool focusLost = false;
|
||||
};
|
||||
|
||||
class EditorUtilityWindowPanel {
|
||||
public:
|
||||
virtual ~EditorUtilityWindowPanel() = default;
|
||||
|
||||
virtual std::string_view GetDrawListId() const = 0;
|
||||
virtual void ResetInteractionState() = 0;
|
||||
virtual void Update(
|
||||
EditorContext& context,
|
||||
const EditorUtilityWindowHostContext& hostContext,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents) = 0;
|
||||
virtual void Append(::XCEngine::UI::UIDrawList& drawList) const = 0;
|
||||
};
|
||||
|
||||
using EditorUtilityWindowPanelFactory =
|
||||
std::function<std::unique_ptr<EditorUtilityWindowPanel>(EditorUtilityWindowKind)>;
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user