Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make egu::menu types public #4544

Merged
merged 6 commits into from
May 31, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Self>(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));
}

Expand Down Expand Up @@ -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<MenuRoot>,
}

Expand Down Expand Up @@ -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<RwLock<MenuState>>,
pub id: Id,
}
Expand Down Expand Up @@ -373,7 +373,7 @@ impl MenuRoot {
}

/// Interaction with a context menu (secondary click).
fn context_interaction(response: &Response, root: &mut Option<Self>) -> MenuResponse {
pub fn context_interaction(response: &Response, root: &mut Option<Self>) -> MenuResponse {
let response = response.interact(Sense::click());
let hovered = response.hovered();
let secondary_clicked = response.secondary_clicked();
Expand All @@ -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));
Expand All @@ -423,7 +423,7 @@ impl MenuRoot {
}

#[derive(Copy, Clone, PartialEq)]
pub(crate) enum MenuResponse {
pub enum MenuResponse {
Close,
Stay,
Create(Pos2, Id),
Expand Down Expand Up @@ -553,7 +553,7 @@ impl SubMenu {
}
}

pub(crate) struct MenuState {
pub struct MenuState {
emilk marked this conversation as resolved.
Show resolved Hide resolved
/// The opened sub-menu and its [`Id`]
sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>,

Expand Down
Loading