Skip to content

Commit 941cbf5

Browse files
authored
fix: padding, spacing, context menu style, and settings buttons
1 parent 0a32d27 commit 941cbf5

38 files changed

+693
-537
lines changed

Cargo.lock

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

cosmic-app-list/src/app.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use cosmic::{
4141
accept_mime_type, finish_dnd, request_dnd_data, set_actions, start_drag,
4242
},
4343
iced_style::{application, svg},
44-
theme::{Button, Container},
44+
theme::{self, Button, Container},
4545
widget::{
4646
button, divider, horizontal_space, icon,
4747
icon::from_name,
@@ -62,7 +62,7 @@ use futures::future::pending;
6262
use iced::{widget::container, Alignment, Background, Length};
6363
use itertools::Itertools;
6464
use rand::{thread_rng, Rng};
65-
use std::{collections::HashMap, fs, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
65+
use std::{collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
6666
use switcheroo_control::Gpu;
6767
use tokio::time::sleep;
6868
use url::Url;
@@ -262,7 +262,7 @@ impl DockItem {
262262
.into(),
263263
};
264264

265-
let icon_button = cosmic::widget::button(icon_wrapper)
265+
let icon_button = button::custom(icon_wrapper)
266266
.padding(app_icon.padding)
267267
.selected(is_focused)
268268
.style(app_list_icon_style(is_focused));
@@ -456,7 +456,7 @@ where
456456
Msg: 'static + Clone,
457457
{
458458
let border = 1.0;
459-
cosmic::widget::button(
459+
button::custom(
460460
container(
461461
column![
462462
container(if let Some(img) = img {
@@ -1715,14 +1715,14 @@ impl cosmic::Application for CosmicAppList {
17151715
fn menu_button<'a, Message>(
17161716
content: impl Into<Element<'a, Message>>,
17171717
) -> cosmic::widget::Button<'a, Message> {
1718-
cosmic::widget::button(content)
1719-
.height(36)
1720-
.style(Button::AppletMenu)
1718+
button::custom(content)
1719+
.height(20 + 2 * theme::active().cosmic().space_xxs())
1720+
.style(Button::MenuItem)
17211721
.padding(menu_control_padding())
17221722
.width(Length::Fill)
17231723
}
17241724

1725-
let mut content = column![].padding([8, 0]).align_items(Alignment::Center);
1725+
let mut content = column![].align_items(Alignment::Center);
17261726

17271727
if let Some(exec) = desktop_info.exec() {
17281728
if !toplevels.is_empty() {
@@ -1774,7 +1774,7 @@ impl cosmic::Application for CosmicAppList {
17741774
.on_press(Message::Exec(exec.into(), None)),
17751775
);
17761776
}
1777-
content = content.push(divider::horizontal::default());
1777+
content = content.push(divider::horizontal::light());
17781778
}
17791779

17801780
if !toplevels.is_empty() {
@@ -1791,7 +1791,7 @@ impl cosmic::Application for CosmicAppList {
17911791
);
17921792
}
17931793
content = content.push(list_col);
1794-
content = content.push(divider::horizontal::default());
1794+
content = content.push(divider::horizontal::light());
17951795
}
17961796

17971797
let svg_accent = Rc::new(|theme: &cosmic::Theme| {
@@ -1820,7 +1820,7 @@ impl cosmic::Application for CosmicAppList {
18201820
);
18211821

18221822
if toplevels.len() > 0 {
1823-
content = content.push(divider::horizontal::default());
1823+
content = content.push(divider::horizontal::light());
18241824
content = match toplevels.len() {
18251825
1 => content.push(
18261826
menu_button(text::body(fl!("quit")))
@@ -1832,7 +1832,26 @@ impl cosmic::Application for CosmicAppList {
18321832
),
18331833
};
18341834
}
1835-
self.core.applet.popup_container(content).into()
1835+
container(content)
1836+
.padding(1)
1837+
//TODO: move style to libcosmic
1838+
.style(theme::Container::custom(|theme| {
1839+
let cosmic = theme.cosmic();
1840+
let component = &cosmic.background.component;
1841+
container::Appearance {
1842+
icon_color: Some(component.on.into()),
1843+
text_color: Some(component.on.into()),
1844+
background: Some(Background::Color(component.base.into())),
1845+
border: Border {
1846+
radius: 8.0.into(),
1847+
width: 1.0,
1848+
color: component.divider.into(),
1849+
},
1850+
..Default::default()
1851+
}
1852+
}))
1853+
.width(Length::Fill)
1854+
.into()
18361855
}
18371856
PopupType::TopLevelList => match self.core.applet.anchor {
18381857
PanelAnchor::Left | PanelAnchor::Right => {

cosmic-applet-audio/i18n/en/cosmic_applet_audio.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
output = Output
22
input = Input
3-
show-media-controls = Show Media Controls on Top Panel
3+
show-media-controls = Show media controls on panel
44
sound-settings = Sound Settings...
55
disconnected = PulseAudio Disconnected
66
no-device = No device selected

cosmic-applet-audio/src/lib.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ use cosmic::{
1515
menu_button, menu_control_padding, padded_control,
1616
token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
1717
},
18-
cctk::sctk::reexports::{calloop, protocols::xdg::shell::client::xdg_positioner::Anchor},
18+
cctk::sctk::reexports::calloop,
1919
cosmic_config::CosmicConfigEntry,
20+
cosmic_theme::Spacing,
2021
iced::{
2122
self,
2223
widget::{self, column, row, slider},
23-
window, Alignment, Length, Limits, Rectangle, Subscription,
24+
window, Alignment, Length, Limits, Subscription,
2425
},
2526
iced_runtime::core::alignment::Horizontal,
2627
iced_style::application,
28+
theme,
2729
widget::{button, divider, horizontal_space, icon, text, Column, Row},
2830
Element, Renderer, Theme,
2931
};
@@ -665,6 +667,9 @@ impl cosmic::Application for Audio {
665667
input.mute = value;
666668
}
667669
}
670+
sub_pulse::Event::DefaultSink(_) => {}
671+
sub_pulse::Event::DefaultSource(_) => {}
672+
sub_pulse::Event::CardInfo(_) => {}
668673
},
669674
};
670675

@@ -735,16 +740,19 @@ impl cosmic::Application for Audio {
735740
}
736741

737742
fn view_window(&self, _id: window::Id) -> Element<Message> {
743+
let Spacing {
744+
space_xxs, space_s, ..
745+
} = theme::active().cosmic().spacing;
746+
738747
let audio_disabled = matches!(self.pulse_state, PulseState::Disconnected(_));
739748
let out_mute = self.current_output_mute();
740749
let in_mute = self.current_input_mute();
741750

742751
let mut audio_content = if audio_disabled {
743752
column![padded_control(
744-
text(fl!("disconnected"))
753+
text::title3(fl!("disconnected"))
745754
.width(Length::Fill)
746755
.horizontal_alignment(Horizontal::Center)
747-
.size(24)
748756
)]
749757
} else {
750758
column![
@@ -790,7 +798,7 @@ impl cosmic::Application for Audio {
790798
.spacing(12)
791799
.align_items(Alignment::Center)
792800
),
793-
padded_control(divider::horizontal::default()),
801+
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
794802
revealer(
795803
self.is_open == IsOpen::Output,
796804
fl!("output"),
@@ -906,7 +914,8 @@ impl cosmic::Application for Audio {
906914
.into(),
907915
);
908916

909-
audio_content = audio_content.push(padded_control(divider::horizontal::default()));
917+
audio_content = audio_content
918+
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
910919
audio_content = audio_content.push(
911920
Row::with_children(elements)
912921
.align_items(Alignment::Center)
@@ -916,7 +925,7 @@ impl cosmic::Application for Audio {
916925
}
917926
let content = column![
918927
audio_content,
919-
padded_control(divider::horizontal::default()),
928+
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
920929
padded_control(
921930
anim!(
922931
// toggler
@@ -928,9 +937,8 @@ impl cosmic::Application for Audio {
928937
)
929938
.text_size(14)
930939
.width(Length::Fill)
931-
)
932-
.padding([8, 24]),
933-
padded_control(divider::horizontal::default()),
940+
),
941+
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
934942
menu_button(text::body(fl!("sound-settings"))).on_press(Message::OpenSettings)
935943
]
936944
.align_items(Alignment::Start)

cosmic-applet-battery/i18n/de/cosmic_applet_battery.ftl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = Cosmic Taste
21
battery = Akku
32
battery-desc = Reduzierter Stromverbrauch und Leistung.
43
balanced = Ausgeglichen
@@ -12,4 +11,4 @@ hours = h
1211
until-empty = bis leer
1312
power-settings = Energie- und Akkueinstellungen...
1413
dgpu-running = Dedizierte GPU ist aktiv und kann die Akkulaufzeit reduzieren
15-
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen
14+
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen

cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = Cosmic Button
21
battery = Battery
32
battery-desc = Reduced power usage and performance.
43
balanced = Balanced
@@ -10,6 +9,6 @@ seconds = s
109
minutes = m
1110
hours = h
1211
until-empty = until empty
13-
power-settings = Power and Battery Settings...
12+
power-settings = Power & Battery settings...
1413
dgpu-running = Discrete GPU is active and can reduce battery life
15-
dgpu-applications = Applications using {$gpu_name} discrete GPU
14+
dgpu-applications = Applications using {$gpu_name} discrete GPU

cosmic-applet-battery/i18n/es-419/cosmic_applet_battery.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = Botón de Cosmic
21
battery = Ahorro de energía
32
battery-desc = Rendimiento y uso de energía reducido.
43
balanced = Balanceado

cosmic-applet-battery/i18n/es-ES/cosmic_applet_battery.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = Botón Cosmic
21
battery = Batería
32
battery-desc = Rendimiento y consumo de alimentación reducidos.
43
balanced = Balanceado

cosmic-applet-battery/i18n/fa/cosmic_applet_battery.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = دکمه Cosmic
21
battery = باتری
32
battery-desc = کاهش مصرف برق و عملکرد.
43
balanced = متعادل

cosmic-applet-battery/i18n/fi/cosmic_applet_battery.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
cosmic-applet-button = Cosmic Painike
21
battery = Akku
32
battery-desc = Vähentynyt virrankulutus ja suorituskyky.
43
balanced = Tasapainoitettu

0 commit comments

Comments
 (0)