Skip to content

Commit fc33ded

Browse files
committed
fix: autosize wrapper for group add/delete
1 parent cf10d16 commit fc33ded

File tree

1 file changed

+45
-49
lines changed

1 file changed

+45
-49
lines changed

src/app.rs

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ static SYSTEM: Lazy<String> = Lazy::new(|| fl!("system"));
109109

110110
pub(crate) static WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
111111
static NEW_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
112+
static NEW_GROUP_AUTOSIZE_ID: Lazy<cosmic::widget::Id> = Lazy::new(|| cosmic::widget::Id::unique());
112113
static DELETE_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
113-
pub(crate) static DND_ICON_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
114+
static DELETE_GROUP_AUTOSIZE_ID: Lazy<cosmic::widget::Id> =
115+
Lazy::new(|| cosmic::widget::Id::unique());
114116
pub(crate) static MENU_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
115117
pub(crate) static MENU_AUTOSIZE_ID: Lazy<cosmic::widget::Id> =
116118
Lazy::new(|| cosmic::widget::Id::unique());
@@ -789,18 +791,6 @@ impl cosmic::Application for CosmicAppLibrary {
789791
..
790792
} = theme::active().cosmic().spacing;
791793

792-
if id == DND_ICON_ID.clone() {
793-
let Some(icon_source) = self
794-
.dnd_icon
795-
.and_then(|i| self.entry_path_input.get(i).map(|e| &e.icon))
796-
else {
797-
return container(horizontal_space())
798-
.width(Length::Fixed(1.0))
799-
.height(Length::Fixed(1.0))
800-
.into();
801-
};
802-
return icon_source.as_cosmic_icon().size(32).into();
803-
}
804794
if id == MENU_ID.clone() {
805795
let Some((menu, i)) = self
806796
.menu
@@ -965,24 +955,27 @@ impl cosmic::Application for CosmicAppLibrary {
965955
]
966956
.align_x(Alignment::Center)
967957
.spacing(space_s);
968-
return container(dialog)
969-
.class(theme::Container::Custom(Box::new(|theme| {
970-
container::Style {
971-
text_color: Some(theme.cosmic().on_bg_color().into()),
972-
icon_color: Some(theme.cosmic().on_bg_color().into()),
973-
background: Some(Color::from(theme.cosmic().background.base).into()),
974-
border: Border {
975-
color: theme.cosmic().bg_divider().into(),
976-
radius: theme.cosmic().corner_radii.radius_m.into(),
977-
width: 1.0,
978-
},
979-
shadow: Shadow::default(),
980-
}
981-
})))
982-
.width(Length::Shrink)
983-
.height(Length::Shrink)
984-
.padding(space_s)
985-
.into();
958+
return autosize(
959+
container(dialog)
960+
.class(theme::Container::Custom(Box::new(|theme| {
961+
container::Style {
962+
text_color: Some(theme.cosmic().on_bg_color().into()),
963+
icon_color: Some(theme.cosmic().on_bg_color().into()),
964+
background: Some(Color::from(theme.cosmic().background.base).into()),
965+
border: Border {
966+
color: theme.cosmic().bg_divider().into(),
967+
radius: theme.cosmic().corner_radii.radius_m.into(),
968+
width: 1.0,
969+
},
970+
shadow: Shadow::default(),
971+
}
972+
})))
973+
.width(Length::Shrink)
974+
.height(Length::Shrink)
975+
.padding(space_s),
976+
NEW_GROUP_AUTOSIZE_ID.clone(),
977+
)
978+
.into();
986979
}
987980
if id == DELETE_GROUP_WINDOW_ID.clone() {
988981
let dialog = column![
@@ -1029,24 +1022,27 @@ impl cosmic::Application for CosmicAppLibrary {
10291022
]
10301023
.align_x(Alignment::Center)
10311024
.spacing(space_l);
1032-
return container(dialog)
1033-
.class(theme::Container::Custom(Box::new(|theme| {
1034-
container::Style {
1035-
text_color: Some(theme.cosmic().on_bg_color().into()),
1036-
icon_color: Some(theme.cosmic().on_bg_color().into()),
1037-
background: Some(Color::from(theme.cosmic().background.base).into()),
1038-
border: Border {
1039-
color: theme.cosmic().bg_divider().into(),
1040-
radius: theme.cosmic().corner_radii.radius_m.into(),
1041-
width: 1.0,
1042-
},
1043-
shadow: Shadow::default(),
1044-
}
1045-
})))
1046-
.width(Length::Shrink)
1047-
.height(Length::Shrink)
1048-
.padding(space_m)
1049-
.into();
1025+
return autosize(
1026+
container(dialog)
1027+
.class(theme::Container::Custom(Box::new(|theme| {
1028+
container::Style {
1029+
text_color: Some(theme.cosmic().on_bg_color().into()),
1030+
icon_color: Some(theme.cosmic().on_bg_color().into()),
1031+
background: Some(Color::from(theme.cosmic().background.base).into()),
1032+
border: Border {
1033+
color: theme.cosmic().bg_divider().into(),
1034+
radius: theme.cosmic().corner_radii.radius_m.into(),
1035+
width: 1.0,
1036+
},
1037+
shadow: Shadow::default(),
1038+
}
1039+
})))
1040+
.width(Length::Shrink)
1041+
.height(Length::Shrink)
1042+
.padding(space_m),
1043+
DELETE_GROUP_AUTOSIZE_ID.clone(),
1044+
)
1045+
.into();
10501046
}
10511047

10521048
let cur_group = self.config.groups()[self.cur_group];

0 commit comments

Comments
 (0)