Skip to content

Commit

Permalink
fix: condensed padding
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Nov 1, 2024
1 parent ef051c3 commit 103df97
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 209 deletions.
228 changes: 131 additions & 97 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cosmic-settings/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ impl SettingsApp {
let theme = cosmic::theme::active();

let padding = if self.core.is_condensed() {
theme.cosmic().space_xxs()
theme.cosmic().space_s()
} else {
theme.cosmic().space_l()
};
Expand Down
6 changes: 3 additions & 3 deletions cosmic-settings/src/pages/bluetooth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 System76 <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only

use cosmic::iced::{alignment, color, Length};
use cosmic::iced::{color, Alignment, Length};
use cosmic::iced_core::text::Wrapping;
use cosmic::widget::{self, settings, text};
use cosmic::Task;
Expand Down Expand Up @@ -121,7 +121,7 @@ impl page::Page<crate::pages::Message> for Page {

let pin = widget::text::title1(itoa::Buffer::new().format(*passkey).to_owned())
.width(Length::Fill)
.align_x(alignment::Horizontal::Center)
.align_x(Alignment::Center)
.wrapping(Wrapping::None);

let control = widget::column::with_capacity(2)
Expand Down Expand Up @@ -641,7 +641,7 @@ fn popup_button(message: Option<Message>, text: &str) -> Element<'_, Message> {
let theme = cosmic::theme::active();
let theme = theme.cosmic();
widget::text::body(text)
.align_y(alignment::Vertical::Center)
.align_y(Alignment::Center)
.apply(widget::button::custom)
.padding([theme.space_xxxs(), theme.space_xs()])
.width(Length::Fill)
Expand Down
24 changes: 11 additions & 13 deletions cosmic-settings/src/pages/desktop/appearance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cosmic::cosmic_theme::{
CornerRadii, Density, Spacing, Theme, ThemeBuilder, ThemeMode, DARK_THEME_BUILDER_ID,
LIGHT_THEME_BUILDER_ID,
};
use cosmic::iced_core::{alignment, Color, Length};
use cosmic::iced_core::{Alignment, Color, Length};
use cosmic::iced_widget::scrollable::{Direction, Scrollbar};
use cosmic::widget::icon::{from_name, icon};
use cosmic::widget::{
Expand Down Expand Up @@ -1431,7 +1431,7 @@ impl page::Page<crate::pages::Message> for Page {
.push(button::standard(fl!("export")).on_press(Message::StartExport))
.apply(container)
.width(Length::Fill)
.align_x(alignment::Horizontal::Right)
.align_x(Alignment::End)
.apply(Element::from)
.map(crate::pages::Message::Appearance);

Expand Down Expand Up @@ -1609,7 +1609,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
]
.spacing(space_xxs)
.width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center),
.align_x(Alignment::Center),
cosmic::iced::widget::column![
button::custom(
icon(light_mode_illustration.clone(),)
Expand All @@ -1624,14 +1624,13 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
]
.spacing(space_xxs)
.width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center)
.align_x(Alignment::Center)
]
.spacing(48)
.align_y(cosmic::iced_core::Alignment::Center)
.align_y(Alignment::Center)
.width(Length::Fixed(424.0)),
)
.width(Length::Fill)
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
.center_x(Length::Fill),
)
.add(
settings::item::builder(&descriptions[auto_switch])
Expand Down Expand Up @@ -1864,7 +1863,7 @@ pub fn style() -> Section<crate::pages::Message> {
]
.spacing(8)
.width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center),
.align_x(Alignment::Center),
cosmic::iced::widget::column![
button::custom(
icon(
Expand All @@ -1886,7 +1885,7 @@ pub fn style() -> Section<crate::pages::Message> {
]
.spacing(8)
.width(Length::FillPortion(1))
.align_x(cosmic::iced_core::Alignment::Center),
.align_x(Alignment::Center),
cosmic::iced::widget::column![
button::custom(
icon(
Expand All @@ -1908,15 +1907,14 @@ pub fn style() -> Section<crate::pages::Message> {
text::body(&descriptions[square])
]
.spacing(8)
.align_x(cosmic::iced_core::Alignment::Center)
.align_x(Alignment::Center)
.width(Length::FillPortion(1))
]
.spacing(12)
.width(Length::Fixed(628.0))
.align_y(cosmic::iced_core::Alignment::Center),
.align_y(Alignment::Center),
)
.width(Length::Fill)
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
.center_x(Length::Fill),
)
.apply(Element::from)
.map(crate::pages::Message::Appearance)
Expand Down
9 changes: 4 additions & 5 deletions cosmic-settings/src/pages/desktop/dock/applets.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmic::{
cosmic_config::CosmicConfigEntry,
iced::{alignment, Length},
iced::{Alignment, Length},
widget::{button, container, row},
Apply, Element, Task,
};
Expand Down Expand Up @@ -82,17 +82,16 @@ impl page::Page<crate::pages::Message> for Page {
}

fn header_view(&self) -> Option<Element<'_, crate::pages::Message>> {
let theme = cosmic::theme::active();
let spacing = theme.cosmic().spacing;
let space_xxs = cosmic::theme::active().cosmic().spacing.space_xxs;
let content = row::with_capacity(2)
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.push(
button::standard(fl!("add-applet"))
.on_press(Message(applets_inner::Message::AddAppletDrawer)),
)
.apply(container)
.width(Length::Fill)
.align_x(alignment::Horizontal::Right)
.align_x(Alignment::End)
.apply(Element::from)
.map(crate::pages::Message::DockApplet);

Expand Down
80 changes: 46 additions & 34 deletions cosmic-settings/src/pages/desktop/panel/applets_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ use cosmic::iced::clipboard::dnd::{
};
use cosmic::iced::clipboard::mime::AsMimeTypes;
use cosmic::iced::id::Internal;
use cosmic::iced::{alignment, Vector};
use cosmic::iced::Vector;

use cosmic::iced_core;
use cosmic::widget::{button, column, container, icon, list_column, row, text, text_input, Column};

use cosmic::{
cosmic_config::{Config, CosmicConfigEntry},
iced::{
alignment::{Horizontal, Vertical},
core::window,
event, mouse, overlay, touch, Alignment, Color, Length, Point, Rectangle, Size,
core::window, event, mouse, overlay, touch, Alignment, Color, Length, Point, Rectangle,
Size,
},
iced_runtime::{core::id::Id, Task},
iced_widget::core::{
Expand Down Expand Up @@ -120,14 +119,13 @@ impl page::Page<crate::pages::Message> for Page {
}

fn header_view(&self) -> Option<Element<'_, crate::pages::Message>> {
let theme = cosmic::theme::active();
let spacing = theme.cosmic().spacing;
let space_xxs = theme::active().cosmic().spacing.space_xxs;
let content = row::with_capacity(2)
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.push(button::standard(fl!("add-applet")).on_press(Message::AddAppletDrawer))
.apply(container)
.width(Length::Fill)
.align_x(alignment::Horizontal::Right)
.align_x(Alignment::End)
.apply(Element::from)
.map(crate::pages::Message::PanelApplet);

Expand Down Expand Up @@ -226,7 +224,13 @@ impl Page {
&self,
msg_map: T,
) -> Element<crate::pages::Message> {
let spacing = cosmic::theme::active().cosmic().spacing;
let cosmic::cosmic_theme::Spacing {
space_xxxs,
space_xxs,
space_xs,
space_l,
..
} = theme::active().cosmic().spacing;
let mut list_column = list_column();
let mut has_some = false;
for info in self
Expand Down Expand Up @@ -259,7 +263,7 @@ impl Page {
column::with_capacity(2)
.push(text::body(info.name.clone()))
.push(text::caption(info.description.clone()))
.spacing(spacing.space_xxxs)
.spacing(space_xxxs)
.width(Length::Fill)
.into(),
button::standard(fl!("add"))
Expand Down Expand Up @@ -291,16 +295,16 @@ impl Page {
.on_press(msg_map(Message::AddApplet(info.clone())))
.into(),
])
.padding([0, spacing.space_l])
.spacing(spacing.space_xs)
.padding([0, space_l])
.spacing(space_xs)
.align_y(Alignment::Center),
);
}
if !has_some {
list_column = list_column.add(
text::body(fl!("no-applets-found"))
.width(Length::Fill)
.align_x(Horizontal::Center),
.align_x(Alignment::Center),
);
}

Expand All @@ -313,7 +317,7 @@ impl Page {
list_column.into(),
])
.align_x(Alignment::Center)
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.into()
}

Expand Down Expand Up @@ -456,7 +460,12 @@ pub fn lists<
msg_map: T,
) -> Section<crate::pages::Message> {
Section::default().view::<P>(move |_binder, page, _section| {
let spacing = cosmic::theme::active().cosmic().spacing;
let cosmic::cosmic_theme::Spacing {
space_xxs,
space_xs,
space_s,
..
} = theme::active().cosmic().spacing;
let page = page.inner();
let Some(config) = page.current_config.as_ref() else {
return Element::from(text::body(fl!("unknown")));
Expand Down Expand Up @@ -492,7 +501,7 @@ pub fn lists<
)
.into(),
])
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.into(),
column::with_children(vec![
text::body(fl!("center-segment")).into(),
Expand Down Expand Up @@ -522,7 +531,7 @@ pub fn lists<
)
.into(),
])
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.into(),
column::with_children(vec![
text::body(fl!("end-segment")).into(),
Expand Down Expand Up @@ -553,11 +562,11 @@ pub fn lists<
)
.into(),
])
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.into(),
])
.padding([0, spacing.space_s])
.spacing(spacing.space_xs)
.padding([0, space_s])
.spacing(space_xs)
.apply(Element::from)
.map(msg_map)
})
Expand Down Expand Up @@ -651,7 +660,12 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
on_cancel: Message,
active_dnd: Option<Applet<'a>>,
) -> Self {
let spacing = cosmic::theme::active().cosmic().spacing;
let cosmic::cosmic_theme::Spacing {
space_xxxs,
space_xxs,
space_xs,
..
} = theme::active().cosmic().spacing;
let applet_buttons = info
.clone()
.into_iter()
Expand All @@ -666,7 +680,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.into(),
icon::from_name(info.icon).size(32).into(),
column::with_capacity(2)
.spacing(spacing.space_xxxs)
.spacing(space_xxxs)
.width(Length::Fill)
.push(text::body(info.name))
.push_maybe(if info.description.is_empty() {
Expand All @@ -680,7 +694,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.on_press(on_remove(id_clone.clone()))
.into(),
])
.spacing(spacing.space_xs)
.spacing(space_xs)
.align_y(Alignment::Center),
)
.width(Length::Fill)
Expand Down Expand Up @@ -711,8 +725,8 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
text::body(fl!("drop-here"))
.width(Length::Fill)
.height(Length::Fill)
.align_y(Vertical::Center)
.align_x(Horizontal::Center),
.align_y(Alignment::Center)
.align_x(Alignment::Center),
)
.width(Length::Fill)
.height(Length::Fixed(48.0))
Expand All @@ -728,7 +742,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
.into()
} else {
Column::with_children(applet_buttons)
.spacing(spacing.space_xxs)
.spacing(space_xxs)
.into()
},
active_applet_offer: active_dnd,
Expand All @@ -746,7 +760,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
pos: Point,
offered_applet: Applet<'a>,
) -> Vec<Applet<'a>> {
let spacing = cosmic::theme::active().cosmic().spacing;
let space_xxs = theme::active().cosmic().spacing.space_xxs;
let mut reordered: Vec<_> = self.info.clone();

