mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
A lot of changes:
Now the Viewport render function is passed to the backend I was needed to update the demo because now Window::show() needs a Fn before was a FnOnce I changed from FnOnce to Fn because we want the window to be rendered separately from the main window That means now the variabiles that we are moving to window need to be Rc or Arc! This is making harder to use `Window`! I'am waiting for more ideas! In eframe now any Window has a property render that stores the current window render function, if has not function App::update will be called insted! New problems in any other window excluding the main window we have no mouse input, i don't know why! Now every window has embedded to false by default, for testing purposes!
This commit is contained in:
@@ -5,6 +5,7 @@ use eframe::glow;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use core::any::Any;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
@@ -147,7 +148,7 @@ pub struct WrapApp {
|
||||
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||
custom3d: Option<crate::apps::Custom3d>,
|
||||
|
||||
dropped_files: Vec<egui::DroppedFile>,
|
||||
dropped_files: Arc<RwLock<Vec<egui::DroppedFile>>>,
|
||||
}
|
||||
|
||||
impl WrapApp {
|
||||
@@ -412,17 +413,20 @@ impl WrapApp {
|
||||
// Collect dropped files:
|
||||
ctx.input(|i| {
|
||||
if !i.raw.dropped_files.is_empty() {
|
||||
self.dropped_files = i.raw.dropped_files.clone();
|
||||
*self.dropped_files.write().unwrap() = i.raw.dropped_files.clone();
|
||||
}
|
||||
});
|
||||
|
||||
// Show dropped files (if any):
|
||||
if !self.dropped_files.is_empty() {
|
||||
let is_empty = self.dropped_files.read().unwrap().is_empty();
|
||||
if !is_empty {
|
||||
let mut open = true;
|
||||
let dropped_files = self.dropped_files.clone();
|
||||
egui::Window::new("Dropped files")
|
||||
.open(&mut open)
|
||||
.show(ctx, |ui| {
|
||||
for file in &self.dropped_files {
|
||||
.show(ctx, move |ui| {
|
||||
let dropped_files = &*dropped_files.read().unwrap();
|
||||
for file in dropped_files {
|
||||
let mut info = if let Some(path) = &file.path {
|
||||
path.display().to_string()
|
||||
} else if !file.name.is_empty() {
|
||||
@@ -437,7 +441,7 @@ impl WrapApp {
|
||||
}
|
||||
});
|
||||
if !open {
|
||||
self.dropped_files.clear();
|
||||
self.dropped_files.write().unwrap().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user