mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 06:48:12 +08:00
Store content as a separate field
This commit is contained in:
committed by
Keavon Chambers
parent
e82cc48523
commit
9150630227
@@ -6,7 +6,7 @@
|
|||||||
<if :a="{{IS_MAXIMIZED}}">
|
<if :a="{{IS_MAXIMIZED}}">
|
||||||
<icon :svg="`window_restore_down.svg`" />
|
<icon :svg="`window_restore_down.svg`" />
|
||||||
</if>
|
</if>
|
||||||
<if :a="{{IS_MAXIMIZED}}" b="false">
|
<if :a="{{IS_MAXIMIZED}}" :b="false">
|
||||||
<icon :svg="`maximize.svg`" />
|
<icon :svg="`maximize.svg`" />
|
||||||
</if>
|
</if>
|
||||||
</box>
|
</box>
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ impl LayoutAbstractNode {
|
|||||||
pub struct LayoutAbstractTag {
|
pub struct LayoutAbstractTag {
|
||||||
pub namespace: String,
|
pub namespace: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// Layout attributes, which are used by the layout engine.
|
||||||
pub layout_attributes: LayoutAttributes,
|
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>,
|
pub attributes: Vec<Attribute>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,12 +34,25 @@ impl LayoutAbstractTag {
|
|||||||
namespace,
|
namespace,
|
||||||
name,
|
name,
|
||||||
layout_attributes: Default::default(),
|
layout_attributes: Default::default(),
|
||||||
|
content: None,
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_attribute(&mut self, attribute: Attribute) {
|
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[..] {
|
match &attribute.name[..] {
|
||||||
|
// The special `content` attribute
|
||||||
|
"content" => self.content = Some(attribute.value),
|
||||||
// Layout attributes, stored separately
|
// Layout attributes, stored separately
|
||||||
"width" => self.layout_attributes.width = attribute.dimension(),
|
"width" => self.layout_attributes.width = attribute.dimension(),
|
||||||
"height" => self.layout_attributes.height = 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()),
|
"x-spacing" => self.layout_attributes.spacing.set_horizontal(attribute.dimension()),
|
||||||
"y-spacing" => self.layout_attributes.spacing.set_vertical(attribute.dimension()),
|
"y-spacing" => self.layout_attributes.spacing.set_vertical(attribute.dimension()),
|
||||||
"spacing" => self.layout_attributes.spacing = attribute.box_dimensions(),
|
"spacing" => self.layout_attributes.spacing = attribute.box_dimensions(),
|
||||||
// Non-layout attribute
|
_ => panic!("unknown builtin attribute {}", attribute.name),
|
||||||
_ => self.attributes.push(attribute),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-20
@@ -317,29 +317,26 @@ impl LayoutSystem {
|
|||||||
for node in component {
|
for node in component {
|
||||||
println!("Printing Component:\n{:#?}\n\n", node);
|
println!("Printing Component:\n{:#?}\n\n", node);
|
||||||
match node {
|
match node {
|
||||||
LayoutAbstractNode::Tag(tag) => {
|
LayoutAbstractNode::Tag(ref tag) => match tag.content {
|
||||||
let content = tag.attributes.iter().find(|a| a.name == "content");
|
Some(ref value) => match value {
|
||||||
match content {
|
AttributeValue::TypeValue(ref type_value) => {
|
||||||
Some(attribute) => match attribute.value {
|
for type_value_or_argument in type_value {
|
||||||
AttributeValue::TypeValue(ref type_value) => {
|
match type_value_or_argument {
|
||||||
for type_value_or_argument in type_value {
|
TypeValueOrArgument::TypeValue(type_value) => match type_value {
|
||||||
match type_value_or_argument {
|
TypeValue::Layout(layout) => {
|
||||||
TypeValueOrArgument::TypeValue(type_value) => match type_value {
|
for component_ast in layout {
|
||||||
TypeValue::Layout(layout) => {
|
Self::print_layout_tree(&component_ast);
|
||||||
for component_ast in layout {
|
}
|
||||||
Self::print_layout_tree(&component_ast);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
},
|
},
|
||||||
TypeValueOrArgument::VariableArgument(_) => {},
|
_ => {},
|
||||||
}
|
},
|
||||||
|
TypeValueOrArgument::VariableArgument(_) => {},
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
AttributeValue::VariableParameter(_) => {},
|
|
||||||
},
|
},
|
||||||
None => {},
|
AttributeValue::VariableParameter(_) => {},
|
||||||
}
|
},
|
||||||
|
None => {},
|
||||||
},
|
},
|
||||||
LayoutAbstractNode::Text(_) => {},
|
LayoutAbstractNode::Text(_) => {},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user