fix(app-list): use context menu radius from theme

This commit is contained in:
Vukašin Vojinović 2024-11-01 14:33:25 +01:00 committed by Ashley Wulber
parent 5b5cd77e7c
commit 6b740c59be
14 changed files with 79 additions and 137 deletions

View file

@ -69,7 +69,6 @@ freedesktop-desktop-entry = "0.7.5"
[profile.release] [profile.release]
lto = "fat" lto = "fat"
[workspace.metadata.cargo-machete] [workspace.metadata.cargo-machete]
ignored = ["libcosmic"] ignored = ["libcosmic"]
# [patch."https://github.com/pop-os/libcosmic"] # [patch."https://github.com/pop-os/libcosmic"]

View file

@ -31,10 +31,7 @@ use cosmic::{
window, Color, Limits, Subscription, window, Color, Limits, Subscription,
}, },
iced_core::{Border, Padding, Shadow}, iced_core::{Border, Padding, Shadow},
iced_runtime::{ iced_runtime::{core::event, dnd::peek_dnd},
core::{alignment::Horizontal, event},
dnd::peek_dnd,
},
theme::{self, Button, Container}, theme::{self, Button, Container},
widget::{ widget::{
button, divider, dnd_source, horizontal_space, button, divider, dnd_source, horizontal_space,
@ -215,28 +212,28 @@ impl DockItem {
horizontal_space().width(Length::Fixed(1.0)).into(), horizontal_space().width(Length::Fixed(1.0)).into(),
cosmic_icon.clone().into(), cosmic_icon.clone().into(),
]) ])
.align_y(iced::Alignment::Center) .align_y(Alignment::Center)
.into(), .into(),
PanelAnchor::Right => row(vec![ PanelAnchor::Right => row(vec![
cosmic_icon.clone().into(), cosmic_icon.clone().into(),
horizontal_space().width(Length::Fixed(1.0)).into(), horizontal_space().width(Length::Fixed(1.0)).into(),
column(dots).into(), column(dots).into(),
]) ])
.align_y(iced::Alignment::Center) .align_y(Alignment::Center)
.into(), .into(),
PanelAnchor::Top => column(vec![ PanelAnchor::Top => column(vec![
row(dots).into(), row(dots).into(),
vertical_space().height(Length::Fixed(1.0)).into(), vertical_space().height(Length::Fixed(1.0)).into(),
cosmic_icon.clone().into(), cosmic_icon.clone().into(),
]) ])
.align_x(iced::Alignment::Center) .align_x(Alignment::Center)
.into(), .into(),
PanelAnchor::Bottom => column(vec![ PanelAnchor::Bottom => column(vec![
cosmic_icon.clone().into(), cosmic_icon.clone().into(),
vertical_space().height(Length::Fixed(1.0)).into(), vertical_space().height(Length::Fixed(1.0)).into(),
row(dots).into(), row(dots).into(),
]) ])
.align_x(iced::Alignment::Center) .align_x(Alignment::Center)
.into(), .into(),
}; };
@ -467,15 +464,12 @@ where
.padding(border as u16) .padding(border as u16)
.height(Length::Fill) .height(Length::Fill)
.width(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) .spacing(4)
.align_x(Alignment::Center), .align_x(Alignment::Center),
) )
.align_x(cosmic::iced_core::alignment::Horizontal::Center) .center(Length::Fill),
.align_y(cosmic::iced_core::alignment::Vertical::Center)
.height(Length::Fill)
.width(Length::Fill),
) )
.on_press(on_press) .on_press(on_press)
.class(window_menu_style(is_focused)) .class(window_menu_style(is_focused))
@ -1797,7 +1791,7 @@ impl cosmic::Application for CosmicAppList {
text_color: Some(component.on.into()), text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())), background: Some(Background::Color(component.base.into())),
border: Border { border: Border {
radius: 8.0.into(), radius: cosmic.radius_s().into(),
width: 1.0, width: 1.0,
color: component.divider.into(), color: component.divider.into(),
}, },

View file

