Skip to content

Commit a9d0b3d

Browse files
committed
refactor: set limits when determining size of dnd icon
1 parent bea3f51 commit a9d0b3d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sctk/src/application.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -694,20 +694,22 @@ where
694694
(id, e)
695695
}
696696
};
697+
698+
let parent_size = states
699+
.get(&origin_id)
700+
.map(|s| s.logical_size())
701+
.unwrap_or_else(|| Size::new(1024.0, 1024.0));
702+
697703
let node =
698-
Widget::layout(e.as_widget(), &renderer, &Limits::NONE);
704+
Widget::layout(e.as_widget(), &renderer, &Limits::NONE.min_width(1).min_height(1).max_width(parent_size.width as u32).max_height(parent_size.height as u32));
699705
let bounds = node.bounds();
700706
let w = bounds.width.ceil() as u32;
701707
let h = bounds.height.ceil() as u32;
702708
if w == 0 || h == 0 {
703709
error!("Dnd surface has zero size, ignoring");
704710
continue;
705711
}
706-
let parent_size = states
707-
.get(&origin_id)
708-
.map(|s| s.logical_size())
709-
.unwrap_or_else(|| Size::new(1024.0, 1024.0));
710-
if w > parent_size.width as u32 || h > parent_size.height as u32
712+
if w > parent_size.width as u32 || h > parent_size.height as u32
711713
{
712714
error!("Dnd surface is too large, ignoring");
713715
continue;

0 commit comments

Comments
 (0)