Skip to content

Commit

Permalink
fix(app-list): use context menu radius from theme
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Nov 1, 2024
1 parent 5b5cd77 commit 8914fc9
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 137 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ freedesktop-desktop-entry = "0.7.5"
[profile.release]
lto = "fat"


[workspace.metadata.cargo-machete]
ignored = ["libcosmic"]
# [patch."https://github.com/pop-os/libcosmic"]
Expand Down
22 changes: 8 additions & 14 deletions cosmic-app-list/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ use cosmic::{
window, Color, Limits, Subscription,
},
iced_core::{Border, Padding, Shadow},
iced_runtime::{
core::{alignment::Horizontal, event},
dnd::peek_dnd,
},
iced_runtime::{core::event, dnd::peek_dnd},
theme::{self, Button, Container},
widget::{
button, divider, dnd_source, horizontal_space,
Expand Down Expand Up @@ -215,28 +212,28 @@ impl DockItem {
horizontal_space().width(Length::Fixed(1.0)).into(),
cosmic_icon.clone().into(),
])
.align_y(iced::Alignment::Center)
.align_y(Alignment::Center)
.into(),
PanelAnchor::Right => row(vec![
cosmic_icon.clone().into(),
horizontal_space().width(Length::Fixed(1.0)).into(),
column(dots).into(),
])
.align_y(iced::Alignment::Center)
.align_y(Alignment::Center)
.into(),
PanelAnchor::Top => column(vec![
row(dots).into(),
vertical_space().height(Length::Fixed(1.0)).into(),
cosmic_icon.clone().into(),
])
.align_x(iced::Alignment::Center)
.align_x(Alignment::Center)
.into(),
PanelAnchor::Bottom => column(vec![
cosmic_icon.clone().into(),
vertical_space().height(Length::Fixed(1.0)).into(),
row(dots).into(),
])
.align_x(iced::Alignment::Center)
.align_x(Alignment::Center)
.into(),
};

