fix minor bug when moving a window
This commit is contained in:
parent
d5d6c48974
commit
538db9005e
1 changed files with 8 additions and 6 deletions
|
@ -234,8 +234,8 @@ impl<'open> Window<'open> {
|
||||||
window_id.with("frame_resize"),
|
window_id.with("frame_resize"),
|
||||||
pre_resize,
|
pre_resize,
|
||||||
);
|
);
|
||||||
let new_rect = ctx.round_rect_to_pixels(new_rect);
|
if let Some(new_rect) = new_rect {
|
||||||
if new_rect != pre_resize {
|
let new_rect = ctx.round_rect_to_pixels(new_rect);
|
||||||
// TODO: add this to a Window state instead as a command "move here next frame"
|
// TODO: add this to a Window state instead as a command "move here next frame"
|
||||||
|
|
||||||
let mut area_state = ctx.memory().areas.get(area_layer.id).unwrap();
|
let mut area_state = ctx.memory().areas.get(area_layer.id).unwrap();
|
||||||
|
@ -299,12 +299,12 @@ fn resize_window(
|
||||||
possible: PossibleInteractions,
|
possible: PossibleInteractions,
|
||||||
area_layer: Layer,
|
area_layer: Layer,
|
||||||
id: Id,
|
id: Id,
|
||||||
mut rect: Rect,
|
rect: Rect,
|
||||||
) -> Rect {
|
) -> Option<Rect> {
|
||||||
if let Some(window_interaction) = window_interaction(ctx, possible, area_layer, id, rect) {
|
if let Some(window_interaction) = window_interaction(ctx, possible, area_layer, id, rect) {
|
||||||
window_interaction.set_cursor(ctx);
|
window_interaction.set_cursor(ctx);
|
||||||
if let Some(mouse_pos) = ctx.input().mouse_pos {
|
if let Some(mouse_pos) = ctx.input().mouse_pos {
|
||||||
rect = window_interaction.start_rect; // prevent drift
|
let mut rect = window_interaction.start_rect; // prevent drift
|
||||||
|
|
||||||
if window_interaction.is_resize() {
|
if window_interaction.is_resize() {
|
||||||
if window_interaction.left {
|
if window_interaction.left {
|
||||||
|
@ -322,10 +322,12 @@ fn resize_window(
|
||||||
// movevement
|
// movevement
|
||||||
rect = rect.translate(mouse_pos - window_interaction.start_mouse_pos);
|
rect = rect.translate(mouse_pos - window_interaction.start_mouse_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Some(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rect;
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_interaction(
|
fn window_interaction(
|
||||||
|
|
Loading…
Reference in a new issue