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:
Simon Hausmann 2021-02-02 09:07:01 +01:00
parent c479fd132d
commit 1f091cb1c0
16 changed files with 250 additions and 131 deletions

View file

@ -9,9 +9,9 @@
LICENSE END */
//! Datastructures used to represent layouts in the compiler
use crate::diagnostics::BuildDiagnostics;
use crate::langtype::Type;
use crate::object_tree::{ElementRc, PropertyDeclaration};
use crate::{diagnostics::BuildDiagnostics, langtype::PropertyLookupResult};
use crate::{
expression_tree::{Expression, NamedReference, Path},
object_tree::Component,
@ -69,9 +69,11 @@ pub struct LayoutItem {
impl LayoutItem {
pub fn rect(&self) -> Cow<LayoutRect> {
if let Some(e) = &self.element {
let p = |name: &str| {
if e.borrow().lookup_property(name) == Type::Length {
Some(NamedReference::new(e, name))
let p = |unresolved_name: &str| {
let PropertyLookupResult { resolved_name, property_type } =
e.borrow().lookup_property(unresolved_name);
if property_type == Type::Length {
Some(NamedReference::new(e, resolved_name.as_ref()))
} else {
None
}