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

Merge branch 'main' into lucas/text-edit-min-size

This commit is contained in:
Lucas Meurer
2026-08-18 12:53:07 +02:00
committed by GitHub
19 changed files with 137 additions and 186 deletions

View File

@@ -907,16 +907,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "core-foundation"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.7" version = "0.8.7"
@@ -930,7 +920,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation 0.9.4", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@@ -943,7 +933,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation 0.9.4", "core-foundation",
"libc", "libc",
] ]
@@ -1655,7 +1645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.52.0", "windows-sys 0.61.2",
] ]
[[package]] [[package]]
@@ -4098,7 +4088,7 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys 0.12.1", "linux-raw-sys 0.12.1",
"windows-sys 0.52.0", "windows-sys 0.61.2",
] ]
[[package]] [[package]]
@@ -4558,7 +4548,7 @@ dependencies = [
"getrandom 0.4.3", "getrandom 0.4.3",
"once_cell", "once_cell",
"rustix 1.1.4", "rustix 1.1.4",
"windows-sys 0.52.0", "windows-sys 0.61.2",
] ]
[[package]] [[package]]
@@ -5324,15 +5314,15 @@ dependencies = [
[[package]] [[package]]
name = "webbrowser" name = "webbrowser"
version = "1.2.1" version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fc95580916af1e68ff6a7be07446fc5db73ebf71cf092de939bbf5f7e189f72" checksum = "62c35be770821a214dbc362fc26908c853e776c0004294d0b10b8a6bad582f94"
dependencies = [ dependencies = [
"core-foundation 0.10.1",
"jni", "jni",
"log", "log",
"ndk-context", "ndk-context",
"objc2 0.6.4", "objc2 0.6.4",
"objc2-app-kit 0.3.2",
"objc2-foundation 0.3.2", "objc2-foundation 0.3.2",
"url", "url",
"web-sys", "web-sys",
@@ -5558,7 +5548,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.61.2",
] ]
[[package]] [[package]]
@@ -5774,7 +5764,7 @@ dependencies = [
"calloop", "calloop",
"cfg_aliases", "cfg_aliases",
"concurrent-queue", "concurrent-queue",
"core-foundation 0.9.4", "core-foundation",
"core-graphics", "core-graphics",
"cursor-icon", "cursor-icon",
"dpi", "dpi",

View File

@@ -156,7 +156,7 @@ wasm-bindgen-futures = "0.4.76"
wayland-cursor = { version = "0.31.14", default-features = false } wayland-cursor = { version = "0.31.14", default-features = false }
web-sys = "0.3.103" web-sys = "0.3.103"
web-time = "1.1" # Timekeeping for native and web web-time = "1.1" # Timekeeping for native and web
webbrowser = "1.2" webbrowser = "1.2.2" # 1.2.2 fixes RUSTSEC-2026-0257 (`BROWSER` argument injection)
wgpu = { version = "30.0", default-features = false, features = ["std"] } wgpu = { version = "30.0", default-features = false, features = ["std"] }
windows-sys = "0.61.2" windows-sys = "0.61.2"
winit = { version = "0.30.13", default-features = false } winit = { version = "0.30.13", default-features = false }
@@ -180,138 +180,62 @@ all = "warn"
# See also clippy.toml # See also clippy.toml
[workspace.lints.clippy] [workspace.lints.clippy]
all = { level = "warn", priority = -1 } all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
allow_attributes = "warn" allow_attributes = "warn"
as_ptr_cast_mut = "warn" as_ptr_cast_mut = "warn"
bool_to_int_with_if = "warn"
branches_sharing_code = "warn" branches_sharing_code = "warn"
checked_conversions = "warn"
clear_with_drain = "warn" clear_with_drain = "warn"
clone_on_ref_ptr = "warn" clone_on_ref_ptr = "warn"
cloned_instead_of_copied = "warn"
coerce_container_to_any = "warn" coerce_container_to_any = "warn"
dbg_macro = "warn" dbg_macro = "warn"
debug_assert_with_mut_call = "warn" debug_assert_with_mut_call = "warn"
decimal_bitwise_operands = "warn"
default_union_representation = "warn" default_union_representation = "warn"
derive_partial_eq_without_eq = "warn" derive_partial_eq_without_eq = "warn"
disallowed_script_idents = "warn" # See clippy.toml disallowed_script_idents = "warn" # See clippy.toml
doc_broken_link = "warn"
doc_comment_double_space_linebreaks = "warn"
doc_include_without_cfg = "warn" doc_include_without_cfg = "warn"
doc_link_with_quotes = "warn"
doc_markdown = "warn"
duration_suboptimal_units = "warn"
elidable_lifetime_names = "warn"
empty_enum_variants_with_brackets = "warn" empty_enum_variants_with_brackets = "warn"
empty_enums = "warn"
enum_glob_use = "warn"
equatable_if_let = "warn" equatable_if_let = "warn"
exit = "warn" exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
fallible_impl_from = "warn" fallible_impl_from = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn" float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn" fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
from_iter_instead_of_collect = "warn"
get_unwrap = "warn" get_unwrap = "warn"
ignore_without_reason = "warn"
ignored_unit_patterns = "warn"
implicit_clone = "warn"
imprecise_flops = "warn" imprecise_flops = "warn"
inconsistent_struct_constructor = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn" infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
ip_constant = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_on_empty_collections = "warn" iter_on_empty_collections = "warn"
iter_on_single_items = "warn" iter_on_single_items = "warn"
iter_over_hash_type = "warn" iter_over_hash_type = "warn"
iter_without_into_iter = "warn"
large_digit_groups = "warn"
large_futures = "warn"
large_include_file = "warn" large_include_file = "warn"
large_stack_arrays = "warn"
large_stack_frames = "warn" large_stack_frames = "warn"
large_types_passed_by_value = "warn"
linkedlist = "warn"
literal_string_with_formatting_args = "warn" literal_string_with_formatting_args = "warn"
lossy_float_literal = "warn" lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_ilog2 = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
manual_is_variant_and = "warn"
manual_let_else = "warn"
manual_midpoint = "warn" # NOTE `midpoint` is often a lot slower for floats, so we have our own `emath::fast_midpoint` function.
manual_string_new = "warn"
map_err_ignore = "warn" map_err_ignore = "warn"
match_bool = "warn"
match_same_arms = "warn"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
mem_forget = "warn" mem_forget = "warn"
mismatching_type_param_order = "warn"
missing_assert_message = "warn" missing_assert_message = "warn"
missing_errors_doc = "warn"
missing_fields_in_debug = "warn"
mut_mut = "warn"
mutex_integer = "warn" mutex_integer = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_pass_by_ref_mut = "warn" needless_pass_by_ref_mut = "warn"
needless_pass_by_value = "warn"
needless_raw_string_hashes = "warn"
needless_type_cast = "warn" needless_type_cast = "warn"
negative_feature_names = "warn" negative_feature_names = "warn"
non_std_lazy_statics = "warn"
non_zero_suggestions = "warn" non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn" nonstandard_macro_braces = "warn"
option_as_ref_cloned = "warn"
option_option = "warn"
or_fun_call = "warn" or_fun_call = "warn"
path_buf_push_overwrite = "warn" path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn" pathbuf_init_then_push = "warn"
precedence_bits = "warn" precedence_bits = "warn"
print_stderr = "warn" print_stderr = "warn"
print_stdout = "warn" print_stdout = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
pub_underscore_fields = "warn"
pub_without_shorthand = "warn" pub_without_shorthand = "warn"
rc_mutex = "warn" rc_mutex = "warn"
redundant_type_annotations = "warn" redundant_type_annotations = "warn"
ref_as_ptr = "warn"
ref_option = "warn"
ref_option_ref = "warn"
ref_patterns = "warn" ref_patterns = "warn"
rest_pat_in_fully_bound_structs = "warn" rest_pat_in_fully_bound_structs = "warn"
return_and_then = "warn" return_and_then = "warn"
same_functions_in_if_condition = "warn"
same_length_and_capacity = "warn"
self_only_used_in_recursion = "warn"
semicolon_if_nothing_returned = "warn"
set_contains_or_insert = "warn" set_contains_or_insert = "warn"
single_char_pattern = "warn"
single_match_else = "warn"
single_option_map = "warn" single_option_map = "warn"
std_instead_of_core = "warn" std_instead_of_core = "warn"
str_split_at_newline = "warn"
str_to_string = "warn" str_to_string = "warn"
string_add = "warn" string_add = "warn"
string_add_assign = "warn"
string_lit_as_bytes = "warn" string_lit_as_bytes = "warn"
string_lit_chars_any = "warn" string_lit_chars_any = "warn"
suspicious_xor_used_as_pow = "warn" suspicious_xor_used_as_pow = "warn"
@@ -319,52 +243,58 @@ todo = "warn"
too_long_first_doc_paragraph = "warn" too_long_first_doc_paragraph = "warn"
trailing_empty_array = "warn" trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn" trait_duplication_in_bounds = "warn"
transmute_ptr_to_ptr = "warn"
tuple_array_conversions = "warn" tuple_array_conversions = "warn"
unchecked_time_subtraction = "warn"
undocumented_unsafe_blocks = "warn" undocumented_unsafe_blocks = "warn"
unimplemented = "warn" unimplemented = "warn"
uninhabited_references = "warn" uninhabited_references = "warn"
uninlined_format_args = "warn"
unnecessary_box_returns = "warn"
unnecessary_debug_formatting = "warn"
unnecessary_literal_bound = "warn"
unnecessary_safety_comment = "warn" unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn" unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn" unnecessary_self_imports = "warn"
unnecessary_semicolon = "warn"
unnecessary_struct_initialization = "warn" unnecessary_struct_initialization = "warn"
unnecessary_trailing_comma = "warn"
unnecessary_wraps = "warn"
unnested_or_patterns = "warn"
unused_async = "warn"
unused_peekable = "warn" unused_peekable = "warn"
unused_rounding = "warn" unused_rounding = "warn"
unused_self = "warn"
unused_trait_names = "warn" unused_trait_names = "warn"
unwrap_used = "warn" unwrap_used = "warn"
use_self = "warn" use_self = "warn"
useless_let_if_seq = "warn" useless_let_if_seq = "warn"
verbose_file_reads = "warn" verbose_file_reads = "warn"
wildcard_dependencies = "warn" wildcard_dependencies = "warn"
zero_sized_map_values = "warn"
# TODO(emilk): maybe enable more of these lints? # Pedantic lints we opt out of, with the number of hits at the time we enabled `pedantic`:
# NOTE: these are all in `pedantic`/`restriction`/`nursery`, so the `allow` is a no-op today. cast_lossless = "allow" # 204 hits
# We keep them to record our intent in case we ever enable those groups. cast_possible_truncation = "allow" # 287 hits
cast_possible_wrap = "allow" cast_possible_wrap = "allow" # 43 hits
cast_precision_loss = "allow" # 200 hits
cast_sign_loss = "allow" # 98 hits
comparison_chain = "allow" comparison_chain = "allow"
default_trait_access = "allow" # 278 hits
float_cmp = "allow" # exact float comparisons are usually intentional (`float_cmp_const` is still on)
inline_always = "allow" # 271 hits; we know what we are doing
items_after_statements = "allow" # 82 hits
many_single_char_names = "allow" # `r, g, b, a` and `h, s, v` are fine
missing_panics_doc = "allow" # 68 hits
must_use_candidate = "allow" # 1169 hits
redundant_closure_for_method_calls = "allow" # 89 hits
return_self_not_must_use = "allow" # 246 hits
should_panic_without_expect = "allow" should_panic_without_expect = "allow"
similar_names = "allow" # too many false positives, e.g. `encoder`/`encoded`
struct_excessive_bools = "allow" # 32 hits
struct_field_names = "allow" # 23 hits
too_many_lines = "allow" too_many_lines = "allow"
trivially_copy_pass_by_ref = "allow" # 119 hits
unreadable_literal = "allow" # 513 hits
used_underscore_binding = "allow" # 25 hits
# These are meh: # These are meh:
assigning_clones = "allow" # No please assigning_clones = "allow" # No please
cast_possible_truncation = "allow" # too many hits
let_underscore_must_use = "allow"
let_underscore_untyped = "allow"
manual_range_contains = "allow" # this one is just worse imho manual_range_contains = "allow" # this one is just worse imho
map_unwrap_or = "allow" # so is this one map_unwrap_or = "allow" # so is this one
wildcard_imports = "allow" # `use crate::*` is useful to avoid merge conflicts when adding/removing imports
# NOTE: these are in `restriction`/`nursery`, so the `allow` is a no-op today.
# We keep them to record our intent in case we ever enable those groups.
let_underscore_must_use = "allow"
let_underscore_untyped = "allow"
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602 self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
significant_drop_tightening = "allow" # Too many false positives significant_drop_tightening = "allow" # Too many false positives
wildcard_imports = "allow" # `use crate::*` is useful to avoid merge conflicts when adding/removing imports

View File

@@ -41,7 +41,6 @@ impl Hsva {
/// From linear RGBA with premultiplied alpha /// From linear RGBA with premultiplied alpha
#[inline] #[inline]
pub fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self { pub fn from_rgba_premultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
#![expect(clippy::many_single_char_names)]
if a <= 0.0 { if a <= 0.0 {
if r == 0.0 && b == 0.0 && a == 0.0 { if r == 0.0 && b == 0.0 && a == 0.0 {
Self::default() Self::default()
@@ -57,7 +56,6 @@ impl Hsva {
/// From linear RGBA without premultiplied alpha /// From linear RGBA without premultiplied alpha
#[inline] #[inline]
pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self { pub fn from_rgba_unmultiplied(r: f32, g: f32, b: f32, a: f32) -> Self {
#![expect(clippy::many_single_char_names)]
let (h, s, v) = hsv_from_rgb([r, g, b]); let (h, s, v) = hsv_from_rgb([r, g, b]);
Self { h, s, v, a } Self { h, s, v, a }
} }
@@ -189,7 +187,6 @@ impl From<Color32> for Hsva {
/// All ranges in 0-1, rgb is linear. /// All ranges in 0-1, rgb is linear.
#[inline] #[inline]
pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) { pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
#![expect(clippy::many_single_char_names)]
let min = r.min(g.min(b)); let min = r.min(g.min(b));
let max = r.max(g.max(b)); // value let max = r.max(g.max(b)); // value
@@ -213,7 +210,6 @@ pub fn hsv_from_rgb([r, g, b]: [f32; 3]) -> (f32, f32, f32) {
/// All ranges in 0-1, rgb is linear. /// All ranges in 0-1, rgb is linear.
#[inline] #[inline]
pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] { pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] {
#![expect(clippy::many_single_char_names)]
let h = (h.fract() + 1.0).fract(); // wrap let h = (h.fract() + 1.0).fract(); // wrap
let s = s.clamp(0.0, 1.0); let s = s.clamp(0.0, 1.0);

View File

@@ -161,16 +161,16 @@ fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus {
if icon_big.is_null() { if icon_big.is_null() {
log::warn!("Failed to create HICON (for big icon) from embedded png data."); log::warn!("Failed to create HICON (for big icon) from embedded png data.");
return AppIconStatus::NotSetIgnored; // We could try independently with the small icon but what's the point, it would look bad! return AppIconStatus::NotSetIgnored; // We could try independently with the small icon but what's the point, it would look bad!
} else { }
// SAFETY: Unsafe WinApi function, takes objects previously created with WinAPI, all checked for null prior.
unsafe { // SAFETY: Unsafe WinApi function, takes objects previously created with WinAPI, all checked for null prior.
SendMessageW( unsafe {
window_handle, SendMessageW(
WM_SETICON, window_handle,
ICON_BIG as usize, WM_SETICON,
icon_big as isize, ICON_BIG as usize,
); icon_big as isize,
} );
} }
} }
{ {
@@ -180,16 +180,16 @@ fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus {
if icon_small.is_null() { if icon_small.is_null() {
log::warn!("Failed to create HICON (for small icon) from embedded png data."); log::warn!("Failed to create HICON (for small icon) from embedded png data.");
return AppIconStatus::NotSetIgnored; return AppIconStatus::NotSetIgnored;
} else { }
// SAFETY: Unsafe WinApi function, takes objects previously created with WinAPI, all checked for null prior.
unsafe { // SAFETY: Unsafe WinApi function, takes objects previously created with WinAPI, all checked for null prior.
SendMessageW( unsafe {
window_handle, SendMessageW(
WM_SETICON, window_handle,
ICON_SMALL as usize, WM_SETICON,
icon_small as isize, ICON_SMALL as usize,
); icon_small as isize,
} );
} }
} }

View File

@@ -67,7 +67,7 @@ fn roaming_appdata() -> Option<PathBuf> {
&FOLDERID_RoamingAppData, &FOLDERID_RoamingAppData,
KF_FLAG_DONT_VERIFY as u32, KF_FLAG_DONT_VERIFY as u32,
core::ptr::null_mut(), core::ptr::null_mut(),
&mut path_raw, &raw mut path_raw,
) )
}; };

View File

@@ -1720,7 +1720,7 @@ fn save_screenshot_and_exit(
screen_size_in_pixels: [u32; 2], screen_size_in_pixels: [u32; 2],
) { ) {
assert!( assert!(
path.ends_with(".png"), egui::load::has_extension(path, "png"),
"Expected EFRAME_SCREENSHOT_TO to end with '.png', got {path:?}" "Expected EFRAME_SCREENSHOT_TO to end with '.png', got {path:?}"
); );
let screenshot = painter.read_screen_rgba(screen_size_in_pixels); let screenshot = painter.read_screen_rgba(screen_size_in_pixels);

View File

@@ -1761,11 +1761,11 @@ impl Context {
.get(&id) .get(&id)
.map(|v| v.repaint.cumulative_frame_nr) .map(|v| v.repaint.cumulative_frame_nr)
.unwrap_or_else(|| { .unwrap_or_else(|| {
if cfg!(debug_assertions) { debug_assert!(
panic!("cumulative_frame_nr_for failed to find the viewport {id:?}"); false,
} else { "cumulative_frame_nr_for failed to find the viewport {id:?}"
0 );
} 0
}) })
}) })
} }

View File

@@ -41,6 +41,13 @@ impl<T: core::hash::Hash + core::fmt::Debug> AsId for T {}
/// This is niche-optimized to that `Option<Id>` is the same size as `Id`. /// This is niche-optimized to that `Option<Id>` is the same size as `Id`.
#[derive(Clone, Copy, Hash, Eq, PartialEq)] #[derive(Clone, Copy, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(
feature = "serde",
expect(
clippy::unsafe_derive_deserialize,
reason = "`from_high_entropy_bits` is only `unsafe` about entropy, not memory safety"
)
)]
pub struct Id(NonZeroU64); pub struct Id(NonZeroU64);
impl nohash_hasher::IsEnabled for Id {} impl nohash_hasher::IsEnabled for Id {}

View File

@@ -306,6 +306,19 @@ macro_rules! generate_loader_id {
} }
pub use crate::generate_loader_id; pub use crate::generate_loader_id;
/// Does the given URI end with the given file extension?
///
/// The comparison ignores ASCII case and any `#fragment` at the end of the URI,
/// so `has_extension("cat.GIF#frame=2", "gif")` is `true`.
///
/// This is useful when implementing an [`ImageLoader`].
pub fn has_extension(uri: &str, extension: &str) -> bool {
let path = uri.split('#').next().unwrap_or(uri);
std::path::Path::new(path)
.extension()
.is_some_and(|found| found.eq_ignore_ascii_case(extension))
}
pub type BytesLoadResult = Result<BytesPoll>; pub type BytesLoadResult = Result<BytesPoll>;
/// Represents a loader capable of loading raw unstructured bytes from somewhere, /// Represents a loader capable of loading raw unstructured bytes from somewhere,
@@ -639,3 +652,14 @@ impl Loaders {
} }
} }
} }
#[test]
fn test_has_extension() {
assert!(has_extension("cat.svg", "svg"));
assert!(has_extension("cat.SVG", "svg"));
assert!(has_extension("http://example.com/cat.gif#frame=2", "gif"));
assert!(!has_extension("cat.svg.png", "svg"));
assert!(!has_extension("svg", "svg"));
assert!(!has_extension("cat.jpeg", "jpg"));
assert!(!has_extension("cat.svg?v=1", "svg"));
}

