frontend: the advoware GUI

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-06-12 16:39:45 +02:00
parent 3837183199
commit 51b73d0978
68 changed files with 3499 additions and 0 deletions

25
frontend/Cargo.toml Normal file
View File

@@ -0,0 +1,25 @@
[package]
name = "advotracker_frontend"
version = "0.1.0"
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice\n"
readme = "README.md"
license = "(0BSD OR MIT)"
edition = "2018"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winuser"] }
#diesel = { version = "1.4", features = [ "postgres", "sqlite" ] }
[dependencies]
#orbtk = "0.3.1-alpha3"
orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
[dev-dependencies]
#euc = "0.4.2"
#vek = "0.9.10"
[features]
# no features by default
default = []
light-theme = []

View File

@@ -0,0 +1,5 @@
[advotracker.conf]
mode = interative

View File

@@ -0,0 +1,20 @@
# OrbTk examples
[![Build and test](https://github.com/redox-os/orbtk/workflows/build/badge.svg)](https://github.com/redox-os/orbtk/actions)
![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
* calculator: calculator example
* canvas: use third party render library in canvas
* clear: interaction between widgets
* grid: grid layout example
* image: image widget
* minimal: minimal example
* multi_window: multi window example
* overlay: draw widgets on the top
* settings: use registry and settings service (load / save)
* stack: stack layout example
* widgets: widget overview
## License
Licensed under MIT license ([LICENSE](../LICENSE)).

View File

@@ -0,0 +1,240 @@
use std::{cell::Cell, 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 {
IncrementCounter,
}
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());
}
}
impl Default for MainViewState {
fn default() -> Self {
MainViewState {
counter: Cell::new(0),
action: Cell::new(None),
}
}
}
impl State for MainViewState {
fn update(&self, ctx: &mut Context<'_>) {
if let Some(action) = self.action.get() {
match action {
Action::IncrementCounter => {
self.counter.set(self.counter.get() + 1);
ctx.widget().set(
"result",
String16::from(format!("Button count: {}", self.counter.get())),
);
}
}
self.action.set(None);
}
}
}
fn create_header(ctx: &mut BuildContext, text: &str) -> Entity {
TextBlock::create()
.text(text)
.selector(Selector::new().with("text-block").class("h1"))
.build(ctx)
}
widget!(
MainView<MainViewState> {
selected_indices: SelectedIndices,
text_harm: String16,
result: String16
}
);
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
let state = self.clone_state();
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),
)
.build(ctx),
)
*/
}
}
fn main() {
// use this only if you want to run it as web application.
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")
.position((100.0, 100.0))
//.size(600.0, 800.0)
.size(640.0, 480.0)
.resizeable(true)
//.theme(get_theme())
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
*/
}

View File

@@ -0,0 +1,32 @@
.header {
background: #444e55;
}
.content {
background: #3b434a;
}
text_box {
background: transparent;
border-width: 0;
color: #9dafbf;
font-size: 16;
}
#input {
font-size: 16;
}
text-block {
font-size: 42;
color: #dfebf5;
}
#input {
background: transparent;
}
button {
border-radius: 1;
font-size: 20;
}

View File

@@ -0,0 +1,15 @@
.header {
background: #ffffff;
}
.content {
background: #fafafa;
}
text_box {
color: #4d4c4c;
}
text-block {
color: #4d4c4c;
}

View File

