26 Commits

Author SHA1 Message Date
fafd38f210 widgets/configuration: reference styling to theme handling
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:52:41 +01:00
667a2e39bf widget/policycheck: update logic
* remove handling of the menu logic (isolated in dedicated widget)
* reference styling via theme
* update documentation strings

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:47:43 +01:00
c90099e1cf widgets/menu: introduce dedicated module menu
* new menu_view
* new menu_state
* update constants
* update main_view referencing a tab_view

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:45:33 +01:00
9624567dbd assets: update theme definitions for default_dark.ron
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-08 18:43:29 +01:00
014b98bd85 widgets/menu: introduce dedicated menu module
* new menu_view
* new menu_state
* adapt constant values for the menu structure

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-07 13:14:14 +01:00
8fd512b83f theme update dark
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:23:32 +01:00
85f9fdf7db widget/configuration: correcting label constant
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:10:16 +01:00
c4d6506dee language: update
* update constants
* adopt width of languages combo box

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:10:07 +01:00
646955c0fb widget/policycheck: intoduce os dependent theme handling
* theme_fluent: only makes sense in windows environment

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:02:17 +01:00
df6bae482c widgets/localization: update label constant
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 20:00:19 +01:00
00ad56ce71 assets: adapt default_dark theme definitions
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:51:45 +01:00
6350d14ce7 assets: adapt fluent_dark theme definitions
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:49:57 +01:00
e8a86e8afd policycheck:
* insert copyright hint
* more descriptive import of allianzdirectcall function
* documentation update
* introduce KeyHandler in menu popup
* rename action function to `set_action`

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:46:18 +01:00
26cea8e844 widgets/configuration: break out configuration functionality
* handle widget `configuration` in dedicated subdir
* adopt constants to handle widget id's

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:43:23 +01:00
48545d2879 widgets/localization: break out as localization functionality
* handle widget `localization` in dedicated subdir
* adopt constants to handle widget id's

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-05 17:38:11 +01:00
b352f2a581 widget/policycheck: introduce key_event
* handle Escape in menu

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-03 10:27:07 +01:00
89a6842106 policycheck: introduce toggle theme
* new functions:
  - popup_menu_toggle_theme
  - set_menu_toggle_theme
  - create_menu_toggle_theme
  - messages
* rename function: menu  -> popup_menu
* reorder enum: PolicycheckAction
* new actions: SetMenuPopup, SetToggleTheme

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-02 14:00:06 +01:00
76e6e7503f Merge branch 'next' of https://gitea.networkx.de:50443/rzerres/advotracker into wip_toggle_theme_menu
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-02 09:43:32 +01:00
a1541ae307 implement a toggle theme menu
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-01 20:15:57 +01:00
c66335951f structure update
* rename PolicyCheckView to PolicycheckView
* rename PolicyCheckState to PolicycheckState
* rename menu to popup_menu

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-11-01 20:09:45 +01:00
d0e661d5d0 module structure update 2
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-31 16:42:04 +01:00
2253c2892b main: reflect new module structure
* include from assets
* get widgets into place
* introduce style extensions (theme_fluent)

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-31 14:39:41 +01:00
8cc9ba5782 update project structure
* assets: all resources are bundled in this subdirectory
* widgets: use subdirs to group them by function
  the subdir hold their callbacks (state handling) and views
* theming: update to new theming syntax
* fonts: remove fonts that are provovided by default in OrbTK

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-31 14:23:03 +01:00
ef8b884efa main_view: introduce configuration view
* allow to load and save config parameters to ron file

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-07 03:22:51 +02:00
6b7ae9d17d policycheck_view: update to 0.3.1-alpha4 changes
* lose_focus_on_activate()

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-07 03:20:56 +02:00
f0e9014fb7 policycheck_state: update localization of menu entries
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
2020-10-02 17:34:15 +02:00
19 changed files with 1074 additions and 645 deletions

View File

