new_editor: remove tree panel behavior layer
This commit is contained in:
@@ -73,12 +73,46 @@ inline std::size_t FindVisibleIndexForItemId(
|
||||
return UIEditorTreeViewInvalidIndex;
|
||||
}
|
||||
|
||||
inline bool IsSuppressedPointerInputEvent(
|
||||
const DragDropInteraction::UIInputEvent& event) {
|
||||
switch (event.type) {
|
||||
case ::XCEngine::UI::UIInputEventType::PointerMove:
|
||||
case ::XCEngine::UI::UIInputEventType::PointerButtonDown:
|
||||
case ::XCEngine::UI::UIInputEventType::PointerButtonUp:
|
||||
case ::XCEngine::UI::UIInputEventType::PointerWheel:
|
||||
case ::XCEngine::UI::UIInputEventType::PointerEnter:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<DragDropInteraction::UIInputEvent> FilterPointerInputEvents(
|
||||
const std::vector<DragDropInteraction::UIInputEvent>& inputEvents,
|
||||
bool suppressPointerInput) {
|
||||
if (!suppressPointerInput) {
|
||||
return inputEvents;
|
||||
}
|
||||
|
||||
std::vector<DragDropInteraction::UIInputEvent> filteredEvents = {};
|
||||
filteredEvents.reserve(inputEvents.size());
|
||||
for (const DragDropInteraction::UIInputEvent& event : inputEvents) {
|
||||
if (!IsSuppressedPointerInputEvent(event)) {
|
||||
filteredEvents.push_back(event);
|
||||
}
|
||||
}
|
||||
|
||||
return filteredEvents;
|
||||
}
|
||||
|
||||
inline std::vector<DragDropInteraction::UIInputEvent> BuildInteractionInputEvents(
|
||||
const State& state,
|
||||
const Widgets::UIEditorTreeViewLayout& layout,
|
||||
const std::vector<Widgets::UIEditorTreeViewItem>& items,
|
||||
const std::vector<DragDropInteraction::UIInputEvent>& rawEvents,
|
||||
float dragThreshold = kDefaultDragThreshold) {
|
||||
float dragThreshold = kDefaultDragThreshold,
|
||||
bool suppressPointerInput = false) {
|
||||
auto resolveDraggableItem =
|
||||
[&layout, &items](const UIPoint& point) -> std::string {
|
||||
UIEditorTreeViewHitTarget hitTarget = {};
|
||||
@@ -94,9 +128,11 @@ inline std::vector<DragDropInteraction::UIInputEvent> BuildInteractionInputEvent
|
||||
|
||||
DragDropInteraction::PreviewState preview =
|
||||
DragDropInteraction::BuildPreviewState(state);
|
||||
const std::vector<DragDropInteraction::UIInputEvent> inputEvents =
|
||||
FilterPointerInputEvents(rawEvents, suppressPointerInput);
|
||||
std::vector<DragDropInteraction::UIInputEvent> filteredEvents = {};
|
||||
filteredEvents.reserve(rawEvents.size());
|
||||
for (const DragDropInteraction::UIInputEvent& event : rawEvents) {
|
||||
filteredEvents.reserve(inputEvents.size());
|
||||
for (const DragDropInteraction::UIInputEvent& event : inputEvents) {
|
||||
if (!DragDropInteraction::ProcessPreviewEvent(
|
||||
preview,
|
||||
event,
|
||||
@@ -117,7 +153,8 @@ ProcessResult ProcessInputEvents(
|
||||
const std::vector<DragDropInteraction::UIInputEvent>& inputEvents,
|
||||
const UIRect& bounds,
|
||||
Callbacks& callbacks,
|
||||
float dragThreshold = kDefaultDragThreshold) {
|
||||
float dragThreshold = kDefaultDragThreshold,
|
||||
bool suppressPointerInput = false) {
|
||||
struct AdaptedCallbacks {
|
||||
const Widgets::UIEditorTreeViewLayout& layout;
|
||||
const std::vector<Widgets::UIEditorTreeViewItem>& items;
|
||||
@@ -184,10 +221,12 @@ ProcessResult ProcessInputEvents(
|
||||
} adaptedCallbacks{ layout, items, bounds, callbacks };
|
||||
|
||||
ProcessResult result = {};
|
||||
const std::vector<DragDropInteraction::UIInputEvent> filteredInputEvents =
|
||||
FilterPointerInputEvents(inputEvents, suppressPointerInput);
|
||||
const DragDropInteraction::ProcessResult interactionResult =
|
||||
DragDropInteraction::ProcessInputEvents(
|
||||
state,
|
||||
inputEvents,
|
||||
filteredInputEvents,
|
||||
adaptedCallbacks,
|
||||
dragThreshold);
|
||||
result.selectionForced = interactionResult.selectionForced;
|
||||
|
||||
Reference in New Issue
Block a user