mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Rename Rectangle.color to Rectangle.background
Add support for built-in property aliases and rename `color` to `background` - in preparation for it also changing to type brush. Right now the alias is silent, a deprecation and overall change will come in a subsequent change.
This commit is contained in:
parent
c479fd132d
commit
1f091cb1c0
16 changed files with 250 additions and 131 deletions
|
@ -81,11 +81,15 @@ pub fn load_builtins(register: &mut TypeRegister) {
|
|||
let mut n = NativeClass::new_with_properties(
|
||||
&id,
|
||||
e.PropertyDeclaration()
|
||||
.map(|p| {
|
||||
(
|
||||
identifier_text(&p.DeclaredIdentifier()).unwrap(),
|
||||
object_tree::type_from_node(p.Type(), *diag.borrow_mut(), register),
|
||||
)
|
||||
.flat_map(|p| {
|
||||
if p.TwoWayBinding().is_some() {
|
||||
None // aliases are handled further down
|
||||
} else {
|
||||
Some((
|
||||
identifier_text(&p.DeclaredIdentifier()).unwrap(),
|
||||
object_tree::type_from_node(p.Type(), *diag.borrow_mut(), register),
|
||||
))
|
||||
}
|
||||
})
|
||||
.chain(e.CallbackDeclaration().map(|s| {
|
||||
(
|
||||
|
@ -108,6 +112,21 @@ pub fn load_builtins(register: &mut TypeRegister) {
|
|||
)
|
||||
})),
|
||||
);
|
||||
n.deprecated_aliases = e
|
||||
.PropertyDeclaration()
|
||||
.flat_map(|p| {
|
||||
if let Some(twb) = p.TwoWayBinding() {
|
||||
let alias_name = identifier_text(&p.DeclaredIdentifier()).unwrap();
|
||||
let alias_target = identifier_text(&twb.Expression().QualifiedName().expect(
|
||||
"internal error: built-in aliases can only be declared within the type",
|
||||
))
|
||||
.unwrap();
|
||||
Some((alias_name, alias_target))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
n.cpp_type = parse_annotation("cpp_type", &e.node).map(|x| x.unwrap());
|
||||
n.rust_type_constructor =
|
||||
parse_annotation("rust_type_constructor", &e.node).map(|x| x.unwrap());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue