structure update
* rename PolicyCheckView to PolicycheckView * rename PolicyCheckState to PolicycheckState * rename menu to popup_menu Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -19,13 +19,15 @@ use std::env;
|
|||||||
//use std::process;
|
//use std::process;
|
||||||
use tracing::{info, trace, Level};
|
use tracing::{info, trace, Level};
|
||||||
|
|
||||||
use orbtk::prelude::*;
|
use orbtk::{
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
// The Main view
|
// The Main view
|
||||||
use advotracker::{
|
use advotracker::{
|
||||||
widgets::{
|
widgets::{
|
||||||
main_view,
|
main_view,
|
||||||
policycheck::policycheck_state::PolicyCheckState,
|
//policycheck::policycheck_state::PolicyCheckState,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,8 +44,8 @@ struct Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Style extension
|
// Style extension
|
||||||
static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/advotracker_dark.ron");
|
//static FLUENT_DARK_EXT: &str = include_str!("../assets/advotracker/fluent_dark.ron");
|
||||||
static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/advotracker_light.ron");
|
//static FLUENT_LIGHT_EXT: &str = include_str!("../assets/advotracker/fluent_light.ron");
|
||||||
|
|
||||||
// German localization file.
|
// German localization file.
|
||||||
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker_de_DE.ron");
|
static ADVOTRACKER_DE_DE: &str = include_str!("../assets/advotracker/advotracker_de_DE.ron");
|
||||||
@@ -65,6 +67,20 @@ fn get_lang() -> String {
|
|||||||
lang
|
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)),
|
||||||
|
// ))
|
||||||
|
// }
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use parse_args::parse_args;
|
use parse_args::parse_args;
|
||||||
use tracing_subscriber::fmt;
|
use tracing_subscriber::fmt;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use orbtk::prelude::*;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::structures::PolicyCheck,
|
data::structures::PolicyCheck,
|
||||||
widgets::policycheck::policycheck_view::PolicyCheckView,
|
widgets::policycheck::policycheck_view::PolicycheckView,
|
||||||
};
|
};
|
||||||
|
|
||||||
type List = Vec<String>;
|
type List = Vec<String>;
|
||||||
@@ -26,7 +26,7 @@ widget!(MainView {
|
|||||||
|
|
||||||
impl Template for MainView {
|
impl Template for MainView {
|
||||||
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, _id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let policycheck_view = PolicyCheckView::new()
|
let policycheck_view = PolicycheckView::new()
|
||||||
//.policy_number_count(0)
|
//.policy_number_count(0)
|
||||||
//.policylist_view(id)
|
//.policylist_view(id)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|||||||
@@ -8,16 +8,22 @@ use std::time::{Duration, SystemTime};
|
|||||||
use tracing::{error, info, trace};
|
use tracing::{error, info, trace};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
widgets::global_state::GlobalState,
|
widgets::{
|
||||||
data::structures::{PolicyCode, PolicyDataList, PolicyList},
|
global_state::GlobalState,
|
||||||
data::constants::*,
|
policycheck::policycheck_view::PolicycheckView,
|
||||||
|
},
|
||||||
|
data::{
|
||||||
|
structures::{PolicyCode, PolicyDataList, PolicyList},
|
||||||
|
constants::*,
|
||||||
|
},
|
||||||
services::imports::allianzdirectcall::import,
|
services::imports::allianzdirectcall::import,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Actions that can execute on the task view.
|
/// Actions that can execute on the task view.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Action {
|
pub enum PolicycheckAction {
|
||||||
ClearEntry(Entity),
|
ClearEntry(Entity),
|
||||||
|
ChangeTheme(),
|
||||||
InputTextChanged(Entity),
|
InputTextChanged(Entity),
|
||||||
ImportData,
|
ImportData,
|
||||||
OpenMenu(Entity),
|
OpenMenu(Entity),
|
||||||
@@ -45,30 +51,28 @@ struct Environment {
|
|||||||
rust_log: String,
|
rust_log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles the requests from `PolicyCheckView`.
|
/// Handles the requests from `PolicycheckView`.
|
||||||
#[derive(AsAny, Default)]
|
#[derive(AsAny, Default)]
|
||||||
pub struct PolicyCheckState {
|
pub struct PolicycheckState {
|
||||||
action: Option<Action>,
|
action: Option<PolicycheckAction>,
|
||||||
duration: Duration,
|
duration: Duration,
|
||||||
label_result: Entity,
|
label_result: Entity,
|
||||||
lang: String,
|
lang: String,
|
||||||
//last_focused: Option<Entity>,
|
//last_focused: Option<Entity>,
|
||||||
button_menu: Entity,
|
button_menu: Entity,
|
||||||
menu: Entity,
|
|
||||||
policy_data_count: u64,
|
policy_data_count: u64,
|
||||||
policy_numbers: HashMap<u64, PolicyCode>,
|
policy_numbers: HashMap<u64, PolicyCode>,
|
||||||
progress_bar: Entity,
|
progress_bar: Entity,
|
||||||
progress_count: f64,
|
progress_count: f64,
|
||||||
progress_popup: Entity,
|
progress_popup: Entity
|
||||||
theme_name: String
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState for 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 view
|
||||||
impl PolicyCheckState {
|
impl PolicycheckState {
|
||||||
/// Sets a new action.
|
/// Sets a new action.
|
||||||
pub fn action(&mut self, action: Action) {
|
pub fn action(&mut self, action: PolicycheckAction) {
|
||||||
self.action = action.into();
|
self.action = action.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,11 +321,11 @@ impl PolicyCheckState {
|
|||||||
|
|
||||||
/// Remove the menu popup box
|
/// Remove the menu popup box
|
||||||
fn remove_menu(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
fn remove_menu(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||||
ctx.remove_child(self.menu);
|
ctx.remove_child(self.popup_menu);
|
||||||
println!("Popup {:?} removed !", id);
|
println!("Popup {:?} removed !", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the menu popup box
|
/// Remove the popup box
|
||||||
fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
fn remove_popup(&mut self, id: Entity, ctx: &mut Context<'_>) {
|
||||||
ctx.remove_child(self.progress_popup);
|
ctx.remove_child(self.progress_popup);
|
||||||
println!("Popup {:?} removed !", id);
|
println!("Popup {:?} removed !", id);
|
||||||
@@ -355,19 +359,17 @@ impl PolicyCheckState {
|
|||||||
fn set_menu(&mut self, ctx: &mut Context<'_>) {
|
fn set_menu(&mut self, ctx: &mut Context<'_>) {
|
||||||
let stack = ctx
|
let stack = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||||
.expect("PolicyCheckState: Can't find entity of resource 'ID_POLICY_CHECK_BUTTON_MENU'.");
|
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
|
||||||
let current_entity = ctx.entity();
|
let current_entity = ctx.entity();
|
||||||
let build_context = &mut ctx.build_context();
|
let build_context = &mut ctx.build_context();
|
||||||
|
|
||||||
// create a menu overlay
|
// create a popup menu overlay
|
||||||
self.menu = create_menu(current_entity, build_context);
|
self.popup_menu = create_menu(current_entity, build_context);
|
||||||
|
|
||||||
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_POLICY_NUMBER"
|
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_BUTTON_MENU"
|
||||||
build_context.append_child(stack, self.menu);
|
build_context.append_child(stack, self.popup_menu);
|
||||||
//.expect("PolicyCheckState: Can't find entity of resource 'ID_POLICY_CHECK_MENU'");
|
|
||||||
//.expect("PolicyCheckState: Can't create overlay as child of entity");
|
|
||||||
|
|
||||||
println!("Popup Menu created: {:?}", self.menu);
|
println!("Popup Menu created: {:?}", self.popup_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a progress popup that updates the import status in a progress bar
|
/// Set a progress popup that updates the import status in a progress bar
|
||||||
@@ -375,7 +377,7 @@ impl PolicyCheckState {
|
|||||||
//println!("Set up Progress popup: {:?}", text_box);
|
//println!("Set up Progress popup: {:?}", text_box);
|
||||||
let stack = ctx
|
let stack = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_RESULT)
|
.entity_of_child(ID_POLICY_CHECK_RESULT)
|
||||||
.expect("PolicyCheckState: Can't find entity of resource 'ID_POLICY_CHECK_RESULT'.");
|
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_RESULT'.");
|
||||||
let current_entity = ctx.entity();
|
let current_entity = ctx.entity();
|
||||||
let build_context = &mut ctx.build_context();
|
let build_context = &mut ctx.build_context();
|
||||||
|
|
||||||
@@ -386,7 +388,7 @@ impl PolicyCheckState {
|
|||||||
|
|
||||||
self.progress_bar = ctx
|
self.progress_bar = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
.entity_of_child(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||||
.expect("PolicyCheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
.expect("PolicycheckState.init: Can't find entity of resource 'ID_POLICY_CHECK_PROGRESS_BAR'.");
|
||||||
|
|
||||||
println!("PopupProgress created: {:?}", self.progress_popup);
|
println!("PopupProgress created: {:?}", self.progress_popup);
|
||||||
}
|
}
|
||||||
@@ -422,7 +424,7 @@ impl PolicyCheckState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// upported states for our view
|
/// upported states for our view
|
||||||
impl State for PolicyCheckState {
|
impl State for PolicycheckState {
|
||||||
/// Initialize the widget state
|
/// Initialize the widget state
|
||||||
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn init(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
let time_start= SystemTime::now();
|
let time_start= SystemTime::now();
|
||||||
@@ -432,11 +434,11 @@ impl State for PolicyCheckState {
|
|||||||
// Entities
|
// Entities
|
||||||
self.button_menu = ctx
|
self.button_menu = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
|
||||||
.expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
|
.expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_BUTTON_MENU'.");
|
||||||
|
|
||||||
self.label_result = ctx
|
self.label_result = ctx
|
||||||
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
.entity_of_child(ID_POLICY_CHECK_LABEL_RESULT)
|
||||||
.expect("PolicyCheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
.expect("PolicycheckState.init: Can't find resource entity 'ID_POLICY_CHECK_LABEL_RESULT'.");
|
||||||
|
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
//TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
@@ -445,7 +447,7 @@ impl State for PolicyCheckState {
|
|||||||
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
Stack::visibility_set(&mut ctx.child(ID_POLICY_CHECK_FORM_ROW_2), Visibility::Collapsed);
|
||||||
|
|
||||||
// Preset localization with given environment lang
|
// Preset localization with given environment lang
|
||||||
self.lang = PolicyCheckState::get_lang();
|
self.lang = PolicycheckState::get_lang();
|
||||||
ctx.set_language(&self.lang);
|
ctx.set_language(&self.lang);
|
||||||
|
|
||||||
// // Load the saved data from a file in 'ron' format into our data structure.
|
// // Load the saved data from a file in 'ron' format into our data structure.
|
||||||
@@ -480,7 +482,7 @@ impl State for PolicyCheckState {
|
|||||||
|
|
||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
Action::AddProgress(increment) => {
|
PolicycheckAction::AddProgress(increment) => {
|
||||||
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
let old_width = ProgressBar::val_clone(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR));
|
||||||
|
|
||||||
let new_width = old_width + increment;
|
let new_width = old_width + increment;
|
||||||
@@ -492,13 +494,16 @@ impl State for PolicyCheckState {
|
|||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::ClearEntry(policy_check_policy_number) => {
|
PolicycheckAction::ChangeTheme() => {
|
||||||
|
println!("Changing active theme.");
|
||||||
|
}
|
||||||
|
PolicycheckAction::ClearEntry(policy_check_policy_number) => {
|
||||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||||
}
|
}
|
||||||
Action::InputTextChanged(entity) => {
|
PolicycheckAction::InputTextChanged(entity) => {
|
||||||
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
println!("entry changed: {}", TextBox::text_clone(&ctx.get_widget(entity)));
|
||||||
}
|
}
|
||||||
Action::ImportData => {
|
PolicycheckAction::ImportData => {
|
||||||
match self.import_data(ctx) {
|
match self.import_data(ctx) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
trace!(target: "advotracker", import_data = "success");
|
trace!(target: "advotracker", import_data = "success");
|
||||||
@@ -509,50 +514,47 @@ impl State for PolicyCheckState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::OpenMenu(entity) => {
|
PolicycheckAction::OpenMenu(entity) => {
|
||||||
self.open_menu(entity, ctx);
|
self.open_menu(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::ParseEntry(text_box) => {
|
PolicycheckAction::ParseEntry(text_box) => {
|
||||||
self.parse_entry(text_box, ctx);
|
self.parse_entry(text_box, ctx);
|
||||||
}
|
}
|
||||||
Action::RemoveFocus(policy_check_policy_number) => {
|
PolicycheckAction::RemoveFocus(policy_check_policy_number) => {
|
||||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||||
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
//ctx.EventAdapter(FocusEvent::RemoveFocus(policy_check_policy_number));
|
||||||
}
|
}
|
||||||
Action::RemoveMenu(entity) => {
|
PolicycheckAction::RemoveMenu(entity) => {
|
||||||
self.remove_menu(entity, ctx);
|
self.remove_menu(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::RemovePopup(entity) => {
|
PolicycheckAction::RemovePopup(entity) => {
|
||||||
self.remove_popup(entity, ctx);
|
self.remove_popup(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::ResetProgress => {
|
PolicycheckAction::ResetProgress => {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
||||||
}
|
}
|
||||||
Action::SetEntry(policy_check_policy_number) => {
|
PolicycheckAction::SetEntry(policy_check_policy_number) => {
|
||||||
//self.last_focused = Some();
|
//self.last_focused = Some();
|
||||||
self.set_entry(policy_check_policy_number, ctx);
|
self.set_entry(policy_check_policy_number, ctx);
|
||||||
}
|
}
|
||||||
Action::SetMenu(_entity) => {
|
PolicycheckAction::SetMenu(_entity) => {
|
||||||
self.set_menu(ctx);
|
self.set_menu(ctx);
|
||||||
}
|
}
|
||||||
Action::SetProgress(value) => {
|
PolicycheckAction::SetProgress(value) => {
|
||||||
if value >= 0. || value <= 1. {
|
if value >= 0. || value <= 1. {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), value);
|
||||||
} else {
|
} else {
|
||||||
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
ProgressBar::val_set(&mut ctx.child(ID_POLICY_CHECK_PROGRESS_BAR), 0.);
|
||||||
} }
|
} }
|
||||||
Action::SetProgressPopup(_entity) => {
|
PolicycheckAction::SetProgressPopup(_entity) => {
|
||||||
self.set_popup_progress(ctx);
|
self.set_popup_progress(ctx);
|
||||||
}
|
}
|
||||||
Action::SetVisibility(_entity) => {
|
PolicycheckAction::SetVisibility(_entity) => {
|
||||||
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
TextBlock::visibility_set(&mut ctx.child(ID_POLICY_CHECK_LABEL_RESULT), Visibility::Collapsed);
|
||||||
}
|
}
|
||||||
Action::TextChanged(entity, _index) => {
|
PolicycheckAction::TextChanged(entity, _index) => {
|
||||||
self.set_entry(entity, ctx);
|
self.set_entry(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::ToggleTheme(_entity) => {
|
|
||||||
println!{"Switch theme to {:?}", self.theme_name};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reset action
|
// Reset action
|
||||||
@@ -565,18 +567,18 @@ impl State for PolicyCheckState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a menu popup
|
/// Create a menu popup
|
||||||
fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
fn create_menu(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
Popup::new()
|
Popup::new()
|
||||||
.id(ID_POLICY_CHECK_POPUP_MENU)
|
.id(ID_POLICY_CHECK_POPUP_MENU)
|
||||||
.style("container_menu")
|
.style("container_menu")
|
||||||
.target(menu)
|
.target(target)
|
||||||
.open(true)
|
.open(true)
|
||||||
.width(280)
|
.width(280)
|
||||||
.height(140)
|
.height(140)
|
||||||
.on_mouse_down(move |ctx, _| {
|
.on_mouse_down(move |ctx, _| {
|
||||||
println!("on_click -> remove_menu()");
|
println!("on_click -> remove_menu()");
|
||||||
ctx.get_mut::<PolicyCheckState>(menu)
|
ctx.get_mut::<PolicycheckState>(target)
|
||||||
.action(Action::RemoveMenu(menu));
|
.action(PolicycheckAction::RemoveMenu(target));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
@@ -613,7 +615,6 @@ fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME)
|
.id(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME)
|
||||||
//.style("body")
|
|
||||||
.style("button_menu")
|
.style("button_menu")
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
@@ -621,8 +622,8 @@ fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.icon(material_icons_font::MD_EDIT)
|
.icon(material_icons_font::MD_EDIT)
|
||||||
.text("Toggle theme")
|
.text("Toggle theme")
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
states.get_mut::<PolicyCheckState>(menu)
|
states.get_mut::<PolicycheckState>(target)
|
||||||
.action(Action::ToggleTheme(menu));
|
.action(PolicycheckAction::ToggleTheme(target));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -669,8 +670,8 @@ fn create_popup_progress(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
|||||||
.height(100)
|
.height(100)
|
||||||
.on_mouse_down(move |ctx, _| {
|
.on_mouse_down(move |ctx, _| {
|
||||||
println!("on_click -> remove_popup_progress()");
|
println!("on_click -> remove_popup_progress()");
|
||||||
ctx.get_mut::<PolicyCheckState>(target)
|
ctx.get_mut::<PolicycheckState>(target)
|
||||||
.action(Action::RemovePopup(target));
|
.action(PolicycheckAction::RemovePopup(target));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::constants::*,
|
data::{
|
||||||
data::structures::PolicyCheck,
|
constants::*,
|
||||||
|
structures::PolicyCheck,
|
||||||
|
},
|
||||||
widgets::policycheck::policycheck_state::*,
|
widgets::policycheck::policycheck_state::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -17,20 +19,21 @@ use crate::{
|
|||||||
widget!(
|
widget!(
|
||||||
/// Dialog to enter a policy identifier/number.
|
/// Dialog to enter a policy identifier/number.
|
||||||
/// This identifier is checked agains a map of valid policy codes.
|
/// This identifier is checked agains a map of valid policy codes.
|
||||||
PolicyCheckView<PolicyCheckState> {
|
PolicycheckView<PolicycheckState> {
|
||||||
lang: String,
|
lang: String,
|
||||||
policy_check: PolicyCheck,
|
policy_check: PolicyCheck,
|
||||||
policy_check_title: String16,
|
policy_check_title: String,
|
||||||
policy_data_count: u32
|
policy_data_count: u32
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/// The template implementation of the policy check view
|
/// The template implementation of the policy check view
|
||||||
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
/// All GUI elements are styled using the "style" attribute referencing to a ron based css
|
||||||
impl Template for PolicyCheckView {
|
impl Template for PolicycheckView {
|
||||||
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
//fn template(self, policycheck_view: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
fn template(self, id: Entity, ctx: &mut BuildContext<'_>) -> Self {
|
||||||
let policy_check_bottom_bar = Container::new()
|
|
||||||
|
let policy_check_bottom_bar = Container::new()
|
||||||
//.style(STYLE_BOTTOM_BAR)
|
//.style(STYLE_BOTTOM_BAR)
|
||||||
.attach(Grid::row(4))
|
.attach(Grid::row(4))
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
@@ -82,9 +85,9 @@ impl Template for PolicyCheckView {
|
|||||||
//.min_size(16, 16)
|
//.min_size(16, 16)
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.on_click(move |ctx, _| {
|
.on_click(move |ctx, _| {
|
||||||
//ctx.get_mut::<PolicyCheckState>(policycheck_state)
|
//ctx.get_mut::<PolicycheckState>(policycheck_state)
|
||||||
ctx.get_mut::<PolicyCheckState>(id)
|
ctx.get_mut::<PolicycheckState>(id)
|
||||||
.action(Action::OpenMenu(policy_check_label_menu));
|
.action(PolicycheckAction::OpenMenu(policy_check_label_menu));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
@@ -153,30 +156,30 @@ impl Template for PolicyCheckView {
|
|||||||
.water_mark("10-stellig")
|
.water_mark("10-stellig")
|
||||||
.on_activate(move |ctx, entity| {
|
.on_activate(move |ctx, entity| {
|
||||||
// Entity is entered/activated via Mouse/Keyboard
|
// Entity is entered/activated via Mouse/Keyboard
|
||||||
//ctx.get_mut::<PolicyCheckState>(policy_check_view)
|
//ctx.get_mut::<PolicycheckState>(policy_check_view)
|
||||||
println!("ParseEntry: {:?}", entity);
|
println!("ParseEntry: {:?}", entity);
|
||||||
ctx.get_mut::<PolicyCheckState>(id)
|
ctx.get_mut::<PolicycheckState>(id)
|
||||||
.action(Action::ParseEntry(entity));
|
.action(PolicycheckAction::ParseEntry(entity));
|
||||||
})
|
})
|
||||||
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
|
//.on_changed(|_, entity, _, _| println!("Selection changed: {:?}", entity))
|
||||||
// .on_changed(move |ctx, entity, _| {
|
// .on_changed(move |ctx, entity, _| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::SetProgressBox(entity));
|
// .action(Action::SetProgressBox(entity));
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::AddProgress(0.5));
|
// .action(Action::AddProgress(0.5));
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::InputTextChanged(entity));
|
// .action(Action::InputTextChanged(entity));
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::SetVisibility(entity));
|
// .action(Action::SetVisibility(entity));
|
||||||
// ctx.get_widget(policy_check_label_policy_number).set("visible");
|
// ctx.get_widget(policy_check_label_policy_number).set("visible");
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::SetVisility(entity));
|
// .action(Action::SetVisility(entity));
|
||||||
// })
|
// })
|
||||||
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
||||||
// state(id, states).action(Action::AddItem);
|
// state(id, states).action(Action::AddItem);
|
||||||
// })
|
// })
|
||||||
//.on_key_down(move |ctx, _| {
|
//.on_key_down(move |ctx, _| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::ImportData);
|
// .action(Action::ImportData);
|
||||||
// true
|
// true
|
||||||
//})
|
//})
|
||||||
@@ -216,6 +219,7 @@ impl Template for PolicyCheckView {
|
|||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.h_align("start")
|
.h_align("start")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
|
.text("empty")
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
@@ -309,11 +313,11 @@ impl Template for PolicyCheckView {
|
|||||||
.margin((0, 0, 0, 16))
|
.margin((0, 0, 0, 16))
|
||||||
// WIP code @kivimango
|
// WIP code @kivimango
|
||||||
// .on_activate(move |ctx, entity| {
|
// .on_activate(move |ctx, entity| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::ParseEntry(entity));
|
// .action(Action::ParseEntry(entity));
|
||||||
// })
|
// })
|
||||||
// .on_changed(move |ctx, entity| {
|
// .on_changed(move |ctx, entity| {
|
||||||
// ctx.get_mut::<PolicyCheckState>(id)
|
// ctx.get_mut::<PolicycheckState>(id)
|
||||||
// .action(Action::InputTextChanged(entity));
|
// .action(Action::InputTextChanged(entity));
|
||||||
//})
|
//})
|
||||||
.build(ctx);
|
.build(ctx);
|
||||||
@@ -346,7 +350,7 @@ impl Template for PolicyCheckView {
|
|||||||
.build(ctx);
|
.build(ctx);
|
||||||
|
|
||||||
// Starter page: check policy numbers
|
// Starter page: check policy numbers
|
||||||
self.name("PolicyCheckView")
|
self.name("PolicycheckView")
|
||||||
// initialize struct (derived default macro)
|
// initialize struct (derived default macro)
|
||||||
.policy_check(PolicyCheck::default())
|
.policy_check(PolicyCheck::default())
|
||||||
.child(
|
.child(
|
||||||
@@ -387,7 +391,7 @@ impl Template for PolicyCheckView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to request PolicyCheckState
|
// helper to request PolicycheckState
|
||||||
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicyCheckState {
|
//fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut PolicycheckState {
|
||||||
// states.get_mut(id)
|
// states.get_mut(id)
|
||||||
//}
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user