Skip to main content

ContextMenuOverlay

Struct ContextMenuOverlay 

Source
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: usize

Index into entries of the currently-selected row. The caller is responsible for clamping to selectable rows.

§x: i32

Requested 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: i32

Implementations§

Source§

impl ContextMenuOverlay

Source

pub fn preferred_width(&self) -> u32

Compute the pixel width required to display all entry labels.

Source

pub fn preferred_height(&self) -> u32

Compute the pixel height of the entire panel.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ContextMenuOverlay

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContextMenuOverlay

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.