Skip to content

Commit

Permalink
fmt and clippy
Browse files Browse the repository at this point in the history
Fix collapse action
  • Loading branch information
Norlock committed Jul 16, 2024
1 parent 5116a19 commit 1bab9e6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/ecolor/src/rgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> for Rgba {
type Output = f32;
Expand Down
12 changes: 3 additions & 9 deletions crates/egui/src/containers/collapsing_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ impl CollapsingState {
match action {
WindowAction::Show => self.state.shown = true,
WindowAction::Hide => self.state.shown = false,
WindowAction::Expand => {
self.state.shown = true;
self.state.expanded = true;
}
WindowAction::Collapse => {
self.state.shown = true;
self.state.expanded = true;
}
WindowAction::Expand => self.state.expanded = true,
WindowAction::Collapse => self.state.expanded = false,
WindowAction::ToggleShow => {
self.state.shown = !self.state.shown;
}
Expand Down Expand Up @@ -309,7 +303,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()
}
Expand Down
6 changes: 2 additions & 4 deletions crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WindowAction>) -> Self {
self.window_action = action.take();
Expand Down Expand Up @@ -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;

Expand Down
10 changes: 7 additions & 3 deletions crates/egui_demo_lib/src/demo/about.rs
Original file line number Diff line number Diff line change
@@ -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))]
Expand All @@ -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<WindowAction>) {
pub fn show_action(
&mut self,
ctx: &egui::Context,
open: &mut bool,
action: &mut Option<WindowAction>,
) {
egui::Window::new(self.name())
.default_width(320.0)
.default_height(480.0)
Expand All @@ -38,7 +43,6 @@ impl About {
self.ui(ui);
});
}

}

impl crate::View for About {
Expand Down
3 changes: 2 additions & 1 deletion crates/egui_demo_lib/src/demo/demo_app_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1bab9e6

Please sign in to comment.