mirror of
https://github.com/emilk/egui.git
synced 2026-06-28 07:23:13 -04:00
Merge branch 'master' into zlayer
# Conflicts: # crates/egui/src/containers/area.rs # crates/egui/src/containers/popup.rs # crates/egui/src/context.rs # crates/egui/src/painter.rs # crates/egui/src/ui.rs
This commit is contained in:
@@ -65,9 +65,11 @@ impl eframe::App for MyApp {
|
||||
preview_files_being_dropped(ctx);
|
||||
|
||||
// Collect dropped files:
|
||||
if !ctx.input().raw.dropped_files.is_empty() {
|
||||
self.dropped_files = ctx.input().raw.dropped_files.clone();
|
||||
}
|
||||
ctx.input(|i| {
|
||||
if !i.raw.dropped_files.is_empty() {
|
||||
self.dropped_files = i.raw.dropped_files.clone();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,24 +78,27 @@ fn preview_files_being_dropped(ctx: &egui::Context) {
|
||||
use egui::*;
|
||||
use std::fmt::Write as _;
|
||||
|
||||
if !ctx.input().raw.hovered_files.is_empty() {
|
||||
let mut text = "Dropping files:\n".to_owned();
|
||||
for file in &ctx.input().raw.hovered_files {
|
||||
if let Some(path) = &file.path {
|
||||
write!(text, "\n{}", path.display()).ok();
|
||||
} else if !file.mime.is_empty() {
|
||||
write!(text, "\n{}", file.mime).ok();
|
||||
} else {
|
||||
text += "\n???";
|
||||
if !ctx.input(|i| i.raw.hovered_files.is_empty()) {
|
||||
let text = ctx.input(|i| {
|
||||
let mut text = "Dropping files:\n".to_owned();
|
||||
for file in &i.raw.hovered_files {
|
||||
if let Some(path) = &file.path {
|
||||
write!(text, "\n{}", path.display()).ok();
|
||||
} else if !file.mime.is_empty() {
|
||||
write!(text, "\n{}", file.mime).ok();
|
||||
} else {
|
||||
text += "\n???";
|
||||
}
|
||||
}
|
||||
}
|
||||
text
|
||||
});
|
||||
|
||||
let painter = ctx.layer_painter(AreaLayerId::new(
|
||||
Order::Foreground,
|
||||
Id::new("file_drop_target"),
|
||||
));
|
||||
|
||||
let screen_rect = ctx.input().screen_rect();
|
||||
let screen_rect = ctx.screen_rect();
|
||||
painter.rect_filled(screen_rect, 0.0, Color32::from_black_alpha(192));
|
||||
painter.text(
|
||||
screen_rect.center(),
|
||||
|
||||
Reference in New Issue
Block a user