diff --git a/gui/header/window-buttons.xml b/gui/header/window-buttons.xml
index f594b9efe..ef22f25ee 100644
--- a/gui/header/window-buttons.xml
+++ b/gui/header/window-buttons.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/src/layout_abstract_syntax.rs b/src/layout_abstract_syntax.rs
index 60903e03e..cc92b3ec2 100644
--- a/src/layout_abstract_syntax.rs
+++ b/src/layout_abstract_syntax.rs
@@ -20,7 +20,11 @@ impl LayoutAbstractNode {
pub struct LayoutAbstractTag {
pub namespace: String,
pub name: String,
+ /// Layout attributes, which are used by the layout engine.
pub layout_attributes: LayoutAttributes,
+ /// The special content attribute, representing the inner elements of this tag.
+ pub content: Option,
+ /// User-defined attributes, which are prefixed with ':'
pub attributes: Vec,
}
@@ -30,12 +34,25 @@ impl LayoutAbstractTag {
namespace,
name,
layout_attributes: Default::default(),
+ content: None,
attributes: Vec::new(),
}
}
pub fn add_attribute(&mut self, attribute: Attribute) {
+ // User-defined attribute
+ if attribute.name.chars().next().unwrap() == ':' {
+ self.attributes.push(attribute);
+ }
+ else {
+ self.add_builtin_attribute(attribute);
+ }
+ }
+
+ fn add_builtin_attribute(&mut self, attribute: Attribute) {
match &attribute.name[..] {
+ // The special `content` attribute
+ "content" => self.content = Some(attribute.value),
// Layout attributes, stored separately
"width" => self.layout_attributes.width = attribute.dimension(),
"height" => self.layout_attributes.height = attribute.dimension(),
@@ -47,8 +64,7 @@ impl LayoutAbstractTag {
"x-spacing" => self.layout_attributes.spacing.set_horizontal(attribute.dimension()),
"y-spacing" => self.layout_attributes.spacing.set_vertical(attribute.dimension()),
"spacing" => self.layout_attributes.spacing = attribute.box_dimensions(),
- // Non-layout attribute
- _ => self.attributes.push(attribute),
+ _ => panic!("unknown builtin attribute {}", attribute.name),
}
}
}
diff --git a/src/layout_system.rs b/src/layout_system.rs
index 23b3278a1..d14874e59 100644
--- a/src/layout_system.rs
+++ b/src/layout_system.rs
@@ -317,29 +317,26 @@ impl LayoutSystem {
for node in component {
println!("Printing Component:\n{:#?}\n\n", node);
match node {
- LayoutAbstractNode::Tag(tag) => {
- let content = tag.attributes.iter().find(|a| a.name == "content");
- match content {
- Some(attribute) => match attribute.value {
- AttributeValue::TypeValue(ref type_value) => {
- for type_value_or_argument in type_value {
- match type_value_or_argument {
- TypeValueOrArgument::TypeValue(type_value) => match type_value {
- TypeValue::Layout(layout) => {
- for component_ast in layout {
- Self::print_layout_tree(&component_ast);
- }
- },
- _ => {},
+ LayoutAbstractNode::Tag(ref tag) => match tag.content {
+ Some(ref value) => match value {
+ AttributeValue::TypeValue(ref type_value) => {
+ for type_value_or_argument in type_value {
+ match type_value_or_argument {
+ TypeValueOrArgument::TypeValue(type_value) => match type_value {
+ TypeValue::Layout(layout) => {
+ for component_ast in layout {
+ Self::print_layout_tree(&component_ast);
+ }
},
- TypeValueOrArgument::VariableArgument(_) => {},
- }
+ _ => {},
+ },
+ TypeValueOrArgument::VariableArgument(_) => {},
}
- },
- AttributeValue::VariableParameter(_) => {},
+ }
},
- None => {},
- }
+ AttributeValue::VariableParameter(_) => {},
+ },
+ None => {},
},
LayoutAbstractNode::Text(_) => {},
}