Files
XCEngine/new_editor/app/Panels/ProductHierarchyPanel.h

97 lines
3.1 KiB
C++

#pragma once
#include "Hierarchy/ProductHierarchyModel.h"
#include <XCEditor/Collections/UIEditorTreeViewInteraction.h>
#include <XCEditor/Shell/UIEditorPanelContentHost.h>
#include <XCEngine/UI/DrawData.h>
#include <XCEngine/UI/Widgets/UIExpansionModel.h>
#include <XCEngine/UI/Widgets/UISelectionModel.h>
#include <cstdint>
#include <string>
#include <vector>
namespace XCEngine::UI::Editor::App {
class ProductBuiltInIcons;
class ProductHierarchyPanel {
public:
enum class EventKind : std::uint8_t {
None = 0,
SelectionChanged,
Reparented,
MovedToRoot,
RenameRequested
};
struct Event {
EventKind kind = EventKind::None;
std::string itemId = {};
std::string targetItemId = {};
std::string label = {};
};
void Initialize();
void SetBuiltInIcons(const ProductBuiltInIcons* icons);
void Update(
const UIEditorPanelContentHostFrame& contentHostFrame,
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
bool allowInteraction,
bool panelActive);
void Append(::XCEngine::UI::UIDrawList& drawList) const;
bool WantsHostPointerCapture() const;
bool WantsHostPointerRelease() const;
bool HasActivePointerCapture() const;
const std::vector<Event>& GetFrameEvents() const;
private:
struct DragState {
std::string armedItemId = {};
std::string draggedItemId = {};
std::string dropTargetItemId = {};
::XCEngine::UI::UIPoint pressPosition = {};
bool armed = false;
bool dragging = false;
bool dropToRoot = false;
bool validDropTarget = false;
bool requestPointerCapture = false;
bool requestPointerRelease = false;
};
const UIEditorPanelContentHostPanelState* FindMountedHierarchyPanel(
const UIEditorPanelContentHostFrame& contentHostFrame) const;
void ResetTransientState();
void RebuildItems();
void ProcessDragAndFrameEvents(
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
const ::XCEngine::UI::UIRect& bounds,
bool allowInteraction,
bool panelActive);
void EmitSelectionEvent();
void EmitReparentEvent(
EventKind kind,
std::string itemId,
std::string targetItemId);
std::vector<::XCEngine::UI::UIInputEvent> BuildInteractionInputEvents(
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
const ::XCEngine::UI::UIRect& bounds,
bool allowInteraction,
bool panelActive) const;
const ProductBuiltInIcons* m_icons = nullptr;
ProductHierarchyModel m_model = {};
std::vector<Widgets::UIEditorTreeViewItem> m_treeItems = {};
::XCEngine::UI::Widgets::UISelectionModel m_selection = {};
::XCEngine::UI::Widgets::UIExpansionModel m_expansion = {};
UIEditorTreeViewInteractionState m_treeInteractionState = {};
UIEditorTreeViewInteractionFrame m_treeFrame = {};
std::vector<Event> m_frameEvents = {};
DragState m_dragState = {};
bool m_visible = false;
};
} // namespace XCEngine::UI::Editor::App