Skip to content

Commit

Permalink
Make it easy to hit corners, even on windows that only expand one way
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 27, 2024
1 parent 9823fd7 commit 127acd0
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,31 +917,52 @@ fn resize_interaction(
}

// ----------------------------------------
// Now check corners:

if possible.resize_right && possible.resize_bottom {
// Now check corners.
// We check any corner that has either side resizable,
// because we shrink the side resize handled by the corner width.
// Also, even if we can only change the width (or height) of a window,
// we show one of the corners as a grab-handle, so it makes sense that
// the whole corner is grabbable:

if possible.resize_right || possible.resize_bottom {
let response = side_response(corner_rect(rect.right_bottom()), id.with("right_bottom"));
if possible.resize_right {
right |= response;
}
if possible.resize_bottom {
bottom |= response;
}
}

if possible.resize_right && possible.resize_top {
if possible.resize_right || possible.resize_top {
let response = side_response(corner_rect(rect.right_top()), id.with("right_top"));
if possible.resize_right {
right |= response;
}
if possible.resize_top {
top |= response;
}
}

if possible.resize_left && possible.resize_bottom {
if possible.resize_left || possible.resize_bottom {
let response = side_response(corner_rect(rect.left_bottom()), id.with("left_bottom"));
if possible.resize_left {
left |= response;
}
if possible.resize_bottom {
bottom |= response;
}
}

if possible.resize_left && possible.resize_top {
if possible.resize_left || possible.resize_top {
let response = side_response(corner_rect(rect.left_top()), id.with("left_top"));
if possible.resize_left {
left |= response;
}
if possible.resize_top {
top |= response;
}
}

let interaction = ResizeInteraction {
start_rect: rect,
Expand Down

0 comments on commit 127acd0

Please sign in to comment.