frontend: update example widgets and linked in resources
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1,240 +1,478 @@
|
||||
use std::{cell::Cell, collections::HashSet};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::theme::DEFAULT_THEME_CSS;
|
||||
use orbtk::*;
|
||||
|
||||
static DARK_EXT: &'static str = include_str!("../resources/stylesheets/advotracker-dark.css");
|
||||
|
||||
//#[cfg(feature = "light-theme")]
|
||||
static LIGHT_EXT: &'static str = include_str!("../resources/stylesheets/advotracker-light.css");
|
||||
|
||||
static CSS_EXT: &'static str = include_str!("../resources/stylesheets/grid.css");
|
||||
|
||||
//#[cfg(not(feature = "light-theme"))]
|
||||
//fn get_theme() -> ThemeValue {
|
||||
// ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
// .extension_css(CSS_EXT)
|
||||
// .build()
|
||||
//}
|
||||
|
||||
fn get_theme() -> ThemeValue {
|
||||
ThemeValue::create()
|
||||
//.extension_css(DARK_EXT)
|
||||
.extension_css(LIGHT_EXT)
|
||||
//.extension_css(CSS_EXT)
|
||||
.build()
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
AddItem,
|
||||
ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity),
|
||||
ValueChanged(Entity),
|
||||
IncrementCounter,
|
||||
RemoveItem,
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
pub struct MainViewState {
|
||||
counter: Cell<i32>,
|
||||
action: Cell<Option<Action>>,
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&self, action: impl Into<Option<Action>>) {
|
||||
self.action.set(action.into());
|
||||
}
|
||||
action: Option<Action>,
|
||||
}
|
||||
|
||||
impl Default for MainViewState {
|
||||
fn default() -> Self {
|
||||
MainViewState {
|
||||
counter: Cell::new(0),
|
||||
action: Cell::new(None),
|
||||
}
|
||||
MainViewState { action: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: impl Into<Option<Action>>) {
|
||||
self.action = action.into();
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn update(&self, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action.get() {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
Action::AddItem => {
|
||||
let len = ctx.widget().get::<List>("list").len();
|
||||
if len < 5 {
|
||||
ctx.widget()
|
||||
.get_mut::<List>("list")
|
||||
.push(format!("Item {}", len + 1));
|
||||
ctx.child("items").set("count", len + 1);
|
||||
ctx.child("remove-item-button").set("enabled", true);
|
||||
|
||||
if len == 4 {
|
||||
ctx.child("add-item-button").set("enabled", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::RemoveItem => {
|
||||
let len = ctx.widget().get::<List>("list").len();
|
||||
if len > 0 {
|
||||
ctx.widget().get_mut::<List>("list").remove(len - 1);
|
||||
ctx.child("items").set("count", len - 1);
|
||||
ctx.child("add-item-button").set("enabled", true);
|
||||
|
||||
if len == 1 {
|
||||
ctx.child("remove-item-button").set("enabled", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action::IncrementCounter => {
|
||||
self.counter.set(self.counter.get() + 1);
|
||||
*ctx.widget().get_mut::<usize>("counter") += 1;
|
||||
|
||||
let counter = *ctx.widget().get::<usize>("counter");
|
||||
|
||||
ctx.widget().set(
|
||||
"result",
|
||||
String16::from(format!("Button count: {}", self.counter.get())),
|
||||
String16::from(format!("Button count: {}", counter)),
|
||||
);
|
||||
}
|
||||
Action::ClearText => {
|
||||
ctx.widget().set("text_one", String16::from(""));
|
||||
ctx.widget().set("text_two", String16::from(""));
|
||||
}
|
||||
Action::EntryActivated(entity) => {
|
||||
let mut widget = ctx.get_widget(entity);
|
||||
let text = widget.get_mut::<String16>("text");
|
||||
println!("submitting {}", text);
|
||||
text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String16>("text");
|
||||
println!("entry changed: {}", text);
|
||||
}
|
||||
Action::ValueChanged(entity) => {
|
||||
let val =
|
||||
((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
|
||||
ctx.child("value_text").set("text", String16::from(val));
|
||||
}
|
||||
}
|
||||
|
||||
self.action.set(None);
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
let mut selection_string = "Selected:".to_string();
|
||||
|
||||
for index in &ctx.widget().get::<SelectedIndices>("selected_indices").0 {
|
||||
selection_string = format!("{} {}", selection_string, index);
|
||||
}
|
||||
|
||||
ctx.child("selection")
|
||||
.set("text", String16::from(selection_string));
|
||||
}
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
.selector(Selector::new().with("text-block").class("h1"))
|
||||
.element("text-block")
|
||||
.class("h1")
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
widget!(
|
||||
MainView<MainViewState> {
|
||||
selected_indices: SelectedIndices,
|
||||
text_harm: String16,
|
||||
counter: usize,
|
||||
list_count: usize,
|
||||
combo_box_list_count: usize,
|
||||
list: List,
|
||||
selection_list: List,
|
||||
combo_box_list: List,
|
||||
selection_list_count: usize,
|
||||
text_one: String16,
|
||||
text_two: String16,
|
||||
result: String16
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
let state = self.clone_state();
|
||||
self.name("MainView")
|
||||
.result("Button count: 0")
|
||||
.counter(0)
|
||||
.selected_indices(HashSet::new())
|
||||
.list(vec![
|
||||
"Item 1".to_string(),
|
||||
"Item 2".to_string(),
|
||||
"Item 3".to_string(),
|
||||
])
|
||||
.list_count(3)
|
||||
.selection_list(vec![
|
||||
"Item 1".to_string(),
|
||||
"Item 2".to_string(),
|
||||
"Item 3".to_string(),
|
||||
"Item 4".to_string(),
|
||||
"Item 5".to_string(),
|
||||
"Item 6".to_string(),
|
||||
"Item 7".to_string(),
|
||||
"Item 8".to_string(),
|
||||
"Item 9".to_string(),
|
||||
"Item 10".to_string(),
|
||||
])
|
||||
.combo_box_list(vec![
|
||||
"CB 1".to_string(),
|
||||
"CB 2".to_string(),
|
||||
"CB 3".to_string(),
|
||||
"CB 4".to_string(),
|
||||
"CB 5".to_string(),
|
||||
"CB 6".to_string(),
|
||||
"CB 7".to_string(),
|
||||
"CB 8".to_string(),
|
||||
"CB 9".to_string(),
|
||||
"CB 10".to_string(),
|
||||
])
|
||||
.selection_list_count(10)
|
||||
.combo_box_list_count(10)
|
||||
.child(
|
||||
Grid::new()
|
||||
.margin(8.0)
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(132.0)
|
||||
.add(16.0)
|
||||
.add(132.0)
|
||||
.add(16.0)
|
||||
.add(132.0),
|
||||
)
|
||||
.child(
|
||||
Stack::new()
|
||||
.attach(Grid::column(0))
|
||||
// Column 0
|
||||
.child(create_header(ctx, "Buttons"))
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Button")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::IncrementCounter);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.text("Primary")
|
||||
.element("button")
|
||||
.class("primary")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ToggleButton::new()
|
||||
.class("single_content")
|
||||
.text("ToggleButton")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(3))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
CheckBox::new()
|
||||
.text("CheckBox")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Switch::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(5))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.element("h1")
|
||||
.id("value_text")
|
||||
.text("0")
|
||||
.h_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Slider::new()
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::ValueChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Stack::new()
|
||||
.attach(Grid::column(2))
|
||||
.child(create_header(ctx, "Text"))
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.class("body")
|
||||
.text(("result", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_one", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.water_mark("TextBox...")
|
||||
.text(("text_two", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.class("single_content")
|
||||
.text("clear text")
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::ClearText);
|
||||
true
|
||||
})
|
||||
.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::new()
|
||||
.rows(
|
||||
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::new()
|
||||
.text("Items")
|
||||
.element("text-block")
|
||||
.class("h1")
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(0))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("combo_box_list")[index]
|
||||
.clone();
|
||||
TextBlock::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.selected_index(0)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(1))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.count(("combo_box_list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ItemsWidget::new()
|
||||
.element("items-widget")
|
||||
.id("items")
|
||||
.padding((4.0, 4.0, 4.0, 2.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(3))
|
||||
.margin((0.0, 0.0, 0.0, 8.0))
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc.get_widget(id).get::<Vec<String>>("list")
|
||||
[index]
|
||||
.clone();
|
||||
|
||||
self.name("MainView").child(
|
||||
//.result("Button count: 0")
|
||||
//.selected_indices(HashSet::new())
|
||||
/*
|
||||
Grid::create()
|
||||
.margin(8.0)
|
||||
.rows(
|
||||
Rows::create()
|
||||
// define two rows
|
||||
.row("*")
|
||||
.row("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
// Container 0
|
||||
Container::create()
|
||||
.padding(8.0)
|
||||
.selector(Selector::from("container").class("header"))
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
*/
|
||||
Grid::create()
|
||||
.selector("lynch")
|
||||
.margin(8.0)
|
||||
.columns(
|
||||
Columns::create()
|
||||
// define three columns
|
||||
.column("auto")
|
||||
.column(24.0)
|
||||
.column("auto")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
Stack::create()
|
||||
// Column 0
|
||||
.attach(Grid::column(0))
|
||||
.child(create_header(ctx, "Buttons"))
|
||||
.child(
|
||||
Button::create()
|
||||
.text("Button")
|
||||
.selector(Selector::new().with("button").class("primary"))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.icon(material_font_icons::CHECK_FONT_ICON)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.on_mouse_move(move |_| {
|
||||
println!("Mouse moved over Button!");
|
||||
true
|
||||
})
|
||||
.on_click(move |_| {
|
||||
println!("Mouse clicked Buttonmoved over Button!");
|
||||
state.action(Action::IncrementCounter);
|
||||
true
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Switch::create()
|
||||
.selector("bluebayoux")
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(2))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Stack::create()
|
||||
// Column 2
|
||||
.attach(Grid::column(2))
|
||||
.child(create_header(ctx, "Text"))
|
||||
.child(
|
||||
TextBlock::create()
|
||||
.selector(Selector::new().class("body"))
|
||||
.text(("result", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::create()
|
||||
.water_mark("Harm...")
|
||||
.text(("text_harm", id))
|
||||
.margin((0.0, 8.0, 0.0, 0.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(2))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
/*.child(
|
||||
// Container 1
|
||||
Container::create()
|
||||
.selector(Selector::from("container").class("content"))
|
||||
.padding(8.0)
|
||||
.attach(Grid::row(1))
|
||||
.child(
|
||||
ImageWidget::create()
|
||||
.image("resources/images/orbtk-space.png")
|
||||
.visibility("Hidden")
|
||||
.margin(8.0)
|
||||
.vertical_alignment("Center")
|
||||
.horizontal_alignment("Center")
|
||||
.size(600.0, 600.0)
|
||||
.clip(true)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
Button::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.count(("list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.element("button")
|
||||
.class("single_content")
|
||||
.id("remove-item-button")
|
||||
.icon(material_font_icons::MINUS_FONT_ICON)
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::RemoveItem);
|
||||
true
|
||||
})
|
||||
.min_width(0.0)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.element("button")
|
||||
.class("single_content")
|
||||
.id("add-item-button")
|
||||
.icon(material_font_icons::ADD_FONT_ICON)
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::AddItem);
|
||||
true
|
||||
})
|
||||
.min_width(0.0)
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(4))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
ListView::new()
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(5))
|
||||
.selected_indices(id)
|
||||
.margin((0.0, 16.0, 0.0, 8.0))
|
||||
.items_builder(move |bc, index| {
|
||||
let text = bc
|
||||
.get_widget(id)
|
||||
.get::<Vec<String>>("selection_list")[index]
|
||||
.clone();
|
||||
TextBlock::new()
|
||||
.margin((0.0, 0.0, 0.0, 2.0))
|
||||
.v_align("center")
|
||||
.text(text)
|
||||
.build(bc)
|
||||
})
|
||||
.count(("selection_list_count", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
// todo: wrong text width????
|
||||
TextBlock::new()
|
||||
.element("text-block")
|
||||
.id("selection")
|
||||
.max_width(120.0)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.attach(Grid::row(6))
|
||||
.text("Selected:")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
*/
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// use this only if you want to run it as web application.
|
||||
orbtk::initialize();
|
||||
//orbtk::initialize();
|
||||
|
||||
let mut application = Application::default();
|
||||
application
|
||||
.create_window()
|
||||
.bounds((100.0, 100.0, 420.0, 730.0))
|
||||
.title("OrbTk - advotracker test GUI")
|
||||
.resizeable(true)
|
||||
.root(MainView::create())
|
||||
.build();
|
||||
application.run();
|
||||
|
||||
/*
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
.title("OrbTk - advotracker test GUI")
|
||||
Window::new()
|
||||
.title("OrbTk - widgets example")
|
||||
.position((100.0, 100.0))
|
||||
//.size(600.0, 800.0)
|
||||
.size(640.0, 480.0)
|
||||
.size(468.0, 730.0)
|
||||
.resizeable(true)
|
||||
//.theme(get_theme())
|
||||
.child(MainView::create().build(ctx))
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
*/
|
||||
}
|
||||
|
||||
// helper to request MainViewState
|
||||
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
|
||||
states.get_mut(id)
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ fn generate_digit_button(
|
||||
column_span: usize,
|
||||
row: usize,
|
||||
) -> Entity {
|
||||
let mut button = Button::create()
|
||||
let mut button = Button::new()
|
||||
.class("single_content")
|
||||
.min_size(48.0, 48.0)
|
||||
.text(sight.to_string())
|
||||
@@ -166,7 +166,7 @@ fn generate_operation_button(
|
||||
column_span: usize,
|
||||
row: usize,
|
||||
) -> Entity {
|
||||
let mut button = Button::create()
|
||||
let mut button = Button::new()
|
||||
.class("single_content")
|
||||
.min_size(48.0, 48.0)
|
||||
.text(sight.to_string())
|
||||
@@ -197,37 +197,37 @@ impl Template for MainView {
|
||||
.height(336.0)
|
||||
.text("")
|
||||
.child(
|
||||
Grid::create()
|
||||
.rows(Rows::create().row(72.0).row("*").build())
|
||||
Grid::new()
|
||||
.rows(Rows::new().add(72.0).add("*").build())
|
||||
.child(
|
||||
Container::create()
|
||||
Container::new()
|
||||
.padding(8.0)
|
||||
.element("container")
|
||||
.class("header")
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
Grid::create()
|
||||
Grid::new()
|
||||
.child(
|
||||
ScrollViewer::create()
|
||||
ScrollViewer::new()
|
||||
.scroll_viewer_mode(("custom", "disabled"))
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.width(0.0)
|
||||
.height(14.0)
|
||||
.text("")
|
||||
.element("text-block")
|
||||
.id("input")
|
||||
.vertical_alignment("start")
|
||||
.v_align("start")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.element("text-block")
|
||||
.text(id)
|
||||
.vertical_alignment("end")
|
||||
.horizontal_alignment("end")
|
||||
.v_align("end")
|
||||
.h_align("end")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -235,35 +235,35 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Container::create()
|
||||
Container::new()
|
||||
.element("container")
|
||||
.class("content")
|
||||
.padding(8.0)
|
||||
.attach(Grid::row(1))
|
||||
.child(
|
||||
Grid::create()
|
||||
Grid::new()
|
||||
.columns(
|
||||
Columns::create()
|
||||
.column(48.0)
|
||||
.column(4.0)
|
||||
.column(48.0)
|
||||
.column(4.0)
|
||||
.column(48.0)
|
||||
.column(4.0)
|
||||
.column(48.0)
|
||||
Columns::new()
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::create()
|
||||
.row(48.0)
|
||||
.row(4.0)
|
||||
.row(48.0)
|
||||
.row(4.0)
|
||||
.row(48.0)
|
||||
.row(4.0)
|
||||
.row(48.0)
|
||||
.row(4.0)
|
||||
.row(48.0)
|
||||
Rows::new()
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.add(4.0)
|
||||
.add(48.0)
|
||||
.build(),
|
||||
)
|
||||
// row 0
|
||||
@@ -300,12 +300,12 @@ impl Template for MainView {
|
||||
fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - Calculator example")
|
||||
.position((100.0, 100.0))
|
||||
.size(212.0, 336.0)
|
||||
.theme(get_theme())
|
||||
.child(MainView::create().build(ctx))
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
@@ -6,13 +6,13 @@ fn main() {
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - image example")
|
||||
.position((100.0, 100.0))
|
||||
.size(800.0, 420.0)
|
||||
.child(
|
||||
ImageWidget::create()
|
||||
.image("res/orbtk-space.png")
|
||||
ImageWidget::new()
|
||||
.image("../resources/orbtk-space.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
|
||||
@@ -11,20 +11,30 @@ impl MainState {
|
||||
fn show_window(&mut self) {
|
||||
self.show_window = true;
|
||||
}
|
||||
fn disable_window(&mut self) {
|
||||
self.show_window = false;
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainState {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
|
||||
if self.show_window {
|
||||
ctx.child("button").set("enabled", false);
|
||||
ctx.child("window1_button").set("enabled", false);
|
||||
ctx.show_window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("Dialog")
|
||||
.position((120.0, 120.0))
|
||||
.size(100.0, 75.0)
|
||||
.size(120.0, 125.0)
|
||||
.child(
|
||||
Stack::create()
|
||||
.child(TextBlock::create().text("New window").margin(4.0).build(ctx))
|
||||
Stack::new()
|
||||
.child(TextBlock::new().text("I'm the new window").margin(4.0).build(ctx))
|
||||
.child(
|
||||
Button::new()
|
||||
.id("window3_button")
|
||||
.margin(4.0)
|
||||
.text("Disable me")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
@@ -39,17 +49,17 @@ widget!(MainView<MainState>);
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.child(
|
||||
Stack::create()
|
||||
.child(TextBlock::create().text("Window 1").margin(4.0).build(ctx))
|
||||
Stack::new()
|
||||
.child(TextBlock::new().text("Window 1").margin(4.0).build(ctx))
|
||||
.child(
|
||||
Button::create()
|
||||
.id("button")
|
||||
Button::new()
|
||||
.id("window1_button")
|
||||
.on_click(move |states, _| {
|
||||
states.get_mut::<MainState>(id).show_window();
|
||||
true
|
||||
})
|
||||
.margin(4.0)
|
||||
.text("Show window")
|
||||
.text("Show new child window")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -63,22 +73,22 @@ fn main() {
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - multi window example window 1")
|
||||
.position((100.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
.child(MainView::create().build(ctx))
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - multi window example window 2")
|
||||
.position((600.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
.child(
|
||||
Stack::create()
|
||||
.child(TextBlock::create().text("Window 2").margin(4.0).build(ctx))
|
||||
.child(Button::create().margin(4.0).text("Click me").build(ctx))
|
||||
Stack::new()
|
||||
.child(TextBlock::new().text("Window 2").margin(4.0).build(ctx))
|
||||
.child(Button::new().margin(4.0).text("Click me").build(ctx))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 237 KiB |
@@ -4,30 +4,46 @@ widget!(MainView);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
|
||||
let container = Container::create()
|
||||
let container = Container::new()
|
||||
.background("#dfebf5")
|
||||
.width(200.0)
|
||||
.height(200.0)
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.foreground("#3b434a")
|
||||
.text("Overlay")
|
||||
.vertical_alignment("center")
|
||||
.horizontal_alignment("center")
|
||||
.text("Overlay 1")
|
||||
.element("h2")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let container = Container::new()
|
||||
.background("#dffff5")
|
||||
.width(180.0)
|
||||
.height(180.0)
|
||||
.position((250.0, 250.0))
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.foreground("#3f3f3f")
|
||||
.text("Overlay 2")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
ctx.append_child_to_overlay(container).unwrap();
|
||||
self.name("MainView").child(
|
||||
Container::create()
|
||||
Container::new()
|
||||
.background("#e1bc21")
|
||||
.child(
|
||||
TextBlock::create()
|
||||
TextBlock::new()
|
||||
.text("MainView")
|
||||
.element("h1")
|
||||
.vertical_alignment("center")
|
||||
.horizontal_alignment("center")
|
||||
.v_align("center")
|
||||
.h_align("center")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -41,7 +57,7 @@ fn main() {
|
||||
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - overlay example")
|
||||
.position((100.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
|
||||
213
frontend/examples/policyholder_check.rs
Normal file
213
frontend/examples/policyholder_check.rs
Normal file
@@ -0,0 +1,213 @@
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::theme::DEFAULT_THEME_CSS;
|
||||
|
||||
static WIDGET_EXT: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
||||
|
||||
fn get_theme() -> ThemeValue {
|
||||
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
.extension_css(WIDGET_EXT)
|
||||
.build()
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
//ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity),
|
||||
//ValueChanged(Entity),
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
pub struct MainViewState {
|
||||
action: Option<Action>,
|
||||
}
|
||||
|
||||
impl Default for MainViewState {
|
||||
fn default() -> Self {
|
||||
MainViewState { action: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: impl Into<Option<Action>>) {
|
||||
self.action = action.into();
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
// Action::ClearText => {
|
||||
// ctx.widget().set("policynumber", String16::from(""));
|
||||
// }
|
||||
Action::EntryActivated(entity) => {
|
||||
let mut widget = ctx.get_widget(entity);
|
||||
let text = widget.get_mut::<String16>("text");
|
||||
println!("submitting {}", text);
|
||||
//text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
let widget = ctx.get_widget(entity);
|
||||
let text = widget.get::<String16>("text");
|
||||
println!("entry changed: {}", text);
|
||||
}
|
||||
// Action::ValueChanged(entity) => {
|
||||
// let val =
|
||||
// ((*ctx.get_widget(entity).get::<f64>("val")).floor() as i32).to_string();
|
||||
// ctx.child("value_text").set("text", String16::from(val));
|
||||
//}
|
||||
}
|
||||
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
|
||||
TextBlock::new()
|
||||
.text(text)
|
||||
.element("text-block")
|
||||
.class("h1")
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
widget!(
|
||||
MainView<MainViewState> {
|
||||
sum_policynumbers: usize,
|
||||
policynumber: String16,
|
||||
result: String16
|
||||
}
|
||||
);
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.name("MainView").child(
|
||||
//.result("Anzahl Versicherungsnummern: 0")
|
||||
//.result("Policyholders count: 0").sum_policynumbers(0)
|
||||
//.sum_policynumbers(0)
|
||||
Grid::new()
|
||||
//.width(200.0)
|
||||
//.height(360.0)
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(200.0)
|
||||
.add("*")
|
||||
//.add(120.0)
|
||||
.add(200.0)
|
||||
//.add("auto")
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
//.add("auto")
|
||||
//.add(150.0)
|
||||
//.add(200.0)
|
||||
.add("*")
|
||||
.add("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("policholder_check")
|
||||
.background("fafafa")
|
||||
.margin((4.0, 24.0, 4.0, 4.0))
|
||||
.min_width(80.0)
|
||||
.min_height(180.0)
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
Stack::new()
|
||||
.spacing(8.0)
|
||||
.orientation("vertical")
|
||||
.h_align("center")
|
||||
//.child(create_header(ctx, "Validation number policyholder"))
|
||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||
.child(
|
||||
TextBox::new()
|
||||
.class("text_box")
|
||||
.water_mark("Versicherungs-Nr...")
|
||||
//.text("Number policyholder", id)
|
||||
.text(("policynumber", id))
|
||||
.font_size(24.0)
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
.on_changed(move |states, entity| {
|
||||
state(id, states).action(Action::EntryChanged(entity));
|
||||
})
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.element("text-block")
|
||||
.id("result")
|
||||
.min_width(80.0)
|
||||
.max_width(180.0)
|
||||
//.text("Result:")
|
||||
.text("Ergebnis:")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx)
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_customer")
|
||||
.margin((4.0, 0.0, 0.0, 4.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("../resources/images/hiedemann_logo.png")
|
||||
//.h_align("center")
|
||||
//.v_align("bottom")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_vendor")
|
||||
.margin((4.0, 0.0, 0.0, 4.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
//.v_align("bottom")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
//.image("../resources/images/networkx_logo.jpg")
|
||||
.image("../resources/images/networkx_logo.png")
|
||||
//.h_align("center")
|
||||
//.v_align("bottom")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
) // MainView
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker example")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.position((-500.0, -100.0))
|
||||
.size(480.0, 360.0)
|
||||
.min_width(80.0)
|
||||
.min_height(180.0)
|
||||
.resizeable(true)
|
||||
//.theme(get_theme())
|
||||
.background("#fafafa")
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
// helper to request MainViewState
|
||||
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
|
||||
states.get_mut(id)
|
||||
}
|
||||
@@ -46,23 +46,23 @@ impl State for MainViewState {
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.child(
|
||||
Stack::create()
|
||||
.horizontal_alignment("center")
|
||||
Stack::new()
|
||||
.h_align("center")
|
||||
.margin((16.0, 16.0, 16.0, 16.0))
|
||||
.spacing(8.0)
|
||||
.child(
|
||||
ProgressBar::create()
|
||||
ProgressBar::new()
|
||||
.id("pgbar")
|
||||
.val(0.0)
|
||||
.width(512.0)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Stack::create()
|
||||
.horizontal_alignment("center")
|
||||
Stack::new()
|
||||
.h_align("center")
|
||||
.spacing(8.0)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.text("Progress by 25%")
|
||||
.width(256.0)
|
||||
.on_click(move |states, _| -> bool {
|
||||
@@ -74,7 +74,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.text("Reset")
|
||||
.width(256.0)
|
||||
.on_click(move |states, _| -> bool {
|
||||
@@ -86,7 +86,7 @@ impl Template for MainView {
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
Button::new()
|
||||
.text("Set to 100%")
|
||||
.width(256.0)
|
||||
.on_click(move |states, _| -> bool {
|
||||
@@ -107,13 +107,13 @@ impl Template for MainView {
|
||||
fn main() {
|
||||
Application::new()
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
Window::new()
|
||||
.title("OrbTk - ProgressBar example")
|
||||
.position((0.0, 0.0))
|
||||
.size(720.0, 576.0)
|
||||
.borderless(false)
|
||||
.resizeable(true)
|
||||
.child(MainView::create().build(ctx))
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
|
||||
@@ -21,50 +21,50 @@ pub struct MainViewState {
|
||||
|
||||
impl MainViewState {
|
||||
fn action(&mut self, action: Action) {
|
||||
self.action = Some(action);
|
||||
self.action = Some(action);
|
||||
}
|
||||
}
|
||||
|
||||
impl State for MainViewState {
|
||||
fn update(&mut self, registry: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
Action::Load => {
|
||||
// load label from settings file.
|
||||
if let Ok(global) = registry
|
||||
.get::<Settings>("settings")
|
||||
.load::<Global>("global")
|
||||
{
|
||||
ctx.widget().set("text", String16::from(global.label));
|
||||
}
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
Action::Load => {
|
||||
// load label from settings file.
|
||||
if let Ok(global) = registry
|
||||
.get::<Settings>("settings")
|
||||
.load::<Global>("global")
|
||||
{
|
||||
ctx.widget().set("text", String16::from(global.label));
|
||||
}
|
||||
|
||||
ctx.widget().set(
|
||||
"info_text",
|
||||
String16::from("Label loaded from settings file."),
|
||||
);
|
||||
}
|
||||
Action::Save => {
|
||||
// save label to settings file.
|
||||
registry
|
||||
.get_mut::<Settings>("settings")
|
||||
.save(
|
||||
"global",
|
||||
&Global {
|
||||
label: ctx.widget().get::<String16>("text").to_string(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
ctx.widget()
|
||||
.set("info_text", String16::from("Label saved to settings file."));
|
||||
}
|
||||
Action::Clear => {
|
||||
ctx.widget().set("text", String16::default());
|
||||
ctx.widget().set("info_text", String16::from(""));
|
||||
}
|
||||
}
|
||||
ctx.widget().set(
|
||||
"info_text",
|
||||
String16::from("Label loaded from settings file."),
|
||||
);
|
||||
}
|
||||
Action::Save => {
|
||||
// save label to settings file.
|
||||
registry
|
||||
.get_mut::<Settings>("settings")
|
||||
.save(
|
||||
"global",
|
||||
&Global {
|
||||
label: ctx.widget().get::<String16>("text").to_string(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
ctx.widget()
|
||||
.set("info_text", String16::from("Label saved to settings file."));
|
||||
}
|
||||
Action::Clear => {
|
||||
ctx.widget().set("text", String16::default());
|
||||
ctx.widget().set("info_text", String16::from(""));
|
||||
}
|
||||
}
|
||||
|
||||
self.action = None;
|
||||
}
|
||||
self.action = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,85 +75,85 @@ widget!(MainView<MainViewState> {
|
||||
|
||||
impl Template for MainView {
|
||||
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
|
||||
self.name("MainView").child(
|
||||
Grid::create()
|
||||
.rows(Rows::create().row(36.0).row(4.0).row("auto").build())
|
||||
.columns(
|
||||
Columns::create()
|
||||
.column(160.0)
|
||||
.column(4.0)
|
||||
.column("Auto")
|
||||
.column(4.0)
|
||||
.column("Auto")
|
||||
.column(4.0)
|
||||
.column("Auto")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
TextBox::create()
|
||||
.vertical_alignment("center")
|
||||
.text(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Load);
|
||||
true
|
||||
})
|
||||
.text("Load")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(4))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Save);
|
||||
true
|
||||
})
|
||||
.text("Save")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::create()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(6))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Clear);
|
||||
true
|
||||
})
|
||||
.text("Clear")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::create()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.text(("info_text", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
self.name("MainView").child(
|
||||
Grid::new()
|
||||
.rows(Rows::new().add(36.0).add(4.0).add("auto").build())
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(160.0)
|
||||
.add(4.0)
|
||||
.add("Auto")
|
||||
.add(4.0)
|
||||
.add("Auto")
|
||||
.add(4.0)
|
||||
.add("Auto")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.v_align("center")
|
||||
.text(id)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Load);
|
||||
true
|
||||
})
|
||||
.text("Load")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(4))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Save);
|
||||
true
|
||||
})
|
||||
.text("Save")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Button::new()
|
||||
.class("single_content")
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(6))
|
||||
.on_click(move |states, _| {
|
||||
state(id, states).action(Action::Clear);
|
||||
true
|
||||
})
|
||||
.text("Clear")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.text(("info_text", id))
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Application::from_name("orbtk-settings")
|
||||
.window(|ctx| {
|
||||
Window::create()
|
||||
.title("OrbTk - settings example")
|
||||
.position((100.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
.child(MainView::create().margin(4.0).build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
.title("OrbTk - settings example")
|
||||
.position((100.0, 100.0))
|
||||
.size(420.0, 730.0)
|
||||
.child(MainView::new().margin(4.0).build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
||||
// helper to request MainViewState
|
||||
|
||||
@@ -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();
|
||||
|
||||
BIN
frontend/resources/images/customer_background.jpg
Executable file
BIN
frontend/resources/images/customer_background.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
1
frontend/resources/images/customer_logo.png
Symbolic link
1
frontend/resources/images/customer_logo.png
Symbolic link
@@ -0,0 +1 @@
|
||||
hiedemann_logo.png
|
||||
BIN
frontend/resources/images/hiedemann_logo.png
Normal file
BIN
frontend/resources/images/hiedemann_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
BIN
frontend/resources/images/networkx_logo.png
Normal file
BIN
frontend/resources/images/networkx_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
25
frontend/resources/policyholder-check.css
Normal file
25
frontend/resources/policyholder-check.css
Normal file
@@ -0,0 +1,25 @@
|
||||
* {
|
||||
font-size: 24;
|
||||
}
|
||||
|
||||
lynch {
|
||||
background: #647b91;
|
||||
}
|
||||
|
||||
bluebayoux {
|
||||
background: #516475;
|
||||
}
|
||||
|
||||
linkwater {
|
||||
background: #dfebf5;
|
||||
color: #3b434a;
|
||||
}
|
||||
|
||||
light-text {
|
||||
color: #dfebf5;
|
||||
}
|
||||
|
||||
goldendream {
|
||||
background: #efd035;
|
||||
color: #3b434a;
|
||||
}
|
||||
53
frontend/resources/stylesheets/policyholder-check.css
Normal file
53
frontend/resources/stylesheets/policyholder-check.css
Normal file
@@ -0,0 +1,53 @@
|
||||
* {
|
||||
font-size: 24;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.background {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.content {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
text-box {
|
||||
color: #5b0f22;
|
||||
}
|
||||
|
||||
text-block {
|
||||
color: #5b0f22;
|
||||
}
|
||||
|
||||
light-text {
|
||||
color: #dfebf5;
|
||||
}
|
||||
|
||||
|
||||
/* // Hiedemann blue */
|
||||
/* color: #a5b3bf; */
|
||||
/* color: #4d4c4c; */
|
||||
|
||||
/* // Hiedemann red */
|
||||
/* color: #5b0f22; */
|
||||
|
||||
/* // Hiedemann darkgrey */
|
||||
/* color: #879488; */
|
||||
|
||||
/* // Hiedemann grey */
|
||||
/* color: ##b6c3b7; */
|
||||
|
||||
|
||||
|
||||
/* // Qt Green */
|
||||
/* color: #41cd52; */
|
||||
|
||||
/* // lightgrey */
|
||||
/* color: #f0f0f0; */
|
||||
|
||||
/* Accent=#5b0f22 */
|
||||
/* Foreground=#000000 */
|
||||
/* Background=#f0f0f0 */
|
||||
Reference in New Issue
Block a user