Skip to content

Feature request: data binding for []byte and support binding in canvas.Image #2333

Open
@hkparker

Description

@hkparker

Is your feature request related to a problem? Please describe:

Let's say I'm displaying a user with their profile picture everywhere, then the user changes their profile picture. I want to update all copies of it at the same time.

Is it possible to construct a solution with the existing API?

I think so. Every time I create a new canvas.Image, I can store a reference to it in a slice. Think map[string][]*canvas.Image where the string is the user ID and the slice contains every image I've created for that user across the entire app. Then, when the profile picture is changed, I would iterate over that slice and for each image assign a new fyne.Resource and call Refresh(). This feels sub-optimal.

Describe the solution you'd like to see:

Something like:

profilePicture := binding.NewBytes(originalImageBytes)
canvas.NewImageFromBinding(profilePicture)

// Later on...
profilePicture.Set(newImageBytes)

Does this seem like a reasonable feature? The binding code looks pretty approachable so I might be able to handle that part, the canvas stuff I've explored less.

Metadata

Metadata

Assignees

No one assigned

    Labels

    data bindingIssue related to bug or improvement of data binding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions