Use Rust edition 2024 (#7280)

This commit is contained in:
Emil Ernerfeldt 2025-06-30 14:01:57 +02:00 committed by GitHub
parent 962c8e26a8
commit b2995dcb83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
190 changed files with 427 additions and 388 deletions

View File

@ -21,7 +21,7 @@ members = [
] ]
[workspace.package] [workspace.package]
edition = "2021" edition = "2024"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
rust-version = "1.85" rust-version = "1.85"
version = "0.31.1" version = "0.31.1"
@ -171,7 +171,6 @@ fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn" fn_to_numeric_cast_any = "warn"
from_iter_instead_of_collect = "warn" from_iter_instead_of_collect = "warn"
get_unwrap = "warn" get_unwrap = "warn"
if_let_mutex = "warn"
implicit_clone = "warn" implicit_clone = "warn"
implied_bounds_in_impls = "warn" implied_bounds_in_impls = "warn"
imprecise_flops = "warn" imprecise_flops = "warn"

View File

@ -1,4 +1,4 @@
use super::{linear_f32_from_linear_u8, linear_u8_from_linear_f32, Color32, Hsva, HsvaGamma, Rgba}; use super::{Color32, Hsva, HsvaGamma, Rgba, linear_f32_from_linear_u8, linear_u8_from_linear_f32};
use cint::{Alpha, ColorInterop, EncodedSrgb, Hsv, LinearSrgb, PremultipliedAlpha}; use cint::{Alpha, ColorInterop, EncodedSrgb, Hsv, LinearSrgb, PremultipliedAlpha};
// ---- Color32 ---- // ---- Color32 ----

View File

@ -1,4 +1,4 @@
use crate::{fast_round, linear_f32_from_linear_u8, Rgba}; use crate::{Rgba, fast_round, linear_f32_from_linear_u8};
/// This format is used for space-efficient color representation (32 bits). /// This format is used for space-efficient color representation (32 bits).
/// ///

View File

@ -1,5 +1,5 @@
use crate::{ use crate::{
gamma_u8_from_linear_f32, linear_f32_from_gamma_u8, linear_u8_from_linear_f32, Color32, Rgba, Color32, Rgba, gamma_u8_from_linear_f32, linear_f32_from_gamma_u8, linear_u8_from_linear_f32,
}; };
/// Hue, saturation, value, alpha. All in the range [0, 1]. /// Hue, saturation, value, alpha. All in the range [0, 1].

View File

@ -1,4 +1,4 @@
use crate::{gamma_from_linear, linear_from_gamma, Color32, Hsva, Rgba}; use crate::{Color32, Hsva, Rgba, gamma_from_linear, linear_from_gamma};
/// Like Hsva but with the `v` value (brightness) being gamma corrected /// Like Hsva but with the `v` value (brightness) being gamma corrected
/// so that it is somewhat perceptually even. /// so that it is somewhat perceptually even.

View File

@ -24,7 +24,7 @@ To use on Linux, first run:
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
``` ```
You need to either use `edition = "2021"`, or set `resolver = "2"` in the `[workspace]` section of your to-level `Cargo.toml`. See [this link](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) for more info. You need to either use `edition = "2024"`, or set `resolver = "2"` in the `[workspace]` section of your to-level `Cargo.toml`. See [this link](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) for more info.
You can opt-in to the using [`egui-wgpu`](https://github.com/emilk/egui/tree/main/crates/egui-wgpu) for rendering by enabling the `wgpu` feature and setting `NativeOptions::renderer` to `Renderer::Wgpu`. You can opt-in to the using [`egui-wgpu`](https://github.com/emilk/egui/tree/main/crates/egui-wgpu) for rendering by enabling the `wgpu` feature and setting `NativeOptions::renderer` to `Renderer::Wgpu`.

View File

@ -574,7 +574,9 @@ impl Default for Renderer {
fn default() -> Self { fn default() -> Self {
#[cfg(not(feature = "glow"))] #[cfg(not(feature = "glow"))]
#[cfg(not(feature = "wgpu"))] #[cfg(not(feature = "wgpu"))]
compile_error!("eframe: you must enable at least one of the rendering backend features: 'glow' or 'wgpu'"); compile_error!(
"eframe: you must enable at least one of the rendering backend features: 'glow' or 'wgpu'"
);
#[cfg(feature = "glow")] #[cfg(feature = "glow")]
#[cfg(not(feature = "wgpu"))] #[cfg(not(feature = "wgpu"))]
@ -617,7 +619,9 @@ impl std::str::FromStr for Renderer {
#[cfg(feature = "wgpu")] #[cfg(feature = "wgpu")]
"wgpu" => Ok(Self::Wgpu), "wgpu" => Ok(Self::Wgpu),
_ => Err(format!("eframe renderer {name:?} is not available. Make sure that the corresponding eframe feature is enabled.")) _ => Err(format!(
"eframe renderer {name:?} is not available. Make sure that the corresponding eframe feature is enabled."
)),
} }
} }
} }

View File

