jkb0o / belly

Define the Bevy UI tree with `eml!`, style it using a very-css-like `ess` syntax and relate data data with `bind!` and `connect!`
Apache License 2.0
406 stars 32 forks source link

Img src from image handle not working #49

Closed Vixeliz closed 1 year ago

Vixeliz commented 1 year ago

I tried using a bevy handle for the image src however I get the error

error[E0277]: the trait bound `Variant: From<bevy::prelude::Handle<bevy::prelude::Image>>` is not satisfied
  --> client/src/states/game/setup.rs:45:22
   |
45 |             <img src=crosshair_handle/>
   |                      ^^^^^^^^^^^^^^^^ the trait `From<bevy::prelude::Handle<bevy::prelude::Image>>` is not implemented for `Variant`
   |
   = help: the following other types implement trait `From<T>`:
             <Variant as From<&&str>>
             <Variant as From<&str>>
             <Variant as From<BtnMode>>
             <Variant as From<ImgMode>>
             <Variant as From<JustifyContent>>
             <Variant as From<PropertyValue>>
             <Variant as From<Val>>
             <Variant as From<belly::belly_core::eml::Params>>
           and 7 others
   = note: required for `bevy::prelude::Handle<bevy::prelude::Image>` to implement `Into<Variant>`

this is the code:

    let crosshair_handle: Handle<Image> = asset_server.load("crosshair.png");

    commands.add(eml! {
        <body s:padding="50px" s:position-type="absolute">
            <img src=crosshair_handle/>
        </body>
    });

Based off of the example image-sources.rs i don't see anything im doing wrong. It's worth noting im on git instead of release so i realize that may be the issue. Im on git due to the alsa in the Cargo.toml not fixed in a release yet afaik. Any help would be appreciated. (Im aware i can just pass in a string and itll load the image however it seems to be inconsistent in my use case)

jkb0o commented 1 year ago

Looks like you use old version of the crate. Try to update the deps:

cargo update -p belly

If this doesn't help share the output of

cargo tree | grep belly

Thank you for the contribution!

Vixeliz commented 1 year ago

Yep that worked thank you!