Skip to main content

HexwebWidget

Struct HexwebWidget 

Source
pub struct HexwebWidget<'a> { /* private fields */ }
Expand description

An egui widget that renders an interactive hexweb board.

Drag a piece onto an empty node to move it there, or onto another piece to swap the two. Arrows answered by a reciprocal arrow are drawn in satisfied_color; the ones still pointing at an empty node or off the board, or meeting no reciprocal arrow, are drawn in unsatisfied_color, which is the board’s live progress feedback. The puzzle is solved when no arrow is unsatisfied.

ⓘ
ui.add(egui_hexweb::HexwebWidget::new(&mut game));

Implementations§

Source§

impl<'a> HexwebWidget<'a>

Source

pub fn new(game: &'a mut HexwebGame) -> Self

Source

pub fn cell_size(self, size: f32) -> Self

Override the size (in logical pixels) of each hexagon’s circumradius. When not set, the cell size is computed automatically to fill the available space of the parent container.

Source

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!". The crate ships no translations; embedding apps pass their own.

Source

pub fn satisfied_color(self, color: Color32) -> Self

Color for arrows that are met by a reciprocal arrow. Defaults to the theme’s strong text color.

Source

pub fn unsatisfied_color(self, color: Color32) -> Self

Color for arrows that point at an empty node, off the board, or at a piece that does not point back. Defaults to the theme’s error color — the accent the player reads as “this piece still needs to move”.

Source

pub fn interactive(self, interactive: bool) -> Self

Whether the widget responds to input at all. Set to false to render the board read-only. Defaults to true.

Trait Implementations§

Source§

impl Widget for HexwebWidget<'_>

Source§

fn ui(self, ui: &mut Ui) -> Response

Allocate space, interact, paint, and return a Response. Read more
Source§

fn boxed<'a>(self) -> Box<dyn FnOnce(&mut Ui) -> Response + 'a>
where Self: Sized + 'a,

Box this widget for dynamic dispatch.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for HexwebWidget<'a>

§

impl<'a> Freeze for HexwebWidget<'a>

§

impl<'a> RefUnwindSafe for HexwebWidget<'a>

§

impl<'a> Send for HexwebWidget<'a>

§

impl<'a> Sync for HexwebWidget<'a>

§

impl<'a> Unpin for HexwebWidget<'a>

§

impl<'a> UnsafeUnpin for HexwebWidget<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.