From 341faf4dcd7113180fc124d95df789c1ad555c20 Mon Sep 17 00:00:00 2001 From: norlock Date: Wed, 17 Jul 2024 00:59:09 +0200 Subject: [PATCH] fmt and clippy Fix collapse action --- crates/ecolor/src/rgba.rs | 2 +- crates/egui/src/containers/collapsing_header.rs | 4 ++-- crates/egui/src/containers/window.rs | 6 ++---- crates/egui_demo_lib/src/demo/about.rs | 10 +++++++--- crates/egui_demo_lib/src/demo/demo_app_windows.rs | 3 ++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/ecolor/src/rgba.rs b/crates/ecolor/src/rgba.rs index cbc6d20373f4..900286cda434 100644 --- a/crates/ecolor/src/rgba.rs +++ b/crates/ecolor/src/rgba.rs @@ -8,7 +8,7 @@ use crate::{ #[derive(Clone, Copy, Debug, Default, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] -pub struct Rgba(pub [f32; 4]); +pub struct Rgba(pub(crate) [f32; 4]); impl std::ops::Index for Rgba { type Output = f32; diff --git a/crates/egui/src/containers/collapsing_header.rs b/crates/egui/src/containers/collapsing_header.rs index 48e4dfbb9931..e49c4cc25fd9 100644 --- a/crates/egui/src/containers/collapsing_header.rs +++ b/crates/egui/src/containers/collapsing_header.rs @@ -72,7 +72,7 @@ impl CollapsingState { } WindowAction::Collapse => { self.state.shown = true; - self.state.expanded = true; + self.state.expanded = false; } WindowAction::ToggleShow => { self.state.shown = !self.state.shown; @@ -309,7 +309,7 @@ pub struct HeaderResponse<'ui, HeaderRet> { } impl<'ui, HeaderRet> HeaderResponse<'ui, HeaderRet> { - #[deprecated = "Use het `HeaderResponse::is_expanded`"] + #[deprecated = "Use the `HeaderResponse::is_expanded` instead"] pub fn is_open(&self) -> bool { self.is_expanded() } diff --git a/crates/egui/src/containers/window.rs b/crates/egui/src/containers/window.rs index 2ded86a70823..30b0f0aa0998 100644 --- a/crates/egui/src/containers/window.rs +++ b/crates/egui/src/containers/window.rs @@ -91,8 +91,8 @@ impl<'open> Window<'open> { self } - /// Call this to programmatically expand, collapse, show, hide the window. - /// The Option value will be taken, so the option will be set to None. + /// Call this to programmatically expand/collapse or to show/hide the window. + /// The passed Option value will be taken, so the option will be set to None. #[inline] pub fn window_action(mut self, action: &mut Option) -> Self { self.window_action = action.take(); @@ -477,8 +477,6 @@ impl<'open> Window<'open> { // Add border padding to the inner margin to prevent it from covering the contents window_frame.inner_margin += border_padding; - //let is_explicitly_closed = matches!(open, Some(false)); - //let is_open = !is_explicitly_closed || ctx.memory(|mem| mem.everything_is_visible()); let all_visible = ctx.memory(|mem| mem.everything_is_visible()); let area_id = area.id; diff --git a/crates/egui_demo_lib/src/demo/about.rs b/crates/egui_demo_lib/src/demo/about.rs index 0795a226277a..f21b2e7ff20b 100644 --- a/crates/egui_demo_lib/src/demo/about.rs +++ b/crates/egui_demo_lib/src/demo/about.rs @@ -1,5 +1,5 @@ -use egui::WindowAction; use crate::demo::Demo; +use egui::WindowAction; #[derive(Default)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] @@ -25,7 +25,12 @@ impl crate::Demo for About { } impl About { - pub fn show_action(&mut self, ctx: &egui::Context, open: &mut bool, action: &mut Option) { + pub fn show_action( + &mut self, + ctx: &egui::Context, + open: &mut bool, + action: &mut Option, + ) { egui::Window::new(self.name()) .default_width(320.0) .default_height(480.0) @@ -38,7 +43,6 @@ impl About { self.ui(ui); }); } - } impl crate::View for About { diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index c3dac45822d1..61eae8e6649a 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -296,7 +296,8 @@ impl DemoWindows { /// Show the open windows. fn show_windows(&mut self, ctx: &Context) { - self.about.show_action(ctx, &mut self.about_is_open, &mut self.about_window_action); + self.about + .show_action(ctx, &mut self.about_is_open, &mut self.about_window_action); self.demos.windows(ctx); self.tests.windows(ctx); }