@@ -30,8 +30,7 @@ Dictionary (
"Quit": "Beenden",
// localization view
"Hello": "Hallo",
"User": "Anwender",
"Language ID": "Sprache ID",
"Localization dialog": "Lokalisierungs-Dialog",
"German": "Deutsch",
"English": "Englisch",

View File

@@ -0,0 +1,54 @@
Theme (
styles: {
"button_menu": (
base: "button",
properties: {
"padding": 4,
"border_radius": 0,
},
),
"container_form": (
base: "container",
properties: {
"padding": 14,
"border_width": 1,
"border_radius": 0,
"border_brush": "$CONTAINER_BORDER",
},
),
"configuration_form": (
base: "container",
properties: {
"margin": 4,
},
),
"container_progress": (
base: "container",
properties: {
"padding": 14,
//"border_width": 1,
//"border_radius": 0,
"border_brush": "$CONTAINER_BORDER",
},
),
"popup_progress": (
base: "popup",
properties: {
//"background": "$BACKGROUND",
"padding": 4,
},
),
"text_block_progress": (
base: "small_text",
properties: {
"background": "$PROGRESS_BAR_BACKGROUND",
},
),
"stack_progress": (
base: "container",
properties: {
"spacing": 10,
},
),
}
)

View File

@@ -1,15 +1,9 @@
Theme (
styles: {
"button_single_content_segmdl2": (
base: "button_single_content",
properties: {
"icon font": "$SEGEO_ICON_FONT",
},
),
"container_master_detail": (
"container_form": (
base: "container",
properties: {
"padding": 14,
"border": 1,
},
),
}

View File

@@ -6,66 +6,83 @@
*/
// Styles (RON based theme system)
pub static STYLE_BOTTOM_BAR: &'static str = "bottom_bar";
pub static STYLE_HEADER_BAR: &'static str = "header_bar";
pub static STYLE_SEPERATOR: &'static str = "seperator";
//pub static STYLE_ITEM_BUTTON: &'static str = "item_button";
pub static STYLE_MENU: &'static str = "menu";
pub static STYLE_BUTTON_MENU: &'static str = "button_menu";
pub static STYLE_STACK_MENU: &'static str = "stack_menu";
pub static STYLE_BOTTOM_BAR: &str = "bottom_bar";
pub static STYLE_HEADER_BAR: &str = "header_bar";
pub static STYLE_SEPERATOR: &str = "seperator";
//pub static STYLE_ITEM_BUTTON: &str = "item_button";
pub static STYLE_MENU: &str = "menu";
pub static STYLE_BUTTON_MENU: &str = "button_menu";
pub static STYLE_STACK_MENU: &str = "stack_menu";
// Widget IDs (DCES: Entity[id] => [Component1, .. , Component<n>] -> data or state)
pub static ID_POLICY_CHECK_FORM: &'static str = "policy_check_form";
pub static ID_POLICY_CHECK_FORM_ROW_0: &'static str = "policy_check_form_row_0";
pub static ID_POLICY_CHECK_FORM_ROW_1: &'static str = "policy_check_form_row_1";
pub static ID_POLICY_CHECK_FORM_ROW_2: &'static str = "policy_check_form_row_2";
pub static ID_POLICY_CHECK_HEADER: &'static str = "policy_check_header";
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &'static str = "policy_check_items_widget";
pub static ID_POLICY_CHECK_BUTTON_RESULT: &'static str = "policy_check_button_result";
pub static ID_POLICY_CHECK_BUTTON_MENU: &'static str = "policy_check_button_menu";
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &'static str = "policy_check_data_count_block";
pub static ID_POLICY_CHECK_HINT: &'static str = "policy_check_hint";
pub static ID_POLICY_CHECK_LABEL_HINT: &'static str = "policy_check_label_hint";
pub static ID_POLICY_CHECK_LABEL_MENU: &'static str = "policy_check_label_menu";
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &'static str = "policy_check_label_policy_number";
pub static ID_POLICY_CHECK_LABEL_RESULT: &'static str = "policy_check_label_result";
pub static ID_POLICY_CHECK_MENU: &'static str = "policy_check_menu";
pub static ID_POLICY_CHECK_MENU_LABEL_ACCOUNT: &'static str = "policy_check_menu_label_account";
pub static ID_POLICY_CHECK_MENU_LABEL_QUIT: &'static str = "policy_check_menu_label_quit";
pub static ID_POLICY_CHECK_MENU_SHORTCUT_QUIT: &'static str = "policy_check_menu_shortcut_quit";
pub static ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME: &'static str = "policy_check_menu_label_toggle_theme";
pub static ID_POLICY_CHECK_POLICY_NUMBER: &'static str = "policy_check_policy_number";
pub static ID_POLICY_CHECK_POPUP_MENU: &'static str = "policy_check_popup_menu";
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &'static str = "policy_check_popup_progress";
pub static ID_POLICY_CHECK_PROGRESS_BAR: &'static str = "policy_check_progress_bar";
pub static ID_POLICY_CHECK_PROGRESS_TIME: &'static str = "policy_check_progress_time";
pub static ID_POLICY_CHECK_PROGRESS_TEXT: &'static str = "policy_check_progress_text";
pub static ID_POLICY_CHECK_RESULT: &'static str = "policy_check_result";
pub static ID_POLICY_CHECK_WIDGET: &'static str = "policy_check_widget";
pub static ID_CONFIGURATION_FORM: &str = "configuration_form";
pub static ID_CONFIGURATION_HEADER: &str = "configuration_header";
pub static ID_CONFIGURATION_LABEL_CONFIG_FILE: &str = "configuration_label_config_file";
pub static ID_CONFIGURATION_CONFIG_FILE: &str = "configuration_config_file";
pub static ID_CONFIGURATION_LABEL_LANGUAGE_ID: &str = "configuration_label_language_id";
pub static ID_CONFIGURATION_LANGUAGE_ID: &str = "configuration_language_id";
pub static ID_POLICY_DATA_ADD_BUTTON: &'static str = "policy_data_add_button";
pub static ID_POLICY_DATA_COUNT: &'static str = "policy_data_count";
pub static ID_POLICY_DATA_LABEL: &'static str = "policy_data_label";
pub static ID_POLICY_DATA_ITEMS_WIDGET: &'static str = "policy_data_items_widget";
pub static ID_POLICY_DATA_DATE_INSERTED: &'static str = "policy_data_date_inserted";
pub static ID_POLICY_DATA_DION: &'static str = "policy_data_dion";
pub static ID_POLICY_DATA_POLICY_CODE: &'static str = "policy_data_policy_code";
pub static ID_POLICY_DATA_POLICY_NUMBER: &'static str = "policy_data_policy_number";
pub static ID_POLICY_DATA_STACK: &'static str = "policy_data_stack";
pub static ID_POLICY_DATA_STATUS: &'static str = "policy_data_status";
pub static ID_POLICY_DATA_LIST_NAME: &'static str = "policy_data_list_name";
pub static ID_LOCALIZATION_FORM: &str = "localization_form";
pub static ID_LOCALIZATION_HEADER: &str = "localization_header";
pub static ID_LOCALIZATION_LANGUAGES: &str = "localization_languages";
pub static ID_LOCALIZATION_LABEL_LANGUAGE_NAME: &str = "localization_label_language_name";
pub static ID_LOCALIZATION_LANGUAGE_NAME: &str = "localization_language_name";
pub static ID_POLICY_LIST_ADD_BUTTON: &'static str = "policy_list_add_button";
pub static ID_POLICY_LIST_ITEMS_WIDGET: &'static str = "policy_list_items_widget";
pub static ID_POLICY_LIST_TEXT_BOX: &'static str = "policy_list_text_box";
pub static ID_MENU_POPUP: &str = "menu_popup";
pub static ID_MENU_STACK: &str = "menu_stack";
pub static ID_MENU_BUTTON: &str = "menu_button";
pub static ID_MENU_GRID: &str = "menu_grid";
pub static ID_MENU_LABEL_ACCOUNT: &str = "menu_label_account";
pub static ID_MENU_LABEL_QUIT: &str = "menu_label_quit";
pub static ID_MENU_LABEL_TOGGLE_THEME: &str = "menu_label_toggle_theme";
pub static ID_MENU_SHORTCUT_QUIT: &str = "menu_shortcut_quit";
pub static ID_MENU_TOGGLE_THEME: &str = "menu_toggle_theme";
pub static ID_POLICY_CHECK_FORM: &str = "policy_check_form";
pub static ID_POLICY_CHECK_FORM_ROW_0: &str = "policy_check_form_row_0";
pub static ID_POLICY_CHECK_FORM_ROW_1: &str = "policy_check_form_row_1";
pub static ID_POLICY_CHECK_FORM_ROW_2: &str = "policy_check_form_row_2";
pub static ID_POLICY_CHECK_HEADER: &str = "policy_check_header";
pub static ID_POLICY_CHECK_ITEMS_WIDGET: &str = "policy_check_items_widget";
pub static ID_POLICY_CHECK_BUTTON_RESULT: &str = "policy_check_button_result";
pub static ID_POLICY_CHECK_BUTTON_MENU: &str = "policy_check_button_menu";
pub static ID_POLICY_CHECK_DATA_COUNT_BLOCK: &str = "policy_check_data_count_block";
pub static ID_POLICY_CHECK_HINT: &str = "policy_check_hint";
pub static ID_POLICY_CHECK_LABEL_HINT: &str = "policy_check_label_hint";
pub static ID_POLICY_CHECK_LABEL_MENU: &str = "policy_check_label_menu";
pub static ID_POLICY_CHECK_LABEL_POLICY_NUMBER: &str = "policy_check_label_policy_number";
pub static ID_POLICY_CHECK_LABEL_RESULT: &str = "policy_check_label_result";
pub static ID_POLICY_CHECK_POLICY_NUMBER: &str = "policy_check_policy_number";
pub static ID_POLICY_CHECK_POPUP_PROGRESS: &str = "policy_check_popup_progress";
pub static ID_POLICY_CHECK_PROGRESS_BAR: &str = "policy_check_progress_bar";
pub static ID_POLICY_CHECK_PROGRESS_TIME: &str = "policy_check_progress_time";
pub static ID_POLICY_CHECK_PROGRESS_TEXT: &str = "policy_check_progress_text";
pub static ID_POLICY_CHECK_RESULT: &str = "policy_check_result";
pub static ID_POLICY_CHECK_WIDGET: &str = "policy_check_widget";
pub static ID_POLICY_DATA_ADD_BUTTON: &str = "policy_data_add_button";
pub static ID_POLICY_DATA_COUNT: &str = "policy_data_count";
pub static ID_POLICY_DATA_LABEL: &str = "policy_data_label";
pub static ID_POLICY_DATA_ITEMS_WIDGET: &str = "policy_data_items_widget";
pub static ID_POLICY_DATA_DATE_INSERTED: &str = "policy_data_date_inserted";
pub static ID_POLICY_DATA_DION: &str = "policy_data_dion";
pub static ID_POLICY_DATA_POLICY_CODE: &str = "policy_data_policy_code";
pub static ID_POLICY_DATA_POLICY_NUMBER: &str = "policy_data_policy_number";
pub static ID_POLICY_DATA_STACK: &str = "policy_data_stack";
pub static ID_POLICY_DATA_STATUS: &str = "policy_data_status";
pub static ID_POLICY_DATA_LIST_NAME: &str = "policy_data_list_name";
pub static ID_POLICY_LIST_ADD_BUTTON: &str = "policy_list_add_button";
pub static ID_POLICY_LIST_ITEMS_WIDGET: &str = "policy_list_items_widget";
pub static ID_POLICY_LIST_TEXT_BOX: &str = "policy_list_text_box";
// Component Values (Properties)
pub static PROP_ADVOTRACKER: &'static str = "advotracker";
pub static PROP_POLICY_CHECK: &'static str = "policy_check";
pub static PROP_POLICY_PROGRESS_COUNT: &'static str = "policy_progress_count";
pub static PROP_ADVOTRACKER: &str = "advotracker";
pub static PROP_POLICY_CHECK: &str = "policy_check";
pub static PROP_POLICY_PROGRESS_COUNT: &str = "policy_progress_count";
pub static PROP_POLICY_DATA_LIST: &'static str = "policy_data_list";
pub static PROP_POLICY_DATA_COUNT: &'static str = "policy_data_count";
pub static PROP_POLICY_DATA_LIST: &str = "policy_data_list";
pub static PROP_POLICY_DATA_COUNT: &str = "policy_data_count";
pub static PROP_POLICY_LIST: &'static str = "policy_list";
pub static PROP_POLICY_LIST_COUNT: &'static str = "policy_list_count";
pub static PROP_POLICY_LIST: &str = "policy_list";
pub static PROP_POLICY_LIST_COUNT: &str = "policy_list_count";

View File

@@ -14,6 +14,7 @@
//use chrono::{Local, DateTime};
use dotenv::dotenv;
use locales::t;
use cfg_if::cfg_if;
use serde::Deserialize;
use std::env;
//use std::process;
@@ -21,15 +22,15 @@ use tracing::{info, trace, Level};
use orbtk::{
prelude::*,
theme_default::{THEME_DEFAULT, THEME_DEFAULT_COLORS_DARK, THEME_DEFAULT_FONTS},
theming::config::ThemeConfig,
};
#[cfg(target_os = "windows")]
use orbtk::theme_fluent::{THEME_FLUENT, THEME_FLUENT_COLORS_DARK, THEME_FLUENT_FONTS};
// The Main view
use advotracker::{
widgets::{
main_view,
//policycheck::policycheck_state::PolicyCheckState,
}
};
use advotracker::widgets::main_view;
mod parse_args;
@@ -44,8 +45,13 @@ struct Environment {
}
// Style extension
//static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
//static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
static DEFAULT_DARK_EXT: &str = include_str!("../assets/advotracker/default_dark.ron");
cfg_if! {
if #[cfg(windows)] {
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
}
}
// German localization file.
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker_de_DE.ron");
@@ -67,19 +73,42 @@ fn get_lang() -> String {
lang
}
// /// Extend and register theme assets.
// fn theme() -> Theme {
// register_default_fonts(Theme::from_config(
// ThemeConfig::from(FLUENT_DARK_EXT)
// .extend(ThemeConfig::from(THEME_FLUENT))
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
// // ThemeConfig::from(FLUENT_LIGHT_EXT)
// // .extend(ThemeConfig::from(THEME_FLUENT))
// // .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
// // .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
// ))
// }
cfg_if! {
if #[cfg(windows)] {
/// Extend and register theme assets.
fn theme() -> Theme {
register_default_fonts(Theme::from_config(
ThemeConfig::from(DEFAULT_DARK_EXT)
.extend(ThemeConfig::from(THEME_DEFAULT))
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
))
}
fn theme_fluent() -> Theme {
register_fluent_fonts(Theme::from_config(
ThemeConfig::from(FLUENT_DARK_EXT)
.extend(ThemeConfig::from(THEME_FLUENT))
.extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
.extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
))
// register_fluent_fonts(Theme::from_config(
// ThemeConfig::from(FLUENT_LIGHT_EXT)
// .extend(ThemeConfig::from(THEME_FLUENT))
// .extend(ThemeConfig::from(THEME_FLUENT_COLORS_DARK))
// .extend(ThemeConfig::from(THEME_FLUENT_FONTS)),
}
} else {
/// Extend and register theme assets.
fn theme() -> Theme {
register_default_fonts(Theme::from_config(
ThemeConfig::from(DEFAULT_DARK_EXT)
.extend(ThemeConfig::from(THEME_DEFAULT))
.extend(ThemeConfig::from(THEME_DEFAULT_COLORS_DARK))
.extend(ThemeConfig::from(THEME_DEFAULT_FONTS)),
))
}
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
use parse_args::parse_args;
@@ -152,6 +181,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Application::from_name("nwx.advotracker")
.localization(localization)
.theme(theme())
.window(|ctx| {
Window::new()
.title("AdvoTracker - DirectCall")

View File

@@ -0,0 +1,73 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use serde::{Deserialize, Serialize};
use crate::widgets::configuration::configuration_view::ConfigurationView;
/// Valid `actions` that are handled as state changes in the `Configuration` widget.
#[derive(Clone, Debug)]
pub enum ConfigurationAction {
SaveConfiguration,
LoadConfiguration,
}
/// Define valid configuration data.
/// This structure is serialized and saved inside the OS dependent settings file.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
struct ConfigurationData(
pub String,
pub String
);
/// Valid `structures` that are handled inside the state of the `Configuration` widget.
#[derive(Debug, Default, AsAny)]
pub struct ConfigurationState {}
impl State for ConfigurationState {
fn messages(
&mut self,
mut messages: MessageReader,
registry: &mut Registry,
ctx: &mut Context<'_>,
) {
for message in messages.read::<ConfigurationAction>() {
match message {
ConfigurationAction::LoadConfiguration => registry
.get::<Settings>("settings")
.load_async::<ConfigurationData>("configuration_data".to_string(), ctx.entity()),
ConfigurationAction::SaveConfiguration => {
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
registry.get::<Settings>("settings").save_async(
"configuration_data".to_string(),
ConfigurationData(
configuration_file,
language_id
),
ctx.entity(),
);
}
}
}
// save result
for message in messages.read::<SettingsResult<()>>() {
println!("Result {:?}", message);
}
// load result
for message in messages.read::<SettingsResult<ConfigurationData>>() {
if let Ok(data) = message {
ConfigurationView::configuration_file_set(&mut ctx.widget(), data.0);
ConfigurationView::language_id_set(&mut ctx.widget(), data.1);
}
}
}
}

View File

@@ -0,0 +1,139 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use crate::{
data::constants::*,
widgets::configuration::configuration_state::{ConfigurationAction, ConfigurationState},
};
// Macro that initializes the widget structures/variables for our view
widget!(
ConfigurationView<ConfigurationState> {
configuration_file: String,
language_id: String
}
);
/// The template implementation of the configuration view
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
impl Template for ConfigurationView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
self.child(
Grid::new()
.id(ID_CONFIGURATION_FORM)
.style(configuration_form)
.columns(
Columns::create()
.push(120)
.push(12)
.push("auto")
)
.rows(Rows::create()
.push("auto")
.push(4)
.push("auto")
.push(4)
.push("auto")
.push(12)
.push("auto"),
)
.child(
TextBlock::new()
.id(ID_CONFIGURATION_HEADER)
.h_align("start")
.attach(Grid::column(0))
.attach(Grid::row(0))
.attach(Grid::column_span(3))
.text("Configuration settings")
.style("header")
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_CONFIGURATION_LABEL_CONFIG_FILE)
.attach(Grid::column(0))
.attach(Grid::row(2))
.v_align("center")
.h_align("end")
.text("Configuration file")
.build(ctx),
)
.child(
TextBox::new()
.id(ID_CONFIGURATION_CONFIG_FILE)
.attach(Grid::column(2))
.attach(Grid::row(2))
.text(("configuration_file", id))
.water_mark("Filename...")
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_CONFIGURATION_LABEL_LANGUAGE_ID)
.attach(Grid::column(0))
.attach(Grid::row(4))
.v_align("center")
.h_align("end")
.text("Language Id")
.build(ctx),
)
.child(
TextBox::new()
.id(ID_CONFIGURATION_LANGUAGE_ID)
.attach(Grid::column(2))
.attach(Grid::row(4))
.text(("language_id", id))
.water_mark("Locale Identifier...")
.build(ctx),
)
.child(
Grid::new()
.h_align("center")
.attach(Grid::column(0))
.attach(Grid::row(6))
.attach(Grid::column_span(3))
.columns(
Columns::create()
.push("auto")
.push(8)
.push("auto")
)
.rows(Rows::create()
.push("auto")
)
.child(
Button::new()
.style("button_single_content")
.attach(Grid::column(0))
.attach(Grid::row(0))
.text("load")
.on_click(move |ctx, _| {
ctx.send_message(ConfigurationAction::LoadConfiguration, id);
true
})
.build(ctx),
)
.child(
Button::new()
.text("save")
.style("button_single_content")
.attach(Grid::column(2))
.attach(Grid::row(0))
.on_click(move |ctx, _| {
ctx.send_message(ConfigurationAction::SaveConfiguration, id);
true
})
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}

View File

@@ -0,0 +1,12 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
/// The configuration state
pub mod configuration_state;
/// The configuration view
pub mod configuration_view;

View File

@@ -0,0 +1,40 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use crate::widgets::localization::localization_view::LocalizationView;
#[derive(AsAny, Debug, Default)]
pub struct LocalizationState {
change_language: bool,
}
impl LocalizationState {
pub fn change_language(&mut self) {
self.change_language = true;
}
}
impl State for LocalizationState {
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
if !self.change_language {
return;
}
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
match selected_language.as_str() {
"English" => ctx.set_language("en_US"),
"German" => ctx.set_language("de_DE"),
_ => {}
}
self.change_language = false;
}
}

View File

@@ -0,0 +1,97 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use crate::{
data::constants::*,
widgets::localization::localization_state::LocalizationState,
};
type List = Vec<String>;
// Macro that initializes the widget structures/variables for our view
widget!(LocalizationView<LocalizationState> {
languages: List,
selected_index: i32 }
);
/// The template implementation of the localization view
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
impl Template for LocalizationView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let languages = vec!["English".to_string(), "German".to_string()];
let count = languages.len();
self.languages(languages)
.selected_index(1)
.child(
Grid::new()
.id(ID_LOCALIZATION_FORM)
.margin(4)
.columns(
Columns::create()
.push(120)
.push(12)
.push(150)
)
.rows(Rows::create()
.push("auto")
.push(4)
.push("auto")
.push(4)
.push("auto")
.push(12)
.push("auto"),
)
.child(
TextBlock::new()
.id(ID_LOCALIZATION_HEADER)
.h_align("start")
.attach(Grid::column(0))
.attach(Grid::row(0))
.attach(Grid::column_span(3))
.text("Localization dialog")
.style("header")
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_LOCALIZATION_LABEL_LANGUAGE_NAME)
.attach(Grid::column(0))
.attach(Grid::row(2))
.v_align("center")
.h_align("end")
.text("Language ID")
.build(ctx),
)
.child(
ComboBox::new()
.id(ID_LOCALIZATION_LANGUAGES)
.count(count)
.attach(Grid::column(2))
.attach(Grid::row(2))
.items_builder(move |bc, index| {
let text = bc.get_widget(id)
.get::<Vec<String>>("languages")[index]
.clone();
TextBlock::new()
.id(ID_LOCALIZATION_LANGUAGE_NAME)
.v_align("center")
.text(text)
.build(bc)
})
.on_changed("selected_index", move |states, _| {
states.get_mut::<LocalizationState>(id).change_language();
})
.selected_index(id)
.build(ctx),
)
.build(ctx),
)
}
}

View File

@@ -0,0 +1,12 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
/// The localization state
pub mod localization_state;
/// The localizatin view
pub mod localization_view;

View File

@@ -10,10 +10,11 @@ use orbtk::prelude::*;
use crate::{
data::structures::PolicyCheck,
widgets::policycheck::policycheck_view::PolicycheckView,
widgets::localization::localization_view::LocalizationView,
widgets::configuration::configuration_view::ConfigurationView,
widgets::menu::menu_view::MenuView,
};
type List = Vec<String>;
// [START] views
widget!(MainView {
@@ -57,262 +58,9 @@ impl Template for MainView {
.tab("Policynumber check", policycheck_view)
.tab("Localization", LocalizationView::new().build(ctx))
.tab("Configuration", ConfigurationView::new().build(ctx))
.tab("Menu", MenuView::new().build(ctx))
.build(ctx),
)
//.child(policycheck_view)
}
}
widget!(LocalizationView<LocalizationState> {
languages: List,
selected_index: i32 }
);
impl Template for LocalizationView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let languages = vec!["English".to_string(), "German".to_string()];
let count = languages.len();
self.languages(languages).selected_index(1).child(
Stack::new()
.width(120)
.margin(16)
.spacing(8)
.child(TextBlock::new().text("Hello").build(ctx))
.child(TextBlock::new().text("User").build(ctx))
.child(TextBlock::new().text("Localization dialog").build(ctx))
.child(
ComboBox::new()
.count(count)
.items_builder(move |bc, index| {
let text = bc.get_widget(id)
.get::<Vec<String>>("languages")[index]
.clone();
TextBlock::new().v_align("center").text(text).build(bc)
})
.on_changed("selected_index", move |states, _| {
states.get_mut::<LocalizationState>(id).change_language();
})
.selected_index(id)
.build(ctx),
)
.build(ctx),
)
}
}
widget!(
ConfigurationView<ConfigurationState> {
configuration_file: String,
language_id: String
}
);
impl Template for ConfigurationView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
self.child(
Grid::new()
.margin(4)
.columns(
Columns::create()
.push(120)
.push(12)
.push("auto")
)
.rows(Rows::create()
.push("auto")
.push(4)
.push("auto")
.push(4)
.push("auto")
.push(12)
.push("auto"),
)
.child(
TextBlock::new()
.h_align("start")
.attach(Grid::column(0))
.attach(Grid::row(0))
.attach(Grid::column_span(3))
.text("Configuration settings")
.style("header")
.build(ctx),
)
.child(
TextBlock::new()
.attach(Grid::column(0))
.attach(Grid::row(2))
.v_align("center")
.h_align("end")
.text("Configuration file")
.build(ctx),
)
.child(
TextBox::new()
.attach(Grid::column(2))
.attach(Grid::row(2))
.text(("configuration_file", id))
.water_mark("Filename...")
.build(ctx),
)
.child(
TextBlock::new()
.attach(Grid::column(0))
.attach(Grid::row(4))
.v_align("center")
.h_align("end")
.text("Language Id")
.build(ctx),
)
.child(
TextBox::new()
.attach(Grid::column(2))
.attach(Grid::row(4))
.text(("language_id", id))
.water_mark("Locale Identifier...")
.build(ctx),
)
.child(
Grid::new()
.h_align("center")
.attach(Grid::column(0))
.attach(Grid::row(6))
.attach(Grid::column_span(3))
.columns(
Columns::create()
.push("auto")
.push(8)
.push("auto")
)
.rows(Rows::create()
.push("auto")
)
.child(
Button::new()
.style("button_single_content")
.attach(Grid::column(0))
.attach(Grid::row(0))
.text("load")
.on_click(move |ctx, _| {
ctx.send_message(ConfigurationAction::LoadConfiguration, id);
true
})
.build(ctx),
)
.child(
Button::new()
.text("save")
.style("button_single_content")
.attach(Grid::column(2))
.attach(Grid::row(0))
.on_click(move |ctx, _| {
ctx.send_message(ConfigurationAction::SaveConfiguration, id);
true
})
.build(ctx),
)
.build(ctx),
)
.build(ctx),
)
}
}
// [END] views
// [START] states
#[derive(AsAny, Debug, Default)]
struct LocalizationState {
change_language: bool,
}
impl LocalizationState {
fn change_language(&mut self) {
self.change_language = true;
}
}
impl State for LocalizationState {
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
if !self.change_language {
return;
}
let index = *LocalizationView::selected_index_ref(&ctx.widget()) as usize;
let selected_language = LocalizationView::languages_ref(&ctx.widget())[index].clone();
match selected_language.as_str() {
"English" => ctx.set_language("en_US"),
"German" => ctx.set_language("de_DE"),
_ => {}
}
self.change_language = false;
}
}
#[derive(Debug, Default, AsAny)]
struct ConfigurationState {}
impl State for ConfigurationState {
fn messages(
&mut self,
mut messages: MessageReader,
registry: &mut Registry,
ctx: &mut Context<'_>,
) {
for message in messages.read::<ConfigurationAction>() {
match message {
ConfigurationAction::LoadConfiguration => registry
.get::<Settings>("settings")
.load_async::<ConfigurationData>("configuration_data".to_string(), ctx.entity()),
ConfigurationAction::SaveConfiguration => {
let configuration_file: String = ConfigurationView::configuration_file_clone(&ctx.widget());
let language_id: String = ConfigurationView::language_id_clone(&ctx.widget());
registry.get::<Settings>("settings").save_async(
"configuration_data".to_string(),
ConfigurationData(
configuration_file,
language_id
),
ctx.entity(),
);
}
}
}
// save result
for message in messages.read::<SettingsResult<()>>() {
println!("Result {:?}", message);
}
// load result
for message in messages.read::<SettingsResult<ConfigurationData>>() {
if let Ok(data) = message {
ConfigurationView::configuration_file_set(&mut ctx.widget(), data.0);
ConfigurationView::language_id_set(&mut ctx.widget(), data.1);
}
}
}
}
// [END] states
// [START] Configuration data
#[derive(Clone, Debug)]
enum ConfigurationAction {
SaveConfiguration,
LoadConfiguration,
}
use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct ConfigurationData(
pub String,
pub String
);
// [END] Configuration data

