frontend: update example widgets and linked in resources
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -86,9 +86,9 @@ impl State for MainViewState {
|
||||
println!("entry changed: {}", text);
|
||||
}
|
||||
Action::ValueChanged(entity) => {
|
||||
let value =
|
||||
((*ctx.get_widget(entity).get::<f64>("value")).floor() as i32).to_string();
|
||||
ctx.child("value_text").set("text", String16::from(value));
|
||||
let val =
|
||||
((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
|
||||
ctx.child("value_text").set("text", String16::from(val));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ impl State for MainViewState {
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
.element("text-block")
|
||||
.class("h1")
|
||||
@@ -173,24 +173,23 @@ impl Template for MainView {
|
||||
.selection_list_count(10)
|
||||
.combo_box_list_count(10)
|
||||
.child(
|
||||
Grid::create()
|
||||
Grid::new()
|
||||
.margin(8.0)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.column(132.0)
|
||||
.column(16.0)
|
||||
.column(132.0)
|
||||
.column(16.0)
|
||||
.column(132.0)
|
||||
.build(),
|
||||
Columns::new()
|
||||
.add(132.0)
|
||||
.add(16.0)
|
||||
.add(132.0)
|
||||
.add(16.0)
|
||||
.add(132.0),
|
||||
)
|
||||
.child(
|
||||
Stack::create()
|
||||
Stack::new()
|
||||
.attach(Grid::column(0))
|
||||
// Column 0
|
||||
.child(create_header(ctx, "Buttons"))
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.text("Button")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
||||
@@ -203,7 +202,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.text("Primary")
|
||||
.element("button")
|
||||
.class("primary")
|
||||
@@ -214,7 +213,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ToggleButton::create()
|
||||
ToggleButton::new()
|
||||
.class("single_content")
|
||||
.text("ToggleButton")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
@@ -223,7 +222,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
CheckBox::create()
|
||||
CheckBox::new()
|
||||
.text("CheckBox")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
@@ -231,23 +230,23 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Switch::create()
|
||||
Switch::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(5))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.element("h1")
|
||||
.id("value_text")
|
||||
.text("0")
|
||||
.horizontal_alignment("center")
|
||||
.h_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Slider::create()
|
||||
Slider::new()
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::ValueChanged(entity));
|
||||
})
|
||||
@@ -256,11 +255,11 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Stack::create()
|
||||
Stack::new()
|
||||
.attach(Grid::column(2))
|
||||
.child(create_header(ctx, "Text"))
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.class("body")
|
||||
.text(("result", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
@@ -269,7 +268,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::create()
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_one", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
@@ -284,7 +283,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::create()
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_two", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
@@ -299,7 +298,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.class("single_content")
|
||||
.text("clear text")
|
||||
@@ -309,31 +308,32 @@ impl Template for MainView {
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
NumericBox::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.max(123.0)
|
||||
.step(0.123)
|
||||
.val(0.123)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::create()
|
||||
Grid::new()
|
||||
.rows(
|
||||
Rows::create()
|
||||
.row("auto")
|
||||
.row(32.0)
|
||||
.row(16.0)
|
||||
.row(204.0)
|
||||
.row("auto")
|
||||
.row(192.0)
|
||||
.row("auto")
|
||||
.build(),
|
||||
)
|
||||
.columns(
|
||||
Columns::create()
|
||||
.column("*")
|
||||
.column(4.0)
|
||||
.column("*")
|
||||
.build(),
|
||||
Rows::new()
|
||||
.add("auto")
|
||||
.add(32.0)
|
||||
.add(16.0)
|
||||
.add(204.0)
|
||||
.add("auto")
|
||||
.add(192.0)
|
||||
.add("auto"),
|
||||
)
|
||||
.columns(Columns::new().add("*").add(4.0).add("*"))
|
||||
.attach(Grid::column(4))
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.text("Items")
|
||||
.element("text-block")
|
||||
.class("h1")
|
||||
@@ -343,15 +343,15 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::create()
|
||||
ComboBox::new()
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("combo_box_list")[index]
|
||||
.clone();
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.vertical_alignment("center")
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
@@ -364,7 +364,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ItemsWidget::create()
|
||||
ItemsWidget::new()
|
||||
.element("items-widget")
|
||||
.id("items")
|
||||
.padding((4.0, 4.0, 4.0, 2.0))
|
||||
@@ -377,7 +377,7 @@ impl Template for MainView {
|
||||
[index]
|
||||
.clone();
|
||||
|
||||
Button::create()
|
||||
Button::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.text(text)
|
||||
.build(bc)
|
||||
@@ -386,7 +386,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.element("button")
|
||||
.class("single_content")
|
||||
.id("remove-item-button")
|
||||
@@ -401,7 +401,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.element("button")
|
||||
.class("single_content")
|
||||
.id("add-item-button")
|
||||
@@ -416,7 +416,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ListView::create()
|
||||
ListView::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(5))
|
||||
@@ -427,9 +427,9 @@ impl Template for MainView {
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("selection_list")[index]
|
||||
.clone();
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.vertical_alignment("center")
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
@@ -438,7 +438,7 @@ impl Template for MainView {
|
||||
)
|
||||
.child(
|
||||
// todo: wrong text width????
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.element("text-block")
|
||||
.id("selection")
|
||||
.max_width(120.0)
|
||||
@@ -461,12 +461,12 @@ fn main() {
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - widgets example")
|
||||
.position((100.0, 100.0))
|
||||
.size(468.0, 730.0)
|
||||
.resizeable(true)
|
||||
.child(MainView::create().build(ctx))
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
Reference in New Issue
Block a user