From 21d6b488642fd20ad5642e4d0f398d3b8018e2f1 Mon Sep 17 00:00:00 2001 From: sor-ca Date: Mon, 20 May 2024 19:46:22 +0300 Subject: [PATCH 1/5] pubs --- crates/egui/src/menu.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 84fd1b2e8e3..0fed25482a8 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -25,16 +25,16 @@ use std::sync::Arc; /// What is saved between frames. #[derive(Clone, Default)] -pub(crate) struct BarState { +pub struct BarState { open_menu: MenuRootManager, } impl BarState { - fn load(ctx: &Context, bar_id: Id) -> Self { + pub fn load(ctx: &Context, bar_id: Id) -> Self { ctx.data_mut(|d| d.get_temp::(bar_id).unwrap_or_default()) } - fn store(self, ctx: &Context, bar_id: Id) { + pub fn store(self, ctx: &Context, bar_id: Id) { ctx.data_mut(|d| d.insert_temp(bar_id, self)); } @@ -242,7 +242,7 @@ pub(crate) fn context_menu_opened(response: &Response) -> bool { /// Stores the state for the context menu. #[derive(Clone, Default)] -pub(crate) struct MenuRootManager { +pub struct MenuRootManager { inner: Option, } @@ -287,7 +287,7 @@ impl std::ops::DerefMut for MenuRootManager { /// Menu root associated with an Id from a Response #[derive(Clone)] -pub(crate) struct MenuRoot { +pub struct MenuRoot { pub menu_state: Arc>, pub id: Id, } @@ -373,7 +373,7 @@ impl MenuRoot { } /// Interaction with a context menu (secondary click). - fn context_interaction(response: &Response, root: &mut Option) -> MenuResponse { + pub fn context_interaction(response: &Response, root: &mut Option) -> MenuResponse { let response = response.interact(Sense::click()); let hovered = response.hovered(); let secondary_clicked = response.secondary_clicked(); @@ -399,7 +399,7 @@ impl MenuRoot { }) } - fn handle_menu_response(root: &mut MenuRootManager, menu_response: MenuResponse) { + pub fn handle_menu_response(root: &mut MenuRootManager, menu_response: MenuResponse) { match menu_response { MenuResponse::Create(pos, id) => { root.inner = Some(Self::new(pos, id)); @@ -423,7 +423,7 @@ impl MenuRoot { } #[derive(Copy, Clone, PartialEq)] -pub(crate) enum MenuResponse { +pub enum MenuResponse { Close, Stay, Create(Pos2, Id), From 73d8a2d52ae89cc57159cc9244175d0aa60e3161 Mon Sep 17 00:00:00 2001 From: sor-ca Date: Sat, 25 May 2024 23:01:45 +0300 Subject: [PATCH 2/5] pub --- crates/egui/src/menu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 0fed25482a8..b8ce90e0e7e 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -553,7 +553,7 @@ impl SubMenu { } } -pub(crate) struct MenuState { +pub struct MenuState { /// The opened sub-menu and its [`Id`] sub_menu: Option<(Id, Arc>)>, From 1195457da25ce50b0c15ec40dfbda3963d83d623 Mon Sep 17 00:00:00 2001 From: sor-ca Date: Mon, 27 May 2024 21:24:01 +0300 Subject: [PATCH 3/5] Docstring for MenuState --- crates/egui/src/menu.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index b8ce90e0e7e..d7f055416a5 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -553,6 +553,7 @@ impl SubMenu { } } +///Components of menu state, public for advanced usage. Usually you don't need to use it directly pub struct MenuState { /// The opened sub-menu and its [`Id`] sub_menu: Option<(Id, Arc>)>, From b531db5f26666930e5b98ecd0e6d874bbe00d0f4 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 27 May 2024 21:01:41 +0200 Subject: [PATCH 4/5] format comment --- crates/egui/src/menu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index d7f055416a5..313e0e5d312 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -553,7 +553,9 @@ impl SubMenu { } } -///Components of menu state, public for advanced usage. Usually you don't need to use it directly +/// Components of menu state, public for advanced usage. +/// +/// Usually you don't need to use it directly. pub struct MenuState { /// The opened sub-menu and its [`Id`] sub_menu: Option<(Id, Arc>)>, From 8c695c297b2cf1e47b1f9c4fafc8970b8da8e7d9 Mon Sep 17 00:00:00 2001 From: sor-ca Date: Thu, 30 May 2024 21:33:31 +0300 Subject: [PATCH 5/5] add derive Eq for MenuResponse to pass Format + check + test --- crates/egui/src/menu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index d7f055416a5..b74b8556795 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -422,7 +422,7 @@ impl MenuRoot { } } -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq)] pub enum MenuResponse { Close, Stay,