View File

@@ -0,0 +1,300 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use cfg_if::cfg_if;
use orbtk::prelude::*;
use orbtk::shell::event::Key;
use std::process;
use crate::{
data::constants::*,
widgets::menu::menu_view::MenuView,
//widgets::policycheck::policycheck_view::PolicycheckView,
};
/// Valid `actions` that are handled as state changes in the `Menu` widget.
#[derive(Debug, Clone, Copy)]
pub enum MenuAction {
CreateMenu,
CreateMenuToggleTheme(Entity),
RemoveMenu,
RemoveMenuToggleTheme(Entity),
SetTheme
}
/// Valid `structures` that are handled inside the state of the `Menu` widget.
#[derive(AsAny, Default)]
pub struct MenuState {
action: Option<MenuAction>,
menu: Entity,
menu_toggle_theme: Entity
}
/// Method definitions, that react on any given state change inside the `Menu` widget.
impl MenuState {
/// Set a menu holding all valid menu elements
/// The elements are ordered compontents inside a stack
pub fn create_menu(&mut self, ctx: &mut Context<'_>) {
// create a stack as a child of the given component
let stack = ctx
.entity_of_child(ID_MENU_BUTTON)
.expect("PolicycheckState: Can't find entity of resource 'ID_MENU_BUTTON'.");
//.entity_of_child(<PolicycheckView>ID_MENU_BUTTON)
//.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create a new popup menu overlay
self.menu = create_menu_popup(current_entity, build_context);
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_BUTTON_MENU"
build_context.append_child(stack, self.menu);
println!("Popup Menu created: {:?}", self.menu);
}
/// Set a toggle_theme menu
/// Select the active theme from a `ComboBox` offering a list of valid `themes``
fn create_menu_toggle_theme(&mut self, ctx: &mut Context<'_>) {
let stack = ctx
.entity_of_child(ID_MENU_LABEL_TOGGLE_THEME)
.expect("MenuState: Can't find entity of resource 'ID_MENU_LABEL_TOGGLE_THEME'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create a new menu overlay
self.menu_toggle_theme = create_menu_toggle_theme_popup(current_entity, build_context);
// create a menu_popup widget as a child of entity "ID_POPUP_MENU"
build_context.append_child(stack, self.menu_toggle_theme);
println!("Popup Menu Toggle Theme created: {:?}", self.menu_toggle_theme);
}
/// Remove the menu popup box
fn remove_menu(&mut self, ctx: &mut Context<'_>) {
ctx.remove_child(ctx.entity());
println!("Popup {:?} removed !", ctx.entity());
}
/// Remove the menu popup box
fn remove_menu_toggle_theme(&mut self, id: Entity, ctx: &mut Context<'_>) {
ctx.remove_child(self.menu_toggle_theme);
println!("Popup {:?} removed !", id);
}
/// Sets a new action.
pub fn set_action(&mut self, action: MenuAction) {
self.action = action.into();
}
}
/// Supported methods handled inside the `MenuState`
impl State for MenuState {
/// Initialize the state of widgets inside `MenuState`
fn init(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
// Initialize required entities
// let menu_button = ctx
// .entity_of_child(ID_MENU_STACK)
// .expect("MenuState.init: Can't find resource entity 'PolicycheckView::ID_POLICY_CHECK_BUTTON_MENU'.");
}
/// Handle messages for the `MenuState`
fn messages(
&mut self,
mut messages: MessageReader,
_registry: &mut Registry,
ctx: &mut Context<'_>,
) {
for message in messages.read::<MenuAction>() {
match message {
MenuAction::SetTheme => {
let theme_index = *MenuView::selected_index_ref(&ctx.widget());
cfg_if! {
if #[cfg(windows)] {
match theme_index {
0 => ctx.switch_theme(theme_default_dark()),
1 => ctx.switch_theme(theme_default_light()),
2 => ctx.switch_theme(theme_redox()),
3 => ctx.switch_theme(theme_fluent_dark()),
4 => ctx.switch_theme(theme_fluent_light()),
_ => {}
}
} else {
match theme_index {
0 => ctx.switch_theme(theme_default_dark()),
1 => ctx.switch_theme(theme_default_light()),
2 => ctx.switch_theme(theme_redox()),
_ => {}
}
}
}
},
_ => (),
}
}
}
/// Update the state of widgets inside the `Menu` view.
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
if let Some(action) = self.action {
match action {
MenuAction::CreateMenu => {
println!("MenuAction::CreateMenu(_entity)");
self.create_menu(ctx);
}
MenuAction::CreateMenuToggleTheme(_entity) => {
self.create_menu_toggle_theme(ctx);
}
MenuAction::RemoveMenu => {
self.remove_menu(ctx);
}
MenuAction::RemoveMenuToggleTheme(entity) => {
self.remove_menu_toggle_theme(entity, ctx);
}
_ => (),
}
}
}
}
/// Create a new popup presenting the menu components
pub fn create_menu_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new()
.id(ID_MENU_POPUP)
.style("container_menu")
.target(id)
.open(true)
.width(280)
.height(140)
.on_key_down(move | ctx, key_event | {
match key_event.key {
Key::Q(..) => {
//if is_ctrl_home_down(ctx)
println!("KeyHandler: got Ctrl+Q");
process::exit(0);
//}
},
Key::Escape => {
println!("KeyHandler: got Escape");
ctx.get_mut::<MenuState>(id)
.set_action(MenuAction::RemoveMenu);
},
_ => {
println!("KeyHandler: got {:?}", key_event.key);
},
};
true
})
.child(
Grid::new()
.id(ID_MENU_GRID)
.columns(
Columns::create()
.push("80") // Menu Button
.push("1") // Seperator
.push("*") // Keyboard Shortcut
.build(),
)
.rows(
Rows::create()
.push("auto")
.push("auto")
.push("auto")
.build(),
)
.child(
Button::new()
.id(ID_MENU_LABEL_ACCOUNT)
.style("button_menu")
.attach(Grid::row(0))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_PERSON)
.text("Account")
.build(ctx),
)
.child(
Button::new()
.id(ID_MENU_LABEL_TOGGLE_THEME)
.style("button_menu")
.attach(Grid::row(1))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_EDIT)
.text("Toggle theme")
// .on_click(move |ctx, _| {
// ctx.get_mut::<MenuState>(id)
// .set_action(MenuAction::SetTheme(id));
// true
// })
.build(ctx),
)
.child(
Button::new()
.id(ID_MENU_LABEL_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_SETTINGS_POWER)
.text("Quit")
.on_mouse_down(move |_states, _| {
process::exit(0);
})
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_MENU_SHORTCUT_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(2))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.text("CTRL+Q")
.build(ctx),
)
.build(ctx),
)
.build(ctx)
}
/// Create a new popup submenu to toogle the active theme
pub fn create_menu_toggle_theme_popup(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
//let themes_count = themes.len();
//ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
Popup::new()
.id(ID_MENU_TOGGLE_THEME)
.style("container_menu")
.target(id)
.open(true)
.width(280)
.height(140)
.child(
ComboBox::new()
.attach(Grid::column(2))
.attach(Grid::row(6))
//.count(themes_count)
.items_builder(move |build_ctx, index| {
let theme_name =
MenuView::themes_ref(&build_ctx.get_widget(id))[index].clone();
TextBlock::new().v_align("center").text(theme_name).build(build_ctx)
})
.on_changed("selected_index", move |ctx, _| {
ctx.send_message(MenuAction::SetTheme, id);
println!("changed theme.");
})
.selected_index(id)
.build(ctx),
)
.build(ctx)
}