@ -23,7 +23,6 @@ use cosmic::{
widget::{self, column, row, slider}, widget::{self, column, row, slider},
window, Alignment, Length, Limits, Subscription, window, Alignment, Length, Limits, Subscription,
}, },
iced_runtime::core::alignment::Horizontal,
theme, theme,
widget::{button, divider, horizontal_space, icon, text, Column, Row}, widget::{button, divider, horizontal_space, icon, text, Column, Row},
Element, Renderer, Task, Theme, Element, Renderer, Task, Theme,
@ -753,7 +752,7 @@ impl cosmic::Application for Audio {
column![padded_control( column![padded_control(
text::title3(fl!("disconnected")) text::title3(fl!("disconnected"))
.width(Length::Fill) .width(Length::Fill)
.align_x(Horizontal::Center) .align_x(Alignment::Center)
)] )]
} else { } else {
column![ column![
@ -773,7 +772,7 @@ impl cosmic::Application for Audio {
text(&self.output_volume_text) text(&self.output_volume_text)
.size(16) .size(16)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(Horizontal::Right) .align_x(Alignment::End)
] ]
.spacing(12) .spacing(12)
.align_y(Alignment::Center) .align_y(Alignment::Center)
@ -794,7 +793,7 @@ impl cosmic::Application for Audio {
text(&self.input_volume_text) text(&self.input_volume_text)
.size(16) .size(16)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
.align_x(Horizontal::Right) .align_x(Alignment::End)
] ]
.spacing(12) .spacing(12)
.align_y(Alignment::Center) .align_y(Alignment::Center)
@ -848,8 +847,8 @@ impl cosmic::Application for Audio {
} }
let title = if let Some(title) = s.title.as_ref() { let title = if let Some(title) = s.title.as_ref() {
if title.chars().count() > 15 { if title.chars().count() > 22 {
let mut title_trunc = title.chars().take(15).collect::<String>(); let mut title_trunc = title.chars().take(20).collect::<String>();
title_trunc.push_str("..."); title_trunc.push_str("...");
title_trunc title_trunc
} else { } else {
@ -861,8 +860,8 @@ impl cosmic::Application for Audio {
let artists = if let Some(artists) = s.artists.as_ref() { let artists = if let Some(artists) = s.artists.as_ref() {
let artists = artists.join(", "); let artists = artists.join(", ");
if artists.chars().count() > 15 { if artists.chars().count() > 27 {
let mut artists_trunc = artists.chars().take(15).collect::<String>(); let mut artists_trunc = artists.chars().take(25).collect::<String>();
artists_trunc.push_str("..."); artists_trunc.push_str("...");
artists_trunc artists_trunc
} else { } else {

View file

@ -19,12 +19,11 @@ use cosmic::{
cctk::sctk::reexports::calloop, cctk::sctk::reexports::calloop,
cosmic_theme::Spacing, cosmic_theme::Spacing,
iced::{ iced::{
alignment::Horizontal,
platform_specific::shell::wayland::commands::popup::{destroy_popup, get_popup}, platform_specific::shell::wayland::commands::popup::{destroy_popup, get_popup},
widget::{column, container, row, slider}, 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_runtime::core::layout::Limits,
iced_widget::{Column, Row}, iced_widget::{Column, Row},
theme, theme,
@ -578,7 +577,7 @@ impl cosmic::Application for CosmicBatteryApplet {
)) ))
.size(16) .size(16)
.width(Length::Fixed(40.0)) .width(Length::Fixed(40.0))
.align_x(Horizontal::Right) .align_x(Alignment::End)
] ]
.spacing(12), .spacing(12),
) )
@ -606,7 +605,7 @@ impl cosmic::Application for CosmicBatteryApplet {
)) ))
.size(16) .size(16)
.width(Length::Fixed(40.0)) .width(Length::Fixed(40.0))
.align_x(Horizontal::Right) .align_x(Alignment::End)
] ]
.spacing(12), .spacing(12),
) )
@ -628,7 +627,7 @@ impl cosmic::Application for CosmicBatteryApplet {
text(fl!("dgpu-running")) text(fl!("dgpu-running"))
.size(16) .size(16)
.width(Length::Fill) .width(Length::Fill)
.align_x(Horizontal::Left), .align_x(Alignment::Start),
container(vertical_space().width(Length::Fixed(0.0))) container(vertical_space().width(Length::Fixed(0.0)))
.padding(4) .padding(4)
.class(cosmic::style::Container::Custom(Box::new(|theme| { .class(cosmic::style::Container::Custom(Box::new(|theme| {
@ -671,7 +670,7 @@ impl cosmic::Application for CosmicBatteryApplet {
gpu_name = format!("\"{}\"", gpu.name.trim()) gpu_name = format!("\"{}\"", gpu.name.trim())
)) ))
.width(Length::Fill) .width(Length::Fill)
.align_y(Vertical::Center), .align_y(Alignment::Center),
container( container(
icon::from_name(if gpu.toggled { icon::from_name(if gpu.toggled {
"go-down-symbolic" "go-down-symbolic"
@ -681,10 +680,7 @@ impl cosmic::Application for CosmicBatteryApplet {
.size(14) .size(14)
.symbolic(true) .symbolic(true)
) )
.align_x(Horizontal::Center) .center(Length::Fixed(24.0)),
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
.height(Length::Fixed(24.0)),
] ]
.align_y(Alignment::Center), .align_y(Alignment::Center),
) )

View file

@ -16,11 +16,7 @@ use cosmic::{
widget::{column, container, row, scrollable, Column}, widget::{column, container, row, scrollable, Column},
Alignment, Length, Subscription, Alignment, Length, Subscription,
}, },
iced_runtime::core::{ iced_runtime::core::{layout::Limits, window},
alignment::{Horizontal, Vertical},
layout::Limits,
window,
},
theme, theme,
widget::{button, divider, icon, text}, widget::{button, divider, icon, text},
Element, Task, Element, Task,
@ -364,8 +360,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
let mut row = row![ let mut row = row![
icon::from_name(dev.icon.as_str()).size(16).symbolic(true), icon::from_name(dev.icon.as_str()).size(16).symbolic(true),
text::body(dev.name.clone()) text::body(dev.name.clone())
.align_x(Horizontal::Left) .align_x(Alignment::Start)
.align_y(Vertical::Center) .align_y(Alignment::Center)
.width(Length::Fill) .width(Length::Fill)
] ]
.align_y(Alignment::Center) .align_y(Alignment::Center)
@ -390,8 +386,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
.width(Length::Shrink); .width(Length::Shrink);
let content = container(status) let content = container(status)
.align_x(Horizontal::Right) .align_x(Alignment::End)
.align_y(Vertical::Center); .align_y(Alignment::Center);
row = row.push(content); row = row.push(content);
} }
@ -400,8 +396,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
BluerDeviceStatus::Connected => { BluerDeviceStatus::Connected => {
row = row.push( row = row.push(
text::body(fl!("connected")) text::body(fl!("connected"))
.align_x(Horizontal::Right) .align_x(Alignment::End)
.align_y(Vertical::Center), .align_y(Alignment::Center),
); );
} }
BluerDeviceStatus::Paired => {} BluerDeviceStatus::Paired => {}
@ -465,12 +461,9 @@ impl cosmic::Application for CosmicBluetoothApplet {
text::body(fl!("other-devices")) text::body(fl!("other-devices"))
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fixed(24.0)) .height(Length::Fixed(24.0))
.align_y(Vertical::Center), .align_y(Alignment::Center),
container(icon::from_name(dropdown_icon).size(16).symbolic(true)) container(icon::from_name(dropdown_icon).size(16).symbolic(true))
.align_x(Horizontal::Center) .center(Length::Fixed(24.0))
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
.height(Length::Fixed(24.0))
]) ])
.on_press(Message::ToggleVisibleDevices(!self.show_visible_devices)); .on_press(Message::ToggleVisibleDevices(!self.show_visible_devices));
if self.bluer_state.bluetooth_enabled { if self.bluer_state.bluetooth_enabled {
@ -488,8 +481,8 @@ impl cosmic::Application for CosmicBluetoothApplet {
.size(16) .size(16)
.symbolic(true), .symbolic(true),
text::body(&device.name) text::body(&device.name)
.align_x(Horizontal::Left) .align_x(Alignment::Start)
.align_y(Vertical::Center) .align_y(Alignment::Center)
.width(Length::Fill) .width(Length::Fill)
]), ]),
padded_control( padded_control(
@ -497,43 +490,30 @@ impl cosmic::Application for CosmicBluetoothApplet {
"confirm-pin", "confirm-pin",
HashMap::from_iter(vec![("deviceName", device.name.clone())]) HashMap::from_iter(vec![("deviceName", device.name.clone())])
)) ))
.align_x(Horizontal::Left) .align_x(Alignment::Start)
.align_y(Vertical::Center) .align_y(Alignment::Center)
.width(Length::Fill) .width(Length::Fill)
), ),
padded_control( padded_control(text::title3(pin).center().width(Length::Fixed(280.0)))
text::title3(pin) .align_x(Alignment::Center),
.align_x(Horizontal::Center)
.align_y(Vertical::Center)
.width(Length::Fixed(280.0)) //.size(22)
)
.align_x(Horizontal::Center),
padded_control( padded_control(
row![ row![
button::custom( button::custom(text::body(fl!("cancel")).center())
text::body(fl!("cancel")) .padding([4, 0])
.align_y(Vertical::Center) .height(Length::Fixed(28.0))
.align_x(Horizontal::Center) .width(Length::Fixed(105.0))
) .on_press(Message::Cancel),
.padding([4, 0]) button::custom(text::body(fl!("confirm")).center())
.height(Length::Fixed(28.0)) .padding([4, 0])
.width(Length::Fixed(105.0)) .height(Length::Fixed(28.0))
.on_press(Message::Cancel), .width(Length::Fixed(105.0))
button::custom( .on_press(Message::Confirm),
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),
] ]
.spacing(self.core.system_theme().cosmic().space_xxs()) .spacing(self.core.system_theme().cosmic().space_xxs())
.width(Length::Shrink) .width(Length::Shrink)
.align_y(Alignment::Center) .align_y(Alignment::Center)
) )
.align_x(Horizontal::Center) .align_x(Alignment::Center)
]; ];
list_column.push(row.into()); list_column.push(row.into());
} }
@ -551,7 +531,7 @@ impl cosmic::Application for CosmicBluetoothApplet {
}) { }) {
let row = row![ let row = row![
icon::from_name(dev.icon.as_str()).size(16).symbolic(true), 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) .align_y(Alignment::Center)
.spacing(12); .spacing(12);

View file

@ -5,7 +5,7 @@ use crate::config::{Config, CONFIG_VERSION};
#[allow(unused_imports)] #[allow(unused_imports)]
use crate::fl; use crate::fl;
#[allow(unused_imports)] #[allow(unused_imports)]
use cosmic::iced::{alignment, Alignment, Length}; use cosmic::iced::{Alignment, Length};
use cosmic::{ use cosmic::{
app::Core, app::Core,
applet::{self}, applet::{self},

View file

@ -19,7 +19,7 @@ use futures::{
}; };
use image::EncodableLayout; use image::EncodableLayout;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::{fmt::Debug, sync::Arc}; use std::fmt::Debug;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use crate::wayland_handler::wayland_handler; use crate::wayland_handler::wayland_handler;

View file

@ -63,10 +63,7 @@ where
.height(Length::Shrink) .height(Length::Shrink)
.width(Length::Shrink), .width(Length::Shrink),
) )
.align_x(cosmic::iced_core::alignment::Horizontal::Center) .center(Length::Fixed(size + padding as f32 * 2.0))
.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))
.padding(padding), .padding(padding),
) )
.on_press(on_press) .on_press(on_press)

