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 1 commit
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
2 changes: 1 addition & 1 deletion i18n/en/cosmic_ext_tweaks.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spacing = Spacing
spacing-description = Spacing is the space between the icons in the dock or panel.

border_radius = Border Radius
ahoneybun marked this conversation as resolved.
Show resolved Hide resolved
border-radius-description = Radius for the dock.
border-radius-description = Radius for the dock or panel.

save = Save
cancel = Cancel
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