diff --git a/crates/re_ui/data/icons/add_big.png b/crates/re_ui/data/icons/add_big.png deleted file mode 100644 index 9ce7ee42fb52..000000000000 Binary files a/crates/re_ui/data/icons/add_big.png and /dev/null differ diff --git a/crates/re_ui/src/icons.rs b/crates/re_ui/src/icons.rs index 1056c2ac7a6e..0a61be8ad3c6 100644 --- a/crates/re_ui/src/icons.rs +++ b/crates/re_ui/src/icons.rs @@ -58,7 +58,6 @@ pub const INVISIBLE: Icon = Icon::new("invisible", include_bytes!("../data/icons pub const ADD: Icon = Icon::new("add", include_bytes!("../data/icons/add.png")); -pub const ADD_BIG: Icon = Icon::new("add_big", include_bytes!("../data/icons/add_big.png")); pub const REMOVE: Icon = Icon::new("remove", include_bytes!("../data/icons/remove.png")); pub const RESET: Icon = Icon::new("reset", include_bytes!("../data/icons/reset.png")); diff --git a/crates/re_viewer/src/ui/add_space_view_or_container_modal.rs b/crates/re_viewer/src/ui/add_space_view_or_container_modal.rs index e36e265a50cb..5ff2ef2bb701 100644 --- a/crates/re_viewer/src/ui/add_space_view_or_container_modal.rs +++ b/crates/re_viewer/src/ui/add_space_view_or_container_modal.rs @@ -29,7 +29,7 @@ impl AddSpaceViewOrContainerModal { .min_width(500.0) .full_span_content(true) }, - |_, ui, _| modal_ui(ui, ctx, viewport, self.target_container), + |_, ui, keep_open| modal_ui(ui, ctx, viewport, self.target_container, keep_open), ); } } @@ -39,6 +39,7 @@ fn modal_ui( ctx: &ViewerContext<'_>, viewport: &Viewport<'_, '_>, target_container: Option, + keep_open: &mut bool, ) { let container_data = [ ( @@ -67,6 +68,7 @@ fn modal_ui( if row_ui(ui, icon_for_container_kind(&kind), title, subtitle).clicked() { viewport.blueprint.add_container(kind, target_container); viewport.blueprint.mark_user_interaction(ctx); + *keep_open = false; } } @@ -96,6 +98,7 @@ fn modal_ui( .blueprint .add_space_views(std::iter::once(space_view), ctx, target_container); viewport.blueprint.mark_user_interaction(ctx); + *keep_open = false; } } } @@ -110,9 +113,9 @@ fn modal_ui( /// ┌───────────────────────────────────────────────────┐──▲ /// │ │ │ row_space/2 /// │ ╔══════╦══════════════════════════════════╗────│──▼▲ -/// │ ║ ║ ┌───┐ ║ │ │ -/// │ ║ Icon ║ Title and Subtitles │ + │ ║ │ │ row_height -/// │ ║ ║ └───┘ ║ │ │ +/// │ ║ ║ ║ │ │ +/// │ ║ Icon ║ Title and Subtitles ║ │ │ row_height +/// │ ║ ║ ║ │ │ /// │ ╚══════╩══════════════════════════════════╝────│──▲▼ /// │ │ │ row_space/2 /// └───────────────────────────────────────────────────┘──▼ @@ -163,50 +166,35 @@ fn row_ui(ui: &mut egui::Ui, icon: &re_ui::Icon, title: &str, subtitle: &str) -> ui.add(egui::Label::new(subtitle).wrap(false)); }); - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let right_coord = ui.cursor().max.x; + let right_coord = ui.cursor().max.x; - // interact with the entire row - let interact_rect = egui::Rect::from_min_max( - top_left_corner, - egui::pos2(right_coord, top_left_corner.y + row_height + row_space), - ); + // interact with the entire row + let interact_rect = egui::Rect::from_min_max( + top_left_corner, + egui::pos2(right_coord, top_left_corner.y + row_height + row_space), + ); + + let response = + ui.interact(interact_rect, title.to_owned().into(), egui::Sense::click()); + + if response.hovered() { + let clip_rect = ui.clip_rect(); - let response = - ui.interact(interact_rect, title.to_owned().into(), egui::Sense::click()); - let tint = if response.hovered() { - ui.visuals().widgets.active.fg_stroke.color - } else { - ui.visuals().widgets.inactive.fg_stroke.color - }; - - ui.add( - re_ui::icons::ADD_BIG - .as_image() - .fit_to_exact_size(egui::vec2(24.0, 24.0)) - .tint(tint), + let bg_rect = interact_rect + .with_min_x(clip_rect.min.x) + .with_max_x(clip_rect.max.x); + + ui.painter().set( + background_frame, + egui::Shape::rect_filled( + bg_rect, + 0.0, + ui.visuals().widgets.hovered.weak_bg_fill, + ), ); + } - if response.hovered() { - let clip_rect = ui.clip_rect(); - - let bg_rect = interact_rect - .with_min_x(clip_rect.min.x) - .with_max_x(clip_rect.max.x); - - ui.painter().set( - background_frame, - egui::Shape::rect_filled( - bg_rect, - 0.0, - ui.visuals().widgets.hovered.weak_bg_fill, - ), - ); - } - - response - }) - .inner + response }) .inner;