pub struct QuickSwitchMenu {
tray_virtual_desktops_quick: Vec<(MenuItem, u32)>,
tray_separators: Vec<MenuSeparator>,
tray_submenus: Vec<(Menu, u32)>,
pub shortcuts: BTreeMap<String, u32>,
pub shortcuts_only_in_root: bool,
call_queue: Vec<(ControlHandle, u32, u32, u32)>,
is_recursive_call: bool,
}
Fields§
§tray_virtual_desktops_quick: Vec<(MenuItem, u32)>
Menu items that map to specific virtual desktops.
tray_separators: Vec<MenuSeparator>
[nwg::Menu
] won’t be automatically removed from their parent when
dropped so make sure to use [crate::nwg_ext::remove_menu
] to manually
remove them.
shortcuts: BTreeMap<String, u32>
Support shortcut access keys to specific virtual desktop indexes. This keys should not be numbers since those access keys are already in use by the quick switch menu.
shortcuts_only_in_root: bool
Only show the shortcut menu items in the root of the quick switch menu.
call_queue: Vec<(ControlHandle, u32, u32, u32)>
Used to limit recursion in order to prevent stack overflow, should be
empty when not inside a Self::create_quick_switch_menu
call.
We could have used a VecDeque
here to more faithfully remember the
call order but its actually more performant to not do that since the
normal call order is breadth first which means we would store more items
in this queue.
is_recursive_call: bool
true
if we are in a recursive call of
Self::create_quick_switch_menu
.
Implementations§
Source§impl QuickSwitchMenu
impl QuickSwitchMenu
Sourcepub fn get_clicked_desktop_index(&self, handle: ControlHandle) -> Option<usize>
pub fn get_clicked_desktop_index(&self, handle: ControlHandle) -> Option<usize>
Get the virtual desktop index that should be selected when a specific context menu item is pressed.
Sourcepub fn get_desktop_index_so_far(&self, submenu_handle: isize) -> Option<usize>
pub fn get_desktop_index_so_far(&self, submenu_handle: isize) -> Option<usize>
Get the number that would be generated by the keyboard shortcuts needed to open the specified submenu.
Find first item/menu inside a submenu.
pub fn clear(&mut self)
Sourcefn create_shortcut_items(&mut self, parent: ControlHandle)
fn create_shortcut_items(&mut self, parent: ControlHandle)
Extra menu items that don’t use numbers as access keys. These allow the user to give specific keys as shortcuts for frequently visited virtual desktops.
Sourcefn try_create_leaf_items(
&mut self,
parent: ControlHandle,
range: Range<u32>,
) -> bool
fn try_create_leaf_items( &mut self, parent: ControlHandle, range: Range<u32>, ) -> bool
If there are 10 items or less in a submenu then each one could get a unique access key. This function will only create context menu items if that is the case.
If there are too many items to assign each a unique access key then we create up to 10 submenus that divide the range into smaller parts.
Returns part of the range for the first created submenu, but changes its start value so that it doesn’t overlap with the submenus’ access keys.
Create a menu that is easily navigable with keyboard access keys.
Here is an example of what it can look like:
quick -> &00 - 09 ------------> 0&1
&10 - 19 --> 1&0 0&2
&20 - 29 1&1 0&3
&30 - 39 1&2 0&4
&40 - 49 1&3 0&5
&50 - 59 1&4 0&6
---------- 1%5 0&7
&6 1&6 0&8
&7 1&7 0&9
&8 1&8
&9 1&9
Trait Implementations§
Source§impl Default for QuickSwitchMenu
impl Default for QuickSwitchMenu
Source§fn default() -> QuickSwitchMenu
fn default() -> QuickSwitchMenu
Auto Trait Implementations§
impl Freeze for QuickSwitchMenu
impl RefUnwindSafe for QuickSwitchMenu
impl !Send for QuickSwitchMenu
impl !Sync for QuickSwitchMenu
impl Unpin for QuickSwitchMenu
impl UnwindSafe for QuickSwitchMenu
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Source§impl<T> DynWithDefault for T
impl<T> DynWithDefault for T
Source§fn with_default_mut(
&mut self,
f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)),
)
fn with_default_mut( &mut self, f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)), )
self
and the second argument
is the new temporary default value. The callback can then modify the
value as needed.Source§fn clear_and_inspect_old(
&mut self,
f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)),
)
fn clear_and_inspect_old( &mut self, f: &mut dyn FnMut(&mut dyn DynWithDefault, &mut (dyn Any + 'static)), )
self
to a new default value and inspect the previous value as the
second argument to the callback.fn clear(&mut self)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.