Fix interaction with moved color-picker (#3395)

This commit is contained in:
Emil Ernerfeldt 2023-09-27 08:20:04 +02:00 committed by GitHub
parent 1b830bbcb4
commit 1911248ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 14 deletions

View File

@ -271,7 +271,7 @@ impl Area {
} }
// interact right away to prevent frame-delay // interact right away to prevent frame-delay
let move_response = { let mut move_response = {
let interact_id = layer_id.id.with("move"); let interact_id = layer_id.id.with("move");
let sense = if movable { let sense = if movable {
Sense::click_and_drag() Sense::click_and_drag()
@ -291,16 +291,8 @@ impl Area {
enabled, enabled,
); );
// Important check - don't try to move e.g. a combobox popup! if movable && move_response.dragged() {
if movable { state.pivot_pos += ctx.input(|i| i.pointer.delta());
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 (move_response.dragged() || move_response.clicked()) if (move_response.dragged() || move_response.clicked())
@ -314,15 +306,18 @@ impl Area {
move_response move_response
}; };
state.set_left_top_pos(ctx.round_pos_to_pixels(state.left_top_pos()));
if constrain { if constrain {
state.set_left_top_pos( state.set_left_top_pos(
ctx.constrain_window_rect_to_area(state.rect(), drag_bounds) 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 { Prepared {
layer_id, layer_id,
state, state,