Skip to content

Commit d9735c9

Browse files
git-f0xmmstick
authored andcommitted
fix: condensed padding
1 parent ef051c3 commit d9735c9

File tree

15 files changed

+246
-209
lines changed

15 files changed

+246
-209
lines changed

Cargo.lock

Lines changed: 131 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmic-settings/src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl SettingsApp {
10821082
let theme = cosmic::theme::active();
10831083

10841084
let padding = if self.core.is_condensed() {
1085-
theme.cosmic().space_xxs()
1085+
theme.cosmic().space_s()
10861086
} else {
10871087
theme.cosmic().space_l()
10881088
};

cosmic-settings/src/pages/bluetooth/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2024 System76 <[email protected]>
22
// SPDX-License-Identifier: GPL-3.0-only
33

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

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

127127
let control = widget::column::with_capacity(2)
@@ -641,7 +641,7 @@ fn popup_button(message: Option<Message>, text: &str) -> Element<'_, Message> {
641641
let theme = cosmic::theme::active();
642642
let theme = theme.cosmic();
643643
widget::text::body(text)
644-
.align_y(alignment::Vertical::Center)
644+
.align_y(Alignment::Center)
645645
.apply(widget::button::custom)
646646
.padding([theme.space_xxxs(), theme.space_xs()])
647647
.width(Length::Fill)

cosmic-settings/src/pages/desktop/appearance/mod.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use cosmic::cosmic_theme::{
1717
CornerRadii, Density, Spacing, Theme, ThemeBuilder, ThemeMode, DARK_THEME_BUILDER_ID,
1818
LIGHT_THEME_BUILDER_ID,
1919
};
20-
use cosmic::iced_core::{alignment, Color, Length};
20+
use cosmic::iced_core::{Alignment, Color, Length};
2121
use cosmic::iced_widget::scrollable::{Direction, Scrollbar};
2222
use cosmic::widget::icon::{from_name, icon};
2323
use cosmic::widget::{
@@ -1431,7 +1431,7 @@ impl page::Page<crate::pages::Message> for Page {
14311431
.push(button::standard(fl!("export")).on_press(Message::StartExport))
14321432
.apply(container)
14331433
.width(Length::Fill)
1434-
.align_x(alignment::Horizontal::Right)
1434+
.align_x(Alignment::End)
14351435
.apply(Element::from)
14361436
.map(crate::pages::Message::Appearance);
14371437

@@ -1609,7 +1609,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
16091609
]
16101610
.spacing(space_xxs)
16111611
.width(Length::FillPortion(1))
1612-
.align_x(cosmic::iced_core::Alignment::Center),
1612+
.align_x(Alignment::Center),
16131613
cosmic::iced::widget::column![
16141614
button::custom(
16151615
icon(light_mode_illustration.clone(),)
@@ -1624,14 +1624,13 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
16241624
]
16251625
.spacing(space_xxs)
16261626
.width(Length::FillPortion(1))
1627-
.align_x(cosmic::iced_core::Alignment::Center)
1627+
.align_x(Alignment::Center)
16281628
]
16291629
.spacing(48)
1630-
.align_y(cosmic::iced_core::Alignment::Center)
1630+
.align_y(Alignment::Center)
16311631
.width(Length::Fixed(424.0)),
16321632
)
1633-
.width(Length::Fill)
1634-
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
1633+
.center_x(Length::Fill),
16351634
)
16361635
.add(
16371636
settings::item::builder(&descriptions[auto_switch])
@@ -1864,7 +1863,7 @@ pub fn style() -> Section<crate::pages::Message> {
18641863
]
18651864
.spacing(8)
18661865
.width(Length::FillPortion(1))
1867-
.align_x(cosmic::iced_core::Alignment::Center),
1866+
.align_x(Alignment::Center),
18681867
cosmic::iced::widget::column![
18691868
button::custom(
18701869
icon(
@@ -1886,7 +1885,7 @@ pub fn style() -> Section<crate::pages::Message> {
18861885
]
18871886
.spacing(8)
18881887
.width(Length::FillPortion(1))
1889-
.align_x(cosmic::iced_core::Alignment::Center),
1888+
.align_x(Alignment::Center),
18901889
cosmic::iced::widget::column![
18911890
button::custom(
18921891
icon(
@@ -1908,15 +1907,14 @@ pub fn style() -> Section<crate::pages::Message> {
19081907
text::body(&descriptions[square])
19091908
]
19101909
.spacing(8)
1911-
.align_x(cosmic::iced_core::Alignment::Center)
1910+
.align_x(Alignment::Center)
19121911
.width(Length::FillPortion(1))
19131912
]
19141913
.spacing(12)
19151914
.width(Length::Fixed(628.0))
1916-
.align_y(cosmic::iced_core::Alignment::Center),
1915+
.align_y(Alignment::Center),
19171916
)
1918-
.width(Length::Fill)
1919-
.align_x(cosmic::iced_core::alignment::Horizontal::Center),
1917+
.center_x(Length::Fill),
19201918
)
19211919
.apply(Element::from)
19221920
.map(crate::pages::Message::Appearance)

cosmic-settings/src/pages/desktop/dock/applets.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cosmic::{
22
cosmic_config::CosmicConfigEntry,
3-
iced::{alignment, Length},
3+
iced::{Alignment, Length},
44
widget::{button, container, row},
55
Apply, Element, Task,
66
};
@@ -82,17 +82,16 @@ impl page::Page<crate::pages::Message> for Page {
8282
}
8383

8484
fn header_view(&self) -> Option<Element<'_, crate::pages::Message>> {
85-
let theme = cosmic::theme::active();
86-
let spacing = theme.cosmic().spacing;
85+
let space_xxs = cosmic::theme::active().cosmic().spacing.space_xxs;
8786
let content = row::with_capacity(2)
88-
.spacing(spacing.space_xxs)
87+
.spacing(space_xxs)
8988
.push(
9089
button::standard(fl!("add-applet"))
9190
.on_press(Message(applets_inner::Message::AddAppletDrawer)),
9291
)
9392
.apply(container)
9493
.width(Length::Fill)
95-
.align_x(alignment::Horizontal::Right)
94+
.align_x(Alignment::End)
9695
.apply(Element::from)
9796
.map(crate::pages::Message::DockApplet);
9897

cosmic-settings/src/pages/desktop/panel/applets_inner.rs

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ use cosmic::iced::clipboard::dnd::{
44
};
55
use cosmic::iced::clipboard::mime::AsMimeTypes;
66
use cosmic::iced::id::Internal;
7-
use cosmic::iced::{alignment, Vector};
7+
use cosmic::iced::Vector;
88

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

1212
use cosmic::{
1313
cosmic_config::{Config, CosmicConfigEntry},
1414
iced::{
15-
alignment::{Horizontal, Vertical},
16-
core::window,
17-
event, mouse, overlay, touch, Alignment, Color, Length, Point, Rectangle, Size,
15+
core::window, event, mouse, overlay, touch, Alignment, Color, Length, Point, Rectangle,
16+
Size,
1817
},
1918
iced_runtime::{core::id::Id, Task},
2019
iced_widget::core::{
@@ -120,14 +119,13 @@ impl page::Page<crate::pages::Message> for Page {
120119
}
121120

122121
fn header_view(&self) -> Option<Element<'_, crate::pages::Message>> {
123-
let theme = cosmic::theme::active();
124-
let spacing = theme.cosmic().spacing;
122+
let space_xxs = theme::active().cosmic().spacing.space_xxs;
125123
let content = row::with_capacity(2)
126-
.spacing(spacing.space_xxs)
124+
.spacing(space_xxs)
127125
.push(button::standard(fl!("add-applet")).on_press(Message::AddAppletDrawer))
128126
.apply(container)
129127
.width(Length::Fill)
130-
.align_x(alignment::Horizontal::Right)
128+
.align_x(Alignment::End)
131129
.apply(Element::from)
132130
.map(crate::pages::Message::PanelApplet);
133131

@@ -226,7 +224,13 @@ impl Page {
226224
&self,
227225
msg_map: T,
228226
) -> Element<crate::pages::Message> {
229-
let spacing = cosmic::theme::active().cosmic().spacing;
227+
let cosmic::cosmic_theme::Spacing {
228+
space_xxxs,
229+
space_xxs,
230+
space_xs,
231+
space_l,
232+
..
233+
} = theme::active().cosmic().spacing;
230234
let mut list_column = list_column();
231235
let mut has_some = false;
232236
for info in self
@@ -259,7 +263,7 @@ impl Page {
259263
column::with_capacity(2)
260264
.push(text::body(info.name.clone()))
261265
.push(text::caption(info.description.clone()))
262-
.spacing(spacing.space_xxxs)
266+
.spacing(space_xxxs)
263267
.width(Length::Fill)
264268
.into(),
265269
button::standard(fl!("add"))
@@ -291,16 +295,16 @@ impl Page {
291295
.on_press(msg_map(Message::AddApplet(info.clone())))
292296
.into(),
293297
])
294-
.padding([0, spacing.space_l])
295-
.spacing(spacing.space_xs)
298+
.padding([0, space_l])
299+
.spacing(space_xs)
296300
.align_y(Alignment::Center),
297301
);
298302
}
299303
if !has_some {
300304
list_column = list_column.add(
301305
text::body(fl!("no-applets-found"))
302306
.width(Length::Fill)
303-
.align_x(Horizontal::Center),
307+
.align_x(Alignment::Center),
304308
);
305309
}
306310

@@ -313,7 +317,7 @@ impl Page {
313317
list_column.into(),
314318
])
315319
.align_x(Alignment::Center)
316-
.spacing(spacing.space_xxs)
320+
.spacing(space_xxs)
317321
.into()
318322
}
319323

@@ -456,7 +460,12 @@ pub fn lists<
456460
msg_map: T,
457461
) -> Section<crate::pages::Message> {
458462
Section::default().view::<P>(move |_binder, page, _section| {
459-
let spacing = cosmic::theme::active().cosmic().spacing;
463+
let cosmic::cosmic_theme::Spacing {
464+
space_xxs,
465+
space_xs,
466+
space_s,
467+
..
468+
} = theme::active().cosmic().spacing;
460469
let page = page.inner();
461470
let Some(config) = page.current_config.as_ref() else {
462471
return Element::from(text::body(fl!("unknown")));
@@ -492,7 +501,7 @@ pub fn lists<
492501
)
493502
.into(),
494503
])
495-
.spacing(spacing.space_xxs)
504+
.spacing(space_xxs)
496505
.into(),
497506
column::with_children(vec![
498507
text::body(fl!("center-segment")).into(),
@@ -522,7 +531,7 @@ pub fn lists<
522531
)
523532
.into(),
524533
])
525-
.spacing(spacing.space_xxs)
534+
.spacing(space_xxs)
526535
.into(),
527536
column::with_children(vec![
528537
text::body(fl!("end-segment")).into(),
@@ -553,11 +562,11 @@ pub fn lists<
553562
)
554563
.into(),
555564
])
556-
.spacing(spacing.space_xxs)
565+
.spacing(space_xxs)
557566
.into(),
558567
])
559-
.padding([0, spacing.space_s])
560-
.spacing(spacing.space_xs)
568+
.padding([0, space_s])
569+
.spacing(space_xs)
561570
.apply(Element::from)
562571
.map(msg_map)
563572
})
@@ -651,7 +660,12 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
651660
on_cancel: Message,
652661
active_dnd: Option<Applet<'a>>,
653662
) -> Self {
654-
let spacing = cosmic::theme::active().cosmic().spacing;
663+
let cosmic::cosmic_theme::Spacing {
664+
space_xxxs,
665+
space_xxs,
666+
space_xs,
667+
..
668+
} = theme::active().cosmic().spacing;
655669
let applet_buttons = info
656670
.clone()
657671
.into_iter()
@@ -666,7 +680,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
666680
.into(),
667681
icon::from_name(info.icon).size(32).into(),
668682
column::with_capacity(2)
669-
.spacing(spacing.space_xxxs)
683+
.spacing(space_xxxs)
670684
.width(Length::Fill)
671685
.push(text::body(info.name))
672686
.push_maybe(if info.description.is_empty() {
@@ -680,7 +694,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
680694
.on_press(on_remove(id_clone.clone()))
681695
.into(),
682696
])
683-
.spacing(spacing.space_xs)
697+
.spacing(space_xs)
684698
.align_y(Alignment::Center),
685699
)
686700
.width(Length::Fill)
@@ -711,8 +725,8 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
711725
text::body(fl!("drop-here"))
712726
.width(Length::Fill)
713727
.height(Length::Fill)
714-
.align_y(Vertical::Center)
715-
.align_x(Horizontal::Center),
728+
.align_y(Alignment::Center)
729+
.align_x(Alignment::Center),
716730
)
717731
.width(Length::Fill)
718732
.height(Length::Fixed(48.0))
@@ -728,7 +742,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
728742
.into()
729743
} else {
730744
Column::with_children(applet_buttons)
731-
.spacing(spacing.space_xxs)
745+
.spacing(space_xxs)
732746
.into()
733747
},
734748
active_applet_offer: active_dnd,
@@ -746,7 +760,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
746760
pos: Point,
747761
offered_applet: Applet<'a>,
748762
) -> Vec<Applet<'a>> {
749-
let spacing = cosmic::theme::active().cosmic().spacing;
763+
let space_xxs = theme::active().cosmic().spacing.space_xxs;
750764
let mut reordered: Vec<_> = self.info.clone();
751765

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

