关键节点
This commit is contained in:
13
editor/app/UtilityWindows/EditorUtilityWindowKind.h
Normal file
13
editor/app/UtilityWindows/EditorUtilityWindowKind.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
enum class EditorUtilityWindowKind : std::uint8_t {
|
||||
None = 0,
|
||||
ColorPicker,
|
||||
AddComponent,
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
34
editor/app/UtilityWindows/EditorUtilityWindowPanel.h
Normal file
34
editor/app/UtilityWindows/EditorUtilityWindowPanel.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorContext;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
56
editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp
Normal file
56
editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "UtilityWindows/EditorUtilityWindowRegistry.h"
|
||||
|
||||
#include "Features/ColorPicker/ColorPickerPanel.h"
|
||||
#include "Features/Inspector/AddComponentPanel.h"
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::XCEngine::UI::UISize;
|
||||
|
||||
constexpr EditorUtilityWindowDescriptor kColorPickerUtilityWindowDescriptor = {
|
||||
.kind = EditorUtilityWindowKind::ColorPicker,
|
||||
.windowId = "utility.color-picker",
|
||||
.title = L"Color Picker",
|
||||
.preferredOuterSize = UISize(352.0f, 500.0f),
|
||||
.minimumOuterSize = UISize(320.0f, 460.0f),
|
||||
};
|
||||
|
||||
constexpr EditorUtilityWindowDescriptor kAddComponentUtilityWindowDescriptor = {
|
||||
.kind = EditorUtilityWindowKind::AddComponent,
|
||||
.windowId = "utility.add-component",
|
||||
.title = L"Add Component",
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<EditorUtilityWindowPanel> CreateEditorUtilityWindowPanel(
|
||||
EditorUtilityWindowKind kind) {
|
||||
switch (kind) {
|
||||
case EditorUtilityWindowKind::ColorPicker:
|
||||
return std::make_unique<ColorPickerPanel>();
|
||||
case EditorUtilityWindowKind::AddComponent:
|
||||
return std::make_unique<AddComponentPanel>();
|
||||
case EditorUtilityWindowKind::None:
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
27
editor/app/UtilityWindows/EditorUtilityWindowRegistry.h
Normal file
27
editor/app/UtilityWindows/EditorUtilityWindowRegistry.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "UtilityWindows/EditorUtilityWindowKind.h"
|
||||
#include "UtilityWindows/EditorUtilityWindowPanel.h"
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
struct EditorUtilityWindowDescriptor {
|
||||
EditorUtilityWindowKind kind = EditorUtilityWindowKind::None;
|
||||
std::string_view windowId = {};
|
||||
const wchar_t* title = L"";
|
||||
::XCEngine::UI::UISize preferredOuterSize = {};
|
||||
::XCEngine::UI::UISize minimumOuterSize = {};
|
||||
};
|
||||
|
||||
const EditorUtilityWindowDescriptor* ResolveEditorUtilityWindowDescriptor(
|
||||
EditorUtilityWindowKind kind);
|
||||
|
||||
std::unique_ptr<EditorUtilityWindowPanel> CreateEditorUtilityWindowPanel(
|
||||
EditorUtilityWindowKind kind);
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
Reference in New Issue
Block a user