Skip to main content

Tweak

Struct Tweak 

Source
pub struct Tweak<W> { /* private fields */ }
Expand description

Raw platform settings for a built-in widget W: the escape hatch past its semantic props, for what only one platform has. Each backend makes them with its tweak (or tweak_with), which gets the native control itself; pick one per platform with platform!:

ⓘ
use mitsuami::{appkit, gtk};

Button::new("Share").native(platform! {
    macos => appkit::tweak(|b: &appkit::objc2_app_kit::NSButton| {
        b.setControlSize(appkit::objc2_app_kit::NSControlSize::Large)
    }),
    gtk => gtk::tweak(|b: &gtk::gtk::Button| b.add_css_class("circular")),
    _ => Tweak::none(),
})

A tweak runs after the widget’s other props, and again whenever they change, so what it sets wins; keep it idempotent. Headless tests don’t run it.

Implementations§

Source§

impl<W> Tweak<W>

Source

pub fn none() -> Tweak<W>

No settings: for platforms the app doesn’t tweak.

Source

pub fn new<T: Clone + 'static>( value: Value<T>, settings: impl Fn(T) -> Opaque + 'static, ) -> Tweak<W>

For backends: settings made from a value, in the backend’s own form, and made again whenever a dynamic value changes.

Source

pub fn apply(self, element: &mut Element)

For widgets: sends the settings as Prop::Tweak.

Auto Trait Implementations§

§

impl<W> !RefUnwindSafe for Tweak<W>

§

impl<W> !Send for Tweak<W>

§

impl<W> !Sync for Tweak<W>

§

impl<W> !UnwindSafe for Tweak<W>

§

impl<W> Forget for Tweak<W>

§

impl<W> Freeze for Tweak<W>
where PhantomData<fn() -> W>: Freeze,

§

impl<W> Move for Tweak<W>

§

impl<W> Unpin for Tweak<W>
where PhantomData<fn() -> W>: Unpin,

§

impl<W> UnsafeUnpin for Tweak<W>
where PhantomData<fn() -> W>: UnsafeUnpin,

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> 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, 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.