ui: window resize
This commit is contained in:
parent
dafd2a1db3
commit
8b0bb2b771
2 changed files with 5 additions and 18 deletions
|
@ -353,15 +353,9 @@ impl<Platform: PlatformCallbacks> App<Platform> {
|
||||||
let sense = egui::Sense::drag();
|
let sense = egui::Sense::drag();
|
||||||
let area_resp = ui.interact(rect, id, sense).on_hover_cursor(cursor);
|
let area_resp = ui.interact(rect, id, sense).on_hover_cursor(cursor);
|
||||||
if area_resp.dragged() {
|
if area_resp.dragged() {
|
||||||
let current_pos = area_resp.interact_pointer_pos();
|
if self.resize_direction.is_none() {
|
||||||
if let Some(pos) = current_pos {
|
self.resize_direction = Some(direction.clone());
|
||||||
if self.resize_direction.is_none() {
|
ui.ctx().send_viewport_cmd(ViewportCommand::BeginResize(direction));
|
||||||
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 area_resp.drag_stopped() {
|
if area_resp.drag_stopped() {
|
||||||
|
|
|
@ -83,15 +83,8 @@ impl View {
|
||||||
|
|
||||||
/// Get width and height of app window.
|
/// Get width and height of app window.
|
||||||
pub fn window_size(ui: &egui::Ui) -> (f32, f32) {
|
pub fn window_size(ui: &egui::Ui) -> (f32, f32) {
|
||||||
ui.ctx().input(|i| {
|
let rect = ui.ctx().screen_rect();
|
||||||
return match i.viewport().inner_rect {
|
(rect.width(), rect.height())
|
||||||
None => {
|
|
||||||
let rect = i.screen_rect;
|
|
||||||
(rect.width(), rect.height())
|
|
||||||
},
|
|
||||||
Some(rect) => (rect.width(), rect.height())
|
|
||||||
};
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Callback on Enter key press event.
|
/// Callback on Enter key press event.
|
||||||
|
|
Loading…
Reference in a new issue