pub struct NumberlinkWidget<'a> { /* private fields */ }Expand description
An egui widget that renders an interactive Numberlink board.
Press and drag from either of a number’s two endpoints (both are always live, symmetrically — grabbing one always starts fresh from there, even if the path was originally drawn from the other end) to draw/redraw its path. Grabbing an interior cell of an already-drawn path instead truncates it to that point. Dragging back over the path’s own previous cell retracts it by one; dragging onto a different number’s path is rejected. A plain click (no drag) on an endpoint or path cell clears/ starts the path immediately, without needing to drag at all.
ui.add(egui_numberlink::NumberlinkWidget::new(&mut game));Implementations§
Source§impl<'a> NumberlinkWidget<'a>
impl<'a> NumberlinkWidget<'a>
pub fn new(game: &'a mut NumberlinkGame) -> Self
Sourcepub fn cell_size(self, size: f32) -> Self
pub fn cell_size(self, size: f32) -> Self
Override the size (in logical pixels) of each grid cell. When not set, the cell size is computed automatically to fill the available space of the parent container.
Sourcepub fn colors(self, colors: &'a [Color32]) -> Self
pub fn colors(self, colors: &'a [Color32]) -> Self
Per-number color, indexed by number (colors[number % colors.len()])
— the customization point for embedding apps that want to reskin the
board. Defaults to DEFAULT_COLORS, a colorblind-safe palette.
§Panics
Panics if colors is empty.
Sourcepub fn show_numbers(self, show: bool) -> Self
pub fn show_numbers(self, show: bool) -> Self
Whether each number’s digit is drawn on its two endpoint markers.
Defaults to true — this is what keeps the board reading as
Numberlink (numbers are the primary identifier) rather than a
colors-only clone; color is a skin on top, not a replacement.
Sourcepub fn win_message(self, message: impl Into<String>) -> Self
pub fn win_message(self, message: impl Into<String>) -> Self
Message shown in the win banner drawn over the board once
GameStatus::Won is reached. Defaults to "Solved!".
Sourcepub fn interactive(self, interactive: bool) -> Self
pub fn interactive(self, interactive: bool) -> Self
Whether the widget responds to drags at all. Set to false to
render the board read-only. Defaults to true.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for NumberlinkWidget<'a>
impl<'a> Freeze for NumberlinkWidget<'a>
impl<'a> RefUnwindSafe for NumberlinkWidget<'a>
impl<'a> Send for NumberlinkWidget<'a>
impl<'a> Sync for NumberlinkWidget<'a>
impl<'a> Unpin for NumberlinkWidget<'a>
impl<'a> UnsafeUnpin for NumberlinkWidget<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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