Struct launchy::DeviceCanvas

source ·
pub struct DeviceCanvas<Spec: DeviceSpec> { /* private fields */ }
Expand description

A generic Canvas implementation for all launchpads, that relies on a DeviceSpec. You as a user of the library don’t need to access this struct directly. Use the “Canvas” type aliases that each launchpad module provides, for example launchy::mk2::Canvas or launchy::s::Canvas.

Implementations§

source§

impl<Spec: DeviceSpec> DeviceCanvas<Spec>

source

pub fn guess( callback: impl FnMut(CanvasMessage) + Send + 'static ) -> Result<Self, MidiError>

Create a new canvas by guessing both input and output MIDI connection by their name. If you need precise control over the specific MIDI connections that will be used, use [DeviceCanvas::from_ports] instead // TODO: not implemented yet

source

pub fn guess_polling() -> Result<(Self, DeviceCanvasPoller), MidiError>

Trait Implementations§

source§

impl<Spec: DeviceSpec> Canvas for DeviceCanvas<Spec>

source§

fn bounding_box(&self) -> (u32, u32)

The width and height of the smallest rectangle that still fully encapsulates the shape of this canvas Read more
source§

fn lowest_visible_brightness(&self) -> f32

The lowest visible brightness on this canvas. Used to calibrate brightness across Launchpads; users of the library probably don’t need to worry about this
source§

fn low_level_get(&self, x: u32, y: u32) -> Option<&Color>

Returns a reference to the currently displayed color at the given position
source§

fn low_level_get_pending_mut(&mut self, x: u32, y: u32) -> Option<&mut Color>

Returns a mutable reference to the in-buffer/unflushed color at the given position
source§

fn low_level_get_pending(&self, x: u32, y: u32) -> Option<&Color>

Returns a reference to the in-buffer/unflushed color at the given position
source§

fn flush(&mut self) -> Result<(), MidiError>

Flush the accumulated changes to the underlying device Read more
source§

fn get(&self, pad: Pad) -> Option<Color>

Returns the currently displayed color at the given position, or None if out of bounds Read more
source§

fn get_pending(&self, pad: Pad) -> Option<Color>

Returns the buffered/unflushed color at the given position, or None if out of bounds Read more
source§

fn set(&mut self, pad: Pad, color: Color) -> Option<()>

Sets the color at the given position. Returns None if out of bounds Read more
source§

fn iter(&self) -> CanvasIterator

An iterator over the buttons of a given Canvas. Create an iterator by calling .iter() on a Canvas. Read more
source§

fn toggle(&mut self, pad: Pad, color: Color) -> Option<()>

Toggles the button at the specified coordinate with the given color. Read more
source§

fn clear(&mut self)where Self: Sized,

Clear the entire canvas by setting all buttons to black. Read more
source§

fn into_padded(self) -> PaddingCanvas<Self>where Self: Sized,

See PaddingCanvas for more details
source§

fn is_valid(&self, pad: Pad) -> bool

source§

impl<S: DeviceSpec> Index<Pad> for DeviceCanvas<S>

§

type Output = Color

The returned type after indexing.
source§

fn index(&self, pad: Pad) -> &Color

Performs the indexing (container[index]) operation. Read more
source§

impl<S: DeviceSpec> IndexMut<Pad> for DeviceCanvas<S>

source§

fn index_mut(&mut self, pad: Pad) -> &mut Color

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<Spec> !RefUnwindSafe for DeviceCanvas<Spec>

§

impl<Spec> Send for DeviceCanvas<Spec>where <Spec as DeviceSpec>::Output: Send,

§

impl<Spec> !Sync for DeviceCanvas<Spec>

§

impl<Spec> Unpin for DeviceCanvas<Spec>where <Spec as DeviceSpec>::Output: Unpin,

§

impl<Spec> !UnwindSafe for DeviceCanvas<Spec>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.