Layers or background image #710
Replies: 2 comments
-
OP has probably since moved on in the last year, so this is for anyone who encounters this issue moving forward to know. From what I can tell (which sucks) this is not possible without manually generating the initial frame context and creating/modifying the available_rect struct to include a way to impl an imageReader (which likely needs to be synced with the refresh rate.) The struct would need to of course check the image/bytes for errors before creating an instance of the available_rect struct also. It's not a difficult task seeing as you can copy emilk's designs/structs and simply add the image part as a property (then, lock it down to certain formats, implement all formats, etc) but it becomes extremely tedious when you consider having to modify each and every widget you use so that you can see the background image through it. I don't think egui was designed for anything beyond simple game engine GUI's and quick mock up GUI's (which is ironic considering the learning curve brought on by the not-so-good documentation available). Its really disappointing that this feature is not easily implemented (altering background color also) since image support is added and examples do exist within egui but aside from displaying images in a simple container, even changing the background color is also tedious when you consider that you have to create an entire theme in order to do that. My advice: seek another GUI library that has support for this from the start and use that until EGUI's community or devs begin working on this more. At this point I only see them bragging about custom projects using egui on discord and its sad. egui has soo much potential but it simply is not there yet. |
Beta Was this translation helpful? Give feedback.
-
Here's how I'm doing it: egui::CentralPanel::default()
.frame(
Frame::none()
.inner_margin({
let margins = c.get_window_margins();
Margin::symmetric(margins.x, margins.y)
})
.fill(Color32::WHITE)
)
.show(ctx, |ui| {
// Paint on background instead of laying out like a widget.
egui::Image::new(egui::include_image!("../assets/img/circle.png")).paint_at(
ui,
[
[0.0, 0.0 ].into(),
[c.vw_to_px(1.0), c.vh_to_px(1.0)].into()
].into()
);
...add widgets to ui here...
}); |
Beta Was this translation helpful? Give feedback.
-
I want to have a background image behind a text window or background color. How do I implement that. I can't see any examples on how to do this. How do I do it?
Beta Was this translation helpful? Give feedback.
All reactions