Expand Down Expand Up @@ -467,15 +464,12 @@ where
.padding(border as u16)
.height(Length::Fill)
.width(Length::Fill),
container(text::body(title).align_x(Horizontal::Center),).center_x(Length::Fill),
container(text::body(title).align_x(Alignment::Center)).center_x(Length::Fill),
]
.spacing(4)
.align_x(Alignment::Center),
)
.align_x(cosmic::iced_core::alignment::Horizontal::Center)
.align_y(cosmic::iced_core::alignment::Vertical::Center)
.height(Length::Fill)
.width(Length::Fill),
.center(Length::Fill),
)
.on_press(on_press)
.class(window_menu_style(is_focused))
Expand Down Expand Up @@ -1797,7 +1791,7 @@ impl cosmic::Application for CosmicAppList {
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border: Border {
radius: 8.0.into(),
radius: cosmic.radius_s().into(),
width: 1.0,
color: component.divider.into(),
},
Expand Down
15 changes: 7 additions & 8 deletions cosmic-applet-audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use cosmic::{
widget::{self, column, row, slider},
window, Alignment, Length, Limits, Subscription,
},
iced_runtime::core::alignment::Horizontal,
theme,
widget::{button, divider, horizontal_space, icon, text, Column, Row},
Element, Renderer, Task, Theme,
Expand Down Expand Up @@ -753,7 +752,7 @@ impl cosmic::Application for Audio {
column![padded_control(
text::title3(fl!("disconnected"))
.width(Length::Fill)
.align_x(Horizontal::Center)
.align_x(Alignment::Center)
)]
} else {
column![
Expand All @@ -773,7 +772,7 @@ impl cosmic::Application for Audio {
text(&self.output_volume_text)
.size(16)
.width(Length::FillPortion(1))
.align_x(Horizontal::Right)
.align_x(Alignment::End)
]
.spacing(12)
.align_y(Alignment::Center)
Expand All @@ -794,7 +793,7 @@ impl cosmic::Application for Audio {
text(&self.input_volume_text)
.size(16)
.width(Length::FillPortion(1))
.align_x(Horizontal::Right)
.align_x(Alignment::End)
]
.spacing(12)
.align_y(Alignment::Center)
Expand Down Expand Up @@ -848,8 +847,8 @@ impl cosmic::Application for Audio {
}

let title = if let Some(title) = s.title.as_ref() {
if title.chars().count() > 15 {
let mut title_trunc = title.chars().take(15).collect::<String>();
if title.chars().count() > 22 {
let mut title_trunc = title.chars().take(20).collect::<String>();
title_trunc.push_str("...");
title_trunc
} else {
Expand All @@ -861,8 +860,8 @@ impl cosmic::Application for Audio {

let artists = if let Some(artists) = s.artists.as_ref() {
let artists = artists.join(", ");
if artists.chars().count() > 15 {
let mut artists_trunc = artists.chars().take(15).collect::<String>();
if artists.chars().count() > 27 {
let mut artists_trunc = artists.chars().take(25).collect::<String>();
artists_trunc.push_str("...");
artists_trunc
} else {
Expand Down
18 changes: 7 additions & 11 deletions cosmic-applet-battery/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use cosmic::{
cctk::sctk::reexports::calloop,
cosmic_theme::Spacing,
iced::{
alignment::Horizontal,
platform_specific::shell::wayland::commands::popup::{destroy_popup, get_popup},
widget::{column, container, row, slider},
window, Alignment, Length, Subscription,
window, Length, Subscription,
},
iced_core::{alignment::Vertical, Background, Border, Color, Shadow},
iced_core::{Alignment, Background, Border, Color, Shadow},
iced_runtime::core::layout::Limits,
iced_widget::{Column, Row},
theme,
Expand Down Expand Up @@ -578,7 +577,7 @@ impl cosmic::Application for CosmicBatteryApplet {
))
.size(16)
.width(Length::Fixed(40.0))
.align_x(Horizontal::Right)
.align_x(Alignment::End)
]
.spacing(12),
)
Expand Down Expand Up @@ -606,7 +605,7 @@ impl cosmic::Application for CosmicBatteryApplet {
))
.size(16)
.width(Length::Fixed(40.0))
.align_x(Horizontal::Right)
.align_x(Alignment::End)
]
.spacing(12),
)
Expand All @@ -628,7 +627,7 @@ impl cosmic::Application for CosmicBatteryApplet {
text(fl!("dgpu-running"))
.size(16)
.width(Length::Fill)
.align_x(Horizontal::Left),
.align_x(Alignment::Start),
container(vertical_space().width(Length::Fixed(0.0)))
.padding(4)
.class(cosmic::style::Container::Custom(Box::new(|theme| {
Expand Down Expand Up @@ -671,7 +670,7 @@ impl cosmic::Application for CosmicBatteryApplet {
gpu_name = format!("\"{}\"", gpu.name.trim())
))
.width(Length::Fill)
.align_y(Vertical::Center),
.align_y(Alignment::Center),
container(
icon::from_name(if gpu.toggled {
"go-down-symbolic"
Expand All @@ -681,10 +680,7 @@ impl cosmic::Application for CosmicBatteryApplet {
.size(14)
.symbolic(true)
)
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
.height(Length::Fixed(24.0)),
.center(Length::Fixed(24.0)),
]
.align_y(Alignment::Center),
)
Expand Down
74 changes: 27 additions & 47 deletions cosmic-applet-bluetooth/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ use cosmic::{
widget::{column, container, row, scrollable, Column},
Alignment, Length, Subscription,
},
iced_runtime::core::{
alignment::{Horizontal, Vertical},
layout::Limits,
window,
},
iced_runtime::core::{layout::Limits, window},
theme,
widget::{button, divider, icon, text},
Element, Task,
Expand Down Expand Up @@ -364,8 +360,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
let mut row = row![
icon::from_name(dev.icon.as_str()).size(16).symbolic(true),
text::body(dev.name.clone())
.align_x(Horizontal::Left)
.align_y(Vertical::Center)
.align_x(Alignment::Start)
.align_y(Alignment::Center)
.width(Length::Fill)
]
.align_y(Alignment::Center)
Expand All @@ -390,8 +386,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
.width(Length::Shrink);

let content = container(status)
.align_x(Horizontal::Right)
.align_y(Vertical::Center);
.align_x(Alignment::End)
.align_y(Alignment::Center);

row = row.push(content);
}
Expand All @@ -400,8 +396,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
BluerDeviceStatus::Connected => {
row = row.push(
text::body(fl!("connected"))
.align_x(Horizontal::Right)
.align_y(Vertical::Center),
.align_x(Alignment::End)
.align_y(Alignment::Center),
);
}
BluerDeviceStatus::Paired => {}
Expand Down Expand Up @@ -465,12 +461,9 @@ impl cosmic::Application for CosmicBluetoothApplet {
text::body(fl!("other-devices"))
.width(Length::Fill)
.height(Length::Fixed(24.0))
.align_y(Vertical::Center),
.align_y(Alignment::Center),
container(icon::from_name(dropdown_icon).size(16).symbolic(true))
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
.height(Length::Fixed(24.0))
.center(Length::Fixed(24.0))
])
.on_press(Message::ToggleVisibleDevices(!self.show_visible_devices));
if self.bluer_state.bluetooth_enabled {
Expand All @@ -488,52 +481,39 @@ impl cosmic::Application for CosmicBluetoothApplet {
.size(16)
.symbolic(true),
text::body(&device.name)
.align_x(Horizontal::Left)
.align_y(Vertical::Center)
.align_x(Alignment::Start)
.align_y(Alignment::Center)
.width(Length::Fill)
]),
padded_control(
text::body(fl!(
"confirm-pin",
HashMap::from_iter(vec![("deviceName", device.name.clone())])
))
.align_x(Horizontal::Left)
.align_y(Vertical::Center)
.align_x(Alignment::Start)
.align_y(Alignment::Center)
.width(Length::Fill)
),
padded_control(
text::title3(pin)
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(280.0)) //.size(22)
)
.align_x(Horizontal::Center),
padded_control(text::title3(pin).center().width(Length::Fixed(280.0)))
.align_x(Alignment::Center),
padded_control(
row![
button::custom(
text::body(fl!("cancel"))
.align_y(Vertical::Center)
.align_x(Horizontal::Center)
)
.padding([4, 0])
.height(Length::Fixed(28.0))
.width(Length::Fixed(105.0))
.on_press(Message::Cancel),
button::custom(
text::body(fl!("confirm"))
.align_y(Vertical::Center)
.align_x(Horizontal::Center)
)
.padding([4, 0])
.height(Length::Fixed(28.0))
.width(Length::Fixed(105.0))
.on_press(Message::Confirm),
button::custom(text::body(fl!("cancel")).center())
.padding([4, 0])
.height(Length::Fixed(28.0))
.width(Length::Fixed(105.0))
.on_press(Message::Cancel),
button::custom(text::body(fl!("confirm")).center())
.padding([4, 0])
.height(Length::Fixed(28.0))
.width(Length::Fixed(105.0))
.on_press(Message::Confirm),
]
.spacing(self.core.system_theme().cosmic().space_xxs())
.width(Length::Shrink)
.align_y(Alignment::Center)
)
.align_x(Horizontal::Center)
.align_x(Alignment::Center)
];
list_column.push(row.into());
}
Expand All @@ -551,7 +531,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
}) {
let row = row![
icon::from_name(dev.icon.as_str()).size(16).symbolic(true),
text::body(dev.name.clone()).align_x(Horizontal::Left),
text::body(dev.name.clone()).align_x(Alignment::Start),
]
.align_y(Alignment::Center)
.spacing(12);
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-input-sources/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::config::{Config, CONFIG_VERSION};
#[allow(unused_imports)]
use crate::fl;
#[allow(unused_imports)]
use cosmic::iced::{alignment, Alignment, Length};
use cosmic::iced::{Alignment, Length};
use cosmic::{
app::Core,
applet::{self},
Expand Down
2 changes: 1 addition & 1 deletion cosmic-applet-minimize/src/wayland_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use futures::{
};
use image::EncodableLayout;
use once_cell::sync::Lazy;
use std::{fmt::Debug, sync::Arc};
use std::fmt::Debug;
use tokio::sync::Mutex;

use crate::wayland_handler::wayland_handler;
Expand Down
5 changes: 1 addition & 4 deletions cosmic-applet-minimize/src/window_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ where
.height(Length::Shrink)
.width(Length::Shrink),
)
.align_x(cosmic::iced_core::alignment::Horizontal::Center)
.align_y(cosmic::iced_core::alignment::Vertical::Center)
.height(Length::Fixed(size + padding as f32 * 2.0))
.width(Length::Fixed(size + padding as f32 * 2.0))
.center(Length::Fixed(size + padding as f32 * 2.0))
.padding(padding),
)
.on_press(on_press)
Expand Down
Loading

0 comments on commit 8914fc9

Please sign in to comment.