if !layout.bounds().contains(pos) {
Expand All @@ -767,8 +781,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
return reordered;
}

let height = (layout.bounds().height
- spacing.space_xxs as f32 * (self.info.len() - 1) as f32)
let height = (layout.bounds().height - space_xxs as f32 * (self.info.len() - 1) as f32)
/ self.info.len() as f32;

let mut found = false;
Expand All @@ -778,7 +791,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
if i == 0 || i == reordered.len() {
y += height / 2.0;
} else {
y += height + spacing.space_xxs as f32;
y += height + space_xxs as f32;
}
if pos.y <= y {
reordered.insert(i, offered_applet.clone());
Expand Down Expand Up @@ -926,7 +939,7 @@ where
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
let spacing = cosmic::theme::active().cosmic().spacing;
let space_xxs = theme::active().cosmic().spacing.space_xxs;
let mut ret = match self.inner.as_widget_mut().on_event(
&mut tree.children[0],
event.clone(),
Expand All @@ -942,7 +955,7 @@ where
};

let height = (layout.bounds().height
- spacing.space_xxs as f32 * (self.info.len().saturating_sub(1)) as f32)
- space_xxs as f32 * (self.info.len().saturating_sub(1)) as f32)
/ self.info.len() as f32;
let state = tree.state.downcast_mut::<ReorderWidgetState>();

Expand Down Expand Up @@ -995,8 +1008,7 @@ where
self.info.iter().enumerate().find(|(i, _)| {
start.y
< layout.bounds().y
+ (*i + 1) as f32
* (height + spacing.space_xxs as f32)
+ (*i + 1) as f32 * (height + space_xxs as f32)
})
{
let applet = applet.clone().into_owned();
Expand Down
Loading

0 comments on commit 103df97

Please sign in to comment.