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

View file

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