Flatten create structure
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
89
advotracker_client/examples/cheet_sheet.rs
Normal file
89
advotracker_client/examples/cheet_sheet.rs
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* OrbTk - The Orbital Widget Toolkit
|
||||
*
|
||||
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||
* SPDX-License-Identifier: (MIT)
|
||||
*/
|
||||
|
||||
// use orbtk::prelude::*;
|
||||
|
||||
// /*
|
||||
// * WidgetContainer = entity
|
||||
// */
|
||||
// // methods get, get_mut, try_get, try_get_mut and clone
|
||||
// // ctx.widget returns a WidgetContainer that wraps the current widget of the state
|
||||
// let mut widget_container: WidgetContainer = ctx.widget();
|
||||
|
||||
// // property handling (componets)
|
||||
// // Gets a reference for the property
|
||||
// // .get<PropertyType>("property_name");
|
||||
// widget_container.get::<String16>("text");
|
||||
|
||||
// // Sets the value of a property
|
||||
// // .set<PropertyType>("property_name", property_value);
|
||||
// widget_container.set::<String16>("text", "my_text");
|
||||
|
||||
|
||||
// /*
|
||||
// * Child WidgetContainer = child entity
|
||||
// */
|
||||
// // child of a state's widget, that is referenced by an entity id.
|
||||
// // e.g: .child(TextBox::new().id(child_entity_id).build(ctx)
|
||||
// let mut child: WidgetContainer = ctx.get_widget(child_entity_id);
|
||||
|
||||
// // child of a state's widget that is referenced by an string id
|
||||
// // e.g: .child(TextBox::new().id("text_box_id").build(ctx)
|
||||
// let child: WidgetContainer = ctx.child("text_box_id");
|
||||
|
||||
// // property handling (components)
|
||||
// // Gets an TextBoxCtx wrapper for the text box child.
|
||||
// let mut text_box: TextBoxCtx = text_box(ctx.child("text_box_id"));
|
||||
|
||||
// // or as an alternative:
|
||||
// let text_box: TextBoxCtx = TextBox::get(ctx.child("text_box_id"));
|
||||
|
||||
// // get child field attributes
|
||||
// let text_len = text_box.text().len();
|
||||
|
||||
// // set child field attributes
|
||||
// text_box.set_text("My new text");
|
||||
|
||||
|
||||
// /*
|
||||
// * Registry handling
|
||||
// */
|
||||
|
||||
// // register service
|
||||
// fn update(registry: &mut Registry, _: &mut Context) {
|
||||
// registry.register("my_db_serve", MyDBServie::new());
|
||||
// }
|
||||
// // access service
|
||||
// fn update(registry: &mut Registry, _: &mut Context) {
|
||||
// let mut my_db_service: MyDBSerivce = registry.get_mut("my_db_service");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// API Update: access properties of widgets in states
|
||||
|
||||
// Old style
|
||||
// let text = *button(&mut ctx.widget()).text();
|
||||
// let text = Button::get(&mut ctx.widget()).text();
|
||||
// let text = *button(&mut ctx.widget()).clone_text();
|
||||
// let text = Button::get(&mut ctx.widget()).clone_text();
|
||||
// button(&mut ctx.widget()).text_mut().push_str("test");
|
||||
// Button::get(&mut ctx.widget()).text_mut().push_str("test");
|
||||
// button(&mut ctx.widget()).set_text(String16::from("test"));
|
||||
// Button::get(&mut ctx.widget()).set_text(String16::from("test"));
|
||||
|
||||
// Current style
|
||||
// let text = Button::text_clone(&ctx.widget());
|
||||
// Button::text_mut(&mut ctx.widget()).push_str("test");
|
||||
// Button::text_set(&mut ctx.widget(), String16::from("test"));
|
||||
//
|
||||
// TextBehaviour::offset_set(&mut ctx.widget(self.text_block), offset);
|
||||
// or
|
||||
// ctx.get_widget(self.text_block).set("offset", offset);
|
||||
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user