Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need more examples #304

Closed
cbeust opened this issue Apr 13, 2021 · 7 comments
Closed

Need more examples #304

cbeust opened this issue Apr 13, 2021 · 7 comments
Labels
feature New feature or request

Comments

@cbeust
Copy link

cbeust commented Apr 13, 2021

I am trying to find out how to

  • Display an image, and/or make that image the background of an existing widget
  • Understand how events such as hovering can lead to changes in appearance

So far, I haven't been able to find examples or documentation showing how to do this

@cbeust cbeust added the feature New feature or request label Apr 13, 2021
@emilk
Copy link
Owner

emilk commented Apr 15, 2021

Have you seen https://emilk.github.io/egui/index.html ?

The Widget Gallery shows how to display an image. Showing an image behind an existing widget (e.g. a slider) is not currently possible; please open a feature request issue if that is something you need!

The toggle switch demo (also shown in the widget gallery) shows how you get hover-effects: https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs

@emilk emilk closed this as completed Apr 15, 2021
@cbeust
Copy link
Author

cbeust commented Apr 15, 2021

I studied the source of the example yes but this code doesn't show how to load an arbitrary png/jpg. Could this be added? (and even better: can you show how to do this here?)

Thanks!

@emilk
Copy link
Owner

emilk commented Apr 15, 2021

Loading images can be done with https://crates.io/crates/image as shown in https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/http_app.rs

@emilk
Copy link
Owner

emilk commented Apr 16, 2021

A better image loading example would be good though. When egui gets a logo, I can add an example for loading it.

@cbeust
Copy link
Author

cbeust commented Apr 16, 2021

Yes. I was able to make it work by copy/pasting a sizeable portion of http_app.rs but it would be helpful if egui could hide as much of the TextureId concept as possible. Most people building GUI's just want to know how to load an image either externally or from an internal bundle, and don't care much about the intermediate steps to get there.

On a related note, I noticed that an image can never be clicked(), is this by design? Should I file a separate bug?

@emilk
Copy link
Owner

emilk commented Apr 16, 2021

On a related note, I noticed that an image can never be clicked(), is this by design?

Yes, that's why there is a separate ImageButton. Please look at the demo and read the docs.

@emilk
Copy link
Owner

emilk commented Apr 16, 2021

I added a task to make a demo to load/show an image to #186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants