Im trying to use iced for the gui in an audio plug in I’m building, but I keep seeing discrepancies in how to accomplish this.

On the iced github page, it says that to implement the Sandbox trait, you use this signature: fn view(&self), yet in the documentation it says to use view(&mut self). When I try to use the non-mut version, I get an error saying that it expects self to be mutable.

I also stumbled across iced-pure, which seems like a better idea. But I need to use a NumberInput widget from the iced-aw crate. Unfortunately, these widgets are not pure.

So how do I go about creating a gui using NumberInput? Do I need to create the widgets myself to make them pure? I’d like to use other widgets from the iced-aw crate too, so that wouldn’t be ideal

Or do i have to use the mutable version of view? If so, why does github say to use non mutable? Is this specific to certain versions of iced? If the newer version of iced uses a non mutable view function, does that mean it’s pure? Have the iced-pure changes been merged into iced?

  • @[email protected]
    link
    fedilink
    1
    edit-2
    1 year ago

    Pure widgets are just ones that don’t contain state. You pick which one you need based on which one you need, so in your case you need state because you must store what’s within the number input box.

    I’m not wholly familiar with iced, but I’d venture to guess the example you looked at didn’t need to store state so it was able to use a non-mutable view, whereas you need to store it so that example doesn’t exactly work for you. However it could just be a bit out of date, and I’m sure they’d appreciate a PR

    • @BarbacamanituOP
      link
      11 year ago

      Gotcha. I unfortunately decided to give up on trying to do this in Rust. I’m trying out JUCE since it’s industry standard. I’m already bashing my head against the wall with this C++ garbage. Hopefully the gui scene looks better for rust soon

          • @[email protected]
            link
            fedilink
            11 year ago

            Agui, but it’s not yet ready for legitimate use. Well, sort of. The engine should be mostly there, I’m just working on integrations with renderers and windowing (winit), now. It doesn’t have focusing or accessibility support yet, but that’s my next task