diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index 88ed838..509fa59 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -41,6 +41,7 @@ syntax-dark = Color scheme dark syntax-light = Color scheme light default-zoom-step = Zoom steps opacity = Background opacity +padding = Padding ### Font font = Font diff --git a/src/config.rs b/src/config.rs index 4aef9df..45d1ba7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -229,6 +229,7 @@ pub struct Config { pub font_stretch: u16, pub font_size_zoom_step_mul_100: u16, pub opacity: u8, + pub padding: u16, pub profiles: BTreeMap, pub show_headerbar: bool, pub use_bright_bold: bool, @@ -253,6 +254,7 @@ impl Default for Config { font_stretch: Stretch::Normal.to_number(), font_weight: Weight::NORMAL.0, opacity: 100, + padding: AppTheme::System.theme().cosmic().space_xxs(), profiles: BTreeMap::new(), show_headerbar: true, syntax_theme_dark: COSMIC_THEME_DARK.to_string(), @@ -333,6 +335,14 @@ impl Config { f32::from(self.opacity) / 100.0 } + pub fn padding_value(&self, space_xxs: u16) -> u16 { + if self.padding <= space_xxs { + u16::from(space_xxs) + } else { + u16::from(self.padding) + } + } + // Get a sorted and adjusted for duplicates list of profile names and ids pub fn profile_names(&self) -> Vec<(String, ProfileId)> { let mut profile_names = Vec::<(String, ProfileId)>::with_capacity(self.profiles.len()); diff --git a/src/main.rs b/src/main.rs index f671b71..fc06591 100644 --- a/src/main.rs +++ b/src/main.rs @@ -366,6 +366,7 @@ pub enum Message { Modifiers(Modifiers), MouseEnter(pane_grid::Pane), Opacity(u8), + Padding(u16), PaneClicked(pane_grid::Pane), PaneDragged(pane_grid::DragEvent), PaneFocusAdjacent(pane_grid::Direction), @@ -1066,6 +1067,7 @@ impl App { } fn settings(&self) -> Element<'_, Message> { + let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing; let app_theme_selected = match self.config.app_theme { AppTheme::Dark => 1, AppTheme::Light => 2, @@ -1155,6 +1157,15 @@ impl App { .control(widget::slider(0..=100, self.config.opacity, |opacity| { Message::Opacity(opacity) })), + ) + .add( + widget::settings::item::builder(fl!("padding")) + .description(format!("{}px", self.config.padding)) + .control(widget::slider( + space_xxs..=100, + self.config.padding, + |padding| Message::Padding(padding), + )), ); let mut font_section = widget::settings::section() @@ -2152,6 +2163,9 @@ impl Application for App { Message::Opacity(opacity) => { config_set!(opacity, cmp::min(100, opacity)); } + Message::Padding(padding) => { + config_set!(padding, cmp::min(100, padding)); + } Message::PaneClicked(pane) => { self.pane_model.set_focus(pane); return self.update_title(Some(pane)); @@ -2845,7 +2859,7 @@ impl Application for App { .on_window_focused(|| Message::WindowFocused) .on_window_unfocused(|| Message::WindowUnfocused) .opacity(self.config.opacity_ratio()) - .padding(space_xxs) + .padding(self.config.padding_value(space_xxs)) .sharp_corners(self.core.window.sharp_corners) .show_headerbar(self.config.show_headerbar);