View File

@@ -150,5 +150,5 @@ impl TextureLoader for DefaultTextureLoader {
} }
fn is_svg(uri: &str) -> bool { fn is_svg(uri: &str) -> bool {
uri.ends_with(".svg") super::has_extension(uri, "svg")
} }

View File

@@ -934,7 +934,7 @@ fn animated_image_frame_index(ctx: &Context, uri: &str) -> usize {
/// Checks if uri is a gif file /// Checks if uri is a gif file
fn is_gif_uri(uri: &str) -> bool { fn is_gif_uri(uri: &str) -> bool {
uri.ends_with(".gif") || uri.contains(".gif#") crate::load::has_extension(uri, "gif")
} }
/// Checks if bytes are gifs /// Checks if bytes are gifs
@@ -944,7 +944,7 @@ pub fn has_gif_magic_header(bytes: &[u8]) -> bool {
/// Checks if uri is a webp file /// Checks if uri is a webp file
fn is_webp_uri(uri: &str) -> bool { fn is_webp_uri(uri: &str) -> bool {
uri.ends_with(".webp") || uri.contains(".webp#") crate::load::has_extension(uri, "webp")
} }
/// Checks if bytes are webp /// Checks if bytes are webp

View File

@@ -118,15 +118,15 @@ impl<'a> Parser<'a> {
{ {
let language = &language_start[..newline]; let language = &language_start[..newline];
let code_start = &language_start[newline + 1..]; let code_start = &language_start[newline + 1..];
if let Some(end) = code_start.find("\n```") { return if let Some(end) = code_start.find("\n```") {
let code = &code_start[..end].trim(); let code = &code_start[..end].trim();
self.s = &code_start[end + 4..]; self.s = &code_start[end + 4..];
self.start_of_line = false; self.start_of_line = false;
return Some(Item::CodeBlock(language, code)); Some(Item::CodeBlock(language, code))
} else { } else {
self.s = ""; self.s = "";
return Some(Item::CodeBlock(language, code_start)); Some(Item::CodeBlock(language, code_start))
} };
} }
None None
} }
@@ -138,18 +138,18 @@ impl<'a> Parser<'a> {
self.start_of_line = false; self.start_of_line = false;
self.style.code = true; self.style.code = true;
let rest_of_line = &self.s[..self.s.find('\n').unwrap_or(self.s.len())]; let rest_of_line = &self.s[..self.s.find('\n').unwrap_or(self.s.len())];
if let Some(end) = rest_of_line.find('`') { return if let Some(end) = rest_of_line.find('`') {
let item = Item::Text(self.style, &self.s[..end]); let item = Item::Text(self.style, &self.s[..end]);
self.s = &self.s[end + 1..]; self.s = &self.s[end + 1..];
self.style.code = false; self.style.code = false;
return Some(item); Some(item)
} else { } else {
let end = rest_of_line.len(); let end = rest_of_line.len();
let item = Item::Text(self.style, rest_of_line); let item = Item::Text(self.style, rest_of_line);
self.s = &self.s[end..]; self.s = &self.s[end..];
self.style.code = false; self.style.code = false;
return Some(item); Some(item)
} };
} }
None None
} }

