From 43b180847aeaded9ec5ed1a8ff2dae8f65f5a7ab Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 12 Sep 2024 11:35:57 +0200 Subject: [PATCH] Rename `begin/end_frame` -> `begin/end_pass` --- crates/egui/src/context.rs | 6 +++--- crates/egui/src/drag_and_drop.rs | 4 ++-- crates/egui/src/input_state/mod.rs | 6 +++--- crates/egui/src/input_state/touch_state.rs | 2 +- crates/egui/src/load.rs | 10 +++++----- crates/egui/src/load/texture_loader.rs | 2 +- crates/egui/src/memory/mod.rs | 18 +++++++++--------- .../src/text_selection/label_text_selection.rs | 11 ++++------- 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index d69b64bf330..818278aafa3 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2047,7 +2047,7 @@ impl Context { #[cfg(debug_assertions)] self.debug_painting(); - self.write(|ctx| ctx.end_frame()) + self.write(|ctx| ctx.end_pass()) } /// Called at the end of the pass. @@ -2185,14 +2185,14 @@ impl Context { } impl ContextImpl { - fn end_frame(&mut self) -> FullOutput { + fn end_pass(&mut self) -> FullOutput { let ended_viewport_id = self.viewport_id(); let viewport = self.viewports.entry(ended_viewport_id).or_default(); let pixels_per_point = viewport.input.pixels_per_point; viewport.repaint.pass_nr += 1; - self.memory.end_frame(&viewport.this_pass.used_ids); + self.memory.end_pass(&viewport.this_pass.used_ids); if let Some(fonts) = self.fonts.get(&pixels_per_point.into()) { let tex_mngr = &mut self.tex_manager.0.write(); diff --git a/crates/egui/src/drag_and_drop.rs b/crates/egui/src/drag_and_drop.rs index ee7c4524565..13da9d314c1 100644 --- a/crates/egui/src/drag_and_drop.rs +++ b/crates/egui/src/drag_and_drop.rs @@ -23,10 +23,10 @@ pub struct DragAndDrop { impl DragAndDrop { pub(crate) fn register(ctx: &Context) { - ctx.on_end_pass("debug_text", std::sync::Arc::new(Self::end_frame)); + ctx.on_end_pass("debug_text", std::sync::Arc::new(Self::end_pass)); } - fn end_frame(ctx: &Context) { + fn end_pass(ctx: &Context) { let abort_dnd = ctx.input(|i| i.pointer.any_released() || i.key_pressed(crate::Key::Escape)); diff --git a/crates/egui/src/input_state/mod.rs b/crates/egui/src/input_state/mod.rs index 1766de6ec2e..7f743ee709a 100644 --- a/crates/egui/src/input_state/mod.rs +++ b/crates/egui/src/input_state/mod.rs @@ -285,9 +285,9 @@ impl InputState { let screen_rect = new.screen_rect.unwrap_or(self.screen_rect); self.create_touch_states_for_new_devices(&new.events); for touch_state in self.touch_states.values_mut() { - touch_state.begin_frame(time, &new, self.pointer.interact_pos); + touch_state.begin_pass(time, &new, self.pointer.interact_pos); } - let pointer = self.pointer.begin_frame(time, &new, options); + let pointer = self.pointer.begin_pass(time, &new, options); let mut keys_down = self.keys_down; let mut zoom_factor_delta = 1.0; // TODO(emilk): smoothing for zoom factor @@ -900,7 +900,7 @@ impl Default for PointerState { impl PointerState { #[must_use] - pub(crate) fn begin_frame( + pub(crate) fn begin_pass( mut self, time: f64, new: &RawInput, diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index e9425dba24c..df39d961925 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -134,7 +134,7 @@ impl TouchState { } } - pub fn begin_frame(&mut self, time: f64, new: &RawInput, pointer_pos: Option) { + pub fn begin_pass(&mut self, time: f64, new: &RawInput, pointer_pos: Option) { let mut added_or_removed_touches = false; for event in &new.events { match *event { diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index ee12d8de845..b6711de3c52 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -302,7 +302,7 @@ pub trait BytesLoader { /// Implementations may use this to perform work at the end of a frame, /// such as evicting unused entries from a cache. - fn end_frame(&self, frame_index: usize) { + fn end_pass(&self, frame_index: usize) { let _ = frame_index; } @@ -367,9 +367,9 @@ pub trait ImageLoader { /// so that all of them may be fully reloaded. fn forget_all(&self); - /// Implementations may use this to perform work at the end of a frame, + /// Implementations may use this to perform work at the end of a pass, /// such as evicting unused entries from a cache. - fn end_frame(&self, frame_index: usize) { + fn end_pass(&self, frame_index: usize) { let _ = frame_index; } @@ -505,9 +505,9 @@ pub trait TextureLoader { /// so that all of them may be fully reloaded. fn forget_all(&self); - /// Implementations may use this to perform work at the end of a frame, + /// Implementations may use this to perform work at the end of a pass, /// such as evicting unused entries from a cache. - fn end_frame(&self, frame_index: usize) { + fn end_pass(&self, frame_index: usize) { let _ = frame_index; } diff --git a/crates/egui/src/load/texture_loader.rs b/crates/egui/src/load/texture_loader.rs index 88533e5d95d..6845e86ff82 100644 --- a/crates/egui/src/load/texture_loader.rs +++ b/crates/egui/src/load/texture_loader.rs @@ -62,7 +62,7 @@ impl TextureLoader for DefaultTextureLoader { self.cache.lock().clear(); } - fn end_frame(&self, _: usize) {} + fn end_pass(&self, _: usize) {} fn byte_size(&self) -> usize { self.cache diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index 86efc689a34..cf0d2b872d1 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -331,7 +331,7 @@ impl Default for Options { } impl Options { - pub(crate) fn begin_frame(&mut self, new_raw_input: &RawInput) { + pub(crate) fn begin_pass(&mut self, new_raw_input: &RawInput) { self.system_theme = new_raw_input.system_theme; } @@ -541,7 +541,7 @@ impl Focus { self.focused_widget.as_ref().map(|w| w.id) } - fn begin_frame(&mut self, new_input: &crate::data::input::RawInput) { + fn begin_pass(&mut self, new_input: &crate::data::input::RawInput) { self.id_previous_frame = self.focused(); if let Some(id) = self.id_next_frame.take() { self.focused_widget = Some(FocusWidget::new(id)); @@ -602,7 +602,7 @@ impl Focus { } } - pub(crate) fn end_frame(&mut self, used_ids: &IdMap) { + pub(crate) fn end_pass(&mut self, used_ids: &IdMap) { if self.focus_direction.is_cardinal() { if let Some(found_widget) = self.find_widget_in_direction(used_ids) { self.focused_widget = Some(FocusWidget::new(found_widget)); @@ -765,18 +765,18 @@ impl Memory { // self.interactions is handled elsewhere - self.options.begin_frame(new_raw_input); + self.options.begin_pass(new_raw_input); self.focus .entry(self.viewport_id) .or_default() - .begin_frame(new_raw_input); + .begin_pass(new_raw_input); } - pub(crate) fn end_frame(&mut self, used_ids: &IdMap) { + pub(crate) fn end_pass(&mut self, used_ids: &IdMap) { self.caches.update(); - self.areas_mut().end_frame(); - self.focus_mut().end_frame(used_ids); + self.areas_mut().end_pass(); + self.focus_mut().end_pass(used_ids); } pub(crate) fn set_viewport_id(&mut self, viewport_id: ViewportId) { @@ -1175,7 +1175,7 @@ impl Areas { .any(|(_, children)| children.contains(layer)) } - pub(crate) fn end_frame(&mut self) { + pub(crate) fn end_pass(&mut self) { let Self { visible_last_frame, visible_current_frame, diff --git a/crates/egui/src/text_selection/label_text_selection.rs b/crates/egui/src/text_selection/label_text_selection.rs index fae89bd5ac7..fe5eac00e78 100644 --- a/crates/egui/src/text_selection/label_text_selection.rs +++ b/crates/egui/src/text_selection/label_text_selection.rs @@ -118,11 +118,8 @@ impl Default for LabelSelectionState { impl LabelSelectionState { pub(crate) fn register(ctx: &Context) { - ctx.on_begin_pass( - "LabelSelectionState", - std::sync::Arc::new(Self::begin_frame), - ); - ctx.on_end_pass("LabelSelectionState", std::sync::Arc::new(Self::end_frame)); + ctx.on_begin_pass("LabelSelectionState", std::sync::Arc::new(Self::begin_pass)); + ctx.on_end_pass("LabelSelectionState", std::sync::Arc::new(Self::end_pass)); } pub fn load(ctx: &Context) -> Self { @@ -138,7 +135,7 @@ impl LabelSelectionState { }); } - fn begin_frame(ctx: &Context) { + fn begin_pass(ctx: &Context) { let mut state = Self::load(ctx); if ctx.input(|i| i.pointer.any_pressed() && !i.modifiers.shift) { @@ -159,7 +156,7 @@ impl LabelSelectionState { state.store(ctx); } - fn end_frame(ctx: &Context) { + fn end_pass(ctx: &Context) { let mut state = Self::load(ctx); if state.is_dragging {