i_slint_compiler/passes/
border_radius.rs1use crate::diagnostics::BuildDiagnostics;
7use crate::expression_tree::{Expression, NamedReference};
8use crate::object_tree::Component;
9use smol_str::SmolStr;
10use std::rc::Rc;
11
12pub const BORDER_RADIUS_PROPERTIES: [&str; 4] = [
13 "border-top-left-radius",
14 "border-top-right-radius",
15 "border-bottom-right-radius",
16 "border-bottom-left-radius",
17];
18
19pub fn handle_border_radius(root_component: &Rc<Component>, _diag: &mut BuildDiagnostics) {
20 crate::object_tree::recurse_elem_including_sub_components_no_borrow(
21 root_component,
22 &(),
23 &mut |elem, _| {
24 let bty = if let Some(bty) = elem.borrow().builtin_type() { bty } else { return };
25 if bty.name == "Rectangle"
26 && elem.borrow().is_binding_set("border-radius", true)
27 && BORDER_RADIUS_PROPERTIES
28 .iter()
29 .any(|property_name| elem.borrow().is_binding_set(property_name, true))
30 {
31 let border_radius = NamedReference::new(elem, SmolStr::new_static("border-radius"));
32 for property_name in BORDER_RADIUS_PROPERTIES.iter() {
33 elem.borrow_mut().set_binding_if_not_set(SmolStr::new(property_name), || {
34 Expression::PropertyReference(border_radius.clone())
35 });
36 }
37 }
38 },
39 )
40}