Skip to content

Commit

Permalink
Revert "Add a warning if a PopupWindow is in a layout"
Browse files Browse the repository at this point in the history
This reverts commit 66652cd.

The warning in the gallery are hard to fix because the component inherit
from a layout and there is nowhere to place the popups
  • Loading branch information
ogoffart committed Jun 24, 2024
1 parent 1c8b373 commit 539abfc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 52 deletions.
11 changes: 0 additions & 11 deletions internal/compiler/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,3 @@ pub fn create_new_prop(elem: &ElementRc, tentative_name: &str, ty: Type) -> Name
}
}
}

/// Return true if this type is a layout that has constraints
pub fn is_layout(base_type: &ElementType) -> bool {
match base_type {
ElementType::Builtin(b) => {
matches!(b.name.as_str(), "GridLayout" | "HorizontalLayout" | "VerticalLayout" | "Row")
}
ElementType::Component(c) => is_layout(&c.root_element.borrow().base_type),
_ => false,
}
}
15 changes: 12 additions & 3 deletions internal/compiler/passes/flickable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn fixup_geometry(flickable_elem: &ElementRc) {
.borrow()
.children
.iter()
.filter(|x| crate::layout::is_layout(&x.borrow().base_type))
.filter(|x| is_layout(&x.borrow().base_type))
// FIXME: we should ideally add runtime code to merge layout info of all elements that are repeated (#407)
.filter(|x| x.borrow().repeated.is_none())
.map(|x| Expression::PropertyReference(NamedReference::new(x, prop)))
Expand All @@ -106,7 +106,7 @@ fn fixup_geometry(flickable_elem: &ElementRc) {
.borrow()
.children
.iter()
.filter(|x| crate::layout::is_layout(&x.borrow().base_type))
.filter(|x| is_layout(&x.borrow().base_type))
// FIXME: (#407)
.filter(|x| x.borrow().repeated.is_none())
.map(|x| Expression::PropertyReference(NamedReference::new(x, "min-width")))
Expand All @@ -122,7 +122,7 @@ fn fixup_geometry(flickable_elem: &ElementRc) {
.borrow()
.children
.iter()
.filter(|x| crate::layout::is_layout(&x.borrow().base_type))
.filter(|x| is_layout(&x.borrow().base_type))
// FIXME: (#407)
.filter(|x| x.borrow().repeated.is_none())
.map(|x| Expression::PropertyReference(NamedReference::new(x, "min-height")))
Expand All @@ -134,6 +134,15 @@ fn fixup_geometry(flickable_elem: &ElementRc) {
});
}

/// Return true if this type is a layout that has constraints
fn is_layout(base_type: &ElementType) -> bool {
if let ElementType::Builtin(be) = base_type {
matches!(be.name.as_str(), "GridLayout" | "HorizontalLayout" | "VerticalLayout")
} else {
false
}
}

/// Set the property binding on the given element to the given expression (computed lazily).
/// The parameter to the lazily calculation is the element's children
fn set_binding_if_not_explicit(
Expand Down
10 changes: 1 addition & 9 deletions internal/compiler/passes/lower_popups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ fn lower_popup_window(
parent_component.inherits_popup_window.set(true);
return;
}
Some(parent_element) => {
if crate::layout::is_layout(&parent_element.borrow().base_type) {
diag.push_warning(
"PopupWindow shouldn't be a children of a layout".into(),
&*popup_window_element.borrow(),
)
}
parent_element
}
Some(parent_element) => parent_element,
};

if Rc::ptr_eq(&parent_component.root_element, popup_window_element) {
Expand Down
29 changes: 0 additions & 29 deletions internal/compiler/tests/syntax/elements/popup3.slint

This file was deleted.

0 comments on commit 539abfc

Please sign in to comment.