mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 23:13:13 -04:00
More cleaning
This commit is contained in:
@@ -417,7 +417,7 @@ impl EguiWindows {
|
||||
egui::Window::new("🔧 Settings")
|
||||
.open(settings)
|
||||
.vscroll(true)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
tmp_ctx.settings_ui(ui);
|
||||
});
|
||||
|
||||
@@ -425,7 +425,7 @@ impl EguiWindows {
|
||||
egui::Window::new("🔍 Inspection")
|
||||
.open(inspection)
|
||||
.vscroll(true)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
tmp_ctx.inspection_ui(ui);
|
||||
});
|
||||
|
||||
@@ -433,7 +433,7 @@ impl EguiWindows {
|
||||
egui::Window::new("📝 Memory")
|
||||
.open(memory)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
tmp_ctx.memory_ui(ui);
|
||||
});
|
||||
|
||||
@@ -442,7 +442,7 @@ impl EguiWindows {
|
||||
.open(output_events)
|
||||
.resizable(true)
|
||||
.default_width(520.0)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
ui.label(
|
||||
"Recent output events from egui. \
|
||||
These are emitted when you interact with widgets, or move focus between them with TAB. \
|
||||
|
||||
@@ -6,7 +6,6 @@ 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))]
|
||||
@@ -185,7 +184,7 @@ pub struct WrapApp {
|
||||
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||
custom3d: Option<crate::apps::Custom3d>,
|
||||
|
||||
dropped_files: Arc<RwLock<Vec<egui::DroppedFile>>>,
|
||||
dropped_files: Vec<egui::DroppedFile>,
|
||||
}
|
||||
|
||||
impl WrapApp {
|
||||
@@ -464,20 +463,19 @@ impl WrapApp {
|
||||
// Collect dropped files:
|
||||
ctx.input(|i| {
|
||||
if !i.raw.dropped_files.is_empty() {
|
||||
*self.dropped_files.write().unwrap() = i.raw.dropped_files.clone();
|
||||
self.dropped_files = i.raw.dropped_files.clone();
|
||||
}
|
||||
});
|
||||
|
||||
// Show dropped files (if any):
|
||||
let is_empty = self.dropped_files.read().unwrap().is_empty();
|
||||
let is_empty = self.dropped_files.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, move |ui| {
|
||||
let dropped_files = &*dropped_files.read().unwrap();
|
||||
for file in dropped_files {
|
||||
.show(ctx, |ui| {
|
||||
for file in &dropped_files {
|
||||
let mut info = if let Some(path) = &file.path {
|
||||
path.display().to_string()
|
||||
} else if !file.name.is_empty() {
|
||||
@@ -492,7 +490,7 @@ impl WrapApp {
|
||||
}
|
||||
});
|
||||
if !open {
|
||||
self.dropped_files.write().unwrap().clear();
|
||||
self.dropped_files.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ impl super::Demo for CodeEditor {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.default_height(500.0)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ impl super::Demo for CodeExample {
|
||||
.default_size([800.0, 400.0])
|
||||
.vscroll(false)
|
||||
.hscroll(true)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ impl super::Demo for ContextMenus {
|
||||
.vscroll(false)
|
||||
.resizable(false)
|
||||
.open(open)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ impl DemoWindows {
|
||||
.open(&mut about_is_open)
|
||||
.resizable(false)
|
||||
.collapsible(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
let close = close.clone();
|
||||
clone.data.write().unwrap().about.ui(ui);
|
||||
ui.add_space(12.0);
|
||||
|
||||
@@ -108,7 +108,7 @@ impl super::Demo for DragAndDropDemo {
|
||||
.default_size(vec2(256.0, 256.0))
|
||||
.vscroll(false)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,10 @@ impl super::Demo for FontBook {
|
||||
}
|
||||
|
||||
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.show(ctx, move |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ impl super::Demo for LayoutTest {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ impl Demo for MiscDemoWindow {
|
||||
.open(open)
|
||||
.vscroll(true)
|
||||
.hscroll(true)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ impl super::Demo for MultiTouch {
|
||||
.open(open)
|
||||
.default_size(vec2(512.0, 512.0))
|
||||
.resizable(true)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ impl super::Demo for PaintBezier {
|
||||
.vscroll(false)
|
||||
.resizable(false)
|
||||
.default_size([300.0, 350.0])
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ impl super::Demo for Painting {
|
||||
.open(open)
|
||||
.default_size(vec2(512.0, 512.0))
|
||||
.vscroll(false)
|
||||
.show(ctx, move |ui| self.ui(ui));
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ impl super::Demo for Scrolling {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ impl super::Demo for Sliders {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ impl super::Demo for TableDemo {
|
||||
.open(open)
|
||||
.resizable(true)
|
||||
.default_width(400.0)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -124,7 +124,7 @@ impl super::Demo for ManualLayoutTest {
|
||||
egui::Window::new(self.name())
|
||||
.resizable(false)
|
||||
.open(open)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
@@ -207,12 +207,10 @@ impl super::Demo for TableTest {
|
||||
}
|
||||
|
||||
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.show(ctx, move |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +326,7 @@ impl super::Demo for InputTest {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
@@ -466,7 +464,7 @@ impl super::Demo for WindowResizeTest {
|
||||
.vscroll(false)
|
||||
.resizable(true)
|
||||
.default_height(300.0)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
ui.label("Shows how you can fill an area with a widget.");
|
||||
let mut text = clone.text.write().unwrap();
|
||||
ui.add_sized(ui.available_size(), TextEdit::multiline(&mut *text));
|
||||
|
||||
@@ -22,7 +22,7 @@ impl super::Demo for TextEdit {
|
||||
egui::Window::new(self.name())
|
||||
.open(open)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ impl super::Demo for WidgetGallery {
|
||||
.open(open)
|
||||
.resizable(true)
|
||||
.default_width(280.0)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
use super::View as _;
|
||||
self.ui(ui);
|
||||
});
|
||||
|
||||
@@ -69,7 +69,7 @@ impl super::Demo for WindowOptions {
|
||||
if anchored {
|
||||
window = window.anchor(anchor, anchor_offset);
|
||||
}
|
||||
window.show(ctx, move |ui| self.ui(ui));
|
||||
window.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ impl eframe::App for MyApp {
|
||||
egui::Window::new("Do you want to quit?")
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.show(ctx, move |ui| {
|
||||
.show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Cancel").clicked() {
|
||||
data.write().unwrap().show_confirmation_dialog = false;
|
||||
|
||||
@@ -51,20 +51,18 @@ impl ThreadState {
|
||||
let pos = egui::pos2(16.0, 128.0 * (thread_nr as f32 + 1.0));
|
||||
let clone = self.clone();
|
||||
let title = self.data.read().unwrap().title.clone();
|
||||
egui::Window::new(title)
|
||||
.default_pos(pos)
|
||||
.show(ctx, move |ui| {
|
||||
let data = &mut *clone.data.write().unwrap();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Your name: ");
|
||||
ui.text_edit_singleline(&mut data.name);
|
||||
});
|
||||
ui.add(egui::Slider::new(&mut data.age, 0..=120).text("age"));
|
||||
if ui.button("Click each year").clicked() {
|
||||
data.age += 1;
|
||||
}
|
||||
ui.label(format!("Hello '{}', age {}", data.name, data.age));
|
||||
egui::Window::new(title).default_pos(pos).show(ctx, |ui| {
|
||||
let data = &mut *clone.data.write().unwrap();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Your name: ");
|
||||
ui.text_edit_singleline(&mut data.name);
|
||||
});
|
||||
ui.add(egui::Slider::new(&mut data.age, 0..=120).text("age"));
|
||||
if ui.button("Click each year").clicked() {
|
||||
data.age += 1;
|
||||
}
|
||||
ui.label(format!("Hello '{}', age {}", data.name, data.age));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +145,7 @@ impl eframe::App for MyApp {
|
||||
return;
|
||||
}
|
||||
let data = self.data.clone();
|
||||
egui::Window::new("Main thread").show(ctx, move |ui| {
|
||||
egui::Window::new("Main thread").show(ctx, |ui| {
|
||||
if ui.button("Spawn another thread").clicked() {
|
||||
data.write().unwrap().spawn_thread();
|
||||
ui.ctx()
|
||||
|
||||
Reference in New Issue
Block a user