Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en/cosmic_term.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProfileId, Profile>,
pub show_headerbar: bool,
pub use_bright_bold: bool,
Expand All @@ -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(),
Expand Down Expand Up @@ -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());
Expand Down
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down