View File

@@ -0,0 +1,82 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use cfg_if::cfg_if;
use orbtk::prelude::*;
use crate::data::constants::*;
use crate::widgets::menu::menu_state::{MenuAction, MenuState};
type List = Vec<String>;
// Macro that initializes the widget structures/variables for the menu view
widget!(
MenuView<MenuState> {
//menu_stack: Entity,
//button_menu: Entity,
selected_index: i32,
themes: List
}
);
/// The template implementation of the menu view
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
impl Template for MenuView {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
cfg_if! {
if #[cfg(windows)] {
// define the list of supported themes
let themes = vec![
"default_dark".to_string(),
"default_light".to_string(),
"redox".to_string(),
"fluent_dark".to_string(),
"fluent_light".to_string()
];
} else {
// define the list of supported themes
let themes = vec![
"default_dark".to_string(),
"default_light".to_string(),
"redox".to_string(),
];
}
}
//self.themes(themes).child(MenuState::create_menu(ID_MENU_POPUP, ctx))
self.themes(themes).child(
Stack::new()
.id(ID_MENU_STACK)
.child(
TextBlock::new()
.style("header")
.attach(Grid::row(0))
.attach(Grid::column(0))
.style("small_text")
.text("Select theme")
.build(ctx),
)
.child(
Button::new()
//.id("button_menu")
.id(ID_MENU_BUTTON)
.style("button_single_content")
.icon(material_icons_font::MD_MENU)
.attach(Grid::column(2))
.h_align("end")
.on_click(move |ctx, _| {
println!("WIP: open menu popup from MenuView");
ctx.get_mut::<MenuState>(id)
.set_action(MenuAction::CreateMenu);
true
})
.build(ctx),
)
.build(ctx),
)
}
}

