1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 21:00:03 -04:00

Merge branch 'main' into theme_plugin

# Conflicts:
#	crates/egui/src/widget_style.rs
This commit is contained in:
Lucas Meurer
2026-08-21 11:33:30 +02:00
252 changed files with 4993 additions and 1936 deletions

View File

@@ -1,8 +1,9 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs, clippy::unwrap_used)] // it's an example
use core::cell::Cell;
use eframe::{UserEvent, egui};
use std::{cell::Cell, rc::Rc};
use std::rc::Rc;
use winit::event_loop::{ControlFlow, EventLoop};
fn main() -> eframe::Result {

View File

@@ -1,6 +1,7 @@
#![expect(clippy::unwrap_used)] // It's an example
use std::{cell::Cell, io, os::fd::AsRawFd as _, rc::Rc, time::Duration};
use core::{cell::Cell, time::Duration};
use std::{io, os::fd::AsRawFd as _, rc::Rc};
use tokio::task::LocalSet;
use winit::event_loop::{ControlFlow, EventLoop};

View File

@@ -20,7 +20,7 @@ fn main() -> eframe::Result {
#[derive(Default)]
struct MyApp {
dropped_files: Vec<egui::DroppedFile>,
dropped_files: Vec<egui::DroppedFileHandle>,
picked_path: Option<String>,
}
@@ -48,27 +48,23 @@ impl eframe::App for MyApp {
ui.label("Dropped files:");
for file in &self.dropped_files {
let mut info = if let Some(path) = &file.path {
path.display().to_string()
} else if file.name.is_empty() {
"???".to_owned()
} else {
file.name.clone()
};
#[cfg(not(target_arch = "wasm32"))]
ui.label(file.path().display().to_string());
let mut additional_info = vec![];
if !file.mime.is_empty() {
additional_info.push(format!("type: {}", file.mime));
#[cfg(target_arch = "wasm32")]
{
let Some(web_file) = file.web_file() else {
continue;
};
let name = web_file.name();
let mime = web_file.type_();
let size = web_file.size();
if mime.is_empty() {
ui.label(format!("{name} ({size} bytes)"));
} else {
ui.label(format!("{name} (type: {mime}, {size} bytes)"));
}
}
if let Some(bytes) = &file.bytes {
additional_info.push(format!("{} bytes", bytes.len()));
}
if !additional_info.is_empty() {
use std::fmt::Write as _;
write!(info, " ({})", additional_info.join(", ")).ok();
}
ui.label(info);
}
});
}
@@ -87,8 +83,8 @@ impl eframe::App for MyApp {
/// Preview hovering files:
fn preview_files_being_dropped(ctx: &egui::Context) {
use core::fmt::Write as _;
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};
use std::fmt::Write as _;
if !ctx.input(|i| i.raw.hovered_files.is_empty()) {
let text = ctx.input(|i| {

View File

@@ -106,10 +106,10 @@ impl MyApp {
}
}
impl std::ops::Drop for MyApp {
impl core::ops::Drop for MyApp {
fn drop(&mut self) {
for (handle, show_tx) in self.threads.drain(..) {
std::mem::drop(show_tx);
core::mem::drop(show_tx);
handle.join().unwrap();
}
}

View File

@@ -1,10 +1,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{
Arc,
atomic::{AtomicBool, Ordering},
};
use core::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use eframe::egui;

View File

@@ -2,6 +2,7 @@
name = "popups"
edition.workspace = true
license.workspace = true
publish = false
rust-version.workspace = true
version.workspace = true

View File

@@ -1,10 +1,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{
Arc,
atomic::{AtomicBool, Ordering},
};
use core::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use eframe::egui;
@@ -88,7 +86,7 @@ impl eframe::App for MyApp {
.clicked()
{
puffin::profile_scope!("long_sleep");
std::thread::sleep(std::time::Duration::from_millis(50));
std::thread::sleep(core::time::Duration::from_millis(50));
}
ui.checkbox(
@@ -172,7 +170,7 @@ fn start_puffin_server() {
// We can store the server if we want, but in this case we just want
// it to keep running. Dropping it closes the server, so let's not drop it!
#[expect(clippy::mem_forget)]
std::mem::forget(puffin_server);
core::mem::forget(puffin_server);
}
Err(err) => {
log::error!("Failed to start puffin server: {err}");

View File

@@ -19,7 +19,7 @@ fn main() -> eframe::Result {
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
)?;
std::thread::sleep(std::time::Duration::from_secs(2));
std::thread::sleep(core::time::Duration::from_secs(2));
log::info!("Starting second window…");
eframe::run_native(
@@ -28,7 +28,7 @@ fn main() -> eframe::Result {
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
)?;
std::thread::sleep(std::time::Duration::from_secs(2));
std::thread::sleep(core::time::Duration::from_secs(2));
log::info!("Starting third window…");
eframe::run_native(

View File

@@ -4,7 +4,8 @@
use eframe::{CreationContext, NativeOptions, egui};
use egui::{Button, CentralPanel, UserAttentionType};
use std::time::{Duration, SystemTime};
use core::time::Duration;
use std::time::SystemTime;
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).