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

ComponentFallbackProvider and greatly simplified edit_ui #6465

Merged
merged 24 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8d0e5fd
Replace `initial_override_value` with new `TypedComponentFallbackProv…
Wumpf May 27, 2024
b0e9846
iterate on fallback provider
Wumpf May 28, 2024
8133695
all visualizers have to implement `as_fallback_provider` conversion f…
Wumpf May 29, 2024
f6dd969
query context rename leftover
Wumpf May 29, 2024
2e51ad5
use new fallback provider with edit ui and introduce typed edit ui
Wumpf May 29, 2024
8c037ca
rename component_fallback module
Wumpf May 29, 2024
85b43d4
move QueryContext to query_context module, some doc improvements
Wumpf May 29, 2024
7578801
integrate base fallback into component fallback system
Wumpf May 30, 2024
1f82118
rename base fallback to placeholder, fill various documentation gaps
Wumpf May 30, 2024
c1bf0db
fixed / better error handling for edit_ui
Wumpf May 30, 2024
8f23d56
remove dead code flag from list_default_components
Wumpf May 30, 2024
f95a372
code cleanup, comment improvements
Wumpf May 30, 2024
7c79ecc
simplify component ui registry impl a bit
Wumpf May 30, 2024
463d654
rename initial_override_color to fallback_color
Wumpf May 30, 2024
380dcb3
lint fixes
Wumpf May 30, 2024
04e9a39
fix typo
Wumpf May 30, 2024
d705704
use `|` instead of union for concatting responses
Wumpf May 31, 2024
74a80f2
remove some no longer needed ui calls
Wumpf May 31, 2024
37976d7
copy text on click on error label
Wumpf May 31, 2024
8e56876
document MissingBaseFallback error
Wumpf May 31, 2024
611e822
fix confusing/wrong comment
Wumpf May 31, 2024
a3def7e
typo
Wumpf May 31, 2024
888d3bd
another response combine
Wumpf May 31, 2024
73836bc
use outer reponse with change mark from inner response
Wumpf May 31, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5223,6 +5223,7 @@ dependencies = [
"re_data_source",
"re_data_store",
"re_entity_db",
"re_error",
"re_log",
"re_log_types",
"re_query",
Expand Down
93 changes: 29 additions & 64 deletions crates/re_edit_ui/src/corner2d.rs
Original file line number Diff line number Diff line change
@@ -1,69 +1,34 @@
use re_data_store::LatestAtQuery;
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityDb};
use re_log_types::{EntityPath, Instance};
use re_types::blueprint::components::Corner2D;
use re_viewer_context::{UiLayout, ViewerContext};
use re_viewer_context::ViewerContext;

#[allow(clippy::too_many_arguments)]
pub fn edit_corner2d(
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_ui_layout: UiLayout,
query: &LatestAtQuery,
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &LatestAtComponentResults,
instance: &Instance,
) {
let corner = component
// TODO(#5607): what should happen if the promise is still pending?
.try_instance::<Corner2D>(db.resolver(), instance.get() as _)
.unwrap_or_else(|| default_corner2d(ctx, query, db, entity_path));
let mut edit_corner = corner;
use crate::response_utils::response_with_changes_of_inner;

egui::ComboBox::from_id_source("corner2d")
.selected_text(format!("{corner}"))
.show_ui(ui, |ui| {
ui.selectable_value(
&mut edit_corner,
egui_plot::Corner::LeftTop.into(),
format!("{}", Corner2D::from(egui_plot::Corner::LeftTop)),
);
ui.selectable_value(
&mut edit_corner,
egui_plot::Corner::RightTop.into(),
format!("{}", Corner2D::from(egui_plot::Corner::RightTop)),
);
ui.selectable_value(
&mut edit_corner,
egui_plot::Corner::LeftBottom.into(),
format!("{}", Corner2D::from(egui_plot::Corner::LeftBottom)),
);
ui.selectable_value(
&mut edit_corner,
egui_plot::Corner::RightBottom.into(),
format!("{}", Corner2D::from(egui_plot::Corner::RightBottom)),
);
});

if corner != edit_corner {
ctx.save_blueprint_component(override_path, &edit_corner);
}
}

#[inline]
pub fn default_corner2d(
pub fn edit_corner2d(
_ctx: &ViewerContext<'_>,
_query: &LatestAtQuery,
_db: &EntityDb,
_entity_path: &EntityPath,
) -> Corner2D {
// TODO(#4194): Want to distinguish the space view this happens in.
// TimeSeriesView: RightBottom
// BarChart: RightTop
// Need to make handling of editors a bit more powerful for this.
// Rough idea right now is to have "default providers" which can be either a View or a Visualizer.
// They then get queried with a ComponentName and return LatestAtComponentResults (or similar).
Corner2D::RightBottom
ui: &mut egui::Ui,
value: &mut Corner2D,
) -> egui::Response {
response_with_changes_of_inner(
egui::ComboBox::from_id_source("corner2d")
.selected_text(format!("{value}"))
.show_ui(ui, |ui| {
ui.selectable_value(
value,
egui_plot::Corner::LeftTop.into(),
format!("{}", Corner2D::from(egui_plot::Corner::LeftTop)),
) | ui.selectable_value(
value,
egui_plot::Corner::RightTop.into(),
format!("{}", Corner2D::from(egui_plot::Corner::RightTop)),
) | ui.selectable_value(
value,
egui_plot::Corner::LeftBottom.into(),
format!("{}", Corner2D::from(egui_plot::Corner::LeftBottom)),
) | ui.selectable_value(
value,
egui_plot::Corner::RightBottom.into(),
format!("{}", Corner2D::from(egui_plot::Corner::RightBottom)),
)
}),
)
}
Loading
Loading