Struct fltk_decl::DeclarativeApp
source · pub struct DeclarativeApp { /* private fields */ }Expand description
Entry point for your declarative app
Implementations§
source§impl DeclarativeApp
impl DeclarativeApp
sourcepub fn new<P: AsRef<Path>>(w: i32, h: i32, label: &str, path: P) -> Self
pub fn new<P: AsRef<Path>>(w: i32, h: i32, label: &str, path: P) -> Self
Instantiate a new declarative app
Examples found in repository?
examples/counter.rs (line 28)
26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", PATH)
.run(|_win| {
app::set_scheme(app::Scheme::Oxy);
if let Some(mut btn) = app::widget_from_id::<button::Button>("inc") {
btn.set_callback(btn_cb);
}
if let Some(mut btn) = app::widget_from_id::<button::Button>("dec") {
btn.set_callback(btn_cb);
}
})
.unwrap();
}sourcepub fn run<F: FnMut(&mut Window) + 'static>(
&self,
run_cb: F
) -> Result<(), Box<dyn Error>>
pub fn run<F: FnMut(&mut Window) + 'static>( &self, run_cb: F ) -> Result<(), Box<dyn Error>>
Run your declarative app. The callback exposes the app’s main window
Examples found in repository?
examples/counter.rs (lines 29-37)
26 27 28 29 30 31 32 33 34 35 36 37 38 39
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", PATH)
.run(|_win| {
app::set_scheme(app::Scheme::Oxy);
if let Some(mut btn) = app::widget_from_id::<button::Button>("inc") {
btn.set_callback(btn_cb);
}
if let Some(mut btn) = app::widget_from_id::<button::Button>("dec") {
btn.set_callback(btn_cb);
}
})
.unwrap();
}sourcepub fn run_once<F: FnMut(&mut Window) + 'static>(
&self,
run_cb: F
) -> Result<(), Box<dyn Error>>
pub fn run_once<F: FnMut(&mut Window) + 'static>( &self, run_cb: F ) -> Result<(), Box<dyn Error>>
Run the app without hot-reloading!
sourcepub fn dump_image(&self)
pub fn dump_image(&self)
Just load the image of the window
Trait Implementations§
source§impl Clone for DeclarativeApp
impl Clone for DeclarativeApp
source§fn clone(&self) -> DeclarativeApp
fn clone(&self) -> DeclarativeApp
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more