diff --git a/src/gui/app.rs b/src/gui/app.rs index 581045f..5480eae 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -353,15 +353,9 @@ impl App { let sense = egui::Sense::drag(); let area_resp = ui.interact(rect, id, sense).on_hover_cursor(cursor); if area_resp.dragged() { - let current_pos = area_resp.interact_pointer_pos(); - if let Some(pos) = current_pos { - if self.resize_direction.is_none() { - self.resize_direction = Some(direction.clone()); - ui.ctx().send_viewport_cmd(ViewportCommand::BeginResize(direction)); - } - ui.ctx().send_viewport_cmd(ViewportCommand::InnerSize( - pos.to_vec2() + egui::vec2(Root::WINDOW_FRAME_MARGIN, Root::WINDOW_FRAME_MARGIN) - )); + if self.resize_direction.is_none() { + self.resize_direction = Some(direction.clone()); + ui.ctx().send_viewport_cmd(ViewportCommand::BeginResize(direction)); } } if area_resp.drag_stopped() { diff --git a/src/gui/views/views.rs b/src/gui/views/views.rs index 80127fc..7f3d92f 100644 --- a/src/gui/views/views.rs +++ b/src/gui/views/views.rs @@ -83,15 +83,8 @@ impl View { /// Get width and height of app window. pub fn window_size(ui: &egui::Ui) -> (f32, f32) { - ui.ctx().input(|i| { - return match i.viewport().inner_rect { - None => { - let rect = i.screen_rect; - (rect.width(), rect.height()) - }, - Some(rect) => (rect.width(), rect.height()) - }; - }) + let rect = ui.ctx().screen_rect(); + (rect.width(), rect.height()) } /// Callback on Enter key press event.