Skip to content

Commit

Permalink
live preview: Use selection based on nodes
Browse files Browse the repository at this point in the history
Now that we keep information on all nodes, use that to do more
"fine grained" selection: We select based on nodes, not elements in
the element tree now.

This assumes that a source locartion based on file path and offset in
that file is enough to define the nodes of an element.
  • Loading branch information
hunger committed Feb 26, 2024
1 parent a3c9955 commit b4e36f1
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 114 deletions.
4 changes: 2 additions & 2 deletions tools/lsp/preview/drop_location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use i_slint_compiler::object_tree::ElementRc;
use i_slint_core::lengths::{LogicalLength, LogicalPoint};
use slint_interpreter::ComponentInstance;

use crate::preview::element_selection::collect_all_elements_covering;
use crate::preview::element_selection::collect_all_element_nodes_covering;

#[cfg(target_arch = "wasm32")]
use crate::wasm_prelude::*;
Expand All @@ -21,7 +21,7 @@ fn find_drop_location(
x: f32,
y: f32,
) -> Option<DropInformation> {
let elements = collect_all_elements_covering(x, y, &component_instance);
let elements = collect_all_element_nodes_covering(x, y, &component_instance);
let (node_index, target_element) = elements.iter().find_map(|sc| {
sc.element
.borrow()
Expand Down
Loading

0 comments on commit b4e36f1

Please sign in to comment.