mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 20:31:27 +00:00
Remove the error when using @children on the root component
This complicates multi-component handling
This commit is contained in:
parent
acb7da11d2
commit
8933f3308c
7 changed files with 14 additions and 26 deletions
|
|
@ -224,11 +224,6 @@ pub async fn compile_syntax_node(
|
|||
&type_registry,
|
||||
);
|
||||
|
||||
if let Some((_, _, node)) = &*doc.root_component.child_insertion_point.borrow() {
|
||||
diagnostics
|
||||
.push_error("@children placeholder not allowed in the final component".into(), node)
|
||||
}
|
||||
|
||||
if !diagnostics.has_error() {
|
||||
passes::run_passes(&doc, &mut loader, false, &mut diagnostics).await;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub async fn run_passes(
|
|||
|
||||
focus_handling::call_focus_on_init(root_component);
|
||||
|
||||
ensure_window::ensure_window(root_component, &doc.local_registry, &style_metrics);
|
||||
ensure_window::ensure_window(root_component, &doc.local_registry, &style_metrics, diag);
|
||||
|
||||
doc.visit_all_used_components(|component| {
|
||||
border_radius::handle_border_radius(component, diag);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
//! Make sure that the top level element of the component is always a Window
|
||||
|
||||
use crate::diagnostics::BuildDiagnostics;
|
||||
use crate::expression_tree::{BindingExpression, BuiltinFunction, Expression};
|
||||
use crate::langtype::Type;
|
||||
use crate::namedreference::NamedReference;
|
||||
|
|
@ -16,7 +17,15 @@ pub fn ensure_window(
|
|||
component: &Rc<Component>,
|
||||
type_register: &TypeRegister,
|
||||
style_metrics: &Rc<Component>,
|
||||
diag: &mut BuildDiagnostics,
|
||||
) {
|
||||
if component.inherits_popup_window.get() {
|
||||
diag.push_error(
|
||||
"PopupWindow cannot be the top level".into(),
|
||||
&*component.root_element.borrow(),
|
||||
);
|
||||
}
|
||||
|
||||
if component.root_element.borrow().builtin_type().map_or(true, |b| {
|
||||
matches!(b.name.as_str(), "Window" | "Dialog" | "WindowItem" | "PopupWindow")
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -45,13 +45,6 @@ fn lower_popup_window(
|
|||
let parent_component = popup_window_element.borrow().enclosing_component.upgrade().unwrap();
|
||||
let parent_element = match parent_element {
|
||||
None => {
|
||||
if parent_component.is_root_component.get() {
|
||||
diag.push_error(
|
||||
"PopupWindow cannot be the top level".into(),
|
||||
&*popup_window_element.borrow(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if matches!(popup_window_element.borrow().base_type, ElementType::Builtin(_)) {
|
||||
popup_window_element.borrow_mut().base_type = window_type.clone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,5 @@ export TestBox2 := Rectangle {
|
|||
export Final := TestBox {
|
||||
Rectangle {
|
||||
@children
|
||||
// ^error{children placeholder not allowed in the final component}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
export Final := Window {
|
||||
VerticalLayout {
|
||||
@children
|
||||
// ^error{children placeholder not allowed in the final component}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
Container := Rectangle {
|
||||
component Container inherits Rectangle {
|
||||
GridLayout {
|
||||
padding: 0phx;
|
||||
spacing: 0phx;
|
||||
|
|
@ -19,15 +19,16 @@ Container := Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
TestCase := Container {
|
||||
export component TestCase inherits Container {
|
||||
width: 300phx;
|
||||
height: 200phx;
|
||||
|
||||
rect1 := Rectangle {
|
||||
background: black;
|
||||
@children
|
||||
}
|
||||
|
||||
property <bool> rect1_pos_ok: rect1.x == 150phx;
|
||||
out property <bool> rect1_pos_ok: rect1.x == 150phx;
|
||||
|
||||
out property <bool> test: rect1_pos_ok;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue