Skip to content

Commit cf10d16

Browse files
committed
fix: autosize wrapper for menu
1 parent 443849c commit cf10d16

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

src/app.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use cosmic::{
5757
},
5858
theme::{self, Button, TextInput},
5959
widget::{
60+
autosize::autosize,
6061
button::{self, Catalog as ButtonStyleSheet},
6162
divider,
6263
dnd_destination::dnd_destination_for_data,
@@ -111,6 +112,8 @@ static NEW_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
111112
static DELETE_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
112113
pub(crate) static DND_ICON_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
113114
pub(crate) static MENU_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
115+
pub(crate) static MENU_AUTOSIZE_ID: Lazy<cosmic::widget::Id> =
116+
Lazy::new(|| cosmic::widget::Id::unique());
114117

115118
#[derive(Parser, Debug, Serialize, Deserialize, Clone)]
116119
#[command(author, version, about, long_about = None)]
@@ -889,26 +892,31 @@ impl cosmic::Application for CosmicAppLibrary {
889892
);
890893
}
891894

892-
return container(scrollable(Column::with_children(list_column)))
893-
.padding([8, 0])
894-
.class(theme::Container::Custom(Box::new(|theme| {
895-
container::Style {
896-
text_color: Some(theme.cosmic().on_bg_color().into()),
897-
background: Some(Color::from(theme.cosmic().background.base).into()),
898-
border: Border {
899-
color: theme.cosmic().bg_divider().into(),
900-
radius: theme.cosmic().corner_radii.radius_m.into(),
901-
width: 1.0,
902-
},
903-
shadow: Shadow::default(),
904-
icon_color: Some(theme.cosmic().on_bg_color().into()),
905-
}
906-
})))
907-
.width(Length::Shrink)
908-
.height(Length::Shrink)
909-
.align_x(Horizontal::Center)
910-
.align_y(Vertical::Top)
911-
.into();
895+
return autosize(
896+
container(scrollable(Column::with_children(list_column)))
897+
.padding([8, 0])
898+
.class(theme::Container::Custom(Box::new(|theme| {
899+
container::Style {
900+
text_color: Some(theme.cosmic().on_bg_color().into()),
901+
background: Some(Color::from(theme.cosmic().background.base).into()),
902+
border: Border {
903+
color: theme.cosmic().bg_divider().into(),
904+
radius: theme.cosmic().corner_radii.radius_m.into(),
905+
width: 1.0,
906+
},
907+
shadow: Shadow::default(),
908+
icon_color: Some(theme.cosmic().on_bg_color().into()),
909+
}
910+
})))
911+
.width(Length::Shrink)
912+
.height(Length::Shrink)
913+
.align_x(Horizontal::Center)
914+
.align_y(Vertical::Top),
915+
MENU_AUTOSIZE_ID.clone(),
916+
)
917+
.max_height(800.)
918+
.max_width(300.)
919+
.into();
912920
}
913921
if id == NEW_GROUP_WINDOW_ID.clone() {
914922
let Some(group_name) = self.new_group.as_ref() else {

0 commit comments

Comments
 (0)