View file

@ -13,11 +13,7 @@ use cosmic::{
widget::{column, row}, widget::{column, row},
Alignment, Length, Subscription, Alignment, Length, Subscription,
}, },
iced_runtime::core::{ iced_runtime::core::{layout::Limits, window},
alignment::{Horizontal, Vertical},
layout::Limits,
window,
},
iced_widget::Row, iced_widget::Row,
theme, theme,
widget::{ widget::{
@ -576,7 +572,7 @@ impl cosmic::Application for CosmicNetworkApplet {
Column::with_children(ipv4), Column::with_children(ipv4),
text::body(fl!("connected")) text::body(fl!("connected"))
.width(Length::Fill) .width(Length::Fill)
.align_x(Horizontal::Right), .align_x(Alignment::End),
] ]
.align_y(Alignment::Center) .align_y(Alignment::Center)
.spacing(8) .spacing(8)
@ -612,7 +608,7 @@ impl cosmic::Application for CosmicNetworkApplet {
fl!("megabits-per-second") fl!("megabits-per-second")
)) ))
.width(Length::Fill) .width(Length::Fill)
.align_x(Horizontal::Right), .align_x(Alignment::End),
] ]
.align_y(Alignment::Center) .align_y(Alignment::Center)
.spacing(8) .spacing(8)
@ -652,8 +648,8 @@ impl cosmic::Application for CosmicNetworkApplet {
} }
ActiveConnectionState::Activated => btn_content.push( ActiveConnectionState::Activated => btn_content.push(
text::body(fl!("connected")) text::body(fl!("connected"))
.align_x(Horizontal::Right) .align_x(Alignment::End)
.align_y(Vertical::Center) .align_y(Alignment::Center)
.into(), .into(),
), ),
_ => {} _ => {}
@ -816,12 +812,9 @@ impl cosmic::Application for CosmicNetworkApplet {
text::body(fl!("visible-wireless-networks")) text::body(fl!("visible-wireless-networks"))
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fixed(24.0)) .height(Length::Fixed(24.0))
.align_y(Vertical::Center), .align_y(Alignment::Center),
container(icon::from_name(dropdown_icon).size(16).symbolic(true)) container(icon::from_name(dropdown_icon).size(16).symbolic(true))
.align_x(Horizontal::Center) .center(Length::Fixed(24.0))
.align_y(Vertical::Center)
.width(Length::Fixed(24.0))
.height(Length::Fixed(24.0)),
]) ])
.on_press(Message::ToggleVisibleNetworks); .on_press(Message::ToggleVisibleNetworks);
content = content.push(available_connections_btn); content = content.push(available_connections_btn);
@ -865,7 +858,7 @@ impl cosmic::Application for CosmicNetworkApplet {
.spacing(8) .spacing(8)
.align_x(Alignment::Center), .align_x(Alignment::Center),
) )
.align_x(Horizontal::Center); .align_x(Alignment::Center);
content = content.push(col); content = content.push(col);
} }
NewConnectionState::Waiting(access_point) => { NewConnectionState::Waiting(access_point) => {
@ -900,7 +893,7 @@ impl cosmic::Application for CosmicNetworkApplet {
.align_y(Alignment::Center) .align_y(Alignment::Center)
.spacing(12), .spacing(12),
) )
.align_x(Horizontal::Center); .align_x(Alignment::Center);
content = content.push(id); content = content.push(id);
let col = padded_control( let col = padded_control(
column![ column![
@ -918,7 +911,7 @@ impl cosmic::Application for CosmicNetworkApplet {
.spacing(16) .spacing(16)
.align_x(Alignment::Center), .align_x(Alignment::Center),
) )
.align_x(Horizontal::Center); .align_x(Alignment::Center);
content = content.push(col); content = content.push(col);
} }
} }
@ -938,7 +931,7 @@ impl cosmic::Application for CosmicNetworkApplet {
icon::from_name(wifi_icon(ap.strength)) icon::from_name(wifi_icon(ap.strength))
.size(16) .size(16)
.symbolic(true), .symbolic(true),
text::body(&ap.ssid).align_y(Vertical::Center) text::body(&ap.ssid).align_y(Alignment::Center)
] ]
.align_y(Alignment::Center) .align_y(Alignment::Center)
.spacing(12), .spacing(12),

