diff --git a/emigui/README.md b/emigui/README.md index b31025b3..29d5d96b 100644 --- a/emigui/README.md +++ b/emigui/README.md @@ -78,8 +78,9 @@ Add extremely quick animations for some things, maybe 2-3 frames. For instance: ### Input * [x] Distinguish between clicks and drags -* [ ] Double-click +* [x] Double-click * [x] Text +* [ ] Support all mouse buttons ### Debugability / Inspection * [x] Widget debug rectangles diff --git a/emigui/src/containers.rs b/emigui/src/containers.rs index cd9c5fab..364856dc 100644 --- a/emigui/src/containers.rs +++ b/emigui/src/containers.rs @@ -11,13 +11,3 @@ pub use { area::Area, collapsing_header::CollapsingHeader, frame::Frame, popup::*, resize::Resize, scroll_area::ScrollArea, window::Window, }; - -// TODO -// pub trait Container { -// fn show(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui)); -// } - -// pub trait Container { -// fn begin(&mut self, parent: &mut Ui) -> Ui; -// fn end(self, parent: &mut Ui, content: Ui); -// } diff --git a/emigui/src/containers/resize.rs b/emigui/src/containers/resize.rs index 835b5c48..9ee6cd75 100644 --- a/emigui/src/containers/resize.rs +++ b/emigui/src/containers/resize.rs @@ -335,7 +335,7 @@ fn paint_resize_corner(ui: &mut Ui, interact: &InteractInfo) { let color = ui.style().interact(interact).stroke_color; let width = ui.style().interact(interact).stroke_width; - let corner = interact.rect.right_bottom().round(); // TODO: round to pixels + let corner = ui.round_pos_to_pixels(interact.rect.right_bottom()); let mut w = 2.0; while w < 12.0 { diff --git a/emigui/src/containers/window.rs b/emigui/src/containers/window.rs index e9764f4a..20f63d24 100644 --- a/emigui/src/containers/window.rs +++ b/emigui/src/containers/window.rs @@ -204,19 +204,6 @@ impl<'open> Window<'open> { let outer_rect = frame.end(&mut area.content_ui); // END FRAME -------------------------------- - title_bar.ui( - &mut area.content_ui, - outer_rect, - content_rect, - open, - &mut collapsing, - ); - - area.content_ui - .memory() - .collapsing_headers - .insert(collapsing_id, collapsing); - let interaction = if possible.movable || possible.resizable { interact( ctx, @@ -230,6 +217,20 @@ impl<'open> Window<'open> { } else { None }; + let hover_interaction = resize_hover(ctx, possible, area_layer, outer_rect); + + title_bar.ui( + &mut area.content_ui, + outer_rect, + content_rect, + open, + &mut collapsing, + ); + + area.content_ui + .memory() + .collapsing_headers + .insert(collapsing_id, collapsing); if let Some(interaction) = interaction { paint_frame_interaction( @@ -239,8 +240,7 @@ impl<'open> Window<'open> { ctx.style().interact.active, ); } else { - if let Some(hover_interaction) = resize_hover(ctx, possible, area_layer, outer_rect) - { + if let Some(hover_interaction) = hover_interaction { paint_frame_interaction( &mut area.content_ui, outer_rect, @@ -290,6 +290,10 @@ impl WindowInteraction { pub fn is_resize(&self) -> bool { self.left || self.right || self.top || self.bottom } + + pub fn is_pure_move(&self) -> bool { + !self.is_resize() + } } fn interact( diff --git a/emigui/src/memory.rs b/emigui/src/memory.rs index c403bf22..4872a22b 100644 --- a/emigui/src/memory.rs +++ b/emigui/src/memory.rs @@ -86,7 +86,7 @@ impl Memory { let window_interaction = self.window_interaction.take(); if let Some(window_interaction) = window_interaction { - if !window_interaction.is_resize() { + if window_interaction.is_pure_move() { // Throw windows because it is fun: let area_layer = window_interaction.area_layer; let area_state = self.areas.get(area_layer.id).clone(); diff --git a/emigui/src/paint/command.rs b/emigui/src/paint/command.rs index ae6a2af4..8dc3bfa4 100644 --- a/emigui/src/paint/command.rs +++ b/emigui/src/paint/command.rs @@ -50,7 +50,6 @@ impl PaintCmd { } } -// TODO: rename LineStyle #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct LineStyle { pub width: f32, diff --git a/emigui/src/ui.rs b/emigui/src/ui.rs index ded79ecb..b16a2b63 100644 --- a/emigui/src/ui.rs +++ b/emigui/src/ui.rs @@ -434,7 +434,6 @@ impl Ui { self.debug_text_at(self.cursor, text); } - // TODO: AsRef pub fn debug_text_at(&self, pos: Pos2, text: impl Into) { self.ctx.debug_text(pos, text); } @@ -565,7 +564,7 @@ impl Ui { // draw a grey line on the left to mark the indented section let line_start = child_rect.min - indent * 0.5; - let line_start = line_start.round(); // TODO: round to pixel instead + let line_start = self.round_pos_to_pixels(line_start); let line_end = pos2(line_start.x, line_start.y + size.y - 2.0); self.add_paint_cmd(PaintCmd::line_segment( [line_start, line_end],