pub struct Config<TMsg, TMainWindow>where
Self: Sync,
TMsg: MsgDataBound,
TMainWindow: ComponentHandle,{
pub slint_window: Weak<TMainWindow>,
pub fn_input: fn(_: Message<TMsg>, _: TMainWindow),
pub fn_output: fn(_: TMainWindow, _: Sender<Message<TMsg>>),
pub output_period: Duration,
}
Expand description
Настройки компонента cmp_slint
Fields§
§slint_window: Weak<TMainWindow>
Ссылка на главное окно
fn_input: fn(_: Message<TMsg>, _: TMainWindow)
Функция обработки входящих сообщений
Пример:
fn_input: |msg, w| {
let input_data = w.global::<Input>();
let Some(msg) = msg.get_custom_data() else {
return;
};
match msg {
Custom::LiveCounter(msg) => match msg {
Livecounter::Counter(c) => input_data.set_value_from_phone(c as i32),
},
_ => (),
};
},
fn_output: fn(_: TMainWindow, _: Sender<Message<TMsg>>)
Функция генерирования исходящих сообщений
Пример:
fn_output: |w, tx| {
let output_data = w.global::<Output>();
output_data.on_slider(move |value| {
let msg = Message::new_custom(Custom::Slint(Slint::Slider(value as f64)));
tx.blocking_send(msg).unwrap();
})
},
output_period: Duration
Период фильтрации исходящих сообщений
Trait Implementations§
Source§impl<TMsg, TMainWindow> Clone for Config<TMsg, TMainWindow>where
TMsg: MsgDataBound,
TMainWindow: ComponentHandle,
impl<TMsg, TMainWindow> Clone for Config<TMsg, TMainWindow>where
TMsg: MsgDataBound,
TMainWindow: ComponentHandle,
Source§impl<TMainWindow, TMsg> IComponentProcess<Config<TMsg, TMainWindow>, TMsg> for Component<Config<TMsg, TMainWindow>, TMsg>where
TMsg: MsgDataBound + 'static,
Self: Sync,
TMainWindow: ComponentHandle + 'static,
impl<TMainWindow, TMsg> IComponentProcess<Config<TMsg, TMainWindow>, TMsg> for Component<Config<TMsg, TMainWindow>, TMsg>where
TMsg: MsgDataBound + 'static,
Self: Sync,
TMainWindow: ComponentHandle + 'static,
Auto Trait Implementations§
impl<TMsg, TMainWindow> Freeze for Config<TMsg, TMainWindow>
impl<TMsg, TMainWindow> RefUnwindSafe for Config<TMsg, TMainWindow>where
<TMainWindow as ComponentHandle>::Inner: RefUnwindSafe,
impl<TMsg, TMainWindow> Send for Config<TMsg, TMainWindow>
impl<TMsg, TMainWindow> Sync for Config<TMsg, TMainWindow>
impl<TMsg, TMainWindow> Unpin for Config<TMsg, TMainWindow>
impl<TMsg, TMainWindow> UnwindSafe for Config<TMsg, TMainWindow>where
<TMainWindow as ComponentHandle>::Inner: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more