From 20c5265eb3c7c9ee33db5de53c5820d299a4b013 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Thu, 12 Dec 2024 09:14:42 +0100 Subject: [PATCH] #1348 Don't include the "custom playtime" toolbar button in the welcomse screen too much clutter --- dialogs/src/welcome_panel.rs | 7 +------ main/src/infrastructure/plugin/actions.rs | 1 - .../infrastructure/plugin/backbone_shell.rs | 15 +++++++------ main/src/infrastructure/ui/bindings.rs | 9 ++++---- main/src/infrastructure/ui/welcome_panel.rs | 21 +++++-------------- 5 files changed, 17 insertions(+), 36 deletions(-) diff --git a/dialogs/src/welcome_panel.rs b/dialogs/src/welcome_panel.rs index a6306819b..146ac1592 100644 --- a/dialogs/src/welcome_panel.rs +++ b/dialogs/src/welcome_panel.rs @@ -25,15 +25,10 @@ pub fn create(context: ScopedContext, ids: &mut IdGenerator) -> Dialog { context.rect(25, 80, 200, 30), ), context.checkbox( - "Add Playtime button to toolbar", + "Add Playtime button to main toolbar", ids.named_id("ID_SETUP_ADD_PLAYTIME_TOOLBAR_BUTTON"), context.rect(60, 120, 150, 8), ), - context.checkbox( - "Add custom Playtime button to toolbar", - ids.named_id("ID_SETUP_ADD_CUSTOM_PLAYTIME_TOOLBAR_BUTTON"), - context.rect(60, 135, 150, 8), - ), ctext( "Tip", ids.named_id("ID_SETUP_TIP_TEXT"), diff --git a/main/src/infrastructure/plugin/actions.rs b/main/src/infrastructure/plugin/actions.rs index 213ca5a72..3ac2ebb42 100644 --- a/main/src/infrastructure/plugin/actions.rs +++ b/main/src/infrastructure/plugin/actions.rs @@ -105,7 +105,6 @@ pub const ACTION_DEFS: &[ActionDef] = &[ command_name: ACTION_SHOW_HIDE_CUSTOM_PLAYTIME_COMMAND_NAME, action_name: "Show/hide custom Playtime", op: BackboneShell::show_hide_custom_playtime, - add_toolbar_button: true, icon: Some(c"toolbar_playtime_custom"), ..DEFAULT_DEF }, diff --git a/main/src/infrastructure/plugin/backbone_shell.rs b/main/src/infrastructure/plugin/backbone_shell.rs index c10bcb159..f2b5f74fc 100644 --- a/main/src/infrastructure/plugin/backbone_shell.rs +++ b/main/src/infrastructure/plugin/backbone_shell.rs @@ -446,18 +446,17 @@ impl BackboneShell { let _ = Self::register_extension_menu(); let _ = Self::register_toolbar_icon_map(); let toolbar_change_detector = if custom_toolbar_api_is_available() { - // Auto-add previously enabled dynamic toolbar buttons, if not present already - for (command_name, enabled) in &config.toolbar { - if *enabled > 0 { - let _ = add_or_remove_toolbar_button(command_name, true); - } - } - // Create change detector to automatically disable a dynamic toolbar button if the user removes the - // button manually. let observed_commands = ACTION_DEFS.iter().filter_map(|def| { if !def.add_toolbar_button { return None; } + // Auto-add previously enabled dynamic toolbar buttons, if not present already + let enabled = config.toolbar.get(def.command_name).is_some_and(|v| *v > 0); + if enabled { + let _ = add_or_remove_toolbar_button(def.command_name, true); + } + // Create change detector to automatically disable a dynamic toolbar button if the user removes the + // button manually. let command_id = Reaper::get() .action_by_command_name(def.command_name) .command_id() diff --git a/main/src/infrastructure/ui/bindings.rs b/main/src/infrastructure/ui/bindings.rs index 232bad45a..887355618 100644 --- a/main/src/infrastructure/ui/bindings.rs +++ b/main/src/infrastructure/ui/bindings.rs @@ -315,9 +315,8 @@ pub mod root { pub const ID_SETUP_INTRO_TEXT_1: u32 = 30244; pub const ID_SETUP_INTRO_TEXT_2: u32 = 30245; pub const ID_SETUP_ADD_PLAYTIME_TOOLBAR_BUTTON: u32 = 30246; - pub const ID_SETUP_ADD_CUSTOM_PLAYTIME_TOOLBAR_BUTTON: u32 = 30247; - pub const ID_SETUP_TIP_TEXT: u32 = 30248; - pub const ID_SETUP_PANEL_OK: u32 = 30249; - pub const ID_COLOR_PANEL: u32 = 30250; - pub const ID_HIDDEN_PANEL: u32 = 30251; + pub const ID_SETUP_TIP_TEXT: u32 = 30247; + pub const ID_SETUP_PANEL_OK: u32 = 30248; + pub const ID_COLOR_PANEL: u32 = 30249; + pub const ID_HIDDEN_PANEL: u32 = 30250; } diff --git a/main/src/infrastructure/ui/welcome_panel.rs b/main/src/infrastructure/ui/welcome_panel.rs index 629fec9e8..a7e436cc5 100644 --- a/main/src/infrastructure/ui/welcome_panel.rs +++ b/main/src/infrastructure/ui/welcome_panel.rs @@ -3,8 +3,7 @@ use std::fmt::Debug; use crate::infrastructure::plugin::dynamic_toolbar::custom_toolbar_api_is_available; use crate::infrastructure::plugin::{ - BackboneShell, ACTION_SHOW_HIDE_CUSTOM_PLAYTIME_COMMAND_NAME, - ACTION_SHOW_HIDE_PLAYTIME_COMMAND_NAME, ACTION_SHOW_WELCOME_SCREEN_LABEL, + BackboneShell, ACTION_SHOW_HIDE_PLAYTIME_COMMAND_NAME, ACTION_SHOW_WELCOME_SCREEN_LABEL, }; use crate::infrastructure::ui::bindings::root; use crate::infrastructure::ui::util::{fonts, symbols}; @@ -71,10 +70,6 @@ impl View for WelcomePanel { self.toggle_toolbar_button(ACTION_SHOW_HIDE_PLAYTIME_COMMAND_NAME) .expect("couldn't toggle toolbar button"); } - root::ID_SETUP_ADD_CUSTOM_PLAYTIME_TOOLBAR_BUTTON => { - self.toggle_toolbar_button(ACTION_SHOW_HIDE_CUSTOM_PLAYTIME_COMMAND_NAME) - .expect("couldn't toggle toolbar button"); - } root::ID_SETUP_PANEL_OK => self.close(), // IDCANCEL is escape button raw::IDCANCEL => { @@ -94,16 +89,10 @@ impl WelcomePanel { } fn invalidate_toolbar_checkboxes(&self) { - let bindings = [ - ( - root::ID_SETUP_ADD_PLAYTIME_TOOLBAR_BUTTON, - ACTION_SHOW_HIDE_PLAYTIME_COMMAND_NAME, - ), - ( - root::ID_SETUP_ADD_CUSTOM_PLAYTIME_TOOLBAR_BUTTON, - ACTION_SHOW_HIDE_CUSTOM_PLAYTIME_COMMAND_NAME, - ), - ]; + let bindings = [( + root::ID_SETUP_ADD_PLAYTIME_TOOLBAR_BUTTON, + ACTION_SHOW_HIDE_PLAYTIME_COMMAND_NAME, + )]; for (control_id, action_name) in bindings { let checked = BackboneShell::get() .config()