pub struct ContextMenuOverlay {
pub entries: Vec<ContextMenuEntry>,
pub selected: usize,
pub x: i32,
pub y: i32,
}Expand description
Snapshot passed to [ContextMenuOverlay::paint_at] each frame.
Fields§
§entries: Vec<ContextMenuEntry>Ordered list of entries to render.
selected: usizeIndex into entries of the currently-selected row.
The caller is responsible for clamping to selectable rows.
x: i32Requested pixel origin (top-left of the menu panel) in
chrome-buffer coordinates. The widget clamps this so the menu
stays inside (buf_w, buf_h).
y: i32Implementations§
Source§impl ContextMenuOverlay
impl ContextMenuOverlay
Sourcepub fn preferred_width(&self) -> u32
pub fn preferred_width(&self) -> u32
Compute the pixel width required to display all entry labels.
Sourcepub fn preferred_height(&self) -> u32
pub fn preferred_height(&self) -> u32
Compute the pixel height of the entire panel.
Sourcepub fn paint(&self, buf: &mut [u32], buf_w: usize, buf_h: usize)
pub fn paint(&self, buf: &mut [u32], buf_w: usize, buf_h: usize)
Paint the overlay into buf.
buf_w and buf_h are the full chrome buffer dimensions.
The panel is clamped to stay fully inside the buffer.
Sourcepub fn panel_rect(&self, buf_w: usize, buf_h: usize) -> (i32, i32, i32, i32)
pub fn panel_rect(&self, buf_w: usize, buf_h: usize) -> (i32, i32, i32, i32)
Compute the clamped panel rect (x, y, w, h) for a buffer of size
(buf_w, buf_h). Mirrors the clamp logic in Self::paint so
callers can hit-test the same pixels that render.
Sourcepub fn contains(&self, buf_w: usize, buf_h: usize, x: i32, y: i32) -> bool
pub fn contains(&self, buf_w: usize, buf_h: usize, x: i32, y: i32) -> bool
True if pixel (x, y) (in chrome-buffer coords) falls inside the
clamped panel rect.
Sourcepub fn row_at(
&self,
buf_w: usize,
buf_h: usize,
x: i32,
y: i32,
) -> Option<usize>
pub fn row_at( &self, buf_w: usize, buf_h: usize, x: i32, y: i32, ) -> Option<usize>
Resolve pixel (x, y) to a row index, or None if the hit lands
on a separator, on the border, or outside the panel.
Disabled rows are returned by index, not filtered out — callers
still want to highlight them on hover for visual continuity. Gate
activation on the entry’s enabled flag at the call site.
Trait Implementations§
Source§impl Clone for ContextMenuOverlay
impl Clone for ContextMenuOverlay
Source§fn clone(&self) -> ContextMenuOverlay
fn clone(&self) -> ContextMenuOverlay
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContextMenuOverlay
impl RefUnwindSafe for ContextMenuOverlay
impl Send for ContextMenuOverlay
impl Sync for ContextMenuOverlay
impl Unpin for ContextMenuOverlay
impl UnsafeUnpin for ContextMenuOverlay
impl UnwindSafe for ContextMenuOverlay
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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