implement a toggle theme menu
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -36,6 +36,7 @@ pub static ID_POLICY_CHECK_MENU_SHORTCUT_QUIT: &'static str = "policy_check_menu
|
||||
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_MENU_TOGGLE_THEME: &'static str = "policy_check_popup_menu_toggle_theme";
|
||||
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";
|
||||
|
||||
@@ -393,6 +393,23 @@ impl PolicycheckState {
|
||||
println!("PopupProgress created: {:?}", self.progress_popup);
|
||||
}
|
||||
|
||||
/// Set a toggle_theme menu
|
||||
fn set_menu_toggle_theme(&mut self, ctx: &mut Context<'_>) {
|
||||
let stack = ctx
|
||||
.entity_of_child(ID_POLICY_CHECK_POPUP_MENU_TOGGLE_THEME)
|
||||
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_MENU_TOGGLE_THEME'.");
|
||||
let current_entity = ctx.entity();
|
||||
let build_context = &mut ctx.build_context();
|
||||
|
||||
// create a menu overlay
|
||||
self.popup_menu_toggle_theme = create_menu_toggle_theme(current_entity, build_context);
|
||||
|
||||
// create a menu_popup widget as a child of entity "ID_POLICY_CHECK_POPUP_MENU"
|
||||
build_context.append_child(stack, self.popup_menu_toggle_theme);
|
||||
|
||||
println!("Popup Menu Toggle Theme created: {:?}", self.popup_menu_toggle_theme);
|
||||
}
|
||||
|
||||
/// Change visibility of the result label.
|
||||
fn _set_visibility(&self, entity: Entity, ctx: &mut Context<'_>) {
|
||||
if ctx.get_widget(entity).get::<String16>("text").is_empty() {
|
||||
@@ -659,6 +676,35 @@ fn create_menu(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
.build(ctx)
|
||||
}
|
||||
|
||||
/// Create a popup submenu to toogle the active theme
|
||||
fn create_menu_toggle_theme(target: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||
Popup::new()
|
||||
.id(ID_POLICY_CHECK_POPUP_MENU_TOGGLE_THEME)
|
||||
.style("container_menu")
|
||||
.target(target)
|
||||
.open(true)
|
||||
.width(280)
|
||||
.height(140)
|
||||
.child(
|
||||
ComboBox::new()
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(6))
|
||||
//.count(themes_count)
|
||||
.items_builder(move |bc, index| {
|
||||
let theme_name =
|
||||
PolicycheckView::themes_ref(&bc.get_widget(target))[index].clone();
|
||||
//TextBlock::new().v_align("center").text(theme_name).build(bc)
|
||||
TextBlock::new().v_align("center").text("redox").build(bc)
|
||||
})
|
||||
.on_changed("selected_index", move |ctx, _| {
|
||||
ctx.send_message(PolicycheckAction::ChangeTheme, target);
|
||||
})
|
||||
.selected_index(target)
|
||||
.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 {
|
||||
Popup::new()
|
||||
|
||||
@@ -15,6 +15,8 @@ use crate::{
|
||||
widgets::policycheck::policycheck_state::*,
|
||||
};
|
||||
|
||||
type List = Vec<String>;
|
||||
|
||||
// Macro that initializes the widget structures/variables for our view
|
||||
widget!(
|
||||
/// Dialog to enter a policy identifier/number.
|
||||
|
||||
Reference in New Issue
Block a user