Skip to content

Commit

Permalink
Fix interaction with moved color-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 27, 2023
1 parent 1b830bb commit 6465386
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl Area {
}

// interact right away to prevent frame-delay
let move_response = {
let mut move_response = {
let interact_id = layer_id.id.with("move");
let sense = if movable {
Sense::click_and_drag()
Expand All @@ -291,16 +291,8 @@ impl Area {
enabled,
);

// Important check - don't try to move e.g. a combobox popup!
if movable {
if move_response.dragged() {
state.pivot_pos += ctx.input(|i| i.pointer.delta());
}

state.set_left_top_pos(
ctx.constrain_window_rect_to_area(state.rect(), drag_bounds)
.min,
);
if movable && move_response.dragged() {
state.pivot_pos += ctx.input(|i| i.pointer.delta());
}

if (move_response.dragged() || move_response.clicked())
Expand All @@ -314,15 +306,18 @@ impl Area {
move_response
};

state.set_left_top_pos(ctx.round_pos_to_pixels(state.left_top_pos()));

if constrain {
state.set_left_top_pos(
ctx.constrain_window_rect_to_area(state.rect(), drag_bounds)
.left_top(),
.min,
);
}

state.set_left_top_pos(ctx.round_pos_to_pixels(state.left_top_pos()));

// Update responsbe with posisbly moved/constrained rect:
move_response = move_response.with_new_rect(state.rect());

Prepared {
layer_id,
state,
Expand Down

0 comments on commit 6465386

Please sign in to comment.