View File

@@ -29,7 +29,7 @@ impl SvgLoader {
} }
fn is_supported(uri: &str) -> bool { fn is_supported(uri: &str) -> bool {
uri.ends_with(".svg") egui::load::has_extension(uri, "svg")
} }
impl Default for SvgLoader { impl Default for SvgLoader {

View File

@@ -210,6 +210,13 @@ impl SyntectTheme {
derive(serde::Deserialize, serde::Serialize), derive(serde::Deserialize, serde::Serialize),
serde(default) serde(default)
)] )]
#[cfg_attr(
all(feature = "serde", not(feature = "syntect")),
expect(
clippy::unsafe_derive_deserialize,
reason = "the `enum_map!` macro expands to `unsafe` code"
)
)]
pub struct CodeTheme { pub struct CodeTheme {
dark_mode: bool, dark_mode: bool,

View File

@@ -247,16 +247,16 @@ impl<'a, State> Harness<'a, State> {
pub fn step(&mut self) { pub fn step(&mut self) {
let events = core::mem::take(&mut *self.queued_events.lock()); let events = core::mem::take(&mut *self.queued_events.lock());
if events.is_empty() { if events.is_empty() {
self._step(false); self.step_impl(false);
} }
for event in events { for event in events {
self.input.events.push(event); self.input.events.push(event);
self._step(false); self.step_impl(false);
} }
} }
/// Run a single step. This will not process any events. /// Run a single step. This will not process any events.
fn _step(&mut self, sizing_pass: bool) { fn step_impl(&mut self, sizing_pass: bool) {
self.input.predicted_dt = self.step_dt; self.input.predicted_dt = self.step_dt;
let mut output = self.ctx.run_ui(self.input.take(), |ui| { let mut output = self.ctx.run_ui(self.input.take(), |ui| {
@@ -297,7 +297,7 @@ impl<'a, State> Harness<'a, State> {
/// [`Harness::new_ui`] / [`Harness::new_ui_state`] or /// [`Harness::new_ui`] / [`Harness::new_ui_state`] or
/// [`HarnessBuilder::build_ui`] / [`HarnessBuilder::build_ui_state`]. /// [`HarnessBuilder::build_ui`] / [`HarnessBuilder::build_ui_state`].
pub fn fit_contents(&mut self) { pub fn fit_contents(&mut self) {
self._step(true); self.step_impl(true);
// Calculate size including all content (main UI + popups + tooltips) // Calculate size including all content (main UI + popups + tooltips)
if let Some(rect) = self.compute_total_rect_with_popups() { if let Some(rect) = self.compute_total_rect_with_popups() {
@@ -333,7 +333,7 @@ impl<'a, State> Harness<'a, State> {
} }
} }
fn _try_run(&mut self, sleep: bool) -> Result<u64, ExceededMaxStepsError> { fn try_run_impl(&mut self, sleep: bool) -> Result<u64, ExceededMaxStepsError> {
let mut steps = 0; let mut steps = 0;
loop { loop {
steps += 1; steps += 1;
@@ -374,7 +374,7 @@ impl<'a, State> Harness<'a, State> {
/// - [`Harness::run_steps`]. /// - [`Harness::run_steps`].
/// - [`Harness::try_run_realtime`]. /// - [`Harness::try_run_realtime`].
pub fn try_run(&mut self) -> Result<u64, ExceededMaxStepsError> { pub fn try_run(&mut self) -> Result<u64, ExceededMaxStepsError> {
self._try_run(false) self.try_run_impl(false)
} }
/// Run until /// Run until
@@ -414,7 +414,7 @@ impl<'a, State> Harness<'a, State> {
/// - [`Harness::run_steps`]. /// - [`Harness::run_steps`].
/// - [`Harness::try_run`]. /// - [`Harness::try_run`].
pub fn try_run_realtime(&mut self) -> Result<u64, ExceededMaxStepsError> { pub fn try_run_realtime(&mut self) -> Result<u64, ExceededMaxStepsError> {
self._try_run(true) self.try_run_impl(true)
} }
/// Run a number of steps. /// Run a number of steps.

View File

@@ -535,31 +535,31 @@ fn try_image_snapshot_options_impl(
Ok(image) => image.to_rgba8(), Ok(image) => image.to_rgba8(),
Err(err) => { Err(err) => {
// No previous snapshot - probably a new test. // No previous snapshot - probably a new test.
if mode.is_update() { return if mode.is_update() {
return update_snapshot(); update_snapshot()
} else { } else {
write_new_png()?; write_new_png()?;
return Err(SnapshotError::OpenSnapshot { Err(SnapshotError::OpenSnapshot {
path: snapshot_path.clone(), path: snapshot_path.clone(),
err, err,
}); })
} };
} }
}; };
if previous.dimensions() != new.dimensions() { if previous.dimensions() != new.dimensions() {
if mode.is_update() { return if mode.is_update() {
return update_snapshot(); update_snapshot()
} else { } else {
write_new_png()?; write_new_png()?;
return Err(SnapshotError::SizeMismatch { Err(SnapshotError::SizeMismatch {
name, name,
expected: previous.dimensions(), expected: previous.dimensions(),
actual: new.dimensions(), actual: new.dimensions(),
}); })
} };
} }
// Compare existing image to the new one: // Compare existing image to the new one:

View File

@@ -1,5 +1,3 @@
#![expect(clippy::many_single_char_names)]
use core::ops::Range; use core::ops::Range;
use crate::{Color32, PathShape, PathStroke, Shape}; use crate::{Color32, PathShape, PathStroke, Shape};

View File

@@ -1519,11 +1519,11 @@ impl Tessellator {
if stroke.is_empty() { if stroke.is_empty() {
return; // we are done return; // we are done
} else {
// we still need to do the stroke
fill = Color32::TRANSPARENT; // don't fill again below
break;
} }
// we still need to do the stroke
fill = Color32::TRANSPARENT; // don't fill again below
break;
} }
} }
} }

View File

@@ -50,7 +50,6 @@ skip = [
{ name = "bit-set" }, # wgpu's naga depends on 0.8, syntect's (used by egui_extras) fancy-regex depends on 0.5 { name = "bit-set" }, # wgpu's naga depends on 0.8, syntect's (used by egui_extras) fancy-regex depends on 0.5
{ name = "bit-vec" }, # dependency of bit-set in turn, different between 0.6 and 0.5 { name = "bit-vec" }, # dependency of bit-set in turn, different between 0.6 and 0.5
{ name = "bitflags" }, # old 1.0 version via glutin, png, spirv, … { name = "bitflags" }, # old 1.0 version via glutin, png, spirv, …
{ name = "core-foundation" }, # version conflict between winit and wgpu ecosystems
{ name = "env_filter" }, # 0.1.4 only used by android_logger, which is only used by the hello_android example { name = "env_filter" }, # 0.1.4 only used by android_logger, which is only used by the hello_android example
{ name = "foldhash" }, # pulled by the duplicated hashbrown versions { name = "foldhash" }, # pulled by the duplicated hashbrown versions
{ name = "getrandom" }, # ring / rustls (and thus ehttp) still depend on getrandom 0.2 { name = "getrandom" }, # ring / rustls (and thus ehttp) still depend on getrandom 0.2