770-
let height = (layout.bounds().height
771-
- spacing.space_xxs as f32 * (self.info.len() - 1) as f32)
784+
let height = (layout.bounds().height - space_xxs as f32 * (self.info.len() - 1) as f32)
772785
/ self.info.len() as f32;
773786

774787
let mut found = false;
@@ -778,7 +791,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
778791
if i == 0 || i == reordered.len() {
779792
y += height / 2.0;
780793
} else {
781-
y += height + spacing.space_xxs as f32;
794+
y += height + space_xxs as f32;
782795
}
783796
if pos.y <= y {
784797
reordered.insert(i, offered_applet.clone());
@@ -926,7 +939,7 @@ where
926939
shell: &mut Shell<'_, Message>,
927940
viewport: &Rectangle,
928941
) -> event::Status {
929-
let spacing = cosmic::theme::active().cosmic().spacing;
942+
let space_xxs = theme::active().cosmic().spacing.space_xxs;
930943
let mut ret = match self.inner.as_widget_mut().on_event(
931944
&mut tree.children[0],
932945
event.clone(),
@@ -942,7 +955,7 @@ where
942955
};
943956

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

@@ -995,8 +1008,7 @@ where
9951008
self.info.iter().enumerate().find(|(i, _)| {
9961009
start.y
9971010
< layout.bounds().y
998-
+ (*i + 1) as f32
999-
* (height + spacing.space_xxs as f32)
1011+
+ (*i + 1) as f32 * (height + space_xxs as f32)
10001012
})
10011013
{
10021014
let applet = applet.clone().into_owned();

0 commit comments

Comments
 (0)