View File

@@ -0,0 +1,12 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
/// The menu view
pub mod menu_view;
/// The menu state
pub mod menu_state;

View File

@@ -5,17 +5,26 @@
* SPDX-License-Identifier: (0BSD or MIT)
*/
/// global helper functions
/// Configuration widget.
pub mod configuration;
/// Global helper functions.
pub mod global_state;
/// The starting point (Main View)
/// Localization widget.
pub mod localization;
/// The starting point (Main View).
pub mod main_view;
/// The policy check wigdet
/// Menu widget.
pub mod menu;
/// Policycheck wigdet.
pub mod policycheck;
// /// The policy data widget
// /// Policydata widget.
// pub mod policydata;
// /// The policy lists widget
// /// Policylists widget.
// pub mod policylist;

View File

@@ -1,70 +0,0 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use orbtk::prelude::*;
use crate::data::constants::*;
widget!(
PolicyCheckMenu {
is_active: Bool
}
);
impl Template for PolicyCheckMenu {
fn template(self, _id: Entity, ctx: &mut BuildContext) -> Self {
// let policy_check_menu_container = Container::new()
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
// .class(CLASS_MENU)
// .attach(Grid::row(3))
// .attach(Grid::column(8))
// .margin((0.0, 0.0, 4.0, 0.0))
// .enabled(false)
// .min_size(120.0, 180.0)
// .v_align("center")
// .on_click(move |ctx, _| {
// ctx.get_mut::<PolicyCheckState>(id)
// .action(Action::NewEntry(quit));
// true
// })
// .build(ctx);
// let policycheck_menu_container = Container::new()
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
// .background("#dfebf5")
// .width(200.0)
// .height(200.0)
// .child(
// The menu implemented as an overlay
//ctx.append_child_to_overlay(policy_check_menu_button).unwrap();
self.name("PolicyCheckMenu").child(
Stack::new()
.id(ID_POLICY_CHECK_MENU)
.orientation("vertical")
.spacing(8)
.h_align("center")
.child(
Button::new()
.icon(material_icons_font::MD_VERIFIED_USER)
.text("angemeldeter Benutzer")
.margin((0, 8, 0, 0))
.build(ctx),
)
.child(
Button::new()
.icon(material_icons_font::MD_EXIT_TO_APP)
.text("Quit")
.margin((0, 8, 0, 0))
.build(ctx),
)
.build(ctx),
)
}
}

