mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Store content as a separate field
This commit is contained in:
parent
e82cc48523
commit
9150630227
3 changed files with 36 additions and 23 deletions
|
|
@ -6,7 +6,7 @@
|
|||
<if :a="{{IS_MAXIMIZED}}">
|
||||
<icon :svg="`window_restore_down.svg`" />
|
||||
</if>
|
||||
<if :a="{{IS_MAXIMIZED}}" b="false">
|
||||
<if :a="{{IS_MAXIMIZED}}" :b="false">
|
||||
<icon :svg="`maximize.svg`" />
|
||||
</if>
|
||||
</box>
|
||||
|
|
|
|||
|
|
@ -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<AttributeValue>,
|
||||
/// User-defined attributes, which are prefixed with ':'
|
||||
pub attributes: Vec<Attribute>,
|
||||
}
|
||||
|
||||
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(_) => {},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue