diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index 18b754408..2e457763b 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -91,7 +91,7 @@ pub fn canvas_element(canvas_id: &str) -> Option { pub fn canvas_element_or_die(canvas_id: &str) -> web_sys::HtmlCanvasElement { canvas_element(canvas_id) - .unwrap_or_else(|| panic!("Failed to find canvas with id '{}'", canvas_id)) + .unwrap_or_else(|| panic!("Failed to find canvas with id {:?}", canvas_id)) } fn canvas_origin(canvas_id: &str) -> egui::Pos2 { diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 7da48cc22..769aa8cd1 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -42,7 +42,7 @@ impl Frame { } } - pub(crate) fn side_top_panel(style: &Style) -> Self { + pub fn side_top_panel(style: &Style) -> Self { Self { inner_margin: Margin::symmetric(8.0, 2.0), fill: style.visuals.window_fill(), @@ -50,7 +50,7 @@ impl Frame { } } - pub(crate) fn central_panel(style: &Style) -> Self { + pub fn central_panel(style: &Style) -> Self { Self { inner_margin: Margin::same(8.0), fill: style.visuals.window_fill(), diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index add3c0359..e6e7e220a 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -349,6 +349,8 @@ impl SidePanel { None } else if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: + // TODO(emilk): move the panel out-of-screen instead of changing its width. + // Then we can actually paint it as it animates. let expanded_width = PanelState::load(ctx, self.id) .map_or(self.default_width, |state| state.rect.width()); let fake_width = how_expanded * expanded_width; @@ -382,6 +384,8 @@ impl SidePanel { None } else if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: + // TODO(emilk): move the panel out-of-screen instead of changing its width. + // Then we can actually paint it as it animates. let expanded_width = PanelState::load(ui.ctx(), self.id) .map_or(self.default_width, |state| state.rect.width()); let fake_width = how_expanded * expanded_width; @@ -785,6 +789,8 @@ impl TopBottomPanel { None } else if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: + // TODO(emilk): move the panel out-of-screen instead of changing its height. + // Then we can actually paint it as it animates. let expanded_height = PanelState::load(ctx, self.id) .map(|state| state.rect.height()) .or(self.default_height) @@ -820,6 +826,8 @@ impl TopBottomPanel { None } else if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: + // TODO(emilk): move the panel out-of-screen instead of changing its height. + // Then we can actually paint it as it animates. let expanded_height = PanelState::load(ui.ctx(), self.id) .map(|state| state.rect.height()) .or(self.default_height) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index d4676957e..345b59723 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -253,12 +253,13 @@ impl ScrollArea { self } - /// Control the scrolling behavior - /// If `true` (default), the scroll area will respond to user scrolling - /// If `false`, the scroll area will not respond to user scrolling + /// Control the scrolling behavior. + /// + /// * If `true` (default), the scroll area will respond to user scrolling. + /// * If `false`, the scroll area will not respond to user scrolling. /// /// This can be used, for example, to optionally freeze scrolling while the user - /// is inputing text in a [`TextEdit`] widget contained within the scroll area. + /// is typing text in a [`TextEdit`] widget contained within the scroll area. /// /// This controls both scrolling directions. pub fn enable_scrolling(mut self, enable: bool) -> Self { @@ -268,8 +269,8 @@ impl ScrollArea { /// For each axis, should the containing area shrink if the content is small? /// - /// If true, egui will add blank space outside the scroll area. - /// If false, egui will add blank space inside the scroll area. + /// * If `true`, egui will add blank space outside the scroll area. + /// * If `false`, egui will add blank space inside the scroll area. /// /// Default: `[true; 2]`. pub fn auto_shrink(mut self, auto_shrink: [bool; 2]) -> Self { diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index a21275366..dc4a479b7 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1293,12 +1293,15 @@ impl Context { } /// Like [`Self::animate_bool`] but allows you to control the animation time. - pub fn animate_bool_with_time(&self, id: Id, value: bool, animation_time: f32) -> f32 { + pub fn animate_bool_with_time(&self, id: Id, target_value: bool, animation_time: f32) -> f32 { let animated_value = { let ctx_impl = &mut *self.write(); - ctx_impl - .animation_manager - .animate_bool(&ctx_impl.input, animation_time, id, value) + ctx_impl.animation_manager.animate_bool( + &ctx_impl.input, + animation_time, + id, + target_value, + ) }; let animation_in_progress = 0.0 < animated_value && animated_value < 1.0; if animation_in_progress { @@ -1310,14 +1313,17 @@ impl Context { /// Allows you to smoothly change the f32 value. /// At the first call the value is written to memory. /// When it is called with a new value, it linearly interpolates to it in the given time. - pub fn animate_value_with_time(&self, id: Id, value: f32, animation_time: f32) -> f32 { + pub fn animate_value_with_time(&self, id: Id, target_value: f32, animation_time: f32) -> f32 { let animated_value = { let ctx_impl = &mut *self.write(); - ctx_impl - .animation_manager - .animate_value(&ctx_impl.input, animation_time, id, value) + ctx_impl.animation_manager.animate_value( + &ctx_impl.input, + animation_time, + id, + target_value, + ) }; - let animation_in_progress = animated_value != value; + let animation_in_progress = animated_value != target_value; if animation_in_progress { self.request_repaint(); } diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 27f772f73..7147f976e 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -2007,7 +2007,7 @@ impl Ui { InnerResponse::new(inner, self.interact(rect, child_ui.id, Sense::hover())) } - #[deprecated = "Use ui.vertical_centered instead"] + #[deprecated = "Use ui.vertical_centered or ui.centered_and_justified"] pub fn centered(&mut self, add_contents: impl FnOnce(&mut Self) -> R) -> InnerResponse { self.vertical_centered(add_contents) } diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 1addbc725..4eb067583 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -34,11 +34,13 @@ impl Label { /// If `true`, the text will wrap to stay within the max width of the [`Ui`]. /// - /// By default [`Self::wrap`] will be true in vertical layouts + /// By default [`Self::wrap`] will be `true` in vertical layouts /// and horizontal layouts with wrapping, - /// and false on non-wrapping horizontal layouts. + /// and `false` on non-wrapping horizontal layouts. /// /// Note that any `\n` in the text will always produce a new line. + /// + /// You can also use [`crate::Style::wrap`]. #[inline] pub fn wrap(mut self, wrap: bool) -> Self { self.wrap = Some(wrap); diff --git a/crates/egui/src/widgets/separator.rs b/crates/egui/src/widgets/separator.rs index 8a9588fd2..7855611ac 100644 --- a/crates/egui/src/widgets/separator.rs +++ b/crates/egui/src/widgets/separator.rs @@ -72,10 +72,19 @@ impl Widget for Separator { if ui.is_rect_visible(response.rect) { let stroke = ui.visuals().widgets.noninteractive.bg_stroke; + let painter = ui.painter(); if is_horizontal_line { - ui.painter().hline(rect.x_range(), rect.center().y, stroke); + painter.hline( + rect.x_range(), + painter.round_to_pixel(rect.center().y), + stroke, + ); } else { - ui.painter().vline(rect.center().x, rect.y_range(), stroke); + painter.vline( + painter.round_to_pixel(rect.center().x), + rect.y_range(), + stroke, + ); } } diff --git a/crates/epaint/src/util/mod.rs b/crates/epaint/src/util/mod.rs index cb3bc66d9..2aa70ee04 100644 --- a/crates/epaint/src/util/mod.rs +++ b/crates/epaint/src/util/mod.rs @@ -5,8 +5,7 @@ pub use ordered_float::*; /// Hash the given value with a predictable hasher. #[inline] pub fn hash(value: impl std::hash::Hash) -> u64 { - use ahash::RandomState; - RandomState::with_seeds(1, 2, 3, 4).hash_one(value) + ahash::RandomState::with_seeds(1, 2, 3, 4).hash_one(value) } /// Hash the given value with the given hasher.