@ -225,7 +225,7 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS
}; };
// TODO(madsmtm): Move this into `objc2-app-kit` // TODO(madsmtm): Move this into `objc2-app-kit`
extern "C" { unsafe extern "C" {
static NSApp: Option<&'static NSApplication>; static NSApp: Option<&'static NSApplication>;
} }
@ -240,7 +240,9 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS
use objc2_app_kit::{NSBitmapImageRep, NSDeviceRGBColorSpace}; use objc2_app_kit::{NSBitmapImageRep, NSDeviceRGBColorSpace};
use objc2_foundation::NSSize; use objc2_foundation::NSSize;
log::trace!("NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel"); log::trace!(
"NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel"
);
let Some(image_rep) = NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel( let Some(image_rep) = NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel(
NSBitmapImageRep::alloc(), NSBitmapImageRep::alloc(),
[image.as_raw().as_ptr().cast_mut()].as_mut_ptr(), [image.as_raw().as_ptr().cast_mut()].as_mut_ptr(),

View File

@ -52,10 +52,10 @@ fn roaming_appdata() -> Option<PathBuf> {
use windows_sys::Win32::Foundation::S_OK; use windows_sys::Win32::Foundation::S_OK;
use windows_sys::Win32::System::Com::CoTaskMemFree; use windows_sys::Win32::System::Com::CoTaskMemFree;
use windows_sys::Win32::UI::Shell::{ use windows_sys::Win32::UI::Shell::{
FOLDERID_RoamingAppData, SHGetKnownFolderPath, KF_FLAG_DONT_VERIFY, FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath,
}; };
extern "C" { unsafe extern "C" {
fn wcslen(buf: *const u16) -> usize; fn wcslen(buf: *const u16) -> usize;
} }
let mut path_raw = ptr::null_mut(); let mut path_raw = ptr::null_mut();

View File

@ -32,13 +32,13 @@ use egui::{
use egui_winit::accesskit_winit; use egui_winit::accesskit_winit;
use crate::{ use crate::{
native::epi_integration::EpiIntegration, App, AppCreator, CreationContext, NativeOptions, App, AppCreator, CreationContext, NativeOptions, Result, Storage,
Result, Storage, native::epi_integration::EpiIntegration,
}; };
use super::{ use super::{
epi_integration, event_loop_context, epi_integration, event_loop_context,
winit_integration::{create_egui_context, EventResult, UserEvent, WinitApp}, winit_integration::{EventResult, UserEvent, WinitApp, create_egui_context},
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1015,7 +1015,9 @@ impl GlutinWindowContext {
let gl_context = match gl_context_result { let gl_context = match gl_context_result {
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
log::warn!("Failed to create context using default context attributes {context_attributes:?} due to error: {err}"); log::warn!(
"Failed to create context using default context attributes {context_attributes:?} due to error: {err}"
);
log::debug!( log::debug!(
"Retrying with fallback context attributes: {fallback_context_attributes:?}" "Retrying with fallback context attributes: {fallback_context_attributes:?}"
); );

View File

@ -10,9 +10,8 @@ use ahash::HashMap;
use super::winit_integration::{UserEvent, WinitApp}; use super::winit_integration::{UserEvent, WinitApp};
use crate::{ use crate::{
epi, Result, epi,
native::{event_loop_context, winit_integration::EventResult}, native::{event_loop_context, winit_integration::EventResult},
Result,
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -25,8 +25,8 @@ use egui_winit::accesskit_winit;
use winit_integration::UserEvent; use winit_integration::UserEvent;
use crate::{ use crate::{
native::{epi_integration::EpiIntegration, winit_integration::EventResult},
App, AppCreator, CreationContext, NativeOptions, Result, Storage, App, AppCreator, CreationContext, NativeOptions, Result, Storage,
native::{epi_integration::EpiIntegration, winit_integration::EventResult},
}; };
use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp}; use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp};

View File

@ -1,8 +1,8 @@
use egui::{TexturesDelta, UserData, ViewportCommand}; use egui::{TexturesDelta, UserData, ViewportCommand};
use crate::{epi, App}; use crate::{App, epi};
use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter as _, NeedRepaint}; use super::{NeedRepaint, now_sec, text_agent::TextAgent, web_painter::WebPainter as _};
pub struct AppRunner { pub struct AppRunner {
#[allow(dead_code, clippy::allow_attributes)] #[allow(dead_code, clippy::allow_attributes)]

View File

@ -1,11 +1,10 @@
use crate::web::string_from_js_value; use crate::web::string_from_js_value;
use super::{ use super::{
button_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event, AppRunner, Closure, DEBUG_RESIZE, JsCast as _, JsValue, WebRunner, button_from_mouse_event,
modifiers_from_wheel_event, native_pixels_per_point, pos_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event, modifiers_from_wheel_event,
prefers_color_scheme_dark, primary_touch_pos, push_touches, text_from_keyboard_event, native_pixels_per_point, pos_from_mouse_event, prefers_color_scheme_dark, primary_touch_pos,
theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast as _, JsValue, WebRunner, push_touches, text_from_keyboard_event, theme_from_dark_mode, translate_key,
DEBUG_RESIZE,
}; };
use web_sys::{Document, EventTarget, ShadowRoot}; use web_sys::{Document, EventTarget, ShadowRoot};

View File

@ -1,4 +1,4 @@
use super::{canvas_content_rect, AppRunner}; use super::{AppRunner, canvas_content_rect};
pub fn pos_from_mouse_event( pub fn pos_from_mouse_event(
canvas: &web_sys::HtmlCanvasElement, canvas: &web_sys::HtmlCanvasElement,

View File

@ -126,12 +126,17 @@ fn shorten_file_path(file_path: &str) -> &str {
#[test] #[test]
fn test_shorten_file_path() { fn test_shorten_file_path() {
for (before, after) in [ for (before, after) in [
("/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", "tokio-1.24.1/src/runtime/runtime.rs"), (
"/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs",
"tokio-1.24.1/src/runtime/runtime.rs",
),
("crates/rerun/src/main.rs", "rerun/src/main.rs"), ("crates/rerun/src/main.rs", "rerun/src/main.rs"),
("/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", "core/src/ops/function.rs"), (
"/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs",
"core/src/ops/function.rs",
),
("/weird/path/file.rs", "/weird/path/file.rs"), ("/weird/path/file.rs", "/weird/path/file.rs"),
] ] {
{
assert_eq!(shorten_file_path(before), after); assert_eq!(shorten_file_path(before), after);
} }
} }

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use super::web_painter::WebPainter; use super::web_painter::WebPainter;
use crate::WebOptions; use crate::WebOptions;
use egui::{Event, UserData, ViewportId}; use egui::{Event, UserData, ViewportId};
use egui_wgpu::capture::{capture_channel, CaptureReceiver, CaptureSender, CaptureState}; use egui_wgpu::capture::{CaptureReceiver, CaptureSender, CaptureState, capture_channel};
use egui_wgpu::{RenderState, SurfaceErrorAction}; use egui_wgpu::{RenderState, SurfaceErrorAction};
use wasm_bindgen::JsValue; use wasm_bindgen::JsValue;
use web_sys::HtmlCanvasElement; use web_sys::HtmlCanvasElement;

View File

@ -2,12 +2,12 @@ use std::{cell::RefCell, rc::Rc};
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
use crate::{epi, App}; use crate::{App, epi};
use super::{ use super::{
AppRunner, PanicHandler,
events::{self, ResizeObserverContext}, events::{self, ResizeObserverContext},
text_agent::TextAgent, text_agent::TextAgent,
AppRunner, PanicHandler,
}; };
/// This is how `eframe` runs your web application /// This is how `eframe` runs your web application

View File

@ -1,6 +1,6 @@
use egui::{UserData, ViewportId}; use egui::{UserData, ViewportId};
use epaint::ColorImage; use epaint::ColorImage;
use std::sync::{mpsc, Arc}; use std::sync::{Arc, mpsc};
use wgpu::{BindGroupLayout, MultisampleState, StoreOp}; use wgpu::{BindGroupLayout, MultisampleState, StoreOp};
/// A texture and a buffer for reading the rendered frame back to the cpu. /// A texture and a buffer for reading the rendered frame back to the cpu.
@ -196,7 +196,10 @@ impl CaptureState {
wgpu::TextureFormat::Rgba8Unorm => [0, 1, 2, 3], wgpu::TextureFormat::Rgba8Unorm => [0, 1, 2, 3],
wgpu::TextureFormat::Bgra8Unorm => [2, 1, 0, 3], wgpu::TextureFormat::Bgra8Unorm => [2, 1, 0, 3],
_ => { _ => {
log::error!("Screen can't be captured unless the surface format is Rgba8Unorm or Bgra8Unorm. Current surface format is {:?}", format); log::error!(
"Screen can't be captured unless the surface format is Rgba8Unorm or Bgra8Unorm. Current surface format is {:?}",
format
);
return; return;
} }
}; };

View File

@ -3,7 +3,7 @@
use std::{borrow::Cow, num::NonZeroU64, ops::Range}; use std::{borrow::Cow, num::NonZeroU64, ops::Range};
use ahash::HashMap; use ahash::HashMap;
use epaint::{emath::NumExt as _, PaintCallbackInfo, Primitive, Vertex}; use epaint::{PaintCallbackInfo, Primitive, Vertex, emath::NumExt as _};
use wgpu::util::DeviceExt as _; use wgpu::util::DeviceExt as _;
@ -909,7 +909,11 @@ impl Renderer {
); );
let Some(mut index_buffer_staging) = index_buffer_staging else { let Some(mut index_buffer_staging) = index_buffer_staging else {
panic!("Failed to create staging buffer for index data. Index count: {index_count}. Required index buffer size: {required_index_buffer_size}. Actual size {} and capacity: {} (bytes)", self.index_buffer.buffer.size(), self.index_buffer.capacity); panic!(
"Failed to create staging buffer for index data. Index count: {index_count}. Required index buffer size: {required_index_buffer_size}. Actual size {} and capacity: {} (bytes)",
self.index_buffer.buffer.size(),
self.index_buffer.capacity
);
}; };
let mut index_offset = 0; let mut index_offset = 0;
@ -948,7 +952,11 @@ impl Renderer {
); );
let Some(mut vertex_buffer_staging) = vertex_buffer_staging else { let Some(mut vertex_buffer_staging) = vertex_buffer_staging else {
panic!("Failed to create staging buffer for vertex data. Vertex count: {vertex_count}. Required vertex buffer size: {required_vertex_buffer_size}. Actual size {} and capacity: {} (bytes)", self.vertex_buffer.buffer.size(), self.vertex_buffer.capacity); panic!(
"Failed to create staging buffer for vertex data. Vertex count: {vertex_count}. Required vertex buffer size: {required_vertex_buffer_size}. Actual size {} and capacity: {} (bytes)",
self.vertex_buffer.buffer.size(),
self.vertex_buffer.capacity
);
}; };
let mut vertex_offset = 0; let mut vertex_offset = 0;

View File

@ -1,8 +1,8 @@
#![allow(clippy::missing_errors_doc)] #![allow(clippy::missing_errors_doc)]
#![allow(clippy::undocumented_unsafe_blocks)] #![allow(clippy::undocumented_unsafe_blocks)]
use crate::capture::{capture_channel, CaptureReceiver, CaptureSender, CaptureState}; use crate::capture::{CaptureReceiver, CaptureSender, CaptureState, capture_channel};
use crate::{renderer, RenderState, SurfaceErrorAction, WgpuConfiguration}; use crate::{RenderState, SurfaceErrorAction, WgpuConfiguration, renderer};
use egui::{Context, Event, UserData, ViewportId, ViewportIdMap, ViewportIdSet}; use egui::{Context, Event, UserData, ViewportId, ViewportIdMap, ViewportIdSet};
use std::{num::NonZeroU32, sync::Arc}; use std::{num::NonZeroU32, sync::Arc};
@ -220,7 +220,9 @@ impl Painter {
} else if supported_alpha_modes.contains(&wgpu::CompositeAlphaMode::PostMultiplied) { } else if supported_alpha_modes.contains(&wgpu::CompositeAlphaMode::PostMultiplied) {
wgpu::CompositeAlphaMode::PostMultiplied wgpu::CompositeAlphaMode::PostMultiplied
} else { } else {
log::warn!("Transparent window was requested, but the active wgpu surface does not support a `CompositeAlphaMode` with transparency."); log::warn!(
"Transparent window was requested, but the active wgpu surface does not support a `CompositeAlphaMode` with transparency."
);
wgpu::CompositeAlphaMode::Auto wgpu::CompositeAlphaMode::Auto
} }
} else { } else {
@ -344,7 +346,9 @@ impl Painter {
height_in_pixels, height_in_pixels,
); );
} else { } else {
log::warn!("Ignoring window resize notification with no surface created via Painter::set_window()"); log::warn!(
"Ignoring window resize notification with no surface created via Painter::set_window()"
);
} }
} }

View File

@ -123,7 +123,9 @@ impl Clipboard {
return; return;
} }
log::error!("Copying images is not supported. Enable the 'clipboard' feature of `egui-winit` to enable it."); log::error!(
"Copying images is not supported. Enable the 'clipboard' feature of `egui-winit` to enable it."
);
_ = image; _ = image;
} }
} }

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
emath::{remap_clamp, NumExt as _},
Id, IdMap, InputState, Id, IdMap, InputState,
emath::{NumExt as _, remap_clamp},
}; };
#[derive(Clone, Default)] #[derive(Clone, Default)]

