Knob

Struct Knob 

Source
pub struct Knob<T>
where T: NormalizedMap,
{ pub normalized_value: f32, pub map: T, /* private fields */ }

Fields§

§normalized_value: f32§map: T

Implementations§

Source§

impl<T> Knob<T>
where T: NormalizedMap,

Source

pub fn new(map: T, normalized_default: f32) -> Knob<T>

Source

pub fn map(&self) -> &T

Source

pub fn on_changing<F>(self, callback: F) -> Knob<T>
where F: 'static + Fn(&mut Knob<T>, &mut State, Entity),

Set the callback triggered when the slider value is changing (dragging).

Takes a closure which triggers when the slider value is changing, either by pressing the track or dragging the thumb along the track.

§Example
Slider::new()
    .on_changing(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_changing: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);
Source

pub fn set_centered(self, val: bool) -> Knob<T>

Trait Implementations§

Source§

impl<T> Widget for Knob<T>
where T: NormalizedMap,

Source§

type Ret = Entity

Source§

type Data = f32

Source§

fn on_build( &mut self, state: &mut State, entity: Entity, ) -> <Knob<T> as Widget>::Ret

Source§

fn on_update( &mut self, state: &mut State, _entity: Entity, data: &<Knob<T> as Widget>::Data, )

Source§

fn on_event(&mut self, state: &mut State, entity: Entity, event: &mut Event)

Source§

fn widget_name(&self) -> String

Source§

fn build<F>( self, state: &mut State, parent: impl AsEntity, builder: F, ) -> Self::Ret
where F: FnMut(Builder<'_, Self>) -> Builder<'_, Self>, Self: Sized + 'static,

Adds the widget into state and returns the associated type Ret - an entity id or a tuple of entity ids
Source§

fn bind<L, F>(self, lens: L, converter: F) -> Wrapper<L, Self>
where L: Lens, F: 'static + Fn(&<L as Lens>::Target) -> Self::Data,

Source§

fn bind2<L>(self, lens: L) -> LensWrap<L, Self>
where L: Lens,

Source§

fn on_style( &mut self, state: &mut State, entity: Entity, property: (String, PropType), )

Source§

fn on_draw( &mut self, state: &mut State, entity: Entity, canvas: &mut Canvas<OpenGl>, )

Auto Trait Implementations§

§

impl<T> Freeze for Knob<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Knob<T>

§

impl<T> !Send for Knob<T>

§

impl<T> !Sync for Knob<T>

§

impl<T> Unpin for Knob<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Knob<T>

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> EventHandler for T
where T: Widget + 'static,

Source§

fn widget_name(&self) -> String

Source§

fn on_update( &mut self, state: &mut State, entity: Entity, node: &(dyn Node + 'static), )

Source§

fn on_event_(&mut self, state: &mut State, entity: Entity, event: &mut Event)

Source§

fn on_style( &mut self, state: &mut State, entity: Entity, property: (String, PropType), )

Source§

fn on_draw_( &mut self, state: &mut State, entity: Entity, canvas: &mut Canvas<OpenGl>, )

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> Node for T
where T: 'static,