Skip to content

Commit e0e372a

Browse files
authored
Slightly change interact behavior around thin splitters (#7806)
* Added in #5468 * Related to #7803 The code doesn't seem to longer be needed. Interacting with a resize splitter isn't very difficult, and I never liked that special case.
1 parent 1fdc741 commit e0e372a

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

crates/egui/src/hit_test.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ahash::HashMap;
22

33
use emath::TSTransform;
44

5-
use crate::{LayerId, Pos2, Rect, Sense, WidgetRect, WidgetRects, ahash, emath, id::IdSet};
5+
use crate::{LayerId, Pos2, Sense, WidgetRect, WidgetRects, ahash, emath, id::IdSet};
66

77
/// Result of a hit-test against [`WidgetRects`].
88
///
@@ -427,16 +427,6 @@ fn find_closest_within(
427427

428428
let dist_sq = widget.interact_rect.distance_sq_to_pos(pos);
429429

430-
if let Some(closest) = closest
431-
&& dist_sq == closest_dist_sq
432-
{
433-
// It's a tie! Pick the thin candidate over the thick one.
434-
// This makes it easier to hit a thin resize-handle, for instance:
435-
if should_prioritize_hits_on_back(closest.interact_rect, widget.interact_rect) {
436-
continue;
437-
}
438-
}
439-
440430
// In case of a tie, take the last one = the one on top.
441431
if dist_sq <= closest_dist_sq {
442432
closest_dist_sq = dist_sq;
@@ -447,27 +437,6 @@ fn find_closest_within(
447437
closest
448438
}
449439

450-
/// Should we prioritize hits on `back` over those on `front`?
451-
///
452-
/// `back` should be behind the `front` widget.
453-
///
454-
/// Returns true if `back` is a small hit-target and `front` is not.
455-
fn should_prioritize_hits_on_back(back: Rect, front: Rect) -> bool {
456-
if front.contains_rect(back) {
457-
return false; // back widget is fully occluded; no way to hit it
458-
}
459-
460-
// Reduce each rect to its width or height, whichever is smaller:
461-
let back = back.width().min(back.height());
462-
let front = front.width().min(front.height());
463-
464-
// These are hard-coded heuristics that could surely be improved.
465-
let back_is_much_thinner = back <= 0.5 * front;
466-
let back_is_thin = back <= 16.0;
467-
468-
back_is_much_thinner && back_is_thin
469-
}
470-
471440
#[cfg(test)]
472441
mod tests {
473442
#![expect(clippy::print_stdout)]

crates/egui/src/style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ impl Default for Interaction {
13921392
fn default() -> Self {
13931393
Self {
13941394
interact_radius: 5.0,
1395-
resize_grab_radius_side: 5.0,
1395+
resize_grab_radius_side: 3.0,
13961396
resize_grab_radius_corner: 10.0,
13971397
show_tooltips_only_when_still: true,
13981398
tooltip_delay: 0.5,

0 commit comments

Comments
 (0)