Skip to content

Commit

Permalink
Change remove icon, switch to table, and re-order columns
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Jan 26, 2024
1 parent cd2598d commit 37223e7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 63 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

9 changes: 3 additions & 6 deletions crates/re_data_ui/src/editors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ fn edit_text_ui(
let current_text = current_text.to_string();
let mut edit_text = current_text.clone();

// TODO(jleibs): Clip text false isn't exactly what we want. Need
// to figure out how to size this properly to fit the space appropriately.
egui::TextEdit::singleline(&mut edit_text)
.clip_text(false)
.show(ui);
egui::TextEdit::singleline(&mut edit_text).show(ui);

if edit_text != current_text {
let new_text = Text::from(edit_text);
Expand Down Expand Up @@ -123,6 +119,7 @@ fn edit_scatter_ui(
egui::ComboBox::from_id_source("scatter")
.selected_text(scattered_text)
.show_ui(ui, |ui| {
ui.style_mut().wrap = Some(false);
ui.selectable_value(&mut edit_scatter, false, "Line");
ui.selectable_value(&mut edit_scatter, true, "Scattered");
});
Expand Down Expand Up @@ -168,7 +165,7 @@ fn edit_radius_ui(

ui.add(
egui::DragValue::new(&mut edit_radius)
.clamp_range(0.0..=5.0)
.clamp_range(0.0..=f64::INFINITY)
.speed(speed),
);

Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ eframe = { workspace = true, default-features = false, features = [
"puffin",
"wgpu",
] }
egui_extras.workspace = true
egui_plot.workspace = true
egui-wgpu.workspace = true
egui.workspace = true
Expand Down
141 changes: 84 additions & 57 deletions crates/re_viewer/src/ui/override_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,66 +60,93 @@ pub fn override_ui(
return;
};

egui::Grid::new("overrides").num_columns(3).show(ui, |ui| {
for (component_name, (store_kind, entity_path)) in overrides
.component_overrides
.iter()
.sorted_by_key(|(c, _)| *c)
{
if !is_component_visible_in_ui(component_name) {
continue;
}
let components: Vec<_> = overrides
.component_overrides
.into_iter()
.sorted_by_key(|(c, _)| *c)
.filter(|(c, _)| is_component_visible_in_ui(c))
.collect();

temporary_style_ui_for_component(ui, component_name, |ui| {
item_ui::component_path_button(
ctx,
ui,
&ComponentPath::new(entity_path.clone(), *component_name),
);
});
egui_extras::TableBuilder::new(ui)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.auto_shrink([false, false])
.column(egui_extras::Column::auto())
.column(egui_extras::Column::auto())
.column(egui_extras::Column::remainder())
.body(|mut body| {
re_ui::ReUi::setup_table_body(&mut body);
let row_height = re_ui::ReUi::table_line_height();
body.rows(row_height, components.len(), |mut row| {
if let Some((component_name, (store_kind, entity_path))) =
components.get(row.index())
{
// Remove button
row.col(|ui| {
if ctx
.re_ui
.small_icon_button(ui, &re_ui::icons::CLOSE)
.clicked()
{
// Note: need to use the blueprint store since the data might
// not exist in the recording store.
ctx.save_empty_blueprint_component_name(
ctx.store_context.blueprint.store(),
&overrides.override_path,
*component_name,
);
}
});
// Component label
row.col(|ui| {
temporary_style_ui_for_component(ui, component_name, |ui| {
item_ui::component_path_button(
ctx,
ui,
&ComponentPath::new(entity_path.clone(), *component_name),
);
});
});
// Editor last to take up remainder of space
row.col(|ui| {
let component_data = match store_kind {
StoreKind::Blueprint => {
let store = ctx.store_context.blueprint.store();
let query = ctx.blueprint_query;
get_component_with_instances(
store,
query,
entity_path,
*component_name,
)
}
StoreKind::Recording => get_component_with_instances(
store,
&query,
entity_path,
*component_name,
),
};

let component_data = match store_kind {
StoreKind::Blueprint => {
let store = ctx.store_context.blueprint.store();
let query = ctx.blueprint_query;
get_component_with_instances(store, query, entity_path, *component_name)
}
StoreKind::Recording => {
get_component_with_instances(store, &query, entity_path, *component_name)
if let Some((_, _, component_data)) = component_data {
ctx.component_ui_registry.edit(
ctx,
ui,
UiVerbosity::Small,
&query,
store,
entity_path,
&overrides.override_path,
&component_data,
instance_key,
);
} else {
// TODO(jleibs): This shouldn't happen. Warn instead?
ui.weak("(empty)");
}
});
}
};

if let Some((_, _, component_data)) = component_data {
ctx.component_ui_registry.edit(
ctx,
ui,
UiVerbosity::Small,
&query,
store,
entity_path,
&overrides.override_path,
&component_data,
instance_key,
);
} else {
// TODO(jleibs): This shouldn't happen. Warn instead?
ui.weak("(empty)");
}

if ui.button("❎").clicked() {
// Note: need to use the blueprint store since the data might
// not exist in the recording store.
ctx.save_empty_blueprint_component_name(
ctx.store_context.blueprint.store(),
&overrides.override_path,
*component_name,
);
}

ui.end_row();
}
Some(())
});
});
});
}

pub fn add_new_override(
Expand Down

0 comments on commit 37223e7

Please sign in to comment.