-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entities can be dragged from the blueprint tree and streams tree to an existing view in the viewport #8431
Conversation
# Conflicts: # crates/viewer/re_selection_panel/src/view_entity_picker.rs
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
…en they can accept a drop
…ill now looks gray when not droppable.
# Conflicts: # Cargo.lock # Cargo.toml
# Conflicts: # crates/viewer/re_viewer_context/src/viewer_context.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it!
fn try_item_collection_to_contents(items: &ItemCollection) -> Option<Vec<Contents>> { | ||
items.iter().map(|(item, _)| item.try_into().ok()).collect() | ||
} | ||
|
||
fn try_item_collection_to_entities(items: &ItemCollection) -> Option<Vec<EntityPath>> { | ||
items | ||
.iter() | ||
.map(|(item, _)| match item { | ||
Item::InstancePath(instance_path) | Item::DataResult(_, instance_path) => instance_path | ||
.is_all() | ||
.then(|| instance_path.entity_path.clone()), | ||
_ => None, | ||
}) | ||
.collect() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a comment why these aren't filter_map would be nice. Iirc right from the demo session that was a conscious choice but code wide it looks a like bug codewise
(and I reckon that's also the reason this isn't implemented as a TryInto
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to have a TryInto
for part of that iirc, but I find TryInto
to denote a degree of generality that doesn't really apply. In the context of drag-and-drop (and its specific semantics), an ItemCollection
may or may not be converted to a, e.g., Vec<EntityPath>
. The conversion might be otherwise in other contexts, e.g. DataResult
and Instance
might actually be differentiated.
Now this is not a filter_map
because it uses the collect
transpose trick that implies the all
semantics: it returns Some<Vec<_>>
only if all items are Some<_>
. I'll add a comment to that effect.
Related
What
This PR makes it possible to drag one or more entities from the blueprint and streams tree to existing views in the viewport. This involves introducing and/or adjusting a whole bunch of semantics around selection and dragging.
DragAndDropFeedback
This PR introduced the notion of drag-and-drop feedback from the hovered ui element.
Feedback may be either of:
A drop should only ever happen in the latter case.
Payload visualisation
The payload pill display is now adjusted based on the feedback, both its opacity (ranging from 50 to 80%) and its colour (grey or blue). The mouse cursor is also adjusted based on the feedback.
Drop container visualisation
This PR slightly adjust the look of the drop container visualisation: the blue frame is now 2px wide.
Note that the drop container is not necessarily the thing that's hovered by the mouse, see e.g. containers in the blueprint.
Selection handling during drag-and-drop
This PR slightly alter the current behaviour. Now:
cmd
held adds that item to the selection, and drags the entire selectionEntity-to-viewport-view drag semantics
This is the original goal of this PR.
Emphasis on that last point. This subtle UX behaviour (courtesy of @gavrelina) makes the drop success and impact on the entity path filter more explicit.
Theory of operation for drag-and-drop
With this PR, a "framework" slowly starts to emerge. For now, it's mainly this bit of documentation:
TODO
entity_drag.mp4