attribs rework
This commit is contained in:
@@ -2,8 +2,9 @@ use crate::{
|
||||
i18n::Translation,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
ParserContext, ParserFile, iter_attribs, parse_children, parse_widget_universal,
|
||||
parse_children, parse_widget_universal,
|
||||
style::{parse_style, parse_text_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
widget::label::{WidgetLabel, WidgetLabelParams},
|
||||
};
|
||||
@@ -13,23 +14,24 @@ pub fn parse_widget_label<'a, U1, U2>(
|
||||
ctx: &mut ParserContext<U1, U2>,
|
||||
node: roxmltree::Node<'a, 'a>,
|
||||
parent_id: WidgetID,
|
||||
attribs: &[AttribPair],
|
||||
) -> anyhow::Result<WidgetID> {
|
||||
let mut params = WidgetLabelParams::default();
|
||||
let attribs: Vec<_> = iter_attribs(file, ctx, &node, false).collect();
|
||||
|
||||
let style = parse_style(&attribs);
|
||||
params.style = parse_text_style(&attribs);
|
||||
let style = parse_style(attribs);
|
||||
params.style = parse_text_style(attribs);
|
||||
|
||||
for (key, value) in attribs {
|
||||
match &*key {
|
||||
for pair in attribs {
|
||||
let (key, value) = (pair.attrib.as_ref(), pair.value.as_ref());
|
||||
match key {
|
||||
"text" => {
|
||||
if !value.is_empty() {
|
||||
params.content = Translation::from_raw_text(&value);
|
||||
params.content = Translation::from_raw_text(value);
|
||||
}
|
||||
}
|
||||
"translation" => {
|
||||
if !value.is_empty() {
|
||||
params.content = Translation::from_translation_key(&value);
|
||||
params.content = Translation::from_translation_key(value);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -42,7 +44,7 @@ pub fn parse_widget_label<'a, U1, U2>(
|
||||
.layout
|
||||
.add_child(parent_id, WidgetLabel::create(&mut globals.get(), params), style)?;
|
||||
|
||||
parse_widget_universal(file, ctx, node, new_id);
|
||||
parse_widget_universal(ctx, new_id, attribs);
|
||||
parse_children(file, ctx, node, new_id)?;
|
||||
|
||||
Ok(new_id)
|
||||
|
||||
Reference in New Issue
Block a user