diff --git a/egui-wgpu/src/renderer.rs b/egui-wgpu/src/renderer.rs index cbdeada6..0de81f1c 100644 --- a/egui-wgpu/src/renderer.rs +++ b/egui-wgpu/src/renderer.rs @@ -569,7 +569,7 @@ impl RenderPass { /// This could be used by custom paint hooks to render images that have been added through with /// [`egui_extras::RetainedImage`](https://docs.rs/egui_extras/latest/egui_extras/image/struct.RetainedImage.html) /// or [`egui::Context::load_texture`]. - pub fn get_texture( + pub fn texture( &self, id: &egui::TextureId, ) -> Option<&(Option, wgpu::BindGroup)> { diff --git a/egui-winit/src/lib.rs b/egui-winit/src/lib.rs index b9b43980..be98ff47 100644 --- a/egui-winit/src/lib.rs +++ b/egui-winit/src/lib.rs @@ -66,7 +66,7 @@ pub struct State { impl State { pub fn new(event_loop: &EventLoopWindowTarget) -> Self { - Self::new_with_wayland_display(get_wayland_display(event_loop)) + Self::new_with_wayland_display(wayland_display(event_loop)) } pub fn new_with_wayland_display(wayland_display: Option<*mut c_void>) -> Self { @@ -712,7 +712,7 @@ fn translate_cursor(cursor_icon: egui::CursorIcon) -> Option(_event_loop: &EventLoopWindowTarget) -> Option<*mut c_void> { +fn wayland_display(_event_loop: &EventLoopWindowTarget) -> Option<*mut c_void> { #[cfg(any( target_os = "linux", target_os = "dragonfly", diff --git a/egui/src/menu.rs b/egui/src/menu.rs index a3812f3e..1950cb83 100644 --- a/egui/src/menu.rs +++ b/egui/src/menu.rs @@ -532,7 +532,7 @@ impl MenuState { id: Id, add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option { - let (sub_response, response) = self.get_submenu(id).map(|sub| { + let (sub_response, response) = self.submenu(id).map(|sub| { let inner_response = Self::show(ctx, sub, id, add_contents); (sub.read().response, inner_response.inner) })?; @@ -582,7 +582,7 @@ impl MenuState { if pointer.is_still() { return false; } - if let Some(sub_menu) = self.get_current_submenu() { + if let Some(sub_menu) = self.current_submenu() { if let Some(pos) = pointer.hover_pos() { return Self::points_at_left_of_rect(pos, pointer.velocity(), sub_menu.read().rect); } @@ -592,7 +592,7 @@ impl MenuState { /// Check if pointer is hovering current submenu. fn hovering_current_submenu(&self, pointer: &PointerState) -> bool { - if let Some(sub_menu) = self.get_current_submenu() { + if let Some(sub_menu) = self.current_submenu() { if let Some(pos) = pointer.hover_pos() { return sub_menu.read().area_contains(pos); } @@ -608,18 +608,18 @@ impl MenuState { } fn is_open(&self, id: Id) -> bool { - self.get_sub_id() == Some(id) + self.sub_id() == Some(id) } - fn get_sub_id(&self) -> Option { + fn sub_id(&self) -> Option { self.sub_menu.as_ref().map(|(id, _)| *id) } - fn get_current_submenu(&self) -> Option<&Arc>> { + fn current_submenu(&self) -> Option<&Arc>> { self.sub_menu.as_ref().map(|(_, sub)| sub) } - fn get_submenu(&mut self, id: Id) -> Option<&Arc>> { + fn submenu(&mut self, id: Id) -> Option<&Arc>> { self.sub_menu .as_ref() .and_then(|(k, sub)| if id == *k { Some(sub) } else { None }) diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 413677c5..bb915b49 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -99,7 +99,7 @@ impl Ui { crate::egui_assert!(!max_rect.any_nan()); let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value(); self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1); - let menu_state = self.get_menu_state(); + let menu_state = self.menu_state(); Ui { id: self.id.with(id_source), next_auto_id_source, @@ -2096,7 +2096,7 @@ impl Ui { self.menu_state = None; } - pub(crate) fn get_menu_state(&self) -> Option>> { + pub(crate) fn menu_state(&self) -> Option>> { self.menu_state.clone() } diff --git a/egui/src/widgets/plot/items/mod.rs b/egui/src/widgets/plot/items/mod.rs index c9f66772..def04a45 100644 --- a/egui/src/widgets/plot/items/mod.rs +++ b/egui/src/widgets/plot/items/mod.rs @@ -32,7 +32,7 @@ pub(super) struct PlotConfig<'a> { /// Trait shared by things that can be drawn in the plot. pub(super) trait PlotItem { - fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec); + fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec); fn initialize(&mut self, x_range: RangeInclusive); @@ -46,7 +46,7 @@ pub(super) trait PlotItem { fn geometry(&self) -> PlotGeometry<'_>; - fn get_bounds(&self) -> PlotBounds; + fn bounds(&self) -> PlotBounds; fn find_closest(&self, point: Pos2, transform: &ScreenTransform) -> Option { match self.geometry() { @@ -167,7 +167,7 @@ impl HLine { } impl PlotItem for HLine { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let HLine { y, stroke, @@ -204,7 +204,7 @@ impl PlotItem for HLine { PlotGeometry::None } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; bounds.min[1] = self.y; bounds.max[1] = self.y; @@ -277,7 +277,7 @@ impl VLine { } impl PlotItem for VLine { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let VLine { x, stroke, @@ -314,7 +314,7 @@ impl PlotItem for VLine { PlotGeometry::None } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; bounds.min[0] = self.x; bounds.max[0] = self.x; @@ -401,7 +401,7 @@ fn y_intersection(p1: &Pos2, p2: &Pos2, y: f32) -> Option { } impl PlotItem for Line { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let Self { series, stroke, @@ -484,8 +484,8 @@ impl PlotItem for Line { PlotGeometry::Points(self.series.points()) } - fn get_bounds(&self) -> PlotBounds { - self.series.get_bounds() + fn bounds(&self) -> PlotBounds { + self.series.bounds() } } @@ -562,7 +562,7 @@ impl Polygon { } impl PlotItem for Polygon { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let Self { series, stroke, @@ -614,8 +614,8 @@ impl PlotItem for Polygon { PlotGeometry::Points(self.series.points()) } - fn get_bounds(&self) -> PlotBounds { - self.series.get_bounds() + fn bounds(&self) -> PlotBounds { + self.series.bounds() } } @@ -674,7 +674,7 @@ impl Text { } impl PlotItem for Text { - fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let color = if self.color == Color32::TRANSPARENT { ui.style().visuals.text_color() } else { @@ -728,7 +728,7 @@ impl PlotItem for Text { PlotGeometry::None } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; bounds.extend_with(&self.position); bounds @@ -814,7 +814,7 @@ impl Points { } impl PlotItem for Points { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let sqrt_3 = 3_f32.sqrt(); let frac_sqrt_3_2 = 3_f32.sqrt() / 2.0; let frac_1_sqrt_2 = 1.0 / 2_f32.sqrt(); @@ -965,8 +965,8 @@ impl PlotItem for Points { PlotGeometry::Points(self.series.points()) } - fn get_bounds(&self) -> PlotBounds { - self.series.get_bounds() + fn bounds(&self) -> PlotBounds { + self.series.bounds() } } @@ -1016,7 +1016,7 @@ impl Arrows { } impl PlotItem for Arrows { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { use crate::emath::*; let Self { origins, @@ -1080,8 +1080,8 @@ impl PlotItem for Arrows { PlotGeometry::Points(self.origins.points()) } - fn get_bounds(&self) -> PlotBounds { - self.origins.get_bounds() + fn bounds(&self) -> PlotBounds { + self.origins.bounds() } } @@ -1155,7 +1155,7 @@ impl PlotImage { } impl PlotItem for PlotImage { - fn get_shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { let Self { position, texture_id, @@ -1215,7 +1215,7 @@ impl PlotItem for PlotImage { PlotGeometry::None } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; let left_top = PlotPoint::new( self.position.x as f32 - self.size.x / 2.0, @@ -1346,7 +1346,7 @@ impl BarChart { } impl PlotItem for BarChart { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { for b in &self.bars { b.add_shapes(transform, self.highlight, shapes); } @@ -1376,7 +1376,7 @@ impl PlotItem for BarChart { PlotGeometry::Rects } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; for b in &self.bars { bounds.merge(&b.bounds()); @@ -1488,7 +1488,7 @@ impl BoxPlot { } impl PlotItem for BoxPlot { - fn get_shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { + fn shapes(&self, _ui: &mut Ui, transform: &ScreenTransform, shapes: &mut Vec) { for b in &self.boxes { b.add_shapes(transform, self.highlight, shapes); } @@ -1518,7 +1518,7 @@ impl PlotItem for BoxPlot { PlotGeometry::Rects } - fn get_bounds(&self) -> PlotBounds { + fn bounds(&self) -> PlotBounds { let mut bounds = PlotBounds::NOTHING; for b in &self.boxes { bounds.merge(&b.bounds()); diff --git a/egui/src/widgets/plot/items/values.rs b/egui/src/widgets/plot/items/values.rs index 95c21dbe..d39947d1 100644 --- a/egui/src/widgets/plot/items/values.rs +++ b/egui/src/widgets/plot/items/values.rs @@ -302,7 +302,7 @@ impl PlotPoints { (start < end).then(|| start..=end) } - pub(super) fn get_bounds(&self) -> PlotBounds { + pub(super) fn bounds(&self) -> PlotBounds { match self { PlotPoints::Owned(points) => { let mut bounds = PlotBounds::NOTHING; diff --git a/egui/src/widgets/plot/legend.rs b/egui/src/widgets/plot/legend.rs index c2beeac5..1679fce3 100644 --- a/egui/src/widgets/plot/legend.rs +++ b/egui/src/widgets/plot/legend.rs @@ -199,7 +199,7 @@ impl LegendWidget { } // Get the names of the hidden items. - pub fn get_hidden_items(&self) -> AHashSet { + pub fn hidden_items(&self) -> AHashSet { self.entries .iter() .filter(|(_, entry)| !entry.checked) @@ -208,7 +208,7 @@ impl LegendWidget { } // Get the name of the hovered items. - pub fn get_hovered_entry_name(&self) -> Option { + pub fn hovered_entry_name(&self) -> Option { self.entries .iter() .find(|(_, entry)| entry.hovered) diff --git a/egui/src/widgets/plot/mod.rs b/egui/src/widgets/plot/mod.rs index 7695a05d..6603451d 100644 --- a/egui/src/widgets/plot/mod.rs +++ b/egui/src/widgets/plot/mod.rs @@ -430,7 +430,7 @@ impl Plot { /// /// The function has this signature: /// ```ignore - /// fn get_step_sizes(input: GridInput) -> Vec; + /// fn step_sizes(input: GridInput) -> Vec; /// ``` /// /// This function should return all marks along the visible range of the X axis. @@ -697,7 +697,7 @@ impl Plot { } for item in &items { - let item_bounds = item.get_bounds(); + let item_bounds = item.bounds(); if auto_bounds.x { bounds.merge_x(&item_bounds); @@ -829,8 +829,8 @@ impl Plot { if let Some(mut legend) = legend { ui.add(&mut legend); - hidden_items = legend.get_hidden_items(); - hovered_entry = legend.get_hovered_entry_name(); + hidden_items = legend.hidden_items(); + hovered_entry = legend.hovered_entry_name(); } if let Some(group) = linked_axes.as_ref() { @@ -1073,7 +1073,7 @@ pub struct GridMark { /// 10 is a typical value, others are possible though. pub fn log_grid_spacer(log_base: i64) -> GridSpacer { let log_base = log_base as f64; - let get_step_sizes = move |input: GridInput| -> Vec { + let step_sizes = move |input: GridInput| -> Vec { // The distance between two of the thinnest grid lines is "rounded" up // to the next-bigger power of base let smallest_visible_unit = next_power(input.base_step_size, log_base); @@ -1087,7 +1087,7 @@ pub fn log_grid_spacer(log_base: i64) -> GridSpacer { generate_marks(step_sizes, input.bounds) }; - Box::new(get_step_sizes) + Box::new(step_sizes) } /// Splits the grid into uniform-sized spacings (e.g. 100, 25, 1). @@ -1136,7 +1136,7 @@ impl PreparedPlot { let mut plot_ui = ui.child_ui(*transform.frame(), Layout::default()); plot_ui.set_clip_rect(*transform.frame()); for item in &self.items { - item.get_shapes(&mut plot_ui, transform, &mut shapes); + item.shapes(&mut plot_ui, transform, &mut shapes); } if let Some(pointer) = response.hover_pos() { diff --git a/egui_demo_lib/src/demo/plot_demo.rs b/egui_demo_lib/src/demo/plot_demo.rs index 709e2fdd..8d6b3667 100644 --- a/egui_demo_lib/src/demo/plot_demo.rs +++ b/egui_demo_lib/src/demo/plot_demo.rs @@ -389,19 +389,19 @@ impl CustomAxisDemo { const MINS_PER_DAY: f64 = CustomAxisDemo::MINS_PER_DAY; const MINS_PER_H: f64 = CustomAxisDemo::MINS_PER_H; - fn get_day(x: f64) -> f64 { + fn day(x: f64) -> f64 { (x / MINS_PER_DAY).floor() } - fn get_hour(x: f64) -> f64 { + fn hour(x: f64) -> f64 { (x.rem_euclid(MINS_PER_DAY) / MINS_PER_H).floor() } - fn get_minute(x: f64) -> f64 { + fn minute(x: f64) -> f64 { x.rem_euclid(MINS_PER_H).floor() } - fn get_percent(y: f64) -> f64 { + fn percent(y: f64) -> f64 { 100.0 * y } @@ -411,17 +411,17 @@ impl CustomAxisDemo { String::new() } else if is_approx_integer(x / MINS_PER_DAY) { // Days - format!("Day {}", get_day(x)) + format!("Day {}", day(x)) } else { // Hours and minutes - format!("{h}:{m:02}", h = get_hour(x), m = get_minute(x)) + format!("{h}:{m:02}", h = hour(x), m = minute(x)) } }; let y_fmt = |y, _range: &RangeInclusive| { // Display only integer percentages if !is_approx_zero(y) && is_approx_integer(100.0 * y) { - format!("{:.0}%", get_percent(y)) + format!("{:.0}%", percent(y)) } else { String::new() } @@ -430,10 +430,10 @@ impl CustomAxisDemo { let label_fmt = |_s: &str, val: &PlotPoint| { format!( "Day {d}, {h}:{m:02}\n{p:.2}%", - d = get_day(val.x), - h = get_hour(val.x), - m = get_minute(val.x), - p = get_percent(val.y) + d = day(val.x), + h = hour(val.x), + m = minute(val.x), + p = percent(val.y) ) }; diff --git a/egui_glium/src/painter.rs b/egui_glium/src/painter.rs index 0730ce08..d0bd8132 100644 --- a/egui_glium/src/painter.rs +++ b/egui_glium/src/painter.rs @@ -145,7 +145,7 @@ impl Painter { let width_in_points = width_in_pixels as f32 / pixels_per_point; let height_in_points = height_in_pixels as f32 / pixels_per_point; - if let Some(texture) = self.get_texture(mesh.texture_id) { + if let Some(texture) = self.texture(mesh.texture_id) { // The texture coordinates for text are so that both nearest and linear should work with the egui font texture. // For user textures linear sampling is more likely to be the right choice. let filter = MagnifySamplerFilter::Linear; @@ -274,7 +274,7 @@ impl Painter { self.textures.remove(&tex_id); } - fn get_texture(&self, texture_id: egui::TextureId) -> Option<&SrgbTexture2d> { + fn texture(&self, texture_id: egui::TextureId) -> Option<&SrgbTexture2d> { self.textures.get(&texture_id).map(|rc| rc.as_ref()) } diff --git a/egui_glow/src/painter.rs b/egui_glow/src/painter.rs index 0645b9a5..524b02f7 100644 --- a/egui_glow/src/painter.rs +++ b/egui_glow/src/painter.rs @@ -452,7 +452,7 @@ impl Painter { #[inline(never)] // Easier profiling fn paint_mesh(&mut self, mesh: &Mesh) { debug_assert!(mesh.is_valid()); - if let Some(texture) = self.get_texture(mesh.texture_id) { + if let Some(texture) = self.texture(mesh.texture_id) { unsafe { self.gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vbo)); self.gl.buffer_data_u8_slice( @@ -634,10 +634,15 @@ impl Painter { } /// Get the [`glow::Texture`] bound to a [`egui::TextureId`]. - pub fn get_texture(&self, texture_id: egui::TextureId) -> Option { + pub fn texture(&self, texture_id: egui::TextureId) -> Option { self.textures.get(&texture_id).copied() } + #[deprecated = "renamed 'texture'"] + pub fn get_texture(&self, texture_id: egui::TextureId) -> Option { + self.texture(texture_id) + } + #[allow(clippy::needless_pass_by_value)] // False positive pub fn register_native_texture(&mut self, native: glow::Texture) -> egui::TextureId { self.assert_not_destroyed();