mirror of https://github.com/wayvr-org/wayvr.git
52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
use crate::{
|
|
assets::AssetPath,
|
|
components::{self, Component},
|
|
layout::WidgetID,
|
|
parser::{
|
|
AttribPair, ParserContext, ParserFile, get_asset_path_from_kv,
|
|
helpers::{TooltipAttribs, parse_attrib_tooltip},
|
|
parse_children, process_component,
|
|
style::parse_style,
|
|
},
|
|
};
|
|
|
|
pub fn parse_component_video<'a>(
|
|
file: &'a ParserFile,
|
|
ctx: &mut ParserContext,
|
|
node: roxmltree::Node<'a, 'a>,
|
|
parent_id: WidgetID,
|
|
attribs: &[AttribPair],
|
|
tag_name: &str,
|
|
) -> anyhow::Result<WidgetID> {
|
|
let mut tooltip = TooltipAttribs::default();
|
|
let mut src: Option<AssetPath> = None;
|
|
|
|
let style = parse_style(ctx, attribs, tag_name);
|
|
|
|
for pair in attribs {
|
|
let (key, value) = (pair.attrib.as_ref(), pair.value.as_ref());
|
|
match key {
|
|
"src" | "src_ext" | "src_builtin" | "src_internal" => {
|
|
let asset_path = get_asset_path_from_kv("", key, value);
|
|
|
|
if !value.is_empty() {
|
|
src = Some(asset_path);
|
|
}
|
|
}
|
|
_ => {
|
|
parse_attrib_tooltip(ctx, tag_name, pair, &mut tooltip);
|
|
}
|
|
}
|
|
}
|
|
|
|
let (widget, video) = components::video::construct(
|
|
&mut ctx.get_construct_essentials(parent_id),
|
|
components::video::Params { style, src },
|
|
)?;
|
|
|
|
process_component(ctx, Component(video), widget.id, attribs);
|
|
parse_children(file, ctx, node, widget.id)?;
|
|
|
|
Ok(widget.id)
|
|
}
|