diff --git a/emigui/src/containers/floating.rs b/emigui/src/containers/floating.rs index c47323f0..f6599184 100644 --- a/emigui/src/containers/floating.rs +++ b/emigui/src/containers/floating.rs @@ -107,6 +107,11 @@ impl Floating { state.pos = state.pos.round(); + // ctx.debug_rect( + // Rect::from_min_size(state.pos, state.size), + // &format!("Floating size: {:?}", state.size), + // ); + if move_interact.active || mouse_pressed_on_floating(ctx, id) { ctx.memory().move_floating_to_top(id); } diff --git a/emigui/src/containers/frame.rs b/emigui/src/containers/frame.rs index e4353f7b..417e8128 100644 --- a/emigui/src/containers/frame.rs +++ b/emigui/src/containers/frame.rs @@ -35,7 +35,7 @@ impl Frame { }, ); - region.expand_to_include_child(child_region.rect().expand2(margin)); + region.expand_to_include_child(child_region.child_bounds().expand2(margin)); // TODO: move up cursor? } } diff --git a/emigui/src/context.rs b/emigui/src/context.rs index b3f23894..5991ae0f 100644 --- a/emigui/src/context.rs +++ b/emigui/src/context.rs @@ -289,6 +289,22 @@ impl Context { ); } + pub fn debug_rect(&self, rect: Rect, text: &str) { + let layer = Layer::Debug; + self.add_paint_cmd( + layer, + PaintCmd::Rect { + corner_radius: 0.0, + fill_color: None, + outline: Some(Outline::new(1.0, color::RED)), + rect, + }, + ); + let align = (Align::Min, Align::Min); + let text_style = TextStyle::Monospace; + self.floating_text(layer, rect.min, text, text_style, align, Some(color::RED)); + } + /// Show some text anywhere on screen. /// To center the text at the given position, use `align: (Center, Center)`. pub fn floating_text(