callbacks: remove unused global functions

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-09-26 19:29:34 +02:00
parent 777fff3776
commit 0c16237c6c
2 changed files with 23 additions and 37 deletions

View File

@@ -23,33 +23,19 @@ struct Environment {
rust_log: String,
}
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyList`).
/// Provides generic methods to handle states of datatypes (e.g. used in `PolicyCheckState`).
pub trait GlobalState {
/// Navigates to the given entity.
fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
let mut old_focused_element = ctx.get_widget(old_focused_element);
old_focused_element.set("focused", false);
//old_focused_element.update_theme_by_state(false);
}
ctx.window().get_mut::<Global>("global").focused_widget = None;
ctx.widget().set("visibility", Visibility::Collapsed);
ctx.get_widget(to).set("visibility", Visibility::Visible);
}
/// Get the text of a widget.
fn get_text(&self, ctx: &mut Context<'_>, entity: Entity) -> Option<String> {
let mut widget = ctx.get_widget(entity);
let entry = widget.get_mut::<String>("text");
if entry.is_empty() {
return None;
}
let copy = entry.to_string();
entry.clear();
Some(copy)
}
// /// Navigates to the given entity.
// fn navigate(&self, to: Entity, ctx: &mut Context<'_>) {
// if let Some(old_focused_element) = ctx.window().get::<Global>("global").focused_widget {
// let mut old_focused_element = ctx.get_widget(old_focused_element);
// old_focused_element.set("focused", false);
// //old_focused_element.update_theme_by_state(false);
// }
// ctx.window().get_mut::<Global>("global").focused_widget = None;
// ctx.widget().set("visibility", Visibility::Collapsed);
// ctx.get_widget(to).set("visibility", Visibility::Visible);
// }
/// Save the our data structure and convert it to `ron` file format.
/// The cargo package identifier (here: 'nwx.advotracker') is taken to create the app directory.

View File

@@ -63,7 +63,7 @@ pub struct PolicyCheckState {
duration: Duration,
label_result: Entity,
lang: String,
last_focused: Option<Entity>,
//last_focused: Option<Entity>,
button_menu: Entity,
menu: Entity,
policy_data_count: u64,
@@ -144,10 +144,10 @@ impl PolicyCheckState {
match envy::from_env::<Environment>() {
Ok(environment) => {
if environment.test_lang != lang { lang = environment.test_lang; }
trace!(target: "advotracker", lang = ?lang);
},
Err(e) => { info!(target: "advotracker", "{}", e) }
}
trace!(target: "advotracker", lang = ?lang);
lang
}
@@ -472,15 +472,15 @@ impl State for PolicyCheckState {
/// Update the widget state.
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 {
if let Some(last_focused) = self.last_focused {
ctx.get_widget(last_focused).set("focused", false);
// widget is unvisible, but takes space to be considered
ctx.get_widget(last_focused)
.set("visibility", Visibility::Collapsed);
}
}
// // clear focus on focus moved
// if self.last_focused != ctx.window().get::<Global>("global").focused_widget {
// if let Some(last_focused) = self.last_focused {
// ctx.get_widget(last_focused).set("focused", false);
// // widget is unvisible, but takes space to be considered
// ctx.get_widget(last_focused)
// .set("visibility", Visibility::Collapsed);
// }
//}
if let Some(action) = self.action {
match action {