From 8512fad64182861a5a3ba2ae8bf457de8f20b016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vuka=C5=A1in=20Vojinovi=C4=87?= Date: Thu, 27 Mar 2025 15:06:01 +0100 Subject: [PATCH] fix(app): padding fixes Also removes some unnecessary code for the applet context drawer content. --- cosmic-settings/src/app.rs | 31 +++++++------------ .../src/pages/applications/startup_apps.rs | 4 +-- .../src/pages/desktop/panel/applets_inner.rs | 28 +---------------- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/cosmic-settings/src/app.rs b/cosmic-settings/src/app.rs index f4d5a5b..66686d5 100644 --- a/cosmic-settings/src/app.rs +++ b/cosmic-settings/src/app.rs @@ -22,23 +22,21 @@ use crate::pages::sound; use crate::pages::{self, system, time}; use crate::subscription::desktop_files; use crate::widget::{page_title, search_header}; -use cosmic::app::context_drawer::ContextDrawer; #[cfg(feature = "wayland")] use cosmic::cctk::{sctk::output::OutputInfo, wayland_client::protocol::wl_output::WlOutput}; -use cosmic::iced::Subscription; -use cosmic::widget::{self, button, row, text_input}; use cosmic::{ Element, - app::{Core, Task}, + app::{Core, Task, context_drawer::ContextDrawer}, iced::{ - self, Length, + self, Length, Subscription, event::{self, PlatformSpecific}, window, }, prelude::*, surface, widget::{ - column, container, icon, id_container, nav_bar, scrollable, segmented_button, settings, + button, column, container, icon, id_container, nav_bar, row, scrollable, segmented_button, + settings, text_input, }, }; #[cfg(feature = "wayland")] @@ -800,9 +798,7 @@ impl cosmic::Application for SettingsApp { return self.page_container(row::row()); }; - container(view) - .padding([cosmic::theme::active().cosmic().space_xxs(), 0]) - .into() + container(view).into() } #[allow(clippy::too_many_lines)] @@ -999,11 +995,8 @@ impl SettingsApp { .height(Length::Fill) .apply(|w| id_container(w, self.id())); - widget::column::with_capacity(3) + column::with_capacity(2) .push(self.page_container(header)) - .push(widget::vertical_space().height(Length::Fixed( - cosmic::theme::active().cosmic().space_m().into(), - ))) .push(view) .height(Length::Fill) .into() @@ -1103,8 +1096,8 @@ impl SettingsApp { { let section = (section.view_fn)(&self.pages, model.as_ref(), section) .map(Message::PageMessage) - .apply(iced::widget::container) - .padding([0, 0, 0, cosmic::theme::active().cosmic().space_xl()]); + .apply(container) + .padding([0, 0, 0, cosmic::theme::active().cosmic().space_l()]); sections.push(section.into()); } @@ -1137,14 +1130,12 @@ impl SettingsApp { }, ) .spacing(theme.cosmic().space_s()) - .padding(0) .apply(|widget| scrollable(self.page_container(widget)).height(Length::Fill)) .apply(Element::from) .map(Message::Page); - widget::column::with_capacity(3) + column::with_capacity(2) .push(self.page_container(page_title(&self.pages.info[self.active_page]))) - .push(widget::vertical_space().height(theme.cosmic().space_m())) .push(page_list) .height(Length::Fill) .into() @@ -1161,13 +1152,15 @@ impl SettingsApp { } else { theme.cosmic().space_l() }; + // prevents content from touching window edge on bottom of scroll + let bottom_spacer = theme.cosmic().space_m(); container(content.into()) .max_width(800) .width(Length::Fill) .apply(container) .center_x(Length::Fill) - .padding([0, padding]) + .padding([0, padding, bottom_spacer, padding]) .into() } } diff --git a/cosmic-settings/src/pages/applications/startup_apps.rs b/cosmic-settings/src/pages/applications/startup_apps.rs index 67eaf09..1b325b4 100644 --- a/cosmic-settings/src/pages/applications/startup_apps.rs +++ b/cosmic-settings/src/pages/applications/startup_apps.rs @@ -417,11 +417,11 @@ fn apps() -> Section { } } - let add_input_source = widget::button::standard(fl!("startup-apps", "add")) + let add_startup_app = widget::button::standard(fl!("startup-apps", "add")) .on_press(Message::ShowApplicationSidebar(directory_type.clone())); view = view.push(section).push(widget::container( - widget::container(add_input_source) + widget::container(add_startup_app) .width(Length::Fill) .align_x(Alignment::End), )); diff --git a/cosmic-settings/src/pages/desktop/panel/applets_inner.rs b/cosmic-settings/src/pages/desktop/panel/applets_inner.rs index 6993e11..018f6b3 100644 --- a/cosmic-settings/src/pages/desktop/panel/applets_inner.rs +++ b/cosmic-settings/src/pages/desktop/panel/applets_inner.rs @@ -1,4 +1,3 @@ -use button::Catalog as ButtonStyleSheet; use cosmic::iced::clipboard::dnd::{ DndAction, DndDestinationRectangle, DndEvent, OfferEvent, SourceEvent, }; @@ -267,32 +266,7 @@ impl Page { .spacing(space_xxxs) .width(Length::Fill) .into(), - button::standard(fl!("add")) - .class(button::ButtonClass::Custom { - active: Box::new(|focused, theme| { - let mut style = - theme.active(focused, false, &button::ButtonClass::Text); - style.text_color = Some(theme.cosmic().accent_color().into()); - style - }), - disabled: Box::new(|theme| { - let mut style = theme.disabled(&button::ButtonClass::Text); - let mut text_color: Color = theme.cosmic().accent_color().into(); - text_color.a *= 0.5; - style.text_color = Some(text_color); - style - }), - hovered: Box::new(|focused, theme| { - let mut style = theme.hovered(focused, false, &theme::Button::Text); - style.text_color = Some(theme.cosmic().accent_color().into()); - style - }), - pressed: Box::new(|focused, theme| { - let mut style = theme.pressed(focused, false, &theme::Button::Text); - style.text_color = Some(theme.cosmic().accent_color().into()); - style - }), - }) + button::text(fl!("add")) .on_press(msg_map(Message::AddApplet(info.clone()))) .into(), ])