Skip to content

Commit

Permalink
Disregard visualisation for selection of nodes. (#6487)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMauderer authored May 4, 2023
1 parent 0a8f809 commit 1817da7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
- [Added capability to create node widgets with complex UI][6347]. Node widgets
such as dropdown can now be placed in the node and affect the code text flow.
- [The IDE UI element for selecting the execution mode of the project is now
sending messages to the backend][6341].
sending messages to the backend.][6341].
- [Area selectionof nodes no longer takes into account the visualisation that
belongs to the node.][6487].
- [List Editor Widget][6470]. Now you can edit lists by clicking buttons on
nodes or by dragging the elements.
- [Fixed text visualisations which were being cut off at the last line.][6421]
Expand Down Expand Up @@ -203,6 +205,8 @@
[5895]: https://github.com/enso-org/enso/pull/6130
[6035]: https://github.com/enso-org/enso/pull/6035
[6097]: https://github.com/enso-org/enso/pull/6097
[6097]: https://github.com/enso-org/enso/pull/6341
[6487]: https://github.com/enso-org/enso/pull/6487
[6341]: https://github.com/enso-org/enso/pull/6341
[6470]: https://github.com/enso-org/enso/pull/6470

Expand Down
12 changes: 8 additions & 4 deletions app/gui/view/graph-editor/src/component/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ ensogl::define_endpoints_2! {
/// [`visualization_visible`] is updated. Please remember, that the [`position`] is not
/// immediately updated, only during the Display Object hierarchy update
bounding_box (BoundingBox),
/// The bounding box of the node without the visualization.
inner_bounding_box (BoundingBox),
/// A set of widgets attached to a method requires metadata to be queried. The tuple
/// contains the ID of the call expression the widget is attached to, and the ID of that
/// call's target expression (`self` or first argument).
Expand Down Expand Up @@ -1009,7 +1011,10 @@ impl Node {
visualization_enabled_and_visible <- visualization_enabled && visualization_visible;
bbox_input <- all4(
&out.position,&new_size,&visualization_enabled_and_visible,visualization_size);
out.bounding_box <+ bbox_input.map(|(a,b,c,d)| bounding_box(*a,*b,*c,*d));
out.bounding_box <+ bbox_input.map(|(a,b,c,d)| bounding_box(*a,*b,c.then(|| *d)));

inner_bbox_input <- all2(&out.position,&new_size);
out.inner_bounding_box <+ inner_bbox_input.map(|(a,b)| bounding_box(*a,*b,None));


// === VCS Handling ===
Expand Down Expand Up @@ -1069,13 +1074,12 @@ fn visualization_offset(node_width: f32) -> Vector2 {
fn bounding_box(
node_position: Vector2,
node_size: Vector2,
visualization_enabled_and_visible: bool,
visualization_size: Vector2,
visualization_size: Option<Vector2>,
) -> BoundingBox {
let x_offset_to_node_center = x_offset_to_node_center(node_size.x);
let node_bbox_pos = node_position + Vector2(x_offset_to_node_center, 0.0) - node_size / 2.0;
let node_bbox = BoundingBox::from_position_and_size(node_bbox_pos, node_size);
if visualization_enabled_and_visible {
if let Some(visualization_size) = visualization_size {
let visualization_offset = visualization_offset(node_size.x);
let visualization_pos = node_position + visualization_offset;
let visualization_bbox_pos = visualization_pos - visualization_size / 2.0;
Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/graph-editor/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn get_nodes_in_bounding_box(bounding_box: &BoundingBox, nodes: &Nodes) -> Vec<N
nodes_raw
.iter()
.filter_map(|(id, node)| {
bounding_box.intersects(&node.view.bounding_box.value()).as_some(*id)
bounding_box.intersects(&node.view.inner_bounding_box.value()).as_some(*id)
})
.collect()
}
Expand Down

0 comments on commit 1817da7

Please sign in to comment.