January 2018
Beginner to intermediate
454 pages
10h 8m
English
This will require two new methods in the impl Widget:
#[widget]
impl Widget for App {
// …
fn set_current_time(&mut self, time: u64) {
self.model.current_time = time;
self.model.adjustment.set_value(time as f64);
}
fn set_play_icon(&self, icon: &str) {
self.model.play_image.set_from_file(format!("assets/{}.png", icon));
}
}
But these methods have nothing to do with a Widget, so why are we allowed to add custom methods in a trait implementation? Well, the #[widget] attribute will take these methods and move them to a separate impl App where they belong. But why do we want to do this instead of placing them ourselves? That's because relm analyzes the assignments to the model attributes in the methods in the implementation decorated ...