diff --git a/egui/src/context.rs b/egui/src/context.rs index 38186efd..baae54c2 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -455,6 +455,7 @@ impl Context { } /// The number of physical pixels for each logical point. + #[inline(always)] pub fn pixels_per_point(&self) -> f32 { self.input.pixels_per_point() } diff --git a/egui/src/input_state.rs b/egui/src/input_state.rs index 94020fa7..22afa989 100644 --- a/egui/src/input_state.rs +++ b/egui/src/input_state.rs @@ -110,6 +110,7 @@ impl InputState { } } + #[inline(always)] pub fn screen_rect(&self) -> Rect { self.screen_rect } @@ -160,17 +161,20 @@ impl InputState { } /// Also known as device pixel ratio, > 1 for high resolution screens. + #[inline(always)] pub fn pixels_per_point(&self) -> f32 { self.pixels_per_point } /// Size of a physical pixel in logical gui coordinates (points). + #[inline(always)] pub fn physical_pixel_size(&self) -> f32 { 1.0 / self.pixels_per_point() } /// How imprecise do we expect the mouse/touch input to be? /// Returns imprecision in points. + #[inline(always)] pub fn aim_radius(&self) -> f32 { // TODO: multiply by ~3 for touch inputs because fingers are fat self.physical_pixel_size() @@ -488,10 +492,12 @@ impl PointerState { // } /// Is this button currently down? + #[inline(always)] pub fn button_down(&self, button: PointerButton) -> bool { self.down[button as usize] } + #[inline(always)] pub(crate) fn could_any_button_be_click(&self) -> bool { self.could_be_click } diff --git a/egui/src/painter.rs b/egui/src/painter.rs index 6396fde9..412281de 100644 --- a/egui/src/painter.rs +++ b/egui/src/painter.rs @@ -83,43 +83,51 @@ impl Painter { /// ## Accessors etc impl Painter { + #[inline(always)] pub(crate) fn ctx(&self) -> &CtxRef { &self.ctx } /// Available fonts + #[inline(always)] pub(crate) fn fonts(&self) -> &Fonts { self.ctx.fonts() } /// Where we paint + #[inline(always)] pub fn layer_id(&self) -> LayerId { self.layer_id } /// Everything painted in this `Painter` will be clipped against this. /// This means nothing outside of this rectangle will be visible on screen. + #[inline(always)] pub fn clip_rect(&self) -> Rect { self.clip_rect } /// Everything painted in this `Painter` will be clipped against this. /// This means nothing outside of this rectangle will be visible on screen. + #[inline(always)] pub fn set_clip_rect(&mut self, clip_rect: Rect) { self.clip_rect = clip_rect; } /// Useful for pixel-perfect rendering + #[inline(always)] pub fn round_to_pixel(&self, point: f32) -> f32 { self.ctx().round_to_pixel(point) } /// Useful for pixel-perfect rendering + #[inline(always)] pub fn round_vec_to_pixels(&self, vec: Vec2) -> Vec2 { self.ctx().round_vec_to_pixels(vec) } /// Useful for pixel-perfect rendering + #[inline(always)] pub fn round_pos_to_pixels(&self, pos: Pos2) -> Pos2 { self.ctx().round_pos_to_pixels(pos) } diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 1b0f6439..4f087294 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -99,11 +99,13 @@ impl Ui { // ------------------------------------------------- /// A unique identity of this `Ui`. + #[inline(always)] pub fn id(&self) -> Id { self.id } /// Style options for this `Ui` and its children. + #[inline(always)] pub fn style(&self) -> &std::sync::Arc