iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.94k stars 1.18k forks source link

Image button #692

Closed ruza-net closed 3 years ago

ruza-net commented 3 years ago

How do you make an image button?

When I try

iced::Button::new(
    &mut state,
    iced::Image::new("a/path/img.svg"),
)

... it doesn't compile:

error[E0277]: the trait bound `iced_wgpu::backend::Backend: iced_graphics::backend::Image` is not satisfied
  --> src/components/general/floating_frame.rs:74:28
   |
74 |         let collapse_btn = iced::Button::new(
   |                            ^^^^^^^^^^^^^^^^^ the trait `iced_graphics::backend::Image` is not implemented for `iced_wgpu::backend::Backend`
   |
   = note: required because of the requirements on the impl of `iced_native::widget::image::Renderer` for `iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>`
   = note: required because of the requirements on the impl of `From<Image>` for `iced_native::element::Element<'_, _, iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>>`
   = note: required because of the requirements on the impl of `Into<iced_native::element::Element<'_, _, iced_graphics::renderer::Renderer<iced_wgpu::backend::Backend>>>` for `Image`
   = note: required by `iced_native::widget::button::Button::<'a, Message, Renderer>::new`

Do I need to use Image from a specific crate (other than iced)?

yusdacra commented 3 years ago

Do you have the image feature enabled on iced?

ruza-net commented 3 years ago

Thank you, it works now.