View File

@ -204,12 +204,17 @@ fn shorten_source_file_path(path: &std::path::Path) -> String {
#[test] #[test]
fn test_shorten_path() { fn test_shorten_path() {
for (before, after) in [ for (before, after) in [
("/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", "tokio-1.24.1/src/runtime/runtime.rs"), (
"/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs",
"tokio-1.24.1/src/runtime/runtime.rs",
),
("crates/rerun/src/main.rs", "rerun/src/main.rs"), ("crates/rerun/src/main.rs", "rerun/src/main.rs"),
("/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", "core/src/ops/function.rs"), (
"/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs",
"core/src/ops/function.rs",
),
("/weird/path/file.rs", "/weird/path/file.rs"), ("/weird/path/file.rs", "/weird/path/file.rs"),
] ] {
{
use std::str::FromStr as _; use std::str::FromStr as _;
let before = std::path::PathBuf::from_str(before).unwrap(); let before = std::path::PathBuf::from_str(before).unwrap();
assert_eq!(shorten_source_file_path(&before), after); assert_eq!(shorten_source_file_path(&before), after);

View File

@ -5,8 +5,8 @@
use emath::GuiRounding as _; use emath::GuiRounding as _;
use crate::{ use crate::{
emath, pos2, Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt as _, Order, Pos2, Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt as _, Order, Pos2, Rect, Response,
Rect, Response, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, emath, pos2,
}; };
/// State of an [`Area`] that is persisted between frames. /// State of an [`Area`] that is persisted between frames.

View File

@ -1,9 +1,9 @@
use std::hash::Hash; use std::hash::Hash;
use crate::{ use crate::{
emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt as _, Rect, Context, Id, InnerResponse, NumExt as _, Rect, Response, Sense, Stroke, TextStyle,
Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetInfo, WidgetText, WidgetType,
WidgetInfo, WidgetText, WidgetType, emath, epaint, pos2, remap, remap_clamp, vec2,
}; };
use emath::GuiRounding as _; use emath::GuiRounding as _;
use epaint::{Shape, StrokeKind}; use epaint::{Shape, StrokeKind};

View File

@ -1,9 +1,9 @@
use epaint::Shape; use epaint::Shape;
use crate::{ use crate::{
epaint, style::StyleModifier, style::WidgetVisuals, vec2, Align2, Context, Id, InnerResponse, Align2, Context, Id, InnerResponse, NumExt as _, Painter, Popup, PopupCloseBehavior, Rect,
NumExt as _, Painter, Popup, PopupCloseBehavior, Rect, Response, ScrollArea, Sense, Stroke, Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo,
TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo, WidgetText, WidgetType, WidgetText, WidgetType, epaint, style::StyleModifier, style::WidgetVisuals, vec2,
}; };
#[expect(unused_imports)] // Documentation #[expect(unused_imports)] // Documentation

View File

@ -1,8 +1,8 @@
//! Frame container //! Frame container
use crate::{ use crate::{
epaint, layers::ShapeIdx, InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind, InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind, UiStackInfo, epaint,
UiStackInfo, layers::ShapeIdx,
}; };
use epaint::{Color32, CornerRadius, Margin, MarginF32, Rect, Shadow, Shape, Stroke}; use epaint::{Color32, CornerRadius, Margin, MarginF32, Rect, Shadow, Shape, Stroke};
@ -143,7 +143,8 @@ pub struct Frame {
#[test] #[test]
fn frame_size() { fn frame_size() {
assert_eq!( assert_eq!(
std::mem::size_of::<Frame>(), 32, std::mem::size_of::<Frame>(),
32,
"Frame changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it." "Frame changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
); );
assert!( assert!(

View File

@ -3,7 +3,7 @@ use crate::{
Button, Color32, Context, Frame, Id, InnerResponse, IntoAtoms, Layout, Popup, Button, Color32, Context, Frame, Id, InnerResponse, IntoAtoms, Layout, Popup,
PopupCloseBehavior, Response, Style, Ui, UiBuilder, UiKind, UiStack, UiStackInfo, Widget as _, PopupCloseBehavior, Response, Style, Ui, UiBuilder, UiKind, UiStack, UiStackInfo, Widget as _,
}; };
use emath::{vec2, Align, RectAlign, Vec2}; use emath::{Align, RectAlign, Vec2, vec2};
use epaint::Stroke; use epaint::Stroke;
/// Apply a menu style to the [`Style`]. /// Apply a menu style to the [`Style`].

View File

@ -18,8 +18,8 @@
use emath::GuiRounding as _; use emath::GuiRounding as _;
use crate::{ use crate::{
lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, Rangef,
Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, lerp, vec2,
}; };
fn animate_expansion(ctx: &Context, id: Id, is_expanded: bool) -> f32 { fn animate_expansion(ctx: &Context, id: Id, is_expanded: bool) -> f32 {

View File

@ -1,10 +1,10 @@
use crate::containers::menu::{menu_style, MenuConfig, MenuState}; use crate::containers::menu::{MenuConfig, MenuState, menu_style};
use crate::style::StyleModifier; use crate::style::StyleModifier;
use crate::{ use crate::{
Area, AreaState, Context, Frame, Id, InnerResponse, Key, LayerId, Layout, Order, Response, Area, AreaState, Context, Frame, Id, InnerResponse, Key, LayerId, Layout, Order, Response,
Sense, Ui, UiKind, UiStackInfo, Sense, Ui, UiKind, UiStackInfo,
}; };
use emath::{vec2, Align, Pos2, Rect, RectAlign, Vec2}; use emath::{Align, Pos2, Rect, RectAlign, Vec2, vec2};
use std::iter::once; use std::iter::once;
/// What should we anchor the popup to? /// What should we anchor the popup to?

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
pos2, vec2, Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, Shape, Ui,
Shape, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, pos2, vec2,
}; };
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View File

@ -3,8 +3,8 @@ use core::f32;
use emath::{GuiRounding as _, Pos2}; use emath::{GuiRounding as _, Pos2};
use crate::{ use crate::{
emath::TSTransform, InnerResponse, LayerId, PointerButton, Rangef, Rect, Response, Sense, Ui, InnerResponse, LayerId, PointerButton, Rangef, Rect, Response, Sense, Ui, UiBuilder, Vec2,
UiBuilder, Vec2, emath::TSTransform,
}; };
/// Creates a transformation that fits a given scene rectangle into the available screen size. /// Creates a transformation that fits a given scene rectangle into the available screen size.

View File

@ -3,8 +3,8 @@
use std::ops::{Add, AddAssign, BitOr, BitOrAssign}; use std::ops::{Add, AddAssign, BitOr, BitOrAssign};
use crate::{ use crate::{
emath, epaint, lerp, pass_state, pos2, remap, remap_clamp, Context, CursorIcon, Id, Context, CursorIcon, Id, NumExt as _, Pos2, Rangef, Rect, Sense, Ui, UiBuilder, UiKind,
NumExt as _, Pos2, Rangef, Rect, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, UiStackInfo, Vec2, Vec2b, emath, epaint, lerp, pass_state, pos2, remap, remap_clamp,
}; };
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View File

@ -9,7 +9,7 @@ use crate::collapsing_header::CollapsingState;
use crate::*; use crate::*;
use super::scroll_area::{ScrollBarVisibility, ScrollSource}; use super::scroll_area::{ScrollBarVisibility, ScrollSource};
use super::{area, resize, Area, Frame, Resize, ScrollArea}; use super::{Area, Frame, Resize, ScrollArea, area, resize};
/// Builder for a floating window which can be dragged, closed, collapsed, resized and scrolled (off by default). /// Builder for a floating window which can be dragged, closed, collapsed, resized and scrolled (off by default).
/// ///

View File

@ -4,16 +4,23 @@ use std::{borrow::Cow, cell::RefCell, panic::Location, sync::Arc, time::Duration
use emath::{GuiRounding as _, OrderedFloat}; use emath::{GuiRounding as _, OrderedFloat};
use epaint::{ use epaint::{
ClippedPrimitive, ClippedShape, Color32, ImageData, ImageDelta, Pos2, Rect, StrokeKind,
TessellationOptions, TextureAtlas, TextureId, Vec2,
emath::{self, TSTransform}, emath::{self, TSTransform},
mutex::RwLock, mutex::RwLock,
stats::PaintStats, stats::PaintStats,
tessellator, tessellator,
text::{FontInsert, FontPriority, Fonts}, text::{FontInsert, FontPriority, Fonts},
vec2, ClippedPrimitive, ClippedShape, Color32, ImageData, ImageDelta, Pos2, Rect, StrokeKind, vec2,
TessellationOptions, TextureAtlas, TextureId, Vec2,
}; };
use crate::{ use crate::{
Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport,
ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory,
ModifierNames, Modifiers, NumExt as _, Order, Painter, RawInput, Response, RichText,
ScrollArea, Sense, Style, TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder,
ViewportCommand, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput,
Widget as _, WidgetRect, WidgetText,
animation_manager::AnimationManager, animation_manager::AnimationManager,
containers::{self, area::AreaState}, containers::{self, area::AreaState},
data::output::PlatformOutput, data::output::PlatformOutput,
@ -29,12 +36,6 @@ use crate::{
resize, response, scroll_area, resize, response, scroll_area,
util::IdTypeMap, util::IdTypeMap,
viewport::ViewportClass, viewport::ViewportClass,
Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport,
ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory,
ModifierNames, Modifiers, NumExt as _, Order, Painter, RawInput, Response, RichText,
ScrollArea, Sense, Style, TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder,
ViewportCommand, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput,
Widget as _, WidgetRect, WidgetText,
}; };
#[cfg(feature = "accesskit")] #[cfg(feature = "accesskit")]
@ -860,7 +861,10 @@ impl Context {
if max_passes <= output.platform_output.num_completed_passes { if max_passes <= output.platform_output.num_completed_passes {
#[cfg(feature = "log")] #[cfg(feature = "log")]
log::debug!("Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}", output.platform_output.request_discard_reasons); log::debug!(
"Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}",
output.platform_output.request_discard_reasons
);
break; break;
} }
@ -2353,7 +2357,9 @@ impl Context {
// If you see this message, it means we've been paying the cost of multi-pass for multiple frames in a row. // If you see this message, it means we've been paying the cost of multi-pass for multiple frames in a row.
// This is likely a bug. `request_discard` should only be called in rare situations, when some layout changes. // This is likely a bug. `request_discard` should only be called in rare situations, when some layout changes.
let mut warning = format!("egui PERF WARNING: request_discard has been called {num_multipass_in_row} frames in a row"); let mut warning = format!(
"egui PERF WARNING: request_discard has been called {num_multipass_in_row} frames in a row"
);
self.viewport(|vp| { self.viewport(|vp| {
for reason in &vp.output.request_discard_reasons { for reason in &vp.output.request_discard_reasons {
warning += &format!("\n {reason}"); warning += &format!("\n {reason}");

View File

@ -3,8 +3,8 @@
use epaint::ColorImage; use epaint::ColorImage;
use crate::{ use crate::{
emath::{Pos2, Rect, Vec2},
Key, Theme, ViewportId, ViewportIdMap, Key, Theme, ViewportId, ViewportIdMap,
emath::{Pos2, Rect, Vec2},
}; };
/// What the integrations provides to egui at the start of each frame. /// What the integrations provides to egui at the start of each frame.

View File

@ -6,7 +6,7 @@
//! to get callbacks on certain events ([`Context::on_begin_pass`], [`Context::on_end_pass`]). //! to get callbacks on certain events ([`Context::on_begin_pass`], [`Context::on_end_pass`]).
use crate::{ use crate::{
text, Align, Align2, Color32, Context, FontFamily, FontId, Id, Rect, Shape, Vec2, WidgetText, Align, Align2, Color32, Context, FontFamily, FontId, Id, Rect, Shape, Vec2, WidgetText, text,
}; };
/// Register this plugin on the given egui context, /// Register this plugin on the given egui context,

View File

@ -1,8 +1,8 @@
use emath::GuiRounding as _; use emath::GuiRounding as _;
use crate::{ use crate::{
vec2, Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, Ui,
Ui, UiBuilder, Vec2, UiBuilder, Vec2, vec2,
}; };
#[cfg(debug_assertions)] #[cfg(debug_assertions)]

View File

@ -2,7 +2,7 @@ use ahash::HashMap;
use emath::TSTransform; use emath::TSTransform;
use crate::{ahash, emath, id::IdSet, LayerId, Pos2, Rect, Sense, WidgetRect, WidgetRects}; use crate::{LayerId, Pos2, Rect, Sense, WidgetRect, WidgetRects, ahash, emath, id::IdSet};
/// Result of a hit-test against [`WidgetRects`]. /// Result of a hit-test against [`WidgetRects`].
/// ///
@ -466,7 +466,7 @@ fn should_prioritize_hits_on_back(back: Rect, front: Rect) -> bool {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use emath::{pos2, vec2, Rect}; use emath::{Rect, pos2, vec2};
use crate::{Id, Sense}; use crate::{Id, Sense};

View File

@ -1,11 +1,11 @@
mod touch_state; mod touch_state;
use crate::data::input::{ use crate::data::input::{
Event, EventFilter, KeyboardShortcut, Modifiers, MouseWheelUnit, PointerButton, RawInput, Event, EventFilter, KeyboardShortcut, Modifiers, MouseWheelUnit, NUM_POINTER_BUTTONS,
TouchDeviceId, ViewportInfo, NUM_POINTER_BUTTONS, PointerButton, RawInput, TouchDeviceId, ViewportInfo,
}; };
use crate::{ use crate::{
emath::{vec2, NumExt as _, Pos2, Rect, Vec2}, emath::{NumExt as _, Pos2, Rect, Vec2, vec2},
util::History, util::History,
}; };
use std::{ use std::{

View File

@ -1,9 +1,9 @@
use std::{collections::BTreeMap, fmt::Debug}; use std::{collections::BTreeMap, fmt::Debug};
use crate::{ use crate::{
data::input::TouchDeviceId,
emath::{normalized_angle, Pos2, Vec2},
Event, RawInput, TouchId, TouchPhase, Event, RawInput, TouchId, TouchPhase,
data::input::TouchDeviceId,
emath::{Pos2, Vec2, normalized_angle},
}; };
/// All you probably need to know about a multi-touch gesture. /// All you probably need to know about a multi-touch gesture.
@ -174,7 +174,7 @@ impl TouchState {
if added_or_removed_touches { if added_or_removed_touches {
// Adding or removing fingers makes the average values "jump". We better forget // Adding or removing fingers makes the average values "jump". We better forget
// about the previous values, and don't create delta information for this frame: // about the previous values, and don't create delta information for this frame:
if let Some(ref mut state) = &mut self.gesture_state { if let Some(state) = &mut self.gesture_state {
state.previous = None; state.previous = None;
} }
} }
@ -224,7 +224,7 @@ impl TouchState {
fn update_gesture(&mut self, time: f64, pointer_pos: Option<Pos2>) { fn update_gesture(&mut self, time: f64, pointer_pos: Option<Pos2>) {
if let Some(dyn_state) = self.calc_dynamic_state() { if let Some(dyn_state) = self.calc_dynamic_state() {
if let Some(ref mut state) = &mut self.gesture_state { if let Some(state) = &mut self.gesture_state {
// updating an ongoing gesture // updating an ongoing gesture
state.previous = Some(state.current); state.previous = Some(state.current);
state.current = dyn_state; state.current = dyn_state;

View File

@ -1,6 +1,6 @@
//! How mouse and touch interzcts with widgets. //! How mouse and touch interzcts with widgets.
use crate::{hit_test, id, input_state, memory, Id, InputState, Key, WidgetRects}; use crate::{Id, InputState, Key, WidgetRects, hit_test, id, input_state, memory};
use self::{hit_test::WidgetHits, id::IdSet, input_state::PointerEvent, memory::InteractionState}; use self::{hit_test::WidgetHits, id::IdSet, input_state::PointerEvent, memory::InteractionState};

View File

@ -1,7 +1,7 @@
//! Showing UI:s for egui/epaint types. //! Showing UI:s for egui/epaint types.
use crate::{ use crate::{
epaint, memory, pos2, remap_clamp, vec2, Color32, CursorIcon, FontFamily, FontId, Label, Mesh, Color32, CursorIcon, FontFamily, FontId, Label, Mesh, NumExt as _, Rect, Response, Sense,
NumExt as _, Rect, Response, Sense, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, epaint, memory, pos2, remap_clamp, vec2,
}; };
pub fn font_family_ui(ui: &mut Ui, font_family: &mut FontFamily) { pub fn font_family_ui(ui: &mut Ui, font_family: &mut FontFamily) {

View File

@ -1,8 +1,8 @@
//! Handles paint layers, i.e. how things //! Handles paint layers, i.e. how things
//! are sometimes painted behind or in front of other things. //! are sometimes painted behind or in front of other things.
use crate::{ahash, epaint, Id, IdMap, Rect}; use crate::{Id, IdMap, Rect, ahash, epaint};
use epaint::{emath::TSTransform, ClippedShape, Shape}; use epaint::{ClippedShape, Shape, emath::TSTransform};
/// Different layer categories /// Different layer categories
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)]

View File

@ -1,8 +1,8 @@
use emath::GuiRounding as _; use emath::GuiRounding as _;
use crate::{ use crate::{
emath::{pos2, vec2, Align2, NumExt as _, Pos2, Rect, Vec2},
Align, Align,
emath::{Align2, NumExt as _, Pos2, Rect, Vec2, pos2, vec2},
}; };
const INFINITY: f32 = f32::INFINITY; const INFINITY: f32 = f32::INFINITY;

View File

@ -463,22 +463,21 @@ pub use epaint::emath;
pub use ecolor::hex_color; pub use ecolor::hex_color;
pub use ecolor::{Color32, Rgba}; pub use ecolor::{Color32, Rgba};
pub use emath::{ pub use emath::{
lerp, pos2, remap, remap_clamp, vec2, Align, Align2, NumExt, Pos2, Rangef, Rect, RectAlign, Align, Align2, NumExt, Pos2, Rangef, Rect, RectAlign, Vec2, Vec2b, lerp, pos2, remap,
Vec2, Vec2b, remap_clamp, vec2,
}; };
pub use epaint::{ pub use epaint::{
mutex, ClippedPrimitive, ColorImage, CornerRadius, FontImage, ImageData, Margin, Mesh, PaintCallback,
PaintCallbackInfo, Shadow, Shape, Stroke, StrokeKind, TextureHandle, TextureId, mutex,
text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak}, text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak},
textures::{TextureFilter, TextureOptions, TextureWrapMode, TexturesDelta}, textures::{TextureFilter, TextureOptions, TextureWrapMode, TexturesDelta},
ClippedPrimitive, ColorImage, CornerRadius, FontImage, ImageData, Margin, Mesh, PaintCallback,
PaintCallbackInfo, Shadow, Shape, Stroke, StrokeKind, TextureHandle, TextureId,
}; };
pub mod text { pub mod text {
pub use crate::text_selection::CCursorRange; pub use crate::text_selection::CCursorRange;
pub use epaint::text::{ pub use epaint::text::{
cursor::CCursor, FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, LayoutSection, TAB_SIZE,
LayoutSection, TextFormat, TextWrapping, TAB_SIZE, TextFormat, TextWrapping, cursor::CCursor,
}; };
} }
@ -487,12 +486,12 @@ pub use self::{
containers::*, containers::*,
context::{Context, RepaintCause, RequestRepaintInfo}, context::{Context, RepaintCause, RequestRepaintInfo},
data::{ data::{
Key, UserData,
input::*, input::*,
output::{ output::{
self, CursorIcon, FullOutput, OpenUrl, OutputCommand, PlatformOutput, self, CursorIcon, FullOutput, OpenUrl, OutputCommand, PlatformOutput,
UserAttentionType, WidgetInfo, UserAttentionType, WidgetInfo,
}, },
Key, UserData,
}, },
drag_and_drop::DragAndDrop, drag_and_drop::DragAndDrop,
epaint::text::TextWrapMode, epaint::text::TextWrapMode,

View File

@ -65,7 +65,7 @@ use std::{
use ahash::HashMap; use ahash::HashMap;
use emath::{Float as _, OrderedFloat}; use emath::{Float as _, OrderedFloat};
use epaint::{mutex::Mutex, textures::TextureOptions, ColorImage, TextureHandle, TextureId, Vec2}; use epaint::{ColorImage, TextureHandle, TextureId, Vec2, mutex::Mutex, textures::TextureOptions};
use crate::Context; use crate::Context;

View File

@ -1,6 +1,6 @@
use super::{ use super::{
generate_loader_id, Bytes, BytesLoadResult, BytesLoader, BytesPoll, Context, Cow, HashMap, Bytes, BytesLoadResult, BytesLoader, BytesPoll, Context, Cow, HashMap, LoadError, Mutex,
LoadError, Mutex, generate_loader_id,
}; };
/// Maps URI:s to [`Bytes`], e.g. found with `include_bytes!`. /// Maps URI:s to [`Bytes`], e.g. found with `include_bytes!`.

View File

@ -6,8 +6,8 @@ use ahash::{HashMap, HashSet};
use epaint::emath::TSTransform; use epaint::emath::TSTransform;
use crate::{ use crate::{
area, vec2, EventFilter, Id, IdMap, LayerId, Order, Pos2, Rangef, RawInput, Rect, Style, Vec2, EventFilter, Id, IdMap, LayerId, Order, Pos2, Rangef, RawInput, Rect, Style, Vec2, ViewportId,
ViewportId, ViewportIdMap, ViewportIdSet, ViewportIdMap, ViewportIdSet, area, vec2,
}; };
mod theme; mod theme;
@ -377,8 +377,8 @@ impl Options {
reduce_texture_memory, reduce_texture_memory,
} = self; } = self;
use crate::containers::CollapsingHeader;
use crate::Widget as _; use crate::Widget as _;
use crate::containers::CollapsingHeader;
CollapsingHeader::new("⚙ Options") CollapsingHeader::new("⚙ Options")
.default_open(false) .default_open(false)
@ -1250,8 +1250,11 @@ impl Areas {
/// ///
/// The two layers must have the same [`LayerId::order`]. /// The two layers must have the same [`LayerId::order`].
pub fn set_sublayer(&mut self, parent: LayerId, child: LayerId) { pub fn set_sublayer(&mut self, parent: LayerId, child: LayerId) {
debug_assert_eq!(parent.order, child.order, debug_assert_eq!(
"DEBUG ASSERT: Trying to set sublayers across layers of different order ({:?}, {:?}), which is currently undefined behavior in egui", parent.order, child.order); parent.order, child.order,
"DEBUG ASSERT: Trying to set sublayers across layers of different order ({:?}, {:?}), which is currently undefined behavior in egui",
parent.order, child.order
);
self.sublayers.entry(parent).or_default().insert(child); self.sublayers.entry(parent).or_default().insert(child);

View File

@ -30,11 +30,7 @@ impl Theme {
/// Chooses between [`Self::Dark`] or [`Self::Light`] based on a boolean value. /// Chooses between [`Self::Dark`] or [`Self::Light`] based on a boolean value.
pub fn from_dark_mode(dark_mode: bool) -> Self { pub fn from_dark_mode(dark_mode: bool) -> Self {
if dark_mode { if dark_mode { Self::Dark } else { Self::Light }
Self::Dark
} else {
Self::Light
}
} }
} }

View File

@ -17,14 +17,13 @@
//! ``` //! ```
use super::{ use super::{
style::WidgetVisuals, Align, Context, Id, InnerResponse, PointerState, Pos2, Rect, Response, Align, Context, Id, InnerResponse, PointerState, Pos2, Rect, Response, Sense, TextStyle, Ui,
Sense, TextStyle, Ui, Vec2, Vec2, style::WidgetVisuals,
}; };
use crate::{ use crate::{
epaint, vec2,
widgets::{Button, ImageButton},
Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt as _, Order, Stroke, Style, Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt as _, Order, Stroke, Style,
TextWrapMode, UiKind, WidgetText, TextWrapMode, UiKind, WidgetText, epaint, vec2,
widgets::{Button, ImageButton},
}; };
use epaint::mutex::RwLock; use epaint::mutex::RwLock;
use std::sync::Arc; use std::sync::Arc;

View File

@ -71,7 +71,8 @@ impl OperatingSystem {
#[cfg(feature = "log")] #[cfg(feature = "log")]
log::warn!( log::warn!(
"egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues", "egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues",
user_agent); user_agent
);
Self::Unknown Self::Unknown
} }

View File

@ -2,14 +2,14 @@ use std::sync::Arc;
use emath::GuiRounding as _; use emath::GuiRounding as _;
use epaint::{ use epaint::{
text::{Fonts, Galley, LayoutJob},
CircleShape, ClippedShape, CornerRadius, PathStroke, RectShape, Shape, Stroke, StrokeKind, CircleShape, ClippedShape, CornerRadius, PathStroke, RectShape, Shape, Stroke, StrokeKind,
text::{Fonts, Galley, LayoutJob},
}; };
use crate::{ use crate::{
Color32, Context, FontId,
emath::{Align2, Pos2, Rangef, Rect, Vec2}, emath::{Align2, Pos2, Rangef, Rect, Vec2},
layers::{LayerId, PaintList, ShapeIdx}, layers::{LayerId, PaintList, ShapeIdx},
Color32, Context, FontId,
}; };
/// Helper to paint shapes and text to a specific region on a specific layer. /// Helper to paint shapes and text to a specific region on a specific layer.

View File

@ -1,9 +1,9 @@
use ahash::HashMap; use ahash::HashMap;
use crate::{id::IdSet, style, Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects}; use crate::{Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects, id::IdSet, style};
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use crate::{pos2, Align2, Color32, FontId, NumExt as _, Painter}; use crate::{Align2, Color32, FontId, NumExt as _, Painter, pos2};
/// Reset at the start of each frame. /// Reset at the start of each frame.
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]

View File

@ -1,4 +1,4 @@
use crate::{grid, vec2, Layout, Painter, Pos2, Rect, Region, Vec2}; use crate::{Layout, Painter, Pos2, Rect, Region, Vec2, grid, vec2};
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use crate::{Align2, Color32, Stroke}; use crate::{Align2, Color32, Stroke};

View File

@ -1,9 +1,10 @@
use std::{any::Any, sync::Arc}; use std::{any::Any, sync::Arc};
use crate::{ use crate::{
Context, CursorIcon, Id, LayerId, PointerButton, Popup, PopupKind, Sense, Tooltip, Ui,
WidgetRect, WidgetText,
emath::{Align, Pos2, Rect, Vec2}, emath::{Align, Pos2, Rect, Vec2},
pass_state, Context, CursorIcon, Id, LayerId, PointerButton, Popup, PopupKind, Sense, Tooltip, pass_state,
Ui, WidgetRect, WidgetText,
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -3,14 +3,14 @@
#![allow(clippy::if_same_then_else)] #![allow(clippy::if_same_then_else)]
use emath::Align; use emath::Align;
use epaint::{text::FontTweak, CornerRadius, Shadow, Stroke}; use epaint::{CornerRadius, Shadow, Stroke, text::FontTweak};
use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc}; use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc};
use crate::{ use crate::{
ecolor::Color32,
emath::{pos2, vec2, Rangef, Rect, Vec2},
ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response, RichText, TextWrapMode, ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response, RichText, TextWrapMode,
WidgetText, WidgetText,
ecolor::Color32,
emath::{Rangef, Rect, Vec2, pos2, vec2},
}; };
/// How to format numbers in e.g. a [`crate::DragValue`]. /// How to format numbers in e.g. a [`crate::DragValue`].
@ -1557,8 +1557,8 @@ impl Default for Widgets {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
use crate::{ use crate::{
widgets::{reset_button, DragValue, Slider, Widget},
Ui, Ui,
widgets::{DragValue, Slider, Widget, reset_button},
}; };
impl Style { impl Style {

View File

@ -2,7 +2,7 @@ use emath::TSTransform;
use crate::{Context, Galley, Id}; use crate::{Context, Galley, Id};
use super::{text_cursor_state::is_word_char, CCursorRange}; use super::{CCursorRange, text_cursor_state::is_word_char};
/// Update accesskit with the current text state. /// Update accesskit with the current text state.
pub fn update_accesskit_for_text_widget( pub fn update_accesskit_for_text_widget(

View File

@ -1,6 +1,6 @@
use epaint::{text::cursor::CCursor, Galley}; use epaint::{Galley, text::cursor::CCursor};
use crate::{os::OperatingSystem, Event, Id, Key, Modifiers}; use crate::{Event, Id, Key, Modifiers, os::OperatingSystem};
use super::text_cursor_state::{ccursor_next_word, ccursor_previous_word, slice_char_range}; use super::text_cursor_state::{ccursor_next_word, ccursor_previous_word, slice_char_range};

View File

@ -3,14 +3,14 @@ use std::sync::Arc;
use emath::TSTransform; use emath::TSTransform;
use crate::{ use crate::{
layers::ShapeIdx, text::CCursor, text_selection::CCursorRange, Context, CursorIcon, Event, Context, CursorIcon, Event, Galley, Id, LayerId, Pos2, Rect, Response, Ui, layers::ShapeIdx,
Galley, Id, LayerId, Pos2, Rect, Response, Ui, text::CCursor, text_selection::CCursorRange,
}; };
use super::{ use super::{
text_cursor_state::cursor_rect,
visuals::{paint_text_selection, RowVertexIndices},
TextCursorState, TextCursorState,
text_cursor_state::cursor_rect,
visuals::{RowVertexIndices, paint_text_selection},
}; };
/// Turn on to help debug this /// Turn on to help debug this

View File

@ -1,9 +1,9 @@
//! Text cursor changes/interaction, without modifying the text. //! Text cursor changes/interaction, without modifying the text.
use epaint::text::{cursor::CCursor, Galley}; use epaint::text::{Galley, cursor::CCursor};
use unicode_segmentation::UnicodeSegmentation as _; use unicode_segmentation::UnicodeSegmentation as _;
use crate::{epaint, NumExt as _, Rect, Response, Ui}; use crate::{NumExt as _, Rect, Response, Ui, epaint};
use super::CCursorRange; use super::CCursorRange;

View File

@ -1,6 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{pos2, vec2, Galley, Painter, Rect, Ui, Visuals}; use crate::{Galley, Painter, Rect, Ui, Visuals, pos2, vec2};
use super::CCursorRange; use super::CCursorRange;

View File

@ -5,11 +5,15 @@ use emath::GuiRounding as _;
use epaint::mutex::RwLock; use epaint::mutex::RwLock;
use std::{any::Any, hash::Hash, sync::Arc}; use std::{any::Any, hash::Hash, sync::Arc};
use crate::close_tag::ClosableTag;
use crate::containers::menu;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use crate::Stroke; use crate::Stroke;
use crate::close_tag::ClosableTag;
use crate::containers::menu;
use crate::{ use crate::{
Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms,
LayerId, Memory, Order, Painter, PlatformOutput, Pos2, Rangef, Rect, Response, Rgba, RichText,
Sense, Style, TextStyle, TextWrapMode, UiBuilder, UiKind, UiStack, UiStackInfo, Vec2,
WidgetRect, WidgetText,
containers::{CollapsingHeader, CollapsingResponse, Frame}, containers::{CollapsingHeader, CollapsingResponse, Frame},
ecolor::Hsva, ecolor::Hsva,
emath, epaint, emath, epaint,
@ -22,13 +26,9 @@ use crate::{
util::IdTypeMap, util::IdTypeMap,
vec2, widgets, vec2, widgets,
widgets::{ widgets::{
color_picker, Button, Checkbox, DragValue, Hyperlink, Image, ImageSource, Label, Link, Button, Checkbox, DragValue, Hyperlink, Image, ImageSource, Label, Link, RadioButton,
RadioButton, SelectableLabel, Separator, Spinner, TextEdit, Widget, SelectableLabel, Separator, Spinner, TextEdit, Widget, color_picker,
}, },
Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms,
LayerId, Memory, Order, Painter, PlatformOutput, Pos2, Rangef, Rect, Response, Rgba, RichText,
Sense, Style, TextStyle, TextWrapMode, UiBuilder, UiKind, UiStack, UiStackInfo, Vec2,
WidgetRect, WidgetText,
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -1,8 +1,8 @@
use std::{hash::Hash, sync::Arc}; use std::{hash::Hash, sync::Arc};
use crate::close_tag::ClosableTag;
#[expect(unused_imports)] // Used for doclinks #[expect(unused_imports)] // Used for doclinks
use crate::Ui; use crate::Ui;
use crate::close_tag::ClosableTag;
use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo}; use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo};
/// Build a [`Ui`] as the child of another [`Ui`]. /// Build a [`Ui`] as the child of another [`Ui`].

View File

@ -4,8 +4,8 @@ use std::fmt::Formatter;
use std::{borrow::Cow, sync::Arc}; use std::{borrow::Cow, sync::Arc};
use crate::{ use crate::{
text::{LayoutJob, TextWrapping},
Align, Color32, FontFamily, FontSelection, Galley, Style, TextStyle, TextWrapMode, Ui, Visuals, Align, Color32, FontFamily, FontSelection, Galley, Style, TextStyle, TextWrapMode, Ui, Visuals,
text::{LayoutJob, TextWrapping},
}; };
/// Text and optional style choices for it. /// Text and optional style choices for it.

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
epaint, pos2, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Shape, Ui, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Shape, Ui, Vec2, Widget,
Vec2, Widget, WidgetInfo, WidgetType, WidgetInfo, WidgetType, epaint, pos2,
}; };
// TODO(emilk): allow checkbox without a text label // TODO(emilk): allow checkbox without a text label

View File

@ -2,12 +2,13 @@
use crate::util::fixed_cache::FixedCache; use crate::util::fixed_cache::FixedCache;
use crate::{ use crate::{
epaint, lerp, remap_clamp, Context, DragValue, Id, Painter, Popup, PopupCloseBehavior, Context, DragValue, Id, Painter, Popup, PopupCloseBehavior, Response, Sense, Ui, Widget as _,
Response, Sense, Ui, Widget as _, WidgetInfo, WidgetType, WidgetInfo, WidgetType, epaint, lerp, remap_clamp,
}; };
use epaint::{ use epaint::{
Mesh, Rect, Shape, Stroke, StrokeKind, Vec2,
ecolor::{Color32, Hsva, HsvaGamma, Rgba}, ecolor::{Color32, Hsva, HsvaGamma, Rgba},
pos2, vec2, Mesh, Rect, Shape, Stroke, StrokeKind, Vec2, pos2, vec2,
}; };
fn contrast_color(color: impl Into<Rgba>) -> Color32 { fn contrast_color(color: impl Into<Rgba>) -> Color32 {

View File

@ -3,8 +3,8 @@
use std::{cmp::Ordering, ops::RangeInclusive}; use std::{cmp::Ordering, ops::RangeInclusive};
use crate::{ use crate::{
emath, text, Button, CursorIcon, Id, Key, Modifiers, NumExt as _, Response, RichText, Sense, Button, CursorIcon, Id, Key, MINUS_CHAR_STR, Modifiers, NumExt as _, Response, RichText, Sense,
TextEdit, TextWrapMode, Ui, Widget, WidgetInfo, MINUS_CHAR_STR, TextEdit, TextWrapMode, Ui, Widget, WidgetInfo, emath, text,
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
epaint, text_selection, CursorIcon, Label, Response, Sense, Stroke, Ui, Widget, WidgetInfo, CursorIcon, Label, Response, Sense, Stroke, Ui, Widget, WidgetInfo, WidgetText, WidgetType,
WidgetText, WidgetType, epaint, text_selection,
}; };
use self::text_selection::LabelSelectionState; use self::text_selection::LabelSelectionState;

View File

@ -2,14 +2,15 @@ use std::{borrow::Cow, slice::Iter, sync::Arc, time::Duration};
use emath::{Align, Float as _, GuiRounding as _, NumExt as _, Rot2}; use emath::{Align, Float as _, GuiRounding as _, NumExt as _, Rot2};
use epaint::{ use epaint::{
text::{LayoutJob, TextFormat, TextWrapping},
RectShape, RectShape,
text::{LayoutJob, TextFormat, TextWrapping},
}; };
use crate::{ use crate::{
load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll}, Color32, Context, CornerRadius, Id, Mesh, Painter, Rect, Response, Sense, Shape, Spinner,
pos2, Color32, Context, CornerRadius, Id, Mesh, Painter, Rect, Response, Sense, Shape, Spinner,
TextStyle, TextureOptions, Ui, Vec2, Widget, WidgetInfo, WidgetType, TextStyle, TextureOptions, Ui, Vec2, Widget, WidgetInfo, WidgetType,
load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll},
pos2,
}; };
/// A widget which displays an image. /// A widget which displays an image.
@ -499,7 +500,7 @@ impl ImageSize {
let point_size = match fit { let point_size = match fit {
ImageFit::Original { scale } => { ImageFit::Original { scale } => {
return SizeHint::Scale((pixels_per_point * scale).ord()) return SizeHint::Scale((pixels_per_point * scale).ord());
} }
ImageFit::Fraction(fract) => available_size * fract, ImageFit::Fraction(fract) => available_size * fract,
ImageFit::Exact(size) => size, ImageFit::Exact(size) => size,

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
widgets, Color32, CornerRadius, Image, Rect, Response, Sense, Ui, Vec2, Widget, WidgetInfo, Color32, CornerRadius, Image, Rect, Response, Sense, Ui, Vec2, Widget, WidgetInfo, WidgetType,
WidgetType, widgets,
}; };
/// A clickable image within a frame. /// A clickable image within a frame.

View File

@ -1,8 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::{
epaint, pos2, text_selection::LabelSelectionState, Align, Direction, FontSelection, Galley, Align, Direction, FontSelection, Galley, Pos2, Response, Sense, Stroke, TextWrapMode, Ui,
Pos2, Response, Sense, Stroke, TextWrapMode, Ui, Widget, WidgetInfo, WidgetText, WidgetType, Widget, WidgetInfo, WidgetText, WidgetType, epaint, pos2, text_selection::LabelSelectionState,
}; };
/// Static text. /// Static text.

View File

@ -4,7 +4,7 @@
//! * `ui.add(Label::new("Text").text_color(color::red));` //! * `ui.add(Label::new("Text").text_color(color::red));`
//! * `if ui.add(Button::new("Click me")).clicked() { … }` //! * `if ui.add(Button::new("Click me")).clicked() { … }`
use crate::{epaint, Response, Ui}; use crate::{Response, Ui, epaint};
mod button; mod button;
mod checkbox; mod checkbox;
@ -28,8 +28,8 @@ pub use self::{
drag_value::DragValue, drag_value::DragValue,
hyperlink::{Hyperlink, Link}, hyperlink::{Hyperlink, Link},
image::{ image::{
decode_animated_image_uri, has_gif_magic_header, has_webp_header, paint_texture_at,
FrameDurations, Image, ImageFit, ImageOptions, ImageSize, ImageSource, FrameDurations, Image, ImageFit, ImageOptions, ImageSize, ImageSource,
decode_animated_image_uri, has_gif_magic_header, has_webp_header, paint_texture_at,
}, },
image_button::ImageButton, image_button::ImageButton,
label::Label, label::Label,

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
lerp, vec2, Color32, CornerRadius, NumExt as _, Pos2, Rect, Response, Rgba, Sense, Shape, Color32, CornerRadius, NumExt as _, Pos2, Rect, Response, Rgba, Sense, Shape, Stroke,
Stroke, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, lerp, vec2,
}; };
enum ProgressBarText { enum ProgressBarText {

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
epaint, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Ui, Vec2, Widget, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Ui, Vec2, Widget,
WidgetInfo, WidgetType, WidgetInfo, WidgetType, epaint,
}; };
/// One out of several alternatives, either selected or not. /// One out of several alternatives, either selected or not.

View File

@ -1,4 +1,4 @@
use crate::{vec2, Response, Sense, Ui, Vec2, Widget}; use crate::{Response, Sense, Ui, Vec2, Widget, vec2};
/// A visual separator. A horizontal or vertical line (depending on [`crate::Layout`]). /// A visual separator. A horizontal or vertical line (depending on [`crate::Layout`]).
/// ///

View File

@ -3,9 +3,9 @@
use std::ops::RangeInclusive; use std::ops::RangeInclusive;
use crate::{ use crate::{
emath, epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2, Color32, Color32, DragValue, EventFilter, Key, Label, MINUS_CHAR_STR, NumExt as _, Pos2, Rangef, Rect,
DragValue, EventFilter, Key, Label, NumExt as _, Pos2, Rangef, Rect, Response, Sense, Response, Sense, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, emath,
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, MINUS_CHAR_STR, epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2,
}; };
use super::drag_value::clamp_value_to_range; use super::drag_value::clamp_value_to_range;
@ -134,11 +134,7 @@ impl<'a> Slider<'a> {
value.to_f64() value.to_f64()
}); });
if Num::INTEGRAL { if Num::INTEGRAL { slf.integer() } else { slf }
slf.integer()
} else {
slf
}
} }
pub fn from_get_set( pub fn from_get_set(

View File

@ -1,4 +1,4 @@
use epaint::{emath::lerp, vec2, Color32, Pos2, Rect, Shape, Stroke}; use epaint::{Color32, Pos2, Rect, Shape, Stroke, emath::lerp, vec2};
use crate::{Response, Sense, Ui, Widget, WidgetInfo, WidgetType}; use crate::{Response, Sense, Ui, Widget, WidgetInfo, WidgetType};

View File

@ -2,19 +2,19 @@ use std::sync::Arc;
use emath::{Rect, TSTransform}; use emath::{Rect, TSTransform};
use epaint::{ use epaint::{
text::{cursor::CCursor, Galley, LayoutJob},
StrokeKind, StrokeKind,
text::{Galley, LayoutJob, cursor::CCursor},
}; };
use crate::{ use crate::{
epaint, Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, ImeEvent,
Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, TextBuffer,
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, epaint,
os::OperatingSystem, os::OperatingSystem,
output::OutputEvent, output::OutputEvent,
response, text_selection, response, text_selection,
text_selection::{text_cursor_state::cursor_rect, visuals::paint_text_selection, CCursorRange}, text_selection::{CCursorRange, text_cursor_state::cursor_rect, visuals::paint_text_selection},
vec2, Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, vec2,
ImeEvent, Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape,
TextBuffer, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState,
}; };
use super::{TextEditOutput, TextEditState}; use super::{TextEditOutput, TextEditState};

View File

@ -3,8 +3,8 @@ use std::sync::Arc;
use crate::mutex::Mutex; use crate::mutex::Mutex;
use crate::{ use crate::{
text_selection::{CCursorRange, TextCursorState},
Context, Id, Context, Id,
text_selection::{CCursorRange, TextCursorState},
}; };
pub type TextEditUndoer = crate::util::undoer::Undoer<(CCursorRange, String)>; pub type TextEditUndoer = crate::util::undoer::Undoer<(CCursorRange, String)>;

View File

@ -1,8 +1,8 @@
use std::{borrow::Cow, ops::Range}; use std::{borrow::Cow, ops::Range};
use epaint::{ use epaint::{
text::{cursor::CCursor, TAB_SIZE},
Galley, Galley,
text::{TAB_SIZE, cursor::CCursor},
}; };
use crate::{ use crate::{

View File

@ -1,8 +1,8 @@
use egui::{ use egui::{
Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2,
containers::{CollapsingHeader, Frame}, containers::{CollapsingHeader, Frame},
emath, pos2, emath, pos2,
widgets::Slider, widgets::Slider,
Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2,
}; };
use std::f32::consts::TAU; use std::f32::consts::TAU;

View File

@ -1,9 +1,9 @@
use egui::emath::Rot2;
use egui::panel::Side;
use egui::panel::TopBottomSide;
use egui::ImageFit; use egui::ImageFit;
use egui::Slider; use egui::Slider;
use egui::Vec2; use egui::Vec2;
use egui::emath::Rot2;
use egui::panel::Side;
use egui::panel::TopBottomSide;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ImageViewer { pub struct ImageViewer {

View File

@ -53,7 +53,7 @@ impl FrameHistory {
} }
fn graph(&self, ui: &mut egui::Ui) -> egui::Response { fn graph(&self, ui: &mut egui::Ui) -> egui::Response {
use egui::{emath, epaint, pos2, vec2, Pos2, Rect, Sense, Shape, Stroke, TextStyle}; use egui::{Pos2, Rect, Sense, Shape, Stroke, TextStyle, emath, epaint, pos2, vec2};
ui.label("egui CPU usage history"); ui.label("egui CPU usage history");

View File

@ -16,7 +16,9 @@ fn main() -> eframe::Result {
start_puffin_server(); start_puffin_server();
#[cfg(not(feature = "puffin"))] #[cfg(not(feature = "puffin"))]
panic!("Unknown argument: {arg} - you need to enable the 'puffin' feature to use this."); panic!(
"Unknown argument: {arg} - you need to enable the 'puffin' feature to use this."
);
} }
_ => { _ => {
@ -39,7 +41,12 @@ fn main() -> eframe::Result {
rust_log += &format!(",{loud_crate}=warn"); rust_log += &format!(",{loud_crate}=warn");
} }
} }
std::env::set_var("RUST_LOG", rust_log);
// SAFETY: we call this from the main thread without any other threads running.
#[expect(unsafe_code)]
unsafe {
std::env::set_var("RUST_LOG", rust_log);
}
} }
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).

View File

@ -1,8 +1,8 @@
use egui::accesskit::Role;
use egui::Vec2; use egui::Vec2;
use egui::accesskit::Role;
use egui_demo_app::{Anchor, WrapApp}; use egui_demo_app::{Anchor, WrapApp};
use egui_kittest::kittest::Queryable as _;
use egui_kittest::SnapshotResults; use egui_kittest::SnapshotResults;
use egui_kittest::kittest::Queryable as _;
#[test] #[test]
fn test_demo_app() { fn test_demo_app() {

View File

@ -1,6 +1,6 @@
use std::fmt::Write as _; use std::fmt::Write as _;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use egui::epaint::TextShape; use egui::epaint::TextShape;
use egui::load::SizedTexture; use egui::load::SizedTexture;
@ -174,7 +174,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut locked_fonts = fonts.lock(); let mut locked_fonts = fonts.lock();
c.bench_function("text_layout_uncached", |b| { c.bench_function("text_layout_uncached", |b| {
b.iter(|| { b.iter(|| {
use egui::epaint::text::{layout, LayoutJob}; use egui::epaint::text::{LayoutJob, layout};
let job = LayoutJob::simple( let job = LayoutJob::simple(
LOREM_IPSUM_LONG.to_owned(), LOREM_IPSUM_LONG.to_owned(),

View File

@ -1,8 +1,9 @@
use egui::{ use egui::{
Color32, Context, Pos2, Rect, Ui,
containers::{Frame, Window}, containers::{Frame, Window},
emath, epaint, emath, epaint,
epaint::PathStroke, epaint::PathStroke,
hex_color, lerp, pos2, remap, vec2, Color32, Context, Pos2, Rect, Ui, hex_color, lerp, pos2, remap, vec2,
}; };
#[derive(Default)] #[derive(Default)]

View File

@ -1,9 +1,9 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use super::About; use super::About;
use crate::is_mobile;
use crate::Demo; use crate::Demo;
use crate::View as _; use crate::View as _;
use crate::is_mobile;
use egui::containers::menu; use egui::containers::menu;
use egui::style::StyleModifier; use egui::style::StyleModifier;
use egui::{Context, Modifiers, ScrollArea, Ui}; use egui::{Context, Modifiers, ScrollArea, Ui};
@ -370,7 +370,7 @@ fn file_menu_button(ui: &mut Ui) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{demo::demo_app_windows::DemoGroups, Demo as _}; use crate::{Demo as _, demo::demo_app_windows::DemoGroups};
use egui_kittest::kittest::{NodeT as _, Queryable as _}; use egui_kittest::kittest::{NodeT as _, Queryable as _};
use egui_kittest::{Harness, SnapshotOptions, SnapshotResults}; use egui_kittest::{Harness, SnapshotOptions, SnapshotResults};

View File

@ -1,4 +1,4 @@
use egui::{vec2, Color32, Context, Frame, Id, Ui, Window}; use egui::{Color32, Context, Frame, Id, Ui, Window, vec2};
#[derive(Clone, PartialEq, Eq)] #[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,8 +1,8 @@
use super::{Demo, View}; use super::{Demo, View};
use egui::{ use egui::{
vec2, Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, Context, FontId, Resize, Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, Context, FontId, Resize,
RichText, Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, RichText, Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, vec2,
}; };
/// Showcase some ui code /// Showcase some ui code

View File

@ -162,10 +162,10 @@ impl crate::View for Modals {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::demo::modals::Modals;
use crate::Demo as _; use crate::Demo as _;
use egui::accesskit::Role; use crate::demo::modals::Modals;
use egui::Key; use egui::Key;
use egui::accesskit::Role;
use egui_kittest::kittest::Queryable as _; use egui_kittest::kittest::Queryable as _;
use egui_kittest::{Harness, SnapshotResults}; use egui_kittest::{Harness, SnapshotResults};

View File

@ -1,6 +1,7 @@
use egui::{ use egui::{
Color32, Frame, Pos2, Rect, Sense, Stroke, Vec2,
emath::{RectTransform, Rot2}, emath::{RectTransform, Rot2},
vec2, Color32, Frame, Pos2, Rect, Sense, Stroke, Vec2, vec2,
}; };
pub struct MultiTouch { pub struct MultiTouch {

View File

@ -1,8 +1,8 @@
use egui::{ use egui::{
emath, Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2,
Widget as _, Window, emath,
epaint::{self, CubicBezierShape, PathShape, QuadraticBezierShape}, epaint::{self, CubicBezierShape, PathShape, QuadraticBezierShape},
pos2, Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2, pos2,
Widget as _, Window,
}; };
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,4 +1,4 @@
use egui::{emath, vec2, Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window}; use egui::{Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window, emath, vec2};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))] #[cfg_attr(feature = "serde", serde(default))]

View File

@ -1,9 +1,9 @@
use crate::rust_view_ui; use crate::rust_view_ui;
use egui::color_picker::{color_picker_color32, Alpha}; use egui::color_picker::{Alpha, color_picker_color32};
use egui::containers::menu::{MenuConfig, SubMenuButton}; use egui::containers::menu::{MenuConfig, SubMenuButton};
use egui::{ use egui::{
include_image, Align, Align2, ComboBox, Frame, Id, Layout, Popup, PopupCloseBehavior, Align, Align2, ComboBox, Frame, Id, Layout, Popup, PopupCloseBehavior, RectAlign, RichText,
RectAlign, RichText, Tooltip, Ui, UiBuilder, Tooltip, Ui, UiBuilder, include_image,
}; };
/// Showcase [`Popup`]. /// Showcase [`Popup`].

View File

@ -1,6 +1,6 @@
use egui::{ use egui::{
pos2, scroll_area::ScrollBarVisibility, Align, Align2, Color32, DragValue, NumExt as _, Rect, Align, Align2, Color32, DragValue, NumExt as _, Rect, ScrollArea, Sense, Slider, TextStyle,
ScrollArea, Sense, Slider, TextStyle, TextWrapMode, Ui, Vec2, Widget as _, TextWrapMode, Ui, Vec2, Widget as _, pos2, scroll_area::ScrollBarVisibility,
}; };
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]

View File

@ -1,4 +1,4 @@
use egui::{style::HandleShape, Slider, SliderClamping, SliderOrientation, Ui}; use egui::{Slider, SliderClamping, SliderOrientation, Ui, style::HandleShape};
/// Showcase sliders /// Showcase sliders
#[derive(PartialEq)] #[derive(PartialEq)]

View File

@ -330,7 +330,9 @@ fn expanding_content(ui: &mut egui::Ui) {
} }
fn long_text(row_index: usize) -> String { fn long_text(row_index: usize) -> String {
format!("Row {row_index} has some long text that you may want to clip, or it will take up too much horizontal space!") format!(
"Row {row_index} has some long text that you may want to clip, or it will take up too much horizontal space!"
)
} }
fn thick_row(row_index: usize) -> bool { fn thick_row(row_index: usize) -> bool {

Some files were not shown because too many files have changed in this diff Show More