Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 @@ -40,6 +40,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
17 changes: 16 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,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 @@ -1021,6 +1022,8 @@ 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 @@ -1110,6 +1113,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 @@ -2058,6 +2070,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 @@ -2701,7 +2716,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))
.show_headerbar(self.config.show_headerbar);

if self.config.focus_follow_mouse {
Expand Down