mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-22 00:02:40 +00:00
live preview: Drop elements into layouts (MVP!)
This is the minimum layout support: It drops elements into a layout right before the layout's closing brace.
This commit is contained in:
parent
e61c97fbdf
commit
171c9e215a
3 changed files with 60 additions and 22 deletions
|
|
@ -70,6 +70,19 @@ pub fn find_element_indent(element: &ElementRc) -> Option<String> {
|
|||
None
|
||||
}
|
||||
|
||||
/// Find the indentation of the element itself as well as the indentation of properties inside the element.
|
||||
/// Returns the element indent followed by the block indent
|
||||
pub fn find_element_node_indent(element: &ElementRc, debug_index: usize) -> Option<String> {
|
||||
let mut token = element.borrow().debug.get(debug_index)?.0.first_token()?.prev_token();
|
||||
while let Some(t) = token {
|
||||
if t.kind() == SyntaxKind::Whitespace && t.text().contains('\n') {
|
||||
return t.text().split('\n').last().map(|s| s.to_owned());
|
||||
}
|
||||
token = t.prev_token();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Given a node within an element, return the Type for the Element under that node.
|
||||
/// (If node is an element, return the Type for that element, otherwise the type of the element under it)
|
||||
/// Will return `Foo` in the following example where `|` is the cursor.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue