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?
More examples
examples/json.rs (line 29)
27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", "examples/gui.json")
.run(true, |_win| {
app::set_scheme(app::Scheme::Oxy);
let mut inc: button::Button = app::widget_from_id("inc").unwrap();
let mut dec: button::Button = app::widget_from_id("dec").unwrap();
inc.set_callback(inc_btn_cb);
dec.set_callback(dec_btn_cb);
})
.unwrap();
}examples/toml.rs (line 29)
27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", "examples/gui.toml")
.run(true, |_win| {
app::set_scheme(app::Scheme::Oxy);
let mut inc: button::Button = app::widget_from_id("inc").unwrap();
let mut dec: button::Button = app::widget_from_id("dec").unwrap();
inc.set_callback(inc_btn_cb);
dec.set_callback(dec_btn_cb);
})
.unwrap();
}sourcepub fn run<F: FnMut(&mut Window) + 'static>(
&self,
hot_reload: bool,
run_cb: F
) -> Result<(), Box<dyn Error>>
pub fn run<F: FnMut(&mut Window) + 'static>( &self, hot_reload: bool, run_cb: F ) -> Result<(), Box<dyn Error>>
Run your declarative app. The bool flag determines whether hot-reloading is enabled. The callback exposes the app’s main window
Examples found in repository?
More examples
examples/json.rs (lines 30-36)
27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", "examples/gui.json")
.run(true, |_win| {
app::set_scheme(app::Scheme::Oxy);
let mut inc: button::Button = app::widget_from_id("inc").unwrap();
let mut dec: button::Button = app::widget_from_id("dec").unwrap();
inc.set_callback(inc_btn_cb);
dec.set_callback(dec_btn_cb);
})
.unwrap();
}examples/toml.rs (lines 30-36)
27 28 29 30 31 32 33 34 35 36 37 38
fn main() {
app::GlobalState::new(State { count: 0 });
DeclarativeApp::new(200, 300, "MyApp", "examples/gui.toml")
.run(true, |_win| {
app::set_scheme(app::Scheme::Oxy);
let mut inc: button::Button = app::widget_from_id("inc").unwrap();
let mut dec: button::Button = app::widget_from_id("dec").unwrap();
inc.set_callback(inc_btn_cb);
dec.set_callback(dec_btn_cb);
})
.unwrap();
}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