examples: introduce advowidgets
* merge orbtk example widgets * rename to advowidgets * incorporate functionality of wip-orbtk branch - using latest material-icons-font code - merge bugfix to add ComboBox items - merge bugfix to handle ComboList Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -41,12 +41,14 @@ impl State for MainViewState {
|
|||||||
main_view(ctx.widget())
|
main_view(ctx.widget())
|
||||||
.list_mut()
|
.list_mut()
|
||||||
.push(format!("Item {}", len + 1));
|
.push(format!("Item {}", len + 1));
|
||||||
ctx.child("items").set::<usize>("blub", len + 1);
|
ctx.child("items").clone_or_default::<usize>("Item");
|
||||||
items_widget(ctx.child("items")).set_count(len + 1);
|
items_widget(ctx.child("items")).set_count(len + 1);
|
||||||
button(ctx.child("remove-item-button")).set_enabled(true);
|
button(ctx.child("remove-item-button")).set_enabled(true);
|
||||||
|
button(ctx.child("remove-item-button")).set_visibility(Visibility::Visible);
|
||||||
|
|
||||||
if len == 4 {
|
if len == 4 {
|
||||||
button(ctx.child("add-item-button")).set_enabled(false);
|
button(ctx.child("add-item-button")).set_enabled(false);
|
||||||
|
button(ctx.child("add-item-button")).set_visibility(Visibility::Collapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,10 +58,11 @@ impl State for MainViewState {
|
|||||||
main_view(ctx.widget()).list_mut().remove(len - 1);
|
main_view(ctx.widget()).list_mut().remove(len - 1);
|
||||||
items_widget(ctx.child("items")).set_count(len - 1);
|
items_widget(ctx.child("items")).set_count(len - 1);
|
||||||
button(ctx.child("add-item-button")).set_enabled(true);
|
button(ctx.child("add-item-button")).set_enabled(true);
|
||||||
|
button(ctx.child("add-item-button")).set_visibility(Visibility::Visible);
|
||||||
|
|
||||||
if len == 1 {
|
if len == 1 {
|
||||||
button(ctx.child("remove-item-button")).set_enabled(false);
|
button(ctx.child("remove-item-button")).set_enabled(false);
|
||||||
}
|
button(ctx.child("remove-item-button")).set_visibility(Visibility::Collapsed); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::IncrementCounter => {
|
Action::IncrementCounter => {
|
||||||
@@ -189,7 +192,7 @@ impl Template for MainView {
|
|||||||
Button::new()
|
Button::new()
|
||||||
.text("Button")
|
.text("Button")
|
||||||
.margin((0., 8., 0., 0.))
|
.margin((0., 8., 0., 0.))
|
||||||
.icon(material_icons_font_ttf::MD_CHECK)
|
.icon(material_icons_font::MD_CHECK)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
@@ -204,7 +207,7 @@ impl Template for MainView {
|
|||||||
.element("button")
|
.element("button")
|
||||||
.class("primary")
|
.class("primary")
|
||||||
.margin((0., 8., 0., 0.))
|
.margin((0., 8., 0., 0.))
|
||||||
.icon(material_icons_font_ttf::MD_360)
|
.icon(material_icons_font::MD_360)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -214,7 +217,7 @@ impl Template for MainView {
|
|||||||
.class("single_content")
|
.class("single_content")
|
||||||
.text("ToggleButton")
|
.text("ToggleButton")
|
||||||
.margin((0., 8., 2., 0.))
|
.margin((0., 8., 2., 0.))
|
||||||
.icon(material_icons_font_ttf::MD_ALARM_ON)
|
.icon(material_icons_font::MD_ALARM_ON)
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::row(3))
|
.attach(Grid::row(3))
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -300,7 +303,7 @@ impl Template for MainView {
|
|||||||
.margin((0., 8., 0., 0.))
|
.margin((0., 8., 0., 0.))
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.margin((0., 8., 8., 0.))
|
.margin((0., 8., 8., 0.))
|
||||||
.icon(material_icons_font_ttf::MD_CLEAR)
|
.icon(material_icons_font::MD_CLEAR)
|
||||||
.text("clear text")
|
.text("clear text")
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::ClearText);
|
state(id, states).action(Action::ClearText);
|
||||||
@@ -390,7 +393,7 @@ impl Template for MainView {
|
|||||||
.element("button")
|
.element("button")
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.id("remove-item-button")
|
.id("remove-item-button")
|
||||||
.icon(material_icons_font_ttf::MD_REMOVE_CIRCLE)
|
.icon(material_icons_font::MD_REMOVE_CIRCLE)
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::RemoveItem);
|
state(id, states).action(Action::RemoveItem);
|
||||||
true
|
true
|
||||||
@@ -405,7 +408,7 @@ impl Template for MainView {
|
|||||||
.element("button")
|
.element("button")
|
||||||
.class("single_content")
|
.class("single_content")
|
||||||
.id("add-item-button")
|
.id("add-item-button")
|
||||||
.icon(material_icons_font_ttf::MD_ADD_CIRCLE)
|
.icon(material_icons_font::MD_ADD_CIRCLE)
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
state(id, states).action(Action::AddItem);
|
state(id, states).action(Action::AddItem);
|
||||||
true
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user