@@ -0,0 +1,317 @@
use orbtk::prelude::*;
use orbtk::theme::DEFAULT_THEME_CSS;
static DARK_EXT: &'static str = include_str!("../resources/calculator-dark.css");
#[cfg(feature = "light-theme")]
static LIGHT_EXT: &'static str = include_str!("../resources/calculator-light.css");
#[cfg(not(feature = "light-theme"))]
fn get_theme() -> ThemeValue {
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
.extension_css(DARK_EXT)
.build()
}
#[cfg(feature = "light-theme")]
fn get_theme() -> ThemeValue {
ThemeValue::create()
.extension_css(DARK_EXT)
.extension_css(LIGHT_EXT)
.build()
}
#[derive(Debug, Copy, Clone)]
enum Action {
Digit(char),
Operator(char),
}
#[derive(Default, AsAny)]
pub struct MainViewState {
input: String,
operator: Option<char>,
left_side: Option<f64>,
right_side: Option<f64>,
action: Option<Action>,
}
impl MainViewState {
fn action(&mut self, action: impl Into<Option<Action>>) {
self.action = action.into();
}
fn calculate(&mut self, ctx: &mut Context) {
let mut result = 0.0;
if let Some(operator) = self.operator {
if let Some(left_side) = self.left_side {
if let Some(right_side) = self.right_side {
match operator {
'+' => {
result = left_side + right_side;
}
'-' => {
result = left_side - right_side;
}
'*' => {
result = left_side * right_side;
}
'/' => {
result = left_side / right_side;
}
_ => {}
}
}
}
}
if result % 1.0 == 0.0 {
ctx.widget()
.set("text", String16::from(format!("{}", result)));
} else {
ctx.widget()
.set("text", String16::from(format!("{:.8}", result)));
}
self.left_side = Some(result);
self.right_side = None;
}
}
impl State for MainViewState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
if let Some(action) = self.action {
match action {
Action::Digit(digit) => {
self.input.push(digit);
ctx.child("input").get_mut::<String16>("text").push(digit);
}
Action::Operator(operator) => match operator {
'C' => {
self.input.clear();
self.left_side = None;
self.operator = None;
self.right_side = None;
ctx.widget().get_mut::<String16>("text").clear();
ctx.child("input").get_mut::<String16>("text").clear()
}
'=' => {
self.right_side = Some(self.input.parse().unwrap_or(0.0));
self.calculate(ctx);
self.input.clear();
self.left_side = None;
self.operator = None;
self.right_side = None;
ctx.child("input").get_mut::<String16>("text").clear()
}
_ => {
if self.input.is_empty() {
return;
}
if self.left_side.is_none() {
self.left_side = Some(self.input.parse().unwrap_or(0.0));
} else {
self.right_side = Some(self.input.parse().unwrap_or(0.0));
self.calculate(ctx);
}
ctx.child("input")
.get_mut::<String16>("text")
.push(operator);
self.input.clear();
self.operator = Some(operator);
}
},
}
self.action = None;
}
}
}
fn generate_digit_button(
ctx: &mut BuildContext,
id: Entity,
sight: char,
primary: bool,
column: usize,
column_span: usize,
row: usize,
) -> Entity {
let mut button = Button::create()
.class("single_content")
.min_size(48.0, 48.0)
.text(sight.to_string())
.on_click(move |states, _| -> bool {
state(id, states).action(Action::Digit(sight));
true
})
.attach(Grid::column(column))
.attach(Grid::row(row))
.attach(Grid::column_span(column_span));
if primary {
button = button.class("primary");
}
button.build(ctx)
}
fn generate_operation_button(
ctx: &mut BuildContext,
id: Entity,
sight: char,
primary: bool,
column: usize,
column_span: usize,
row: usize,
) -> Entity {
let mut button = Button::create()
.class("single_content")
.min_size(48.0, 48.0)
.text(sight.to_string())
.class("square")
.on_click(move |states, _| -> bool {
state(id, states).action(Action::Operator(sight));
true
})
.attach(Grid::column(column))
.attach(Grid::column_span(column_span))
.attach(Grid::row(row));
if primary {
button = button.class("primary");
}
button.build(ctx)
}
widget!(MainView<MainViewState> {
text: String16
});
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView")
.width(212.0)
.height(336.0)
.text("")
.child(
Grid::create()
.rows(Rows::create().row(72.0).row("*").build())
.child(
Container::create()
.padding(8.0)
.element("container")
.class("header")
.attach(Grid::row(0))
.child(
Grid::create()
.child(
ScrollViewer::create()
.scroll_viewer_mode(("custom", "disabled"))
.child(
TextBlock::create()
.width(0.0)
.height(14.0)
.text("")
.element("text-block")
.id("input")
.vertical_alignment("start")
.build(ctx),
)
.build(ctx),
)
.child(
TextBlock::create()
.element("text-block")
.text(id)
.vertical_alignment("end")
.horizontal_alignment("end")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
.child(
Container::create()
.element("container")
.class("content")
.padding(8.0)
.attach(Grid::row(1))
.child(
Grid::create()
.columns(
Columns::create()
.column(48.0)
.column(4.0)
.column(48.0)
.column(4.0)
.column(48.0)
.column(4.0)
.column(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)
.build(),
)
// row 0
.child(generate_operation_button(ctx, id, 'C', false, 0, 5, 0))
.child(generate_operation_button(ctx, id, '/', true, 6, 3, 0))
// row 2
.child(generate_digit_button(ctx, id, '7', false, 0, 1, 2))
.child(generate_digit_button(ctx, id, '8', false, 2, 1, 2))
.child(generate_digit_button(ctx, id, '9', false, 4, 1, 2))
.child(generate_operation_button(ctx, id, '*', true, 6, 1, 2))
// row 4
.child(generate_digit_button(ctx, id, '4', false, 0, 1, 4))
.child(generate_digit_button(ctx, id, '5', false, 2, 1, 4))
.child(generate_digit_button(ctx, id, '6', false, 4, 1, 4))
.child(generate_operation_button(ctx, id, '-', true, 6, 1, 4))
// row 6
.child(generate_digit_button(ctx, id, '1', false, 0, 1, 6))
.child(generate_digit_button(ctx, id, '2', false, 2, 1, 6))
.child(generate_digit_button(ctx, id, '3', false, 4, 1, 6))
.child(generate_operation_button(ctx, id, '+', true, 6, 1, 6))
// row 8
.child(generate_digit_button(ctx, id, '0', false, 0, 3, 8))
.child(generate_digit_button(ctx, id, '.', false, 4, 1, 8))
.child(generate_operation_button(ctx, id, '=', true, 6, 1, 8))
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - Calculator example")
.position((100.0, 100.0))
.size(212.0, 336.0)
.theme(get_theme())
.child(MainView::create().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)
}

279
frontend/examples/canvas.rs Normal file
View File

@@ -0,0 +1,279 @@
use orbtk::{prelude::*, render::platform::RenderContext2D, utils};
use std::cell::Cell;
use euc::{buffer::Buffer2d, rasterizer, Pipeline};
use vek::*;
// Cube is copied from euc spinning_cube example
// https://github.com/zesterer/euc/blob/master/examples/spinning_cube.rs
struct Cube<'a> {
mvp: Mat4<f32>,
positions: &'a [Vec4<f32>],
}
impl<'a> Pipeline for Cube<'a> {
type Vertex = (usize, Rgba<f32>);
type VsOut = Rgba<f32>;
type Pixel = u32;
#[inline(always)]
fn vert(&self, (v_index, v_color): &Self::Vertex) -> ([f32; 4], Self::VsOut) {
((self.mvp * self.positions[*v_index]).into_array(), *v_color)
}
#[inline(always)]
fn frag(&self, v_color: &Self::VsOut) -> Self::Pixel {
let bytes = v_color.map(|e| (e * 255.0) as u8).into_array();
(bytes[2] as u32) << 0
| (bytes[1] as u32) << 8
| (bytes[0] as u32) << 16
| (bytes[3] as u32) << 24
}
}
#[derive(Clone, Default, PartialEq, Pipeline)]
struct CubePipeline {
spin: Cell<f32>,
}
impl render::RenderPipeline for CubePipeline {
fn draw(&self, render_target: &mut render::RenderTarget) {
let mut color = Buffer2d::new(
[
render_target.width() as usize,
render_target.height() as usize,
],
0,
);
let mut depth = Buffer2d::new(
[
render_target.width() as usize,
render_target.height() as usize,
],
1.0,
);
let mvp = Mat4::perspective_fov_rh_no(
1.3,
render_target.width() as f32,
render_target.height() as f32,
0.01,
100.0,
) * Mat4::translation_3d(Vec3::new(0.0, 0.0, -2.0))
* Mat4::<f32>::scaling_3d(0.4)
* Mat4::rotation_x((self.spin.get() * 0.002) * 8.0)
* Mat4::rotation_y((self.spin.get() as f32 * 0.004).cos() * 4.0)
* Mat4::rotation_z((self.spin.get() as f32 * 0.008).sin() * 2.0);
Cube {
mvp,
positions: &[
Vec4::new(-1.0, -1.0, -1.0, 1.0), // 0
Vec4::new(-1.0, -1.0, 1.0, 1.0), // 1
Vec4::new(-1.0, 1.0, -1.0, 1.0), // 2
Vec4::new(-1.0, 1.0, 1.0, 1.0), // 3
Vec4::new(1.0, -1.0, -1.0, 1.0), // 4
Vec4::new(1.0, -1.0, 1.0, 1.0), // 5
Vec4::new(1.0, 1.0, -1.0, 1.0), // 6
Vec4::new(1.0, 1.0, 1.0, 1.0), // 7
],
}
.draw::<rasterizer::Triangles<_, rasterizer::BackfaceCullingEnabled>, _>(
&[
// -x
(0, Rgba::green()),
(3, Rgba::blue()),
(2, Rgba::red()),
(0, Rgba::green()),
(1, Rgba::red()),
(3, Rgba::blue()),
// +x
(7, Rgba::blue()),
(4, Rgba::green()),
(6, Rgba::red()),
(5, Rgba::red()),
(4, Rgba::green()),
(7, Rgba::blue()),
// -y
(5, Rgba::blue()),
(0, Rgba::red()),
(4, Rgba::green()),
(1, Rgba::green()),
(0, Rgba::red()),
(5, Rgba::blue()),
// +y
(2, Rgba::red()),
(7, Rgba::blue()),
(6, Rgba::green()),
(2, Rgba::red()),
(3, Rgba::green()),
(7, Rgba::blue()),
// -z
(0, Rgba::red()),
(6, Rgba::green()),
(4, Rgba::blue()),
(0, Rgba::red()),
(2, Rgba::blue()),
(6, Rgba::green()),
// +z
(7, Rgba::green()),
(1, Rgba::red()),
(5, Rgba::blue()),
(3, Rgba::blue()),
(1, Rgba::red()),
(7, Rgba::green()),
],
&mut color,
Some(&mut depth),
);
render_target.draw(color.as_ref());
}
}
// OrbTk 2D drawing
#[derive(Clone, Default, PartialEq, Pipeline)]
struct Graphic2DPipeline;
impl render::RenderPipeline for Graphic2DPipeline {
fn draw(&self, render_target: &mut render::RenderTarget) {
let mut render_context =
RenderContext2D::new(render_target.width(), render_target.height());
let width = 120.0;
let height = 120.0;
let x = (render_target.width() - width) / 2.0;
let y = (render_target.height() - height) / 2.0;
// render_context.set_fill_style(utils::Brush::SolidColor(Color::from("#000000")));
render_context.set_fill_style(utils::Brush::LinearGradient {
start: Point::new(x, y),
end: Point::new(x + width, y + height),
stops: vec![
LinearGradientStop {
position: 0.0,
color: Color::from("#0021EB"),
},
LinearGradientStop {
position: 0.5,
color: Color::from("#CE2F24"),
},
LinearGradientStop {
position: 1.0,
color: Color::from("#70EF49"),
},
],
});
render_context.fill_rect(x, y, width, height);
// render_target.draw(render_context.data());
}
}
#[derive(Default, AsAny)]
pub struct MainViewState {
cube_spin: f32,
}
impl MainViewState {
fn spin(&mut self) {
self.cube_spin += 32.0;
}
}
impl State for MainViewState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
if let Some(cube) = ctx
.widget()
.get_mut::<RenderPipeline>("render_pipeline")
.0
.as_any()
.downcast_ref::<CubePipeline>()
{
cube.spin.set(self.cube_spin);
}
}
}
widget!(
MainView<MainViewState> {
render_pipeline: RenderPipeline
}
);
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView")
.render_pipeline(RenderPipeline(Box::new(CubePipeline::default())))
.child(
Grid::create()
.rows(
Rows::create()
.row("auto")
.row("*")
.row("auto")
.row("*")
.build(),
)
.child(
TextBlock::create()
.attach(Grid::row(0))
.text("Canvas (render with euc crate)")
.element("text-block")
.class("h1")
.margin(4.0)
.build(ctx),
)
.child(
Canvas::create()
.attach(Grid::row(1))
.render_pipeline(id)
.build(ctx),
)
.child(
Button::create()
.text("spin cube")
.vertical_alignment("end")
.attach(Grid::row(1))
.margin(4.0)
.on_click(move |states, _| {
states.get_mut::<MainViewState>(id).spin();
true
})
.build(ctx),
)
.child(
TextBlock::create()
.attach(Grid::row(2))
.text("Canvas (render with OrbTk)")
.element("text-block")
.class("h1")
.margin(4.0)
.build(ctx),
)
.child(
Canvas::create()
.attach(Grid::row(3))
.render_pipeline(RenderPipeline(Box::new(Graphic2DPipeline::default())))
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - canvas example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,67 @@
use orbtk::prelude::*;
#[derive(Default, AsAny)]
pub struct MainViewState {
clear: bool,
}
impl MainViewState {
// Sets an action the state
fn clear(&mut self) {
self.clear = true;
}
}
impl State for MainViewState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
if self.clear {
// Clears the text property of MainView and because
// of the sharing also the text of the TextBox.
ctx.widget().set("text", String16::from(""));
self.clear = false;
}
}
}
widget!(MainView<MainViewState> {
text: String16
});
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Stack::create()
.orientation("horizontal")
// By injecting the id of the parent the text property
// is shared between the MainView and the TextBox. This
// means both references the same String16 object.
.child(TextBox::create().height(32.0).text(id).build(ctx))
.child(
Button::create()
.margin((8.0, 0.0, 0.0, 0.0))
// mouse click event handler
.on_click(move |states, _| {
// Calls clear of the state of MainView
states.get_mut::<MainViewState>(id).clear();
true
})
.text("Clear")
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(MainView::create().margin(4.0).build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,111 @@
use orbtk::api::widget::StatesContext;
use orbtk::prelude::*;
#[derive(Debug)]
pub enum Event {
Increment(Entity),
}
#[derive(AsAny, Default)]
pub struct AppState {
events: VecDeque<Event>,
pub notes: Entity,
count: u32,
}
//rbtk_api::widget::states_context::StatesContext<'_>
#[derive(Debug, Copy, Clone)]
enum Action {
Increment(usize),
}
#[derive(Default, AsAny)]
pub struct MainViewState {
num: usize,
action: Option<Action>,
}
impl MainViewState {
fn action(&mut self, action: impl Into<Option<Action>>) {
self.action = action.into();
}
}
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView")
.counter(0)
.result("Button count: 0")
.child(
Button::create()
.selector(Selector::from("button").id("btn"))
.min_size(100.0, 50.0)
.text(("result", id))
.on_click(move |states, _| -> bool {
state(id, states).action(Action::Increment(10));
true
})
.build(ctx),
)
}
}
impl State for MainViewState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
if let Some(action) = self.action {
match action {
Action::Increment(digit) => {
*ctx.widget().get_mut::<usize>("counter") += digit as usize;
let counter = *ctx.widget().get::<usize>("counter");
ctx.widget().set(
"result",
String16::from(format!("Button count: {}", counter)),
);
}
_ => {}
}
// Is it possible to get rid of this line ?
self.action = None;
}
if let Some(event) = self.events.pop_front() {
match event {
// Create and append the note to the UI.
Event::Increment(entity) => {
if let Some(copy) = Self::fetch_text(ctx, entity) {
self.append_note(ctx, copy);
let count = self.count + 1;
self.count = count;
if count == 1 {
ctx.widget().set::<f64>("spacing", 12.0);
}
}
}
}
}
}
}
widget!(MainView<MainViewState> {
age:i32,
counter:usize,
result: String16
});
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - counter example")
.position((100.0, 100.0))
.size(400.0, 400.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
states.get_mut(id)
}