View File

@@ -1,3 +1,10 @@
/*
* advotracker - Hotline tackingtool for Advocats
*
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
* SPDX-License-Identifier: (0BSD or MIT)
*/
use locales::t;
use orbtk::prelude::*;
@@ -8,58 +15,55 @@ use std::time::{Duration, SystemTime};
use tracing::{error, info, trace};
use crate::{
widgets::global_state::GlobalState,
data::{
structures::{PolicyCode, PolicyDataList, PolicyList},
constants::*,
},
services::imports::allianzdirectcall::import,
widgets::global_state::GlobalState,
//widgets::menu::menu_view::MenuView,
//services::imports::allianzdirectcall::import,
services::imports::allianzdirectcall,
};
/// Actions that can execute on the task view.
/// Valid `actions` that are handled as state changes in the `Policycheck` widget.
#[derive(Debug, Clone, Copy)]
pub enum PolicycheckAction {
AddProgress(f64),
ClearEntry(Entity),
ChangeTheme(),
InputTextChanged(Entity),
ImportData,
OpenMenu(Entity),
ParseEntry(Entity),
AddProgress(f64),
RemoveFocus(Entity),
RemovePopup(Entity),
ResetProgress,
SetMenu(Entity),
SetProgress(f64),
SetProgressPopup(Entity),
RemoveFocus(Entity),
RemoveMenu(Entity),
RemovePopup(Entity),
SetToggleTheme(Entity),
SetEntry(Entity),
SetVisibility(Entity),
TextChanged(Entity, usize),
ToggleTheme(Entity)
TextChanged(Entity, usize)
}
/// define valid environment variables provided via .env files
/// located in the current call directory
/// this is primarily used in testing scenarios (eg. debugging)
/// Define valid environment variables provided via .env files
/// located in the current call directory.
/// This is primarily used in testing scenarios (eg. debugging).
#[derive(Debug, Deserialize)]
struct Environment {
test_lang: String,
rust_log: String,
}
/// Handles the requests from `PolicycheckView`.
/// Valid `structures` that are handled inside the state of the `Policycheck` widget.
#[derive(AsAny, Default)]
pub struct PolicycheckState {
action: Option<PolicycheckAction>,
duration: Duration,
label_result: Entity,
lang: String,
//last_focused: Option<Entity>,
button_menu: Entity,
policy_data_count: u64,
policy_numbers: HashMap<u64, PolicyCode>,
popup_menu: Entity,
progress_bar: Entity,
progress_count: f64,
progress_popup: Entity
@@ -67,13 +71,8 @@ pub struct PolicycheckState {
impl GlobalState for PolicycheckState {}
/// method definitions, that react on any given state change inside the view
/// Method definitions, that react on any given state change inside the `Policycheck` widget.
impl PolicycheckState {
/// Sets a new action.
pub fn action(&mut self, action: PolicycheckAction) {
self.action = action.into();
}
/// Create a hashmap (key: policy number, value: policy type).
pub fn create_hashmap(&mut self, _ctx: &mut Context<'_>) -> Result<(), Box<dyn std::error::Error>> {
trace!(target: "advotracker", create_hashmap = "started");
@@ -91,7 +90,7 @@ impl PolicycheckState {
// Wip: use cli parameter stored in viperus ...
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
match import(&mut csv_import_path, &mut policy_data,
match allianzdirectcall::import(&mut csv_import_path, &mut policy_data,
&mut policy_numbers, &mut self.policy_data_count,
&self.lang) {
Ok((count, duration)) => {
@@ -128,7 +127,6 @@ impl PolicycheckState {
if self.policy_numbers.len() == 0 {
// initialize popup widget
//let sender = ctx.send_window_request();
self.set_popup_progress(ctx);
self.progress_count += 0.33;
self.update_progress_bar(ctx);
@@ -170,13 +168,6 @@ impl PolicycheckState {
Ok(())
}
/// Open menu.
pub fn open_menu(&mut self, _entity: Entity, ctx: &mut Context<'_>) {
//let menu_string = ctx.get_widget(entity).get::<String16>("text");
//.child(policycheck_menu);
self.set_popup_menu(ctx);
}
/// Parse validity of the given policy number.
fn parse_entry(&mut self, policy_check_policy_number: Entity,
ctx: &mut Context<'_>) {
@@ -316,12 +307,6 @@ impl PolicycheckState {
trace!(target: "advotracker", parse_entry = "finished");
}
/// Remove the menu popup box
fn remove_menu(&mut self, id: Entity, ctx: &mut Context<'_>) {
ctx.remove_child(self.popup_menu);
println!("Popup {:?} removed !", id);
}
/// Remove the popup box
fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) {
ctx.remove_child(self.progress_popup);
@@ -341,6 +326,11 @@ impl PolicycheckState {
// ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true);
// }
/// Sets a new action.
pub fn set_action(&mut self, action: PolicycheckAction) {
self.action = action.into();
}
/// Change status of given text box to edit mode.
fn set_entry(&mut self, text_box: Entity, ctx: &mut Context<'_>) {
if ctx.get_widget(text_box).get::<String16>("text").is_empty() {
@@ -352,42 +342,29 @@ impl PolicycheckState {
}
}
/// Set a menu
fn set_popup_menu(&mut self, ctx: &mut Context<'_>) {
let stack = ctx
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create a popup menu overlay
self.popup_menu = create_menu(current_entity, build_context);
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_BUTTON_MENU"
build_context.append_child(stack, self.popup_menu);
println!("Popup Menu created: {:?}", self.popup_menu);
}
/// Set a progress popup that updates the import status in a progress bar
fn set_popup_progress(&mut self, ctx: &mut Context<'_>) {
//println!("Set up Progress popup: {:?}", text_box);
// create a stack as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
let stack = ctx
.entity_of_child(ID_POLICY_CHECK_RESULT)
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_RESULT'.");
.entity_of_child(ID_POLICY_CHECK_POLICY_NUMBER)
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POLICY_NUMBER'.");
let current_entity = ctx.entity();
let build_context = &mut ctx.build_context();
// create the progress_popup widget
self.progress_popup = create_popup_progress(current_entity, build_context);
println!("New entity `progress_popup` created: {:?}", self.progress_popup);
// create a progress_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
// append the stack inside the progress_popup
build_context.append_child(stack, self.progress_popup);
// make sure we have a
self.progress_bar = ctx
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
println!("New entity `progress_bar` created: {:?}", self.progress_bar);
println!("PopupProgress created: {:?}", self.progress_popup);
println!("function `set_popup_progress()` finished!");
}
/// Change visibility of the result label.
@@ -420,15 +397,15 @@ impl PolicycheckState {
}
}
/// upported states for our view
/// Supported methods handled inside the `PolicycheckState`
impl State for PolicycheckState {
/// Initialize the widget state
/// Initialize the state of widgets inside `PolicycheckState`
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
let time_start= SystemTime::now();
trace!(target: "advotracker", policycheck_state = "init", status = "started");
// Entities
// Initialize required entities
self.button_menu = ctx
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
.expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
@@ -465,7 +442,33 @@ impl State for PolicycheckState {
trace!(target: "advotracker", policycheck_state = "init", status = "finished", duration = ?duration);
}
/// Update the widget state.
/// Handle messages for `PolicycheckState`.
fn messages(
&mut self,
mut messages: MessageReader,
_registry: &mut Registry,
ctx: &mut Context<'_>,
) {
for message in messages.read::<PolicycheckAction>() {
match message {
PolicycheckAction::AddProgress(increment) => {
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
let new_width = old_width + increment;
// Set the ProgressBar's val property to the calculated percentage
// (whereas 0.0 means 0%, and 1.0 means 100%)
if new_width <= 1. {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
} else {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
}
}
_ => (),
}
}
}
/// Update the state of widgets inside the `Policycheck` view.
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context<'_>) {
// // clear focus on focus moved
// if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
@@ -479,21 +482,6 @@ impl State for PolicycheckState {
if let Some(action) = self.action {
match action {
PolicycheckAction::AddProgress(increment) => {
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
let new_width = old_width + increment;
// Set the ProgressBar's val property to the calculated percentage
// (whereas 0.0 means 0 %, and 1.0 means 100 %) to increment the progress
if new_width <= 1. {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), new_width);
} else {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
}
}
PolicycheckAction::ChangeTheme() => {
println!("Changing active theme.");
}
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
ctx.get_widget(policy_check_policy_number).set("enabled", false);
}
@@ -511,9 +499,6 @@ impl State for PolicycheckState {
}
}
}
PolicycheckAction::OpenMenu(entity) => {
self.open_menu(entity, ctx);
}
PolicycheckAction::ParseEntry(text_box) => {
self.parse_entry(text_box, ctx);
}
@@ -521,10 +506,8 @@ impl State for PolicycheckState {
ctx.get_widget(policy_check_policy_number).set("enabled", false);
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
}
PolicycheckAction::RemoveMenu(entity) => {
self.remove_menu(entity, ctx);
}
PolicycheckAction::RemovePopup(entity) => {
//println!("WIP: remove popup");
self.remove_popup(entity, ctx);
}
PolicycheckAction::ResetProgress => {
@@ -534,9 +517,6 @@ impl State for PolicycheckState {
//self.last_focused = Some();
self.set_entry(policy_check_policy_number, ctx);
}
PolicycheckAction::SetMenu(_entity) => {
self.set_popup_menu(ctx);
}
PolicycheckAction::SetProgress(value) => {
if value >= 0. || value <= 1. {
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
@@ -552,10 +532,7 @@ impl State for PolicycheckState {
PolicycheckAction::TextChanged(entity, _index) => {
self.set_entry(entity, ctx);
}
PolicycheckAction::ToggleTheme(_entity) => {
println!("TODO: toggle active theme");
//self.toggle_theme(entity, ctx);
}
_ => (),
}
}
// Reset action
@@ -565,115 +542,21 @@ impl State for PolicycheckState {
// /// Update the view after the layout is rendered.
// fn update_post_layout(&mut self, _: &mut Registry, _ctx: &mut Context<'_>) {
// }
}
/// Create a menu popup
fn create_menu(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new()
.id(ID_POLICY_CHECK_POPUP_MENU)
.style("container_menu")
.target(target)
.open(true)
.width(280)
.height(140)
.on_mouse_down(move |ctx, _| {
println!("on_click -> remove_menu()");
ctx.get_mut::<PolicycheckState>(target)
.action(PolicycheckAction::RemoveMenu(target));
true
})
.child(
Grid::new()
.id(ID_POLICY_CHECK_MENU)
.columns(
Columns::create()
// Menu Button
.push("80")
// Seperator
.push("1")
// Keyboard Shortcut
.push("*")
.build(),
)
.rows(
Rows::create()
.push("auto")
.push("auto")
.push("auto")
.build(),
)
.child(
Button::new()
.id(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT)
.style("button_menu")
.attach(Grid::row(0))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_PERSON)
.text("Account")
.build(ctx),
)
.child(
Button::new()
.id(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME)
.style("button_menu")
.attach(Grid::row(1))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_EDIT)
.text("Toggle theme")
.on_click(move |states, _| {
states.get_mut::<PolicycheckState>(target)
.action(PolicycheckAction::ToggleTheme(target));
true
})
.build(ctx),
)
.child(
Button::new()
.id(ID_POLICY_CHECK_MENU_LABEL_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(0))
.attach(Grid::column_span(2))
.icon(material_icons_font::MD_SETTINGS_POWER)
.text("Quit")
.on_mouse_down(move |_states, _| {
process::exit(0);
})
.build(ctx),
)
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_MENU_SHORTCUT_QUIT)
.style("button_menu")
.attach(Grid::row(2))
.attach(Grid::column(2))
.margin((0, 0, 16, 0))
.h_align("end")
.v_align("center")
.text("CTRL+Q")
.build(ctx),
)
.build(ctx),
)
.build(ctx)
}
/// Create a progress popup with update status of an onging data import
fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
fn create_popup_progress(id: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new()
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
.target(target)
.target(id)
.open(true)
//.style("popup_progress")
.style("popup_progress")
.width(280)
.height(100)
.on_mouse_down(move |ctx, _| {
println!("on_click -> remove_popup_progress()");
ctx.get_mut::<PolicycheckState>(target)
.action(PolicycheckAction::RemovePopup(target));
.on_click(move |ctx, _| {
println!("create_popup_progress: on_click -> remove_popup(popup_progress)");
ctx.get_mut::<PolicycheckState>(id)
.set_action(PolicycheckAction::RemovePopup(id));
true
})
.child(
@@ -685,14 +568,14 @@ fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
//.style("textblock_progress")
.font_size(12)
.style("textblock_progress")
.text("Importing data")
.build(ctx)
)
.child(
ProgressBar::new()
.id(ID_POLICY_CHECK_PROGRESS_BAR)
.style("progress_bar")
.val(0)
//.width(250)
.build(ctx)
@@ -700,9 +583,8 @@ fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
.child(
TextBlock::new()
.id(ID_POLICY_CHECK_PROGRESS_TIME)
//.style("textblock_progress")
.style("textblock_progress")
.h_align("end")
.font_size(12)
.text("Processing time")
.build(ctx)
)

View File

@@ -6,19 +6,22 @@
*/
use orbtk::prelude::*;
use orbtk::shell::event::Key;
use crate::{
data::{
constants::*,
structures::PolicyCheck,
},
widgets::policycheck::policycheck_state::*,
//widgets::menu::menu_state::{MenuAction, MenuState},
widgets::policycheck::policycheck_state::{PolicycheckAction, PolicycheckState},
};
// Macro that initializes the widget structures/variables for our view
// Macro that initializes the widget structures/variables for the policy check view
widget!(
/// Dialog to enter a policy identifier/number.
/// This identifier is checked agains a map of valid policy codes.
// PolicycheckView<PolicycheckState>: KeyDownHandler {
PolicycheckView<PolicycheckState> {
lang: String,
policy_check: PolicyCheck,
@@ -32,7 +35,6 @@ widget!(
impl Template for PolicycheckView {
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
let policy_check_bottom_bar = Container::new()
//.style(STYLE_BOTTOM_BAR)
.attach(Grid::row(4))
@@ -69,14 +71,6 @@ impl Template for PolicycheckView {
)
.build(ctx);
let policy_check_label_menu = TextBlock::new()
.id(ID_POLICY_CHECK_LABEL_MENU)
.style("menu")
.text("Help Menu")
.v_align("center")
.h_align("center")
.build(ctx);
let policy_check_button_menu = Button::new()
.id(ID_POLICY_CHECK_BUTTON_MENU)
.style("button_single_content")
@@ -84,10 +78,10 @@ impl Template for PolicycheckView {
.attach(Grid::column(2))
//.min_size(16, 16)
.h_align("end")
.on_click(move |ctx, _| {
//ctx.get_mut::<PolicycheckState>(policycheck_state)
ctx.get_mut::<PolicycheckState>(id)
.action(PolicycheckAction::OpenMenu(policy_check_label_menu));
.on_click(move |_ctx, _| {
println!("WIP: open menu popup from MenuView");
// ctx.get_mut::<MenuState>(id)
// .set_action(MenuAction::CreateMenu(ID_MENU_STACK));
true
})
.build(ctx);
@@ -157,32 +151,34 @@ impl Template for PolicycheckView {
.on_activate(move |ctx, entity| {
// Entity is entered/activated via Mouse/Keyboard
//ctx.get_mut::<PolicycheckState>(policy_check_view)
println!("ParseEntry: {:?}", entity);
ctx.get_mut::<PolicycheckState>(id)
.action(PolicycheckAction::ParseEntry(entity));
.set_action(PolicycheckAction::ParseEntry(entity));
})
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
// .on_changed(move |ctx, entity, _| {
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::SetProgressBox(entity));
// .set_action(Action::SetProgressBox(entity));
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::AddProgress(0.5));
// .set_action(Action::AddProgress(0.5));
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::InputTextChanged(entity));
// .set_action(Action::InputTextChanged(entity));
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::SetVisibility(entity));
// .set_action(Action::SetVisibility(entity));
// ctx.get_widget(policy_check_label_policy_number).set("visible");
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::SetVisility(entity));
// .set_action(Action::SetVisility(entity));
// })
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
// state(id, states).action(Action::AddItem);
// state(id, states).set_action(Action::AddItem);
// })
//.on_key_down(move |ctx, _| {
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::ImportData);
// true
//})
.on_key_down(move |_, key_event| {
if key_event.key == Key::A(true) {
println!("A key down");
}
// ctx.get_mut::<PolicycheckState>(id)
// .set_action(Action::ImportData);
true
})
.build(ctx),
)
.child(policy_check_button_result)
@@ -301,7 +297,8 @@ impl Template for PolicycheckView {
.build(ctx);
// WIP: this widget type should handle our target natively
// but it isn't able to get textinput ... yet
// but it isn't able to get textinput, nor handle usize values
// ... yet
let _policy_check_numeric_box = NumericBox::new()
.id(ID_POLICY_CHECK_POLICY_NUMBER)
.h_align("start")
@@ -314,14 +311,16 @@ impl Template for PolicycheckView {
// WIP code @kivimango
// .on_activate(move |ctx, entity| {
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::ParseEntry(entity));
// .set_action(Action::ParseEntry(entity));
// })
// .on_changed(move |ctx, entity| {
// ctx.get_mut::<PolicycheckState>(id)
// .action(Action::InputTextChanged(entity));
// .set_action(Action::InputTextChanged(entity));
//})
.build(ctx);
// row3: only shown, if we read in `policy numbers` in
// a hashmap as values
let policy_data_stack = Stack::new()
.id(ID_POLICY_DATA_STACK)
.attach(Grid::row(3))