Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the "+" icon from the "Add SV/Container" modal and close on click #4927

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed crates/re_ui/data/icons/add_big.png
Binary file not shown.
1 change: 0 additions & 1 deletion crates/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
76 changes: 32 additions & 44 deletions crates/re_viewer/src/ui/add_space_view_or_container_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
}
Expand All @@ -39,6 +39,7 @@ fn modal_ui(
ctx: &ViewerContext<'_>,
viewport: &Viewport<'_, '_>,
target_container: Option<ContainerId>,
keep_open: &mut bool,
) {
let container_data = [
(
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}
}
Expand All @@ -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
/// └───────────────────────────────────────────────────┘──▼
Expand Down Expand Up @@ -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;

Expand Down
Loading