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

Click space view title to select it #1032

Merged
merged 3 commits into from
Feb 1, 2023
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ epaint = { git = "https://github.com/emilk/egui", rev = "f222ee044edf8beebfaf5dd
# epaint = { path = "../../egui/crates/epaint" }

# Forks of 3rd party egui crates, tracking latest egui/master:
egui_dock = { git = "https://github.com/rerun-io/egui_dock", rev = "69f52c752695165243d8900b8e11a84df812d67f" } # https://github.com/Adanos020/egui_dock/pull/93
egui_dock = { git = "https://github.com/rerun-io/egui_dock", rev = "bc7c2e3d3bd0261ddf3030ffbc85233a83d02e1e" } # https://github.com/Adanos020/egui_dock/pull/93
egui-notify = { git = "https://github.com/rerun-io/egui-notify", rev = "a158c2b81ca69ac78e3c61a705f478e8af76fd7d" } # https://github.com/ItsEthra/egui-notify/pull/10
# egui_dock = { path = "../../forks/egui_dock" }
# egui-notify = { path = "../../forks/egui-notify" }
Expand Down
7 changes: 1 addition & 6 deletions crates/re_viewer/src/ui/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ impl Blueprint {
egui::CentralPanel::default()
.frame(viewport_frame)
.show_inside(ui, |ui| {
self.viewport.viewport_ui(
ui,
ctx,
&spaces_info,
&mut self.selection_panel_expanded,
);
self.viewport.viewport_ui(ui, ctx, &spaces_info);
});
}

Expand Down
56 changes: 18 additions & 38 deletions crates/re_viewer/src/ui/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ impl Viewport {
ui: &mut egui::Ui,
ctx: &mut ViewerContext<'_>,
spaces_info: &SpaceInfoCollection,
selection_panel_expanded: &mut bool,
) {
if let Some(window) = &mut self.space_view_entity_window {
if let Some(space_view) = self.space_views.get_mut(&window.space_view_id) {
Expand Down Expand Up @@ -476,15 +475,7 @@ impl Viewport {

for (space_view_id, tab_bar_rect) in tab_bars {
// rect/viewport can be invalid for the first frame
space_view_options_ui(
ctx,
ui,
self,
tab_bar_rect,
selection_panel_expanded,
space_view_id,
num_space_views,
);
space_view_options_ui(ctx, ui, self, tab_bar_rect, space_view_id, num_space_views);
}
}
}
Expand Down Expand Up @@ -800,7 +791,23 @@ impl<'a, 'b> egui_dock::TabViewer for TabViewer<'a, 'b> {
.space_views
.get_mut(tab)
.expect("Should have been populated beforehand");
space_view.display_text()

let mut text = space_view.display_text();

if self.ctx.selection().contains(&Selection::SpaceView(*tab)) {
// Show that it is selected:
let egui_ctx = &self.ctx.re_ui.egui_ctx;
let selection_bg_color = egui_ctx.style().visuals.selection.bg_fill;
text = text.background_color(selection_bg_color);
}

text
}

fn on_tab_button(&mut self, tab: &mut Self::Tab, response: &egui::Response) {
if response.clicked() {
self.ctx.set_single_selection(Selection::SpaceView(*tab));
}
}
}

Expand All @@ -817,37 +824,12 @@ fn help_text_ui(ui: &mut egui::Ui, space_view: &SpaceView) {
}
}

fn space_view_options_link(
ctx: &mut ViewerContext<'_>,
selection_panel_expanded: &mut bool,
space_view_id: SpaceViewId,
ui: &mut egui::Ui,
text: &str,
) {
let selection = Selection::SpaceView(space_view_id);
let is_selected = ctx.selection().contains(&selection) && *selection_panel_expanded;
if ui
.selectable_label(is_selected, text)
.on_hover_text("Space View options")
.clicked()
{
if is_selected {
ctx.selection_state_mut().clear_current();
*selection_panel_expanded = false;
} else {
ctx.set_single_selection(selection);
*selection_panel_expanded = true;
}
}
}

/// Shown in the right of the tab panel
fn space_view_options_ui(
ctx: &mut ViewerContext<'_>,
ui: &mut egui::Ui,
viewport: &mut Viewport,
tab_bar_rect: egui::Rect,
selection_panel_expanded: &mut bool,
space_view_id: SpaceViewId,
num_space_views: usize,
) {
Expand All @@ -859,8 +841,6 @@ fn space_view_options_ui(

ui.add_space(4.0);

space_view_options_link(ctx, selection_panel_expanded, space_view.id, ui, "⛭");

if viewport.maximized == Some(space_view_id) {
// Show minimize-button:
if ctx
Expand Down