Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slider for border radius #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions i18n/en/cosmic_ext_tweaks.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ padding-description = Padding is the space between the contents and the borders
spacing = Spacing
spacing-description = Spacing is the space between the icons in the dock or panel.

border_radius = Border radius
border-radius-description = Radius for the dock or panel.

save = Save
cancel = Cancel
save-current-color-scheme = Save current color scheme
Expand Down
27 changes: 27 additions & 0 deletions src/pages/dock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct Dock {
pub dock_config: Option<CosmicPanelConfig>,
pub padding: u32,
pub spacing: u32,
pub border_radius: u32,
}

impl Default for Dock {
Expand All @@ -29,11 +30,16 @@ impl Default for Dock {
.clone()
.map(|config| config.spacing)
.unwrap_or(0);
let border_radius = dock_config
.clone()
.map(|config| config.border_radius)
.unwrap_or(0);
Self {
dock_helper,
dock_config,
padding,
spacing,
border_radius,
}
}
}
Expand All @@ -42,6 +48,7 @@ impl Default for Dock {
pub enum Message {
SetPadding(u32),
SetSpacing(u32),
SetBorder(u32),
}

impl Dock {
Expand Down Expand Up @@ -72,6 +79,19 @@ impl Dock {
])
.spacing(spacing.space_xxs),
),
)
.add(
widget::settings::item::builder(fl!("border_radius"))
.description(fl!("border-radius-description"))
.icon(icons::get_icon("size-horizontally-symbolic", 18))
.control(
widget::row::with_children(vec![
widget::slider(0..=28, self.border_radius, Message::SetBorder)
.into(),
widget::text::text(format!("{} px", self.border_radius)).into(),
])
.spacing(spacing.space_xxs),
),
),
)
.into()
Expand Down Expand Up @@ -100,6 +120,13 @@ impl Dock {
eprintln!("Error updating dock spacing: {}", err);
}
}
Message::SetBorder(border_radius) => {
self.border_radius = border_radius;
let update = dock_config.set_border_radius(dock_helper, self.border_radius);
if let Err(err) = update {
eprintln!("Error updating dock border radius: {}", err);
}
}
}
Command::none()
}
Expand Down
27 changes: 27 additions & 0 deletions src/pages/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Panel {
pub panel_config: Option<CosmicPanelConfig>,
pub padding: u32,
pub spacing: u32,
pub border_radius: u32,
pub show_panel: bool,
pub cosmic_panel_config: CosmicPanel,
pub cosmic_panel_config_helper: Option<Config>,
Expand Down Expand Up @@ -65,12 +66,17 @@ impl Default for Panel {
.clone()
.map(|config| config.spacing)
.unwrap_or(0);
let border_radius = panel_config
.clone()
.map(|config| config.border_radius)
.unwrap_or(0);
let show_panel = cosmic_panel_config.entries.iter().any(|e| e == "Panel");
Self {
panel_helper,
panel_config,
padding,
spacing,
border_radius,
show_panel,
cosmic_panel_config,
cosmic_panel_config_helper,
Expand All @@ -82,6 +88,7 @@ impl Default for Panel {
pub enum Message {
SetPadding(u32),
SetSpacing(u32),
SetBorder(u32),
ShowPanel(bool),
}

Expand Down Expand Up @@ -118,6 +125,19 @@ impl Panel {
])
.spacing(spacing.space_xxs),
),
)
.add(
widget::settings::item::builder(fl!("border_radius"))
.description(fl!("border-radius-description"))
.icon(icons::get_icon("size-horizontally-symbolic", 18))
.control(
widget::row::with_children(vec![
widget::slider(0..=28, self.border_radius, Message::SetBorder)
.into(),
widget::text::text(format!("{} px", self.border_radius)).into(),
])
.spacing(spacing.space_xxs),
),
),
)
.into()
Expand Down Expand Up @@ -146,6 +166,13 @@ impl Panel {
eprintln!("Error updating panel spacing: {}", err);
}
}
Message::SetBorder(border_radius) => {
self.border_radius = border_radius;
let update = panel_config.set_border_radius(panel_helper, self.border_radius);
if let Err(err) = update {
eprintln!("Error updating panel border radius: {}", err);
}
}
Message::ShowPanel(show) => {
if show {
if !self
Expand Down