Skip to content

Commit 3dd148d

Browse files
committed
fix: icon on a raised layer
1 parent 2068668 commit 3dd148d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/widgets/application.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ where
220220
cursor_position: mouse::Cursor,
221221
viewport: &Rectangle,
222222
) {
223+
use cosmic::iced_core::Renderer;
223224
self.content.as_widget().draw(
224225
&tree.children[0],
225226
renderer,
@@ -230,16 +231,23 @@ where
230231
viewport,
231232
);
232233

233-
if let Some(icon) = self.source_icon.as_ref() {
234-
icon.as_widget().draw(
235-
&tree.children[1],
236-
renderer,
237-
theme,
238-
renderer_style,
239-
layout.children().nth(1).unwrap(),
240-
cursor_position,
241-
viewport,
242-
);
234+
if let Some((icon, (l, bounds))) = self.source_icon.as_ref().zip(
235+
layout
236+
.children()
237+
.nth(1)
238+
.and_then(|l| viewport.intersection(&l.bounds()).map(|b| (l, b))),
239+
) {
240+
renderer.with_layer(bounds, |renderer| {
241+
icon.as_widget().draw(
242+
&tree.children[1],
243+
renderer,
244+
theme,
245+
renderer_style,
246+
l,
247+
cursor_position,
248+
viewport,
249+
)
250+
});
243251
}
244252
}
245253

0 commit comments

Comments
 (0)