View file

@ -16,7 +16,6 @@ use cosmic::{
widget::{column, row}, widget::{column, row},
window, Alignment, Length, Limits, Subscription, window, Alignment, Length, Limits, Subscription,
}, },
iced_core::alignment::Horizontal,
iced_widget::{scrollable, Column}, iced_widget::{scrollable, Column},
theme, theme,
widget::{button, container, divider, icon, text}, widget::{button, container, divider, icon, text},
@ -389,8 +388,7 @@ impl cosmic::Application for Notifications {
] ]
.align_x(Alignment::Center) .align_x(Alignment::Center)
) )
.width(Length::Fill) .center_x(Length::Fill)]
.align_x(Horizontal::Center)]
.padding([8, 0]) .padding([8, 0])
.spacing(12) .spacing(12)
} else { } else {
@ -401,7 +399,7 @@ impl cosmic::Application for Notifications {
.on_press(Message::ClearAll(None)), .on_press(Message::ClearAll(None)),
) )
.width(Length::Fill) .width(Length::Fill)
.align_x(Horizontal::Right) .align_x(Alignment::End)
.into(), .into(),
); );
for c in self.cards.iter().rev() { for c in self.cards.iter().rev() {

View file

@ -1,8 +1,6 @@
// Copyright 2023 System76 <info@system76.com> // Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
use std::ops::Sub;
use crate::subscriptions::freedesktop_proxy::NotificationsProxy; use crate::subscriptions::freedesktop_proxy::NotificationsProxy;
use cosmic::{ use cosmic::{
iced::futures::{self, SinkExt}, iced::futures::{self, SinkExt},

View file

@ -9,7 +9,6 @@ use cosmic::{
cosmic_theme::Spacing, cosmic_theme::Spacing,
iced::{ iced::{
self, self,
alignment::{Horizontal, Vertical},
event::{ event::{
listen_with, listen_with,
wayland::{self, LayerEvent}, wayland::{self, LayerEvent},
@ -372,16 +371,10 @@ impl cosmic::Application for Power {
} }
Element::from( Element::from(
mouse_area( mouse_area(container(dialog).center(Length::Fill))
container(dialog) .on_press(Message::Cancel)
.align_x(Horizontal::Center) .on_right_press(Message::Cancel)
.align_y(Vertical::Center) .on_middle_press(Message::Cancel),
.width(Length::Fill)
.height(Length::Fill),
)
.on_press(Message::Cancel)
.on_right_press(Message::Cancel)
.on_middle_press(Message::Cancel),
) )
} else { } else {
//panic!("no view for window {}", id.0) //panic!("no view for window {}", id.0)

View file

@ -17,7 +17,6 @@ use cosmic::{
widget::{column, row, vertical_space}, widget::{column, row, vertical_space},
window, Alignment, Length, Rectangle, Subscription, window, Alignment, Length, Rectangle, Subscription,
}, },
iced_core::alignment::{Horizontal, Vertical},
iced_widget::{horizontal_rule, Column}, iced_widget::{horizontal_rule, Column},
theme, theme,
widget::{ widget::{
@ -613,7 +612,7 @@ impl cosmic::Application for Window {
text(self.format(weekday_bag, &day_iter.next().unwrap())) text(self.format(weekday_bag, &day_iter.next().unwrap()))
.size(12) .size(12)
.width(Length::Fixed(36.0)) .width(Length::Fixed(36.0))
.align_x(Horizontal::Center), .align_x(Alignment::Center),
); );
first_day_of_week = first_day_of_week.succ(); first_day_of_week = first_day_of_week.succ();
@ -669,14 +668,10 @@ fn date_button(day: u32, is_month: bool, is_day: bool) -> Button<'static, Messag
button::ButtonClass::Text button::ButtonClass::Text
}; };
let button = button::custom( let button = button::custom(text::body(format!("{day}")).center())
text::body(format!("{day}")) .class(style)
.align_x(Horizontal::Center) .height(Length::Fixed(36.0))
.align_y(Vertical::Center), .width(Length::Fixed(36.0));
)
.class(style)
.height(Length::Fixed(36.0))
.width(Length::Fixed(36.0));
if is_month { if is_month {
button.on_press(Message::SelectDay(day)) button.on_press(Message::SelectDay(day))

View file

@ -5,10 +5,10 @@ use cctk::sctk::reexports::{calloop::channel::SyncSender, client::backend::Objec
use cosmic::{ use cosmic::{
applet::cosmic_panel_config::PanelAnchor, applet::cosmic_panel_config::PanelAnchor,
iced::{ iced::{
alignment::{Horizontal, Vertical},
event, event,
mouse::{self, ScrollDelta}, mouse::{self, ScrollDelta},
widget::{button, column, row}, widget::{button, column, row},
Alignment,
Event::Mouse, Event::Mouse,
Length, Limits, Subscription, Length, Limits, Subscription,
}, },
@ -190,15 +190,15 @@ impl cosmic::Application for IcedWorkspacesApplet {
}; };
let content = row!(content, vertical_space().height(Length::Fixed(height))) let content = row!(content, vertical_space().height(Length::Fixed(height)))
.align_y(cosmic::iced::Alignment::Center); .align_y(Alignment::Center);
let content = column!(content, horizontal_space().width(Length::Fixed(width))) let content = column!(content, horizontal_space().width(Length::Fixed(width)))
.align_x(cosmic::iced::Alignment::Center); .align_x(Alignment::Center);
let btn = button( let btn = button(
container(content) container(content)
.align_x(Horizontal::Center) .align_x(Alignment::Center)
.align_y(Vertical::Center), .align_y(Alignment::Center),
) )
.padding(if horizontal { .padding(if horizontal {
[0, self.core.applet.suggested_padding(true)] [0, self.core.applet.suggested_padding(true)]