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

Context menu #543

Merged
merged 46 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
01aea23
Only drag with primary pointer button
mankinskin Jul 6, 2021
04e52be
Add ContextMenuSystem for context menu
mankinskin Jul 3, 2021
432ac9c
Syntax simplification in demo context menu builder
mankinskin Jul 3, 2021
185d86e
Store ContextMenuSystem in Context and respect Ui clicked
mankinskin Jul 6, 2021
69a33d8
Add context menu for widget_gallery plot
mankinskin Jul 6, 2021
28ef15d
Fix menu being reset when clicking on it
mankinskin Jul 6, 2021
1817b62
Adapt to removal of From conversions Vec2 <-> Pos2
mankinskin Jul 6, 2021
7011c37
Apply context menu to Response
mankinskin Jul 7, 2021
3519508
Rename context_menu functions
mankinskin Jul 7, 2021
aa91812
Refactor
mankinskin Jul 7, 2021
1da8097
Fix warnings
mankinskin Jul 7, 2021
171a818
Use response.clicked to detect clicks
mankinskin Jul 8, 2021
a3f0c5e
Make MenuState::get_submenu private
mankinskin Jul 8, 2021
3f49d85
Improve submenu navigation by allowing crossing other items
mankinskin Jul 8, 2021
2410c76
Refactor and comment
mankinskin Jul 8, 2021
968233d
Prevent breaking of drag on attached elements
mankinskin Jul 8, 2021
c40c120
Close submenu when pointer outside is not moving towards it
mankinskin Jul 8, 2021
ea27d7c
Draw context menu using same Ui as egui::menu
mankinskin Jul 8, 2021
0698b2b
Improve submenu style
mankinskin Jul 8, 2021
3e0e7aa
Fix submenu button flicker
mankinskin Jul 8, 2021
f25e02f
Better encapsulation of MenuState
mankinskin Jul 8, 2021
5e96b56
Remove Clone implementations
mankinskin Jul 8, 2021
8c46041
Some styling improvements
mankinskin Jul 8, 2021
31e9fd4
Fix submenu text alignment
mankinskin Jul 9, 2021
2a1ac41
Refactor, run cargo fmt
mankinskin Jul 9, 2021
ccbd1d2
Add function for adding items to submenus
mankinskin Jul 23, 2021
dee2611
Keep track of submenu index in parent context menu
mankinskin Jul 23, 2021
1697958
Refactoring
mankinskin Jul 23, 2021
ae95f5f
Add button padding to context menu
mankinskin Jul 23, 2021
97c957a
Don't return any Response from SubMenu::show
mankinskin Jul 23, 2021
85d63b1
Define useful Response for SubMenu::show
mankinskin Jul 24, 2021
1238467
Open ContextMenu on pointer button press, not click
mankinskin Jul 25, 2021
3ed068a
Refactoring: Apply PR Review
mankinskin Aug 27, 2021
557184f
cargo clippy
mankinskin Aug 27, 2021
5a31048
Add MenuUi and demo window
mankinskin Aug 27, 2021
2f573a6
Remove MenuUi and manage MenuState in Ui
mankinskin Aug 29, 2021
b8fe011
Use vscroll() instead of scroll()
mankinskin Aug 29, 2021
aef287b
submenus for normal egui:::menus
mankinskin Aug 29, 2021
88d3900
Fix stationary menus not closing when clicking elsewhere
mankinskin Aug 29, 2021
9f3af74
Rebase on emilk/egui@master
mankinskin Sep 29, 2021
700b166
Fix stationary menu rect not being set
mankinskin Sep 29, 2021
37ac070
Apply review
mankinskin Sep 29, 2021
ffbf96f
Fix stationary menus not reacting to close_menu()
mankinskin Sep 29, 2021
a74dff7
cargo fmt & clippy
mankinskin Sep 29, 2021
b54233c
Delete context_menu module
mankinskin Sep 29, 2021
3db6bdf
Run cargo clippy and cargo fmt
mankinskin Oct 25, 2021
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
16 changes: 16 additions & 0 deletions egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
frame_state::FrameState,
input_state::*,
layers::GraphicLayers,
menu::ContextMenuSystem,
mutex::{Mutex, MutexGuard},
*,
};
Expand Down Expand Up @@ -303,6 +304,15 @@ impl CtxRef {
pub fn debug_painter(&self) -> Painter {
Self::layer_painter(self, LayerId::debug())
}

pub(crate) fn show_context_menu(
&self,
response: &Response,
add_contents: impl FnOnce(&mut Ui),
) {
self.context_menu_system()
.context_menu(response, add_contents);
}
}

// ----------------------------------------------------------------------------
Expand All @@ -329,6 +339,7 @@ pub struct Context {
fonts: Option<Arc<Fonts>>,
memory: Arc<Mutex<Memory>>,
animation_manager: Arc<Mutex<AnimationManager>>,
context_menu_system: Arc<Mutex<ContextMenuSystem>>,

input: InputState,

Expand Down Expand Up @@ -357,6 +368,7 @@ impl Clone for Context {
output: self.output.clone(),
paint_stats: self.paint_stats.clone(),
repaint_requests: self.repaint_requests.load(SeqCst).into(),
context_menu_system: self.context_menu_system.clone(),
}
}
}
Expand All @@ -375,6 +387,10 @@ impl Context {
self.memory.lock()
}

pub(crate) fn context_menu_system(&self) -> MutexGuard<'_, ContextMenuSystem> {
self.context_menu_system.lock()
}

pub(crate) fn graphics(&self) -> MutexGuard<'_, GraphicLayers> {
self.graphics.lock()
}
Expand Down
Loading