Skip to content

Commit

Permalink
feat: add support for configuring "default-hide-toolbars"
Browse files Browse the repository at this point in the history
  • Loading branch information
mistgc committed Feb 14, 2024
1 parent b9553b8 commit 6fb3d68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/command_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ pub struct CommandLine {
/// Increase or decrease the size of the annotations
#[arg(long)]
pub annotation_size_factor: Option<f64>,

/// Hide toolbars by default
#[arg(short, long)]
pub default_hide_toolbars: bool,
}

#[derive(Debug, Clone, Copy, Default, ValueEnum)]
Expand Down
13 changes: 13 additions & 0 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct Configuration {
copy_command: Option<String>,
annotation_size_factor: f64,
color_palette: ColorPalette,
default_hide_toolbars: bool,
}

pub struct ColorPalette {
Expand Down Expand Up @@ -138,6 +139,9 @@ impl Configuration {
if let Some(v) = general.annotation_size_factor {
self.annotation_size_factor = v;
}
if let Some(v) = general.default_hide_toolbars {
self.default_hide_toolbars = v;
}
}
fn merge(&mut self, file: Option<ConfigurationFile>, command_line: CommandLine) {
// input_filename is required and needs to be overwritten
Expand All @@ -160,6 +164,9 @@ impl Configuration {
if command_line.early_exit {
self.early_exit = command_line.early_exit;
}
if command_line.default_hide_toolbars {
self.default_hide_toolbars = command_line.default_hide_toolbars;
}
if let Some(v) = command_line.initial_tool {
self.initial_tool = v.into();
}
Expand Down Expand Up @@ -205,6 +212,10 @@ impl Configuration {
pub fn color_palette(&self) -> &ColorPalette {
&self.color_palette
}

pub fn default_hide_toolbars(&self) -> bool {
self.default_hide_toolbars
}
}

impl Default for Configuration {
Expand All @@ -218,6 +229,7 @@ impl Default for Configuration {
copy_command: None,
annotation_size_factor: 1.0f64,
color_palette: ColorPalette::default(),
default_hide_toolbars: false,
}
}
}
Expand Down Expand Up @@ -251,6 +263,7 @@ struct ConfiguationFileGeneral {
copy_command: Option<String>,
annotation_size_factor: Option<f64>,
output_filename: Option<String>,
default_hide_toolbars: Option<bool>,
}

#[derive(Deserialize)]
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ impl Component for App {
.launch(())
.forward(sketch_board.sender(), SketchBoardInput::ToolbarEvent);

if APP_CONFIG.read().default_hide_toolbars() {
tools_toolbar.widget().hide();
style_toolbar.widget().hide();
}

// Model
let model = App {
sketch_board,
Expand Down

0 comments on commit 6fb3d68

Please sign in to comment.