View 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;
}

108
frontend/examples/grid.rs Normal file
View File

@@ -0,0 +1,108 @@
use orbtk::prelude::*;
use orbtk::theme::DEFAULT_THEME_CSS;
static CSS_EXT: &'static str = include_str!("../resources/grid.css");
fn get_theme() -> ThemeValue {
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
.extension_css(CSS_EXT)
.build()
}
widget!(MainView);
impl Template for MainView {
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Grid::create()
.columns(
Columns::create()
.column("*")
.column("auto")
.column(50.0)
.build(),
)
.rows(Rows::create().row("*").row("*").build())
.child(
Grid::create()
.element("lynch")
.margin((10.0, 0.0, 0.0, 4.0))
.attach(Grid::column(0))
.child(
TextBlock::create()
.text("(0,0)")
.element("light-text")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.element("bluebayoux")
.margin(10.0)
.constraint(Constraint::create().width(150.0).build())
.attach(Grid::column(1))
.child(
TextBlock::create()
.text("(1,0)")
.element("white")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.element("linkwater")
.attach(Grid::column(2))
.child(
TextBlock::create()
.text("(2,0)")
.element("linkwater")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.element("goldendream")
.attach(Grid::column(0))
.attach(Grid::row(1))
.attach(Grid::column_span(3))
.child(
TextBlock::create()
.text("(0,1) - ColumnSpan 3")
.element("goldendream")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - grid example")
.position((400.0, 400.0))
.size(420.0, 730.0)
.theme(get_theme())
.resizeable(true)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,154 @@
use orbtk::prelude::*;
use orbtk::theme::DEFAULT_THEME_CSS;
static CSS_EXT: &'static str = include_str!("../resources/stylesheets/grid.css");
fn get_theme() -> ThemeValue {
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
.extension_css(CSS_EXT)
.build()
}
widget!(MainView);
impl Template for MainView {
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Grid::create()
.columns(
Columns::create()
.column("*")
.column("auto")
.column(90.0)
.build(),
)
.rows(Rows::create().row("*").row("*").row("*").build())
.child(
Grid::create()
.selector("hiedemann")
.margin((30.0, 25.0, 0.0, 20.0))
.constraint(Constraint::create().width(80.0).build())
.attach(Grid::column(0))
.child(
TextBlock::create()
.text("Grid\n(0,0)")
.selector("hiedemann")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.selector("bluebayoux")
.margin(10.0)
.constraint(Constraint::create().width(150.0).build())
.attach(Grid::column(1))
.child(
TextBlock::create()
.text("Grid\n(1,0)")
.selector("white")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.selector("linkwater")
.attach(Grid::column(2))
.child(
TextBlock::create()
.text("Grid\n(2,0)")
.selector("linkwater")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.selector("goldendream")
.attach(Grid::column(0))
.attach(Grid::row(1))
.attach(Grid::column_span(3))
.child(
TextBlock::create()
.text("Grid (0,1) - ColumnSpan 3")
.selector("goldendream")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.selector("bluebayoux")
.margin(10.0)
.constraint(Constraint::create().width(200.0).build())
.attach(Grid::column(0))
.attach(Grid::row(2))
.child(
TextBlock::create()
.text("Row 2")
.selector("white")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.child(
TextBlock::create()
.text("(0,1)")
.selector("white")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
/*.child(
Grid::create()
.selector("hiedemann")
.attach(Grid::column(1))
.attach(Grid::row(2))
//.attach(Grid::column_span(2))
.margin((30.0, 25.0, 0.0, 20.0))
.attach(Grid::column(0))
.child(
TextBlock::create()
.text("(0,2)")
//.selector("light-text")
.selector("hiedemann")
.horizontal_alignment("center")
.vertical_alignment("center")
.build(ctx),
)
.build(ctx),
)
*/
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
//orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - grid example")
.position((100.0, 10.0))
.size(420.0, 530.0)
.theme(get_theme())
.resizeable(true)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,21 @@
use orbtk::prelude::*;
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - image example")
.position((100.0, 100.0))
.size(800.0, 420.0)
.child(
ImageWidget::create()
.image("res/orbtk-space.png")
.build(ctx),
)
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,27 @@
use orbtk::prelude::*;
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - image example")
.position((100.0, 100.0))
.size(610.0, 610.0)
.resizeable(true)
.child(
ImageWidget::create()
.image("resources/images/advotracker.jpg")
.margin(10.0)
.vertical_alignment("Center")
.horizontal_alignment("Center")
.size(600.0, 600.0)
.clip(true)
.build(ctx),
)
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,86 @@
// // This examples shows how you could send messages between different widgets / views.
// use orbtk::*;
// mod sender {
// use orbtk::*;
// use std::{cell::Cell, rc::Rc};
// #[derive(Default)]
// struct SenderState {
// send_message: Cell<bool>,
// }
// impl State for SenderState {
// fn update(&mut self, ctx: &mut Context<'_>) {
// if self.send_message.get() {
// ctx.send_message("receiver_view", StringMessage::from("Hello from sender."));
// }
// }
// }
// widget!(SenderView);
// impl Widget for SenderView {
// fn create() -> Self {
// let state = Rc::new(SenderState::default());
// let send_state = state.clone();
// SenderView::new()
// .debug_name("SenderView")
// .child(
// Button::create()
// .text("Send message")
// .on_click(move |_| -> bool {
// send_state.send_message.set(true);
// true
// }),
// )
// .state(state)
// }
// }
// }
// mod receiver {
// use super::sender;
// use orbtk::*;
// use std::rc::Rc;
// struct ReceiverState;
// impl State for ReceiverState {
// fn receive_messages(&self, _context: &mut Context<'_>, messages: &Vec<MessageBox>) {
// for message in messages {
// if let Ok(message) = message.downcast_ref::<StringMessage>() {
// println!("Message received: {}", message.0);
// }
// }
// }
// }
// widget!(ReceiverView);
// impl Widget for ReceiverView {
// fn create() -> Self {
// ReceiverView::new()
// .debug_name("ReceiverView")
// .child(Container::create().child(sender::SenderView::create()))
// .attach(Selector::default().id("receiver_view"))
// .state(Rc::new(ReceiverState))
// }
// }
// }
// fn main() {
// let mut application = Application::default();
// application
// .create_window()
// .bounds((100.0, 100.0, 420.0, 730.0))
// .title("OrbTk - minimal example")
// .root(receiver::ReceiverView::create())
// .debug_flag(true)
// .build();
// application.run();
// }
fn main() {}

View File

@@ -0,0 +1,17 @@
use orbtk::prelude::*;
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(TextBlock::create().text("OrbTk").margin(4.0).build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,17 @@
use orbtk::prelude::*;
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(TextBlock::create().text("OrbTk").margin(4.0).build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,87 @@
/// mutli window will not work properly on web now. But it will be fixed.
use orbtk::prelude::*;
#[derive(AsAny, Default)]
struct MainState {
show_window: bool,
}
impl MainState {
fn show_window(&mut self) {
self.show_window = true;
}
}
impl State for MainState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
if self.show_window {
ctx.child("button").set("enabled", false);
ctx.show_window(|ctx| {
Window::create()
.title("Dialog")
.position((120.0, 120.0))
.size(100.0, 75.0)
.child(
Stack::create()
.child(TextBlock::create().text("New window").margin(4.0).build(ctx))
.build(ctx),
)
.build(ctx)
});
self.show_window = false;
}
}
}
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))
.child(
Button::create()
.id("button")
.on_click(move |states, _| {
states.get_mut::<MainState>(id).show_window();
true
})
.margin(4.0)
.text("Show window")
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - multi window example window 1")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.window(|ctx| {
Window::create()
.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))
.build(ctx),
)
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,43 @@
use orbtk::prelude::*;
widget!(MainView);
impl Template for MainView {
fn template(self, _id: Entity, ctx: &mut BuildContext) -> Self {
self.child(
Stack::create()
.spacing(8.0)
.orientation("vertical")
.horizontal_alignment("center")
.child(
TextBlock::create()
.text("Tyre pressure")
.font_size(20.0)
.build(ctx),
)
.child(
NumericBox::create()
.max(123.0)
.step(0.123)
.val(0.123)
.build(ctx),
)
.child(Button::create().text("Blow air").build(ctx))
.build(ctx),
)
}
}
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - NumericBox example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.resizeable(true)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

View File

@@ -0,0 +1,52 @@
use orbtk::prelude::*;
widget!(MainView);
impl Template for MainView {
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
let container = Container::create()
.background("#dfebf5")
.width(200.0)
.height(200.0)
.child(
TextBlock::create()
.foreground("#3b434a")
.text("Overlay")
.vertical_alignment("center")
.horizontal_alignment("center")
.build(ctx),
)
.build(ctx);
ctx.append_child_to_overlay(container).unwrap();
self.name("MainView").child(
Container::create()
.background("#e1bc21")
.child(
TextBlock::create()
.text("MainView")
.element("h1")
.vertical_alignment("center")
.horizontal_alignment("center")
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - overlay example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,120 @@
use orbtk::prelude::*;
#[derive(Copy, Clone)]
enum ProgressEvent {
Advance(f64),
Reset,
SetToFull,
}
#[derive(Default, AsAny)]
struct MainViewState {
action: Option<ProgressEvent>,
}
widget!(MainView<MainViewState>);
impl MainViewState {
fn action(&mut self, action: impl Into<Option<ProgressEvent>>) {
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 {
ProgressEvent::Advance(amount) => {
let old_width = ctx.child("pgbar").clone_or_default::<f64>("val");
let new_width = old_width + amount;
// Set the ProgressBar's val property to the calculated percentage
// (whereas 0.0 means 0 %, and 1.0 means 100 %) to advance the progress
ctx.child("pgbar").set::<f64>("val", new_width);
}
ProgressEvent::Reset => {
ctx.child("pgbar").set::<f64>("val", 0.0);
}
ProgressEvent::SetToFull => {
ctx.child("pgbar").set::<f64>("val", 1.0);
}
}
self.action = None;
}
}
}
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.child(
Stack::create()
.horizontal_alignment("center")
.margin((16.0, 16.0, 16.0, 16.0))
.spacing(8.0)
.child(
ProgressBar::create()
.id("pgbar")
.val(0.0)
.width(512.0)
.build(ctx),
)
.child(
Stack::create()
.horizontal_alignment("center")
.spacing(8.0)
.child(
Button::create()
.text("Progress by 25%")
.width(256.0)
.on_click(move |states, _| -> bool {
states
.get_mut::<MainViewState>(id)
.action(ProgressEvent::Advance(0.25));
true
})
.build(ctx),
)
.child(
Button::create()
.text("Reset")
.width(256.0)
.on_click(move |states, _| -> bool {
states
.get_mut::<MainViewState>(id)
.action(ProgressEvent::Reset);
true
})
.build(ctx),
)
.child(
Button::create()
.text("Set to 100%")
.width(256.0)
.on_click(move |states, _| -> bool {
states
.get_mut::<MainViewState>(id)
.action(ProgressEvent::SetToFull);
true
})
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - ProgressBar example")
.position((0.0, 0.0))
.size(720.0, 576.0)
.borderless(false)
.resizeable(true)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,162 @@
use serde_derive::{Deserialize, Serialize};
use orbtk::prelude::*;
#[derive(Copy, Clone, PartialEq)]
enum Action {
Load,
Save,
Clear,
}
#[derive(Default, Clone, Serialize, Deserialize)]
pub struct Global {
pub label: String,
}
#[derive(Default, AsAny)]
pub struct MainViewState {
action: Option<Action>,
}
impl MainViewState {
fn action(&mut self, action: 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));
}
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;
}
}
}
widget!(MainView<MainViewState> {
text: String16,
info_text: String16
});
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),
)
}
}
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();
}
// helper to request MainViewState
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
states.get_mut(id)
}

112
frontend/examples/stack.rs Normal file
View File

@@ -0,0 +1,112 @@
use orbtk::prelude::*;
widget!(MainView);
impl Template for MainView {
fn template(self, _: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Stack::create()
.child(
TextBlock::create()
.margin((0.0, 0.0, 0.0, 8.0))
.text("Stack vertical")
.element("h1")
.build(ctx),
)
.child(
Stack::create()
.spacing(4.0)
.child(
Button::create()
.class("single_content")
.text("left")
.horizontal_alignment("start")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.text("center")
.horizontal_alignment("center")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.text("stretch")
.horizontal_alignment("stretch")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.text("right")
.horizontal_alignment("end")
.build(ctx),
)
.build(ctx),
)
.child(
TextBlock::create()
.margin((0.0, 0.0, 0.0, 8.0))
.text("Stack horizontal")
.element("h1")
.build(ctx),
)
.child(
Stack::create()
.orientation("horizontal")
.spacing(4.0)
.height(100.0)
.child(
Button::create()
.class("single_content")
.text("top")
.vertical_alignment("start")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.text("center")
.vertical_alignment("center")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.height(0.0)
.text("stretch")
.vertical_alignment("stretch")
.build(ctx),
)
.child(
Button::create()
.class("single_content")
.text("bottom")
.vertical_alignment("end")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - stack example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.resizeable(true)
.child(MainView::create().margin(4.0).build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,68 @@
mod state;
use self::state::{AppState, Event};
use orbtk::prelude::*;
widget! {
MainView<AppState> {
orientation: Orientation,
spacing: f64
}
}
impl Template for MainView {
fn template(mut self, id: Entity, ctx: &mut BuildContext) -> Self {
let entry = TextBox::create()
.vertical_alignment(Alignment::End)
.on_activate(move |ctxt, entity| {
ctxt.get_mut::<AppState>(id).send(Event::Create(entity));
})
.build(ctx);
let notes = Stack::create()
.orientation(Orientation::Vertical)
.spacing(4)
.build(ctx);
self.state.notes = notes;
let scroll_viewer = ScrollViewer::create()
.scroll_viewer_mode(("disabled", "auto"))
.child(notes)
.build(ctx);
self.name("main-view")
.orientation(Orientation::Vertical)
.margin(4)
.child(
Container::create()
.child(scroll_viewer)
.child(
ScrollIndicator::create()
.padding(2.0)
.scroll_offset(scroll_viewer)
.build(ctx),
)
.build(ctx)
)
.child(entry)
}
fn layout(&self) -> Box<dyn Layout> {
Box::new(StackLayout::new())
}
}
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("Orbital To Do")
.position((500.0, 500.0))
.size(400.0, 400.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,92 @@
use orbtk::prelude::*;
use std::collections::VecDeque;
#[derive(Debug)]
pub enum Event {
Create(Entity),
Delete(Entity),
}
#[derive(AsAny, Default)]
pub struct AppState {
events: VecDeque<Event>,
pub notes: Entity,
count: u32,
}
impl AppState {
fn append_note(&self, ctx: &mut Context, copy: String) {
let id = ctx.entity;
let bctx = &mut ctx.build_context();
let text = TextBox::create().text(copy);
let container = Stack::create()
.orientation(Orientation::Horizontal)
.vertical_alignment(Alignment::Start)
.child(text.build(bctx))
.build(bctx);
let button = Button::create()
.horizontal_alignment(Alignment::End)
.text("Delete")
.on_click(move |ctxt, _| {
ctxt.get_mut::<AppState>(id)
.events
.push_back(Event::Delete(container));
true
})
.build(bctx);
bctx.append_child(container, button);
bctx.append_child(self.notes, container);
}
fn fetch_text(ctx: &mut Context, entity: Entity) -> Option<String> {
let mut widget = ctx.get_widget(entity);
let entry = widget.get_mut::<String16>("text");
if entry.is_empty() {
return None;
}
let copy = entry.to_string();
entry.clear();
Some(copy)
}
pub fn send(&mut self, event: Event) {
self.events.push_back(event);
}
}
impl State for AppState {
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
if let Some(event) = self.events.pop_front() {
match event {
// Create and append the note to the UI.
Event::Create(entity) => {
if let Some(copy) = Self::fetch_text(ctx, entity) {
self.append_note(ctx, copy);
let count = self.count + 1;
self.count = count;
if count == 1 {
ctx.widget().set::<f64>("spacing", 12.0);
}
}
}
// Delete the note of the given ID from the UI.
Event::Delete(id) => {
ctx.remove_child_from(id, self.notes);
let count = self.count - 1;
self.count = count;
if count == 0 {
ctx.widget().set::<f64>("spacing", 0.0);
}
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
// source: https://gitlab.redox-os.org/redox-os/orbtk/tree/develop
use orbtk::prelude::*;
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(TextBlock::create().text("OrbTk").build(ctx))
.build(ctx)
})
.run();
}

View File

@@ -0,0 +1,478 @@
use std::collections::HashSet;
use orbtk::prelude::*;
#[derive(Debug, Copy, Clone)]
enum Action {
AddItem,
ClearText,
EntryActivated(Entity),
EntryChanged(Entity),
ValueChanged(Entity),
IncrementCounter,
RemoveItem,
}
#[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::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 => {
*ctx.widget().get_mut::<usize>("counter") += 1;
let counter = *ctx.widget().get::<usize>("counter");
ctx.widget().set(
"result",
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 value =
((*ctx.get_widget(entity).get::<f64>("value")).floor() as i32).to_string();
ctx.child("value_text").set("text", String16::from(value));
}
}
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()
.text(text)
.element("text-block")
.class("h1")
.build(ctx)
}
type List = Vec<String>;
widget!(
MainView<MainViewState> {
selected_indices: SelectedIndices,
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 {
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::create()
.margin(8.0)
.columns(
Columns::create()
.column(132.0)
.column(16.0)
.column(132.0)
.column(16.0)
.column(132.0)
.build(),
)
.child(
Stack::create()
.attach(Grid::column(0))
// Column 0
.child(create_header(ctx, "Buttons"))
.child(
Button::create()
.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::create()
.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::create()
.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::create()
.text("CheckBox")
.margin((0.0, 8.0, 0.0, 0.0))
.attach(Grid::column(0))
.attach(Grid::row(4))
.build(ctx),
)
.child(
Switch::create()
.margin((0.0, 8.0, 0.0, 0.0))
.attach(Grid::column(0))
.attach(Grid::row(5))
.build(ctx),
)
.child(
TextBlock::create()
.margin((0.0, 8.0, 0.0, 0.0))
.element("h1")
.id("value_text")
.text("0")
.horizontal_alignment("center")
.build(ctx),
)
.child(
Slider::create()
.on_changed(move |states, entity| {
state(id, states).action(Action::ValueChanged(entity));
})
.build(ctx),
)
.build(ctx),
)
.child(
Stack::create()
.attach(Grid::column(2))
.child(create_header(ctx, "Text"))
.child(
TextBlock::create()
.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("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::create()
.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::create()
.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),
)
.build(ctx),
)
.child(
Grid::create()
.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(),
)
.attach(Grid::column(4))
.child(
TextBlock::create()
.text("Items")
.element("text-block")
.class("h1")
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.attach(Grid::row(0))
.build(ctx),
)
.child(
ComboBox::create()
.items_builder(move |bc, index| {
let text = bc
.get_widget(id)
.get::<Vec<String>>("combo_box_list")[index]
.clone();
TextBlock::create()
.margin((0.0, 0.0, 0.0, 2.0))
.vertical_alignment("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::create()
.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();
Button::create()
.margin((0.0, 0.0, 0.0, 2.0))
.text(text)
.build(bc)
})
.count(("list_count", id))
.build(ctx),
)
.child(
Button::create()
.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::create()
.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::create()
.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::create()
.margin((0.0, 0.0, 0.0, 2.0))
.vertical_alignment("center")
.text(text)
.build(bc)
})
.count(("selection_list_count", id))
.build(ctx),
)
.child(
// todo: wrong text width????
TextBlock::create()
.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();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - widgets example")
.position((100.0, 100.0))
.size(468.0, 730.0)
.resizeable(true)
.child(MainView::create().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)
}

View File

@@ -0,0 +1,415 @@
use std::{
collections::HashSet,
};
use orbtk::prelude::*;
#[derive(Debug, Copy, Clone)]
enum Action {
AddItem,
ClearText,
EntryActivated(Entity),
EntryChanged(Entity),
IncrementCounter,
RemoveItem,
}
#[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::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 => {
*ctx.widget().get_mut::<usize>("counter") += 1;
let counter = *ctx.widget().get::<usize>("counter");
ctx.widget().set(
"result",
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);
}
}
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()
.text(text)
.selector(Selector::new().with("text-block").class("h1"))
.build(ctx)
}
type List = Vec<String>;
widget!(
MainView<MainViewState> {
selected_indices: SelectedIndices,
counter: usize,
list_count: usize,
list: List,
selection_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 {
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(),
])
.selection_list_count(10)
.child(
Grid::create()
.margin(8.0)
.columns(
Columns::create()
.column(132.0)
.column(16.0)
.column(132.0)
.column(16.0)
.column(132.0)
.build(),
)
.child(
Stack::create()
.attach(Grid::column(0))
// Column 0
.child(create_header(ctx, "Buttons"))
.child(
Button::create()
.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_mouse_move(move |states, _| {
println!("ABc");
true
})
.on_click(move |states, _| {
state(id, states).action(Action::IncrementCounter);
true
})
.build(ctx),
)
.child(
Button::create()
.text("Primary")
.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(2))
.build(ctx),
)
.child(
ToggleButton::create()
.text("ToggleButton")
.margin((0.0, 8.0, 0.0, 0.0))
.attach(Grid::column(0))
.attach(Grid::row(3))
.build(ctx),
)
.child(
CheckBox::create()
.text("CheckBox")
.margin((0.0, 8.0, 0.0, 0.0))
.attach(Grid::column(0))
.attach(Grid::row(4))
.build(ctx),
)
.child(
Switch::create()
.margin((0.0, 8.0, 0.0, 0.0))
.attach(Grid::column(0))
.attach(Grid::row(5))
.build(ctx),
)
.build(ctx),
)
.child(
Stack::create()
.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("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::create()
.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::create()
.margin((0.0, 8.0, 0.0, 0.0))
.text("clear text")
.on_click(move |states, _| {
state(id, states).action(Action::ClearText);
true
})
.build(ctx),
)
.build(ctx),
)
.child(
Grid::create()
.rows(
Rows::create()
.row("auto")
.row(192.0)
.row("auto")
.row(192.0)
.row("auto")
.build(),
)
.columns(
Columns::create()
.column("*")
.column(4.0)
.column("*")
.build(),
)
.attach(Grid::column(4))
.child(
TextBlock::create()
.text("Items")
.selector(Selector::new().with("text-block").class("h1"))
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.attach(Grid::row(0))
.build(ctx),
)
.child(
ItemsWidget::create()
.selector(Selector::from("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(1))
.margin((0.0, 8.0, 0.0, 8.0))
.items_builder(move |bc, index| {
let text = bc.get_widget(id).get::<Vec<String>>("list")
[index]
.clone();
Button::create()
.margin((0.0, 0.0, 0.0, 2.0))
.text(text)
.build(bc)
})
.count(("list_count", id))
.build(ctx),
)
.child(
Button::create()
.selector(Selector::from("button").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(2))
.build(ctx),
)
.child(
Button::create()
.selector(Selector::from("button").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(2))
.build(ctx),
)
.child(
ListView::create()
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.attach(Grid::row(3))
.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::create()
.margin((0.0, 0.0, 0.0, 2.0))
.vertical_alignment("center")
.text(text)
.build(bc)
})
.count(("selection_list_count", id))
.build(ctx),
)
.child(
// todo: wrong text width????
TextBlock::create()
.selector(Selector::from("text-block").id("selection"))
.max_width(120.0)
.attach(Grid::column(0))
.attach(Grid::column_span(3))
.attach(Grid::row(4))
.text("Selected:")
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
fn main() {
// use this only if you want to run it as web application.
orbtk::initialize();
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - widgets example")
.position((100.0, 100.0))
.size(468.0, 730.0)
.resizeable(true)
.child(MainView::create().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)
}

View File

@@ -0,0 +1,73 @@
{
"err.lang.not_found": {
"de_DE.UTF-8": "Konnte Sprachkode nicht auslesen",
"de": "Konnte Sprachkode nicht auslesen",
"en": "Couldn't read LANG"
},
"err.user.not_found": {
"fr": "Utilisateur introuvable: $email, $id",
"de-DE.UTF-8": "Anwender nicht gefunden: $email, $id",
"de": "Anwender nicht gefunden: $email, $id",
"en": "User not found: $email, $id"
},
"main.started": {
"de_DE.UTF-8": "Programmlogik starten",
"de": "Programmlogik starten",
"en": "Program logic started"
},
"main.finished": {
"de_DE.UTF-8": "Programmlogik beendet",
"de": "Programmlogik beendet",
"en": "Program logic finished"
},
"parse.arguments": {
"de_DE.UTF-8": "Programmargumente prüfen",
"de": "Programmargumente prüfen",
"en": "Parsing arguments"
},
"parse.environment": {
"de_DE.UTF-8": "Umgebungsvariablen prüfen",
"de": "Umgebungsvariablen prüfen",
"en": "Parsing environment"
},
"config.name": {
"de_DE.UTF-8": "Konfigurationswert für",
"de": "Konfigurationswert für",
"en": "Config Value for"
},
"config.name.lang": {
"de_DE.UTF-8": "Sprach-Code",
"de": "Sprach-Code",
"en": "Language code"
},
"config.name.verbositylevel": {
"de_DE.UTF-8": "Ausgabe-Ebene",
"de": "Ausgabe-Ebene",
"en": "verbosity level"
},
"config.name.environment": {
"de_DE.UTF-8": "Umgebungsvariablen",
"de": "Umgebungsvariablen",
"en": "environment"
},
"config.name.configfile": {
"de_DE.UTF-8": "Konfigurations-Datei",
"de": "Konfigurations-Datei",
"en": "config file"
},
"config.name.dbdriver": {
"de_DE.UTF-8": "Datenbank-Treiber",
"de": "Datenbank-Treiber",
"en": "database driver"
},
"state.started": {
"de_DE.UTF-8": "gestartet",
"de": "gestartet",
"en": "started"
},
"state.finished": {
"de_DE.UTF-8": "beendet",
"de": "beended",
"en": "finished"
}
}

View File

@@ -0,0 +1,32 @@
.header {
background: #444e55;
}
.content {
background: #3b434a;
}
text_box {
background: transparent;
border-width: 0;
color: #9dafbf;
font-size: 16;
}
#input {
font-size: 16;
}
text-block {
font-size: 42;
color: #dfebf5;
}
#input {
background: transparent;
}
button {
border-radius: 1;
font-size: 20;
}

View File

@@ -0,0 +1,15 @@
.header {
background: #ffffff;
}
.content {
background: #fafafa;
}
text_box {
color: #4d4c4c;
}
text-block {
color: #4d4c4c;
}

Binary file not shown.

View 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

View File

@@ -0,0 +1,24 @@
[Icon Theme]
Name=AdvoTracker
Comment=AdvoTracker Icon Theme
Directories=20x20,20x20@2,20x20@3,20x20@4
[20x20]
Size=20
Type=Fixed
[20x20@2]
Size=20
Scale=2
Type=Fixed
[20x20@3]
Size=20
Scale=3
Type=Fixed
[20x20@4]
Size=20
Scale=4
Type=Fixed

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

View File

@@ -0,0 +1,32 @@
.header {
background: #444e55;
}
.content {
background: #3b434a;
}
text-box {
background: transparent;
border-width: 0;
color: #9dafbf;
font-size: 16;
}
#input {
font-size: 16;
}
text-block {
font-size: 42;
color: #dfebf5;
}
#input {
background: transparent;
}
button {
border-radius: 1;
font-size: 20;
}

View File

@@ -0,0 +1,23 @@
* {
font-size: 16;
}
.header {
background: #ffffff;
}
.content {
background: #fafafa;
}
text-box {
color: #4d4c4c;
}
text-block {
color: #4d4c4c;
}
light-text {
color: #dfebf5;
}

View File

@@ -0,0 +1,55 @@
* {
font-size: 16;
}
lynch {
background: #647b91;
}
bluebayoux {
background: #516475;
}
linkwater {
background: #dfebf5;
color: #3b434a;
}
light-text {
color: #dfebf5;
}
goldendream {
background: #efd035;
color: #3b434a;
}
lightgrey {
#f0f0f0;
}
darkgrey {
#879488;
}
grey {
#b6c3b7;
}
Indigo-bases {
#5c6bc0;
}
hiedemann-blue {
#a5b3bf;
}
hiedemann-red {
color: #5b0f22;
}
hiedemann {
background: #5b0f22;
color: #879488;
//color: #3b434a;
}

7
frontend/src/lib.rs Normal file
View File

@@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}