Skip to content

Commit

Permalink
#1348 Don't include the "custom playtime" toolbar button in the welco…
Browse files Browse the repository at this point in the history
…mse screen

too much clutter
  • Loading branch information
helgoboss committed Dec 12, 2024
1 parent a68c725 commit 20c5265
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 36 deletions.
7 changes: 1 addition & 6 deletions dialogs/src/welcome_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion main/src/infrastructure/plugin/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
15 changes: 7 additions & 8 deletions main/src/infrastructure/plugin/backbone_shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 4 additions & 5 deletions main/src/infrastructure/ui/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 5 additions & 16 deletions main/src/infrastructure/ui/welcome_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 => {
Expand All @@ -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()
Expand Down

0 comments on commit 20c5265

Please sign in to comment.