image demo

This commit is contained in:
Daniel Bulant 2024-02-20 22:22:24 +01:00
parent 866a526605
commit 8a63a219c5
2 changed files with 23 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -1,6 +1,6 @@
use rusalka_macro::make_component;
use std::default::Default;
use mangui::{SharedNode, nodes::Style, taffy::prelude::Size, femtovg::{Paint, Color}, nodes::layout::Layout};
use mangui::{femtovg::ImageFlags, nodes::{layout::Layout, Style}, nodes::image::Image, taffy::prelude::Size};
use rusalka::nodes::primitives::{Rectangle, RectangleAttributes, PartialRectangleAttributes};
@ -8,6 +8,10 @@ make_component!(
ComponentDemo,
MainLogic {
let _radius = attrs.radius;
let imgpath = std::path::PathBuf::from("./demo/large/bx117324-97mHyfJGwpBq.jpg");
let imgflags = ImageFlags::empty();
let width = 230.;
let height = 325.;
}
Attributes {
radius: f32
@ -24,6 +28,24 @@ make_component!(
radius: if $test_ { attrs.radius } else { 0. },
..Default::default()
}
@image {
style: Style {
layout: mangui::nodes::TaffyStyle {
min_size: Size {
width: mangui::taffy::style::Dimension::Points(width),
height: mangui::taffy::style::Dimension::Points(height)
},
..Default::default()
},
..Default::default()
},
image: mangui::nodes::image::ImageLoad::LoadFile(imgpath, imgflags),
width,
height,
radius: 5.,
events: Default::default(),
parent: None
}
$|event| {
match event.event {
mangui::events::InnerEvent::MouseDown(_) => {