Skip to content

Commit

Permalink
Switch to menu instead of modal for column visibility ui
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Sep 27, 2024
1 parent e625def commit b043d19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 39 deletions.
11 changes: 1 addition & 10 deletions crates/viewer/re_space_view_dataframe/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ struct DataframeSpaceViewState {

/// Schema for the current query, cached here for the column visibility UI.
schema: Option<Vec<ColumnDescriptor>>,

/// Modal dialog for column visibility.
column_visibility_modal: ModalHandler,
}

impl SpaceViewState for DataframeSpaceViewState {
Expand Down Expand Up @@ -125,13 +122,7 @@ mode sets the default time range to _everything_. You can override this in the s
// for the user to click the menu anyway.
return Ok(());
};
view_query.selection_panel_ui(
ctx,
ui,
space_view_id,
schema,
&mut state.column_visibility_modal,
)
view_query.selection_panel_ui(ctx, ui, space_view_id, schema)
}

fn extra_title_bar_ui(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use re_chunk_store::ColumnDescriptor;
use re_log_types::EntityPath;
use re_types::blueprint::archetypes;
use re_types_core::ComponentName;
use re_ui::modal::ModalHandler;
use re_viewer_context::{SpaceViewId, SpaceViewSystemExecutionError, ViewerContext};
use re_viewport_blueprint::ViewProperty;

Expand Down Expand Up @@ -44,7 +43,6 @@ impl QueryV2 {
ui: &mut egui::Ui,
space_view_id: SpaceViewId,
schema: &[ColumnDescriptor],
column_visibility_modal_handler: &mut ModalHandler,
) -> Result<(), SpaceViewSystemExecutionError> {
let timeline = self.timeline(ctx)?;

Expand All @@ -54,7 +52,7 @@ impl QueryV2 {
ui.separator();
self.filter_event_ui(ctx, ui, &timeline, space_view_id)?;
ui.separator();
self.column_visibility_ui(ctx, ui, &timeline, schema, column_visibility_modal_handler)?;
self.column_visibility_ui(ctx, ui, &timeline, schema)?;
ui.separator();
self.latest_at_ui(ctx, ui)?;

Expand Down
34 changes: 8 additions & 26 deletions crates/viewer/re_space_view_dataframe/src/view_query_v2/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use re_log_types::{
EntityPath, ResolvedTimeRange, TimeInt, TimeType, TimeZone, Timeline, TimelineName,
};
use re_types_core::{ComponentName, ComponentNameSet};
use re_ui::modal::{Modal, ModalHandler};
use re_ui::{list_item, UiExt};
use re_viewer_context::{SpaceViewId, SpaceViewSystemExecutionError, TimeDragValue, ViewerContext};

Expand Down Expand Up @@ -260,7 +259,6 @@ impl QueryV2 {
ui: &mut egui::Ui,
timeline: &Timeline,
schema: &[ColumnDescriptor],
column_visibility_modal_handler: &mut ModalHandler,
) -> Result<(), SpaceViewSystemExecutionError> {
// Gather our selected columns.
let selected_columns: HashSet<_> = self
Expand All @@ -270,23 +268,7 @@ impl QueryV2 {

let visible_count = selected_columns.len();
let hidden_count = schema.len() - visible_count;

ui.label("Columns:");

let visible_count_label = format!("{visible_count} visible, {hidden_count} hidden");
ui.list_item_flat_noninteractive(
list_item::LabelContent::new(&visible_count_label)
.always_show_buttons(true)
.with_buttons(|ui| {
let resp = ui.small_icon_button(&re_ui::icons::EDIT);

if resp.clicked() {
column_visibility_modal_handler.open();
}

resp
}),
);

let mut new_selected_columns = selected_columns.clone();

Expand All @@ -299,7 +281,7 @@ impl QueryV2 {
let mut all_enabled = hidden_count == 0;

if ui
.checkbox_indeterminate(&mut all_enabled, visible_count_label, indeterminate)
.checkbox_indeterminate(&mut all_enabled, &visible_count_label, indeterminate)
.changed()
{
if all_enabled {
Expand Down Expand Up @@ -413,15 +395,15 @@ impl QueryV2 {
}
};

column_visibility_modal_handler.ui(
ui.ctx(),
|| Modal::new("Column visibility"),
ui.list_item_flat_noninteractive(list_item::PropertyContent::new("Columns").value_fn(
|ui, _| {
egui::ScrollArea::vertical()
.auto_shrink([false, false])
.show(ui, modal_ui)
egui::menu::menu_button(ui, &visible_count_label, |ui| {
egui::ScrollArea::vertical()
.auto_shrink([false, false])
.show(ui, modal_ui)
});
},
);
));

// save changes of column visibility
if new_selected_columns != selected_columns {
Expand Down

0 comments on commit b043d19

Please sign in to comment.