Skip to content

Commit

Permalink
refactor: set limits when determining size of dnd icon
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Apr 18, 2023
1 parent bea3f51 commit a9d0b3d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sctk/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,20 +694,22 @@ where
(id, e)
}
};

let parent_size = states
.get(&origin_id)
.map(|s| s.logical_size())
.unwrap_or_else(|| Size::new(1024.0, 1024.0));

let node =
Widget::layout(e.as_widget(), &renderer, &Limits::NONE);
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));
let bounds = node.bounds();
let w = bounds.width.ceil() as u32;
let h = bounds.height.ceil() as u32;
if w == 0 || h == 0 {
error!("Dnd surface has zero size, ignoring");
continue;
}
let parent_size = states
.get(&origin_id)
.map(|s| s.logical_size())
.unwrap_or_else(|| Size::new(1024.0, 1024.0));
if w > parent_size.width as u32 || h > parent_size.height as u32
if w > parent_size.width as u32 || h > parent_size.height as u32
{
error!("Dnd surface is too large, ignoring");
continue;
Expand Down

0 comments on commit a9d0b3d

Please sign in to comment.