fix(minimize): match size of other applets at all sizes

This commit is contained in:
Ashley Wulber 2024-04-26 14:04:05 -04:00 committed by Ashley Wulber
parent d9b8794652
commit 660f5cfc91
2 changed files with 16 additions and 12 deletions

View file

@ -125,6 +125,7 @@ impl cosmic::Application for Minimize {
fn view(&self) -> Element<Message> { fn view(&self) -> Element<Message> {
let (width, _) = self.core.applet.suggested_size(false); let (width, _) = self.core.applet.suggested_size(false);
let padding = self.core.applet.suggested_padding(false);
let theme = self.core.system_theme().cosmic(); let theme = self.core.system_theme().cosmic();
let space_xxs = theme.space_xxs(); let space_xxs = theme.space_xxs();
let icon_buttons = self.apps.iter().map(|(handle, _, data, img)| { let icon_buttons = self.apps.iter().map(|(handle, _, data, img)| {
@ -134,7 +135,7 @@ impl cosmic::Application for Minimize {
&data.icon, &data.icon,
width as f32, width as f32,
Message::Activate(handle.clone()), Message::Activate(handle.clone()),
space_xxs, padding,
)), )),
data.name.clone(), data.name.clone(),
// tooltip::Position::FollowCursor, // tooltip::Position::FollowCursor,
@ -164,7 +165,6 @@ impl cosmic::Application for Minimize {
.height(Length::Shrink) .height(Length::Shrink)
.width(Length::Shrink) .width(Length::Shrink)
.spacing(space_xxs) .spacing(space_xxs)
.padding([0, space_xxs])
.into() .into()
} else { } else {
Column::with_children(icon_buttons) Column::with_children(icon_buttons)
@ -172,7 +172,6 @@ impl cosmic::Application for Minimize {
.height(Length::Shrink) .height(Length::Shrink)
.width(Length::Shrink) .width(Length::Shrink)
.spacing(space_xxs) .spacing(space_xxs)
.padding([space_xxs, 0])
.into() .into()
} }
} }

View file

@ -48,8 +48,8 @@ where
} else { } else {
Element::from( Element::from(
icon.as_cosmic_icon() icon.as_cosmic_icon()
.width(Length::Fixed(size)) .width(Length::Fixed((size - border * 2.0).max(0.)))
.height(Length::Fixed(size)), .height(Length::Fixed((size - border * 2.0).max(0.))),
) )
}) })
.style(Container::Custom(Box::new(move |theme| { .style(Container::Custom(Box::new(move |theme| {
@ -68,14 +68,15 @@ where
) )
.align_x(cosmic::iced_core::alignment::Horizontal::Center) .align_x(cosmic::iced_core::alignment::Horizontal::Center)
.align_y(cosmic::iced_core::alignment::Vertical::Center) .align_y(cosmic::iced_core::alignment::Vertical::Center)
.height(Length::Fixed(size)) .height(Length::Fixed(size + padding as f32 * 2.0))
.width(Length::Fixed(size)), .width(Length::Fixed(size + padding as f32 * 2.0))
.padding(padding),
) )
.on_press(on_press) .on_press(on_press)
.width(Length::Shrink) .width(Length::Shrink)
.height(Length::Shrink) .height(Length::Shrink)
.style(Button::AppletIcon) .style(Button::AppletIcon)
.padding(padding) .padding(0)
.into(), .into(),
icon: icon icon: icon
.as_cosmic_icon() .as_cosmic_icon()
@ -129,10 +130,11 @@ impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'a, M
.image_button .image_button
.as_widget() .as_widget()
.layout(button, renderer, limits); .layout(button, renderer, limits);
let img_node = &button_node.children()[0].children()[0];
let button_bounds = button_node.size(); let button_bounds = img_node.size();
let icon_width = button_bounds.width / 3.0; let icon_width = button_bounds.width.max(button_bounds.height) / 3.0;
let icon_height = button_bounds.height / 3.0; let icon_height = button_bounds.height.max(button_bounds.width) / 3.0;
let icon = &mut children[1]; let icon = &mut children[1];
let icon_node = self let icon_node = self
.icon .icon
@ -142,7 +144,10 @@ impl<'a, Msg> Widget<Msg, cosmic::Theme, cosmic::Renderer> for WindowImage<'a, M
renderer, renderer,
&Limits::NONE.width(icon_width).height(icon_height), &Limits::NONE.width(icon_width).height(icon_height),
) )
.translate(Vector::new(2. * icon_width, 2. * icon_height)); .translate(Vector::new(
img_node.bounds().x + 2. * button_bounds.width / 3.0,
img_node.bounds().y + 2. * button_bounds.height / 3.0,
));
layout::Node::with_children( layout::Node::with_children(
limits.resolve(Length::Shrink, Length::Shrink, button_node.size()), limits.resolve(Length::Shrink, Length::Shrink, button_node.size()),