Skip to content

Commit

Permalink
fix: padding, spacing, context menu style, and settings buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x authored Sep 24, 2024
1 parent 0a32d27 commit 941cbf5
Show file tree
Hide file tree
Showing 38 changed files with 693 additions and 537 deletions.
887 changes: 469 additions & 418 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 31 additions & 12 deletions cosmic-app-list/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use cosmic::{
accept_mime_type, finish_dnd, request_dnd_data, set_actions, start_drag,
},
iced_style::{application, svg},
theme::{Button, Container},
theme::{self, Button, Container},
widget::{
button, divider, horizontal_space, icon,
icon::from_name,
Expand All @@ -62,7 +62,7 @@ use futures::future::pending;
use iced::{widget::container, Alignment, Background, Length};
use itertools::Itertools;
use rand::{thread_rng, Rng};
use std::{collections::HashMap, fs, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
use std::{collections::HashMap, path::PathBuf, rc::Rc, str::FromStr, time::Duration};
use switcheroo_control::Gpu;
use tokio::time::sleep;
use url::Url;
Expand Down Expand Up @@ -262,7 +262,7 @@ impl DockItem {
.into(),
};

let icon_button = cosmic::widget::button(icon_wrapper)
let icon_button = button::custom(icon_wrapper)
.padding(app_icon.padding)
.selected(is_focused)
.style(app_list_icon_style(is_focused));
Expand Down Expand Up @@ -456,7 +456,7 @@ where
Msg: 'static + Clone,
{
let border = 1.0;
cosmic::widget::button(
button::custom(
container(
column![
container(if let Some(img) = img {
Expand Down Expand Up @@ -1715,14 +1715,14 @@ impl cosmic::Application for CosmicAppList {
fn menu_button<'a, Message>(
content: impl Into<Element<'a, Message>>,
) -> cosmic::widget::Button<'a, Message> {
cosmic::widget::button(content)
.height(36)
.style(Button::AppletMenu)
button::custom(content)
.height(20 + 2 * theme::active().cosmic().space_xxs())
.style(Button::MenuItem)
.padding(menu_control_padding())
.width(Length::Fill)
}

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

if let Some(exec) = desktop_info.exec() {
if !toplevels.is_empty() {
Expand Down Expand Up @@ -1774,7 +1774,7 @@ impl cosmic::Application for CosmicAppList {
.on_press(Message::Exec(exec.into(), None)),
);
}
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
}

if !toplevels.is_empty() {
Expand All @@ -1791,7 +1791,7 @@ impl cosmic::Application for CosmicAppList {
);
}
content = content.push(list_col);
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
}

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

if toplevels.len() > 0 {
content = content.push(divider::horizontal::default());
content = content.push(divider::horizontal::light());
content = match toplevels.len() {
1 => content.push(
menu_button(text::body(fl!("quit")))
Expand All @@ -1832,7 +1832,26 @@ impl cosmic::Application for CosmicAppList {
),
};
}
self.core.applet.popup_container(content).into()
container(content)
.padding(1)
//TODO: move style to libcosmic
.style(theme::Container::custom(|theme| {
let cosmic = theme.cosmic();
let component = &cosmic.background.component;
container::Appearance {
icon_color: Some(component.on.into()),
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border: Border {
radius: 8.0.into(),
width: 1.0,
color: component.divider.into(),
},
..Default::default()
}
}))
.width(Length::Fill)
.into()
}
PopupType::TopLevelList => match self.core.applet.anchor {
PanelAnchor::Left | PanelAnchor::Right => {
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-audio/i18n/en/cosmic_applet_audio.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output = Output
input = Input
show-media-controls = Show Media Controls on Top Panel
show-media-controls = Show media controls on panel
sound-settings = Sound Settings...
disconnected = PulseAudio Disconnected
no-device = No device selected
Expand Down
28 changes: 18 additions & 10 deletions cosmic-applet-audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ use cosmic::{
menu_button, menu_control_padding, padded_control,
token::subscription::{activation_token_subscription, TokenRequest, TokenUpdate},
},
cctk::sctk::reexports::{calloop, protocols::xdg::shell::client::xdg_positioner::Anchor},
cctk::sctk::reexports::calloop,
cosmic_config::CosmicConfigEntry,
cosmic_theme::Spacing,
iced::{
self,
widget::{self, column, row, slider},
window, Alignment, Length, Limits, Rectangle, Subscription,
window, Alignment, Length, Limits, Subscription,
},
iced_runtime::core::alignment::Horizontal,
iced_style::application,
theme,
widget::{button, divider, horizontal_space, icon, text, Column, Row},
Element, Renderer, Theme,
};
Expand Down Expand Up @@ -665,6 +667,9 @@ impl cosmic::Application for Audio {
input.mute = value;
}
}
sub_pulse::Event::DefaultSink(_) => {}
sub_pulse::Event::DefaultSource(_) => {}
sub_pulse::Event::CardInfo(_) => {}
},
};

Expand Down Expand Up @@ -735,16 +740,19 @@ impl cosmic::Application for Audio {
}

fn view_window(&self, _id: window::Id) -> Element<Message> {
let Spacing {
space_xxs, space_s, ..
} = theme::active().cosmic().spacing;

let audio_disabled = matches!(self.pulse_state, PulseState::Disconnected(_));
let out_mute = self.current_output_mute();
let in_mute = self.current_input_mute();

let mut audio_content = if audio_disabled {
column![padded_control(
text(fl!("disconnected"))
text::title3(fl!("disconnected"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center)
.size(24)
)]
} else {
column![
Expand Down Expand Up @@ -790,7 +798,7 @@ impl cosmic::Application for Audio {
.spacing(12)
.align_items(Alignment::Center)
),
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
revealer(
self.is_open == IsOpen::Output,
fl!("output"),
Expand Down Expand Up @@ -906,7 +914,8 @@ impl cosmic::Application for Audio {
.into(),
);

audio_content = audio_content.push(padded_control(divider::horizontal::default()));
audio_content = audio_content
.push(padded_control(divider::horizontal::default()).padding([space_xxs, space_s]));
audio_content = audio_content.push(
Row::with_children(elements)
.align_items(Alignment::Center)
Expand All @@ -916,7 +925,7 @@ impl cosmic::Application for Audio {
}
let content = column![
audio_content,
padded_control(divider::horizontal::default()),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
padded_control(
anim!(
// toggler
Expand All @@ -928,9 +937,8 @@ impl cosmic::Application for Audio {
)
.text_size(14)
.width(Length::Fill)
)
.padding([8, 24]),
padded_control(divider::horizontal::default()),
),
padded_control(divider::horizontal::default()).padding([space_xxs, space_s]),
menu_button(text::body(fl!("sound-settings"))).on_press(Message::OpenSettings)
]
.align_items(Alignment::Start)
Expand Down
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/de/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Taste
battery = Akku
battery-desc = Reduzierter Stromverbrauch und Leistung.
balanced = Ausgeglichen
Expand All @@ -12,4 +11,4 @@ hours = h
until-empty = bis leer
power-settings = Energie- und Akkueinstellungen...
dgpu-running = Dedizierte GPU ist aktiv und kann die Akkulaufzeit reduzieren
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen
dgpu-applications = Anwendungen, die die dedizierte GPU {$gpu_name} nutzen
5 changes: 2 additions & 3 deletions cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Button
battery = Battery
battery-desc = Reduced power usage and performance.
balanced = Balanced
Expand All @@ -10,6 +9,6 @@ seconds = s
minutes = m
hours = h
until-empty = until empty
power-settings = Power and Battery Settings...
power-settings = Power & Battery settings...
dgpu-running = Discrete GPU is active and can reduce battery life
dgpu-applications = Applications using {$gpu_name} discrete GPU
dgpu-applications = Applications using {$gpu_name} discrete GPU
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Botón de Cosmic
battery = Ahorro de energía
battery-desc = Rendimiento y uso de energía reducido.
balanced = Balanceado
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/es-ES/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Botón Cosmic
battery = Batería
battery-desc = Rendimiento y consumo de alimentación reducidos.
balanced = Balanceado
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/fa/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = دکمه Cosmic
battery = باتری
battery-desc = کاهش مصرف برق و عملکرد.
balanced = متعادل
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/fi/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Painike
battery = Akku
battery-desc = Vähentynyt virrankulutus ja suorituskyky.
balanced = Tasapainoitettu
Expand Down
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/fr/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Bouton Cosmic
battery = Batterie
battery-desc = Performance et consommation réduites.
balanced = Équilibré
Expand All @@ -12,4 +11,4 @@ hours = h
until-empty = avant la décharge totale
power-settings = Paramètres d'alimentation...
dgpu-running = Le GPU dédié est actif et peu réduire l'autonomie de la batterie
dgpu-applications = Applications utilisant le GPU dédié {$gpu_name}
dgpu-applications = Applications utilisant le GPU dédié {$gpu_name}
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/hu/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Gomb
battery = Akkumulátor
battery-desc = Csökkentett energiafogyasztás és teljesítmény.
balanced = Kiegyensúlyozott
Expand All @@ -12,4 +11,4 @@ hours = h
until-empty = lemerülésig
power-settings = Tápellátás és akkumulátor beállítások...
dgpu-running = A dedikált GPU aktív, és csökkentheti az akkumulátor élettartamát
dgpu-applications = A {$gpu_name} dedikált GPU-t használó alkalmazások
dgpu-applications = A {$gpu_name} dedikált GPU-t használó alkalmazások
5 changes: 2 additions & 3 deletions cosmic-applet-battery/i18n/id/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Tombol Cosmic
battery = Baterai
battery-desc = Penggunaan daya dan kinerja yang dikurangi.
balanced = Seimbang
Expand All @@ -7,9 +6,9 @@ performance = Kinerja Tinggi
performance-desc = Kinerja dan penggunaan daya yang tinggi.
max-charge = Tingkatkan masa pakai baterai Anda dengan mengatur nilai pengisian maksimum 80%
seconds = d
minutes = m
minutes = m
hours = j
until-empty = hingga kosong
power-settings = Pengaturan Daya dan Baterai...
dgpu-running = GPU Diskrit aktif dan dapat mengurangi masa pakai baterai
dgpu-applications = Aplikasi yang menggunakan {$gpu_name} GPU Diskrit
dgpu-applications = Aplikasi yang menggunakan {$gpu_name} GPU Diskrit
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/it/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Pulsante Cosmic
battery = Batteria
battery-desc = Consumi e performance ridotte.
balanced = Bilanciato
Expand All @@ -12,4 +11,4 @@ hours = h
until-empty = fino alla scarica
power-settings = Impostazioni energetiche
dgpu-running = La GPU discreta è attiva e può ridurre la durata della batteria.
dgpu-applications = Applicazioni che stanno usando la GPU discreta {$gpu_name}
dgpu-applications = Applicazioni che stanno usando la GPU discreta {$gpu_name}
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/ja/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmicボタン
battery = バッテリー
battery-desc = 性能と消費は低くなります。
balanced = バランス
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/nl/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Knop
battery = Batterij
battery-desc = Verminderd stroom verbruik en prestatie.
balanced = Gebalanceerd
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/pl/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Przycisk Cosmic
battery = Na Baterii
battery-desc = Zmniejszone zużycie energii i zmniejszona wydajność.
balanced = Zbalansowany
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/pt-BR/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Botão Cosmic
battery = Bateria
battery-desc = Uso reduzido de energia e desempenho.
balanced = Equilibrado
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/pt/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Botão Cosmic
battery = Bateria
battery-desc = Uso reduzido de energia e desempenho.
balanced = Equilibrado
Expand Down
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/ru/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Кнопка Cosmic
battery = Аккумулятор
battery-desc = Пониженные энергопотребление и производительность.
balanced = Сбалансированный
Expand All @@ -12,4 +11,4 @@ hours = ч.
until-empty = до полного разряда
power-settings = Параметры питания и аккумулятора...
dgpu-running = Дискретная видеокарта активна и может сократить время автономной работы
dgpu-applications = Приложения, использующие видеокарту {$gpu_name}
dgpu-applications = Приложения, использующие видеокарту {$gpu_name}
3 changes: 1 addition & 2 deletions cosmic-applet-battery/i18n/sk/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Button
battery = Batéria
battery-desc = Obmedzená spotreba energie a výkonu.
balanced = Vyvážený
Expand All @@ -12,4 +11,4 @@ hours = h
until-empty = pokiaľ prázdne
power-settings = Nastavenia napájania a batérie...
dgpu-running = Diskrétne GPU sa práve používa. To môže ovplyvniť životnosť batérie.
dgpu-applications = Aplikácie, ktoré používajú {$gpu_name} diskrétne GPU
dgpu-applications = Aplikácie, ktoré používajú {$gpu_name} diskrétne GPU
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic дугме
battery = Батерија
battery-desc = Смањене перформансе и потрошња батерије.
balanced = Балансирано
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic dugme
battery = Baterija
battery-desc = Smanjene performanse i potrošnja baterije.
balanced = Balansirano
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/tr/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic Düğmesi
battery = Pil
battery-desc = Daha az güç tüketimi ve başarım.
balanced = Dengeli
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/uk/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Кнопка Cosmic
battery = Акумулятор
battery-desc = Зменшення споживання енергії та продуктивності.
balanced = Збалансовано
Expand Down
1 change: 0 additions & 1 deletion cosmic-applet-battery/i18n/zh-CN/cosmic_applet_battery.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cosmic-applet-button = Cosmic 按钮
battery = 省电
battery-desc = 降低功耗和性能
balanced = 平衡
Expand Down
Loading

0 comments on commit 941cbf5

Please sign in to comment.