From 5892d057d7428e0abd2da94968562958167a1ad5 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 12 Nov 2023 12:52:48 +0100 Subject: [PATCH] Use _px suffix for things in pixel units --- crates/egui-winit/src/lib.rs | 16 ++++++++-------- crates/egui/src/data/input.rs | 12 ++++++------ examples/test_viewports/src/main.rs | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 45835405252..a3355750456 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -209,7 +209,7 @@ impl State { None }; - let inner_pos = if getting_info { + let inner_pos_px = if getting_info { window .inner_position() .map(|pos| Pos2::new(pos.x as f32, pos.y as f32)) @@ -218,7 +218,7 @@ impl State { None }; - let outer_pos = if getting_info { + let outer_pos_px = if getting_info { window .outer_position() .map(|pos| Pos2::new(pos.x as f32, pos.y as f32)) @@ -227,14 +227,14 @@ impl State { None }; - let inner_size = if getting_info { + let inner_size_px = if getting_info { let size = window.inner_size(); Some(Vec2::new(size.width as f32, size.height as f32)) } else { None }; - let outer_size = if getting_info { + let outer_size_px = if getting_info { let size = window.outer_size(); Some(Vec2::new(size.width as f32, size.height as f32)) } else { @@ -242,15 +242,15 @@ impl State { }; self.egui_input.viewport.id_pair = id_pair; - self.egui_input.viewport.inner_rect = - if let (Some(pos), Some(size)) = (inner_pos, inner_size) { + self.egui_input.viewport.inner_rect_px = + if let (Some(pos), Some(size)) = (inner_pos_px, inner_size_px) { Some(Rect::from_min_size(pos, size)) } else { None }; - self.egui_input.viewport.outer_rect = - if let (Some(pos), Some(size)) = (outer_pos, outer_size) { + self.egui_input.viewport.outer_rect_px = + if let (Some(pos), Some(size)) = (outer_pos_px, outer_size_px) { Some(Rect::from_min_size(pos, size)) } else { None diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 0ea87beda41..e18b2a7b192 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -147,11 +147,11 @@ pub struct ViewportInfo { /// Viewport inner position and size, only the drowable area /// unit = physical pixels - pub inner_rect: Option, + pub inner_rect_px: Option, /// Viewport outer position and size, drowable area + decorations /// unit = physical pixels - pub outer_rect: Option, + pub outer_rect_px: Option, /// Viewport should close? pub close_requested: bool, @@ -165,13 +165,13 @@ impl ViewportInfo { pub fn ui(&self, ui: &mut crate::Ui) { let Self { id_pair, - inner_rect, - outer_rect, + inner_rect_px, + outer_rect_px, close_requested, } = self; ui.label(format!("id_pair: {id_pair:?}")); - ui.label(format!("inner_rect: {inner_rect:?}")); - ui.label(format!("outer_rect: {outer_rect:?}")); + ui.label(format!("inner_rect_px: {inner_rect_px:?}")); + ui.label(format!("outer_rect_px: {outer_rect_px:?}")); ui.label(format!("close_requested: {close_requested:?}")); } } diff --git a/examples/test_viewports/src/main.rs b/examples/test_viewports/src/main.rs index 11223f902dc..68eba7ccc96 100644 --- a/examples/test_viewports/src/main.rs +++ b/examples/test_viewports/src/main.rs @@ -197,14 +197,14 @@ fn generic_ui(ui: &mut egui::Ui, children: &[Arc>]) { ui.add_space(8.0); - if let Some(inner_rect) = ctx.input(|i| i.raw.viewport.inner_rect) { + if let Some(inner_rect) = ctx.input(|i| i.raw.viewport.inner_rect_px) { ui.label(format!( "Inner Rect: Pos: {:?}, Size: {:?}", inner_rect.min, inner_rect.size() )); } - if let Some(outer_rect) = ctx.input(|i| i.raw.viewport.outer_rect) { + if let Some(outer_rect) = ctx.input(|i| i.raw.viewport.outer_rect_px) { ui.label(format!( "Outer Rect: Pos: {:?}, Size: {:?}", outer_rect.min,