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

Add help to several sections in the Selection Panel #6668

Merged
merged 3 commits into from
Jun 28, 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
10 changes: 9 additions & 1 deletion crates/re_selection_panel/src/defaults_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ pub fn view_components_defaults_section_ui(
add_button = add_button.enabled(false).disabled_hover_text(reason);
}

let markdown = "# Component defaults\n
This section lists default values for components in the scope of the present view. The visualizers \
corresponding to this view's entities use these defaults when no per-entity store value or \
override is specified.\n
Click on the `+` button to add a new default value.";

let body = |ui: &mut egui::Ui| {
active_default_ui(
ctx,
Expand All @@ -58,6 +64,7 @@ pub fn view_components_defaults_section_ui(
};
ui.section_collapsing_header("Component defaults")
.button(add_button)
.help_markdown(markdown)
.show(ui, body);
}

Expand Down Expand Up @@ -97,7 +104,8 @@ fn active_default_ui(
.get_by_identifier(*visualizer_identifier)
else {
re_log::warn!(
"Failed to resolve visualizer identifier {visualizer_identifier}, to a visualizer implementation"
"Failed to resolve visualizer identifier {visualizer_identifier}, to a \
visualizer implementation"
);
continue;
};
Expand Down
10 changes: 3 additions & 7 deletions crates/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ impl SelectionPanel {
view_id: &SpaceViewId,
view_states: &mut ViewStates,
) {
fn entity_path_filter_help_ui(ui: &mut egui::Ui) {
let markdown = r#"
let markdown = r#"
# Entity path query syntax

Entity path queries are described as a list of include/exclude rules that act on paths:
Expand Down Expand Up @@ -355,10 +354,7 @@ The last rule matching `/world/car/hood` is `- /world/car/**`, so it is excluded
The last rule matching `/world` is `- /world`, so it is excluded.
The last rule matching `/world/house` is `+ /world/**`, so it is included.
"#
.trim();

ui.markdown_ui(egui::Id::new("entity_path_filter_help_ui"), markdown);
}
.trim();

clone_space_view_button_ui(ctx, ui, blueprint, *view_id);

Expand All @@ -370,7 +366,7 @@ The last rule matching `/world/house` is `+ /world/**`, so it is included.
})
.hover_text("Modify the entity query using the editor"),
)
.help_ui(entity_path_filter_help_ui)
.help_markdown(markdown)
.show(ui, |ui| {
// TODO(#6075): Because `list_item_scope` changes it. Temporary until everything is `ListItem`.
ui.spacing_mut().item_spacing.y = ui.ctx().style().spacing.item_spacing.y;
Expand Down
32 changes: 12 additions & 20 deletions crates/re_selection_panel/src/visible_time_range_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ fn save_visible_time_ranges(
let time_range = match query_range {
QueryRange::TimeRange(time_range) => time_range,
QueryRange::LatestAt => {
re_log::error!("Latest-at queries can't be used as an override yet. They can only come from defaults.");
re_log::error!(
"Latest-at queries can't be used as an override yet. They can only \
come from defaults."
);
return;
}
};
Expand All @@ -173,10 +176,18 @@ fn query_range_ui(
let time_type = time_ctrl.timeline().typ();

let mut interacting_with_controls = false;
let markdown = "# Visible time range\n
This feature controls the time range used to display data in the space view.

Notes:
- The settings are inherited from the parent entity or enclosing space view if not overridden.
- Visible time range properties are stored on a per-timeline basis.
- The data current as of the time range starting time is included.";

let collapsing_response = ui
.section_collapsing_header("Visible time range")
.default_open(false)
.help_markdown(markdown)
.show(ui, |ui| {
ui.horizontal(|ui| {
ui.re_radio_value(has_individual_time_range, false, "Default")
Expand Down Expand Up @@ -264,25 +275,6 @@ fn query_range_ui(
}
}
}

let markdown = format!("# Visible time range\n
This feature controls the time range used to display data in the space view.

The settings are inherited from the parent entity or enclosing space view if not overridden.

Visible time range properties are stored separately for each _type_ of timelines. They may differ depending on \
whether the current timeline is temporal or a sequence. The current settings apply to all _{}_ timelines.

Notes that the data current as of the time range starting time is included.",
match time_type {
TimeType::Time => "temporal",
TimeType::Sequence => "sequence",
}
);

collapsing_response.header_response.on_hover_ui(|ui| {
ui.markdown_ui(egui::Id::new(markdown.as_str()), &markdown);
});
}

fn time_range_editor(
Expand Down
19 changes: 19 additions & 0 deletions crates/re_selection_panel/src/visualizer_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,27 @@ pub fn visualizer_ui(
.hover_text("Add additional visualizers")
.disabled_hover_text("No additional visualizers available");

let markdown = "# Visualizers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, love it! we can re-use some of this on the doc page we still haven't written on this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, these tooltip will very much benefit from links to the docs, when those exists.


This section lists the active visualizers for the selected entity. Visualizers use an entity's \
components to display it in the current view.

Each visualizer lists the components it uses and their values. The component values may come from \
a variety of sources and can be overridden in place.

The final component value is determined using the following priority order:
- **Override**: A value set from the UI and/or the blueprint. It has the highest precedence and is \
always used if set.
- **Store**: If any, the value logged to the data store for this entity, e.g. via the SDK's `log` \
function.
- **Default**: If set, the default value for this component in the current view, which can be set \
in the blueprint or in the UI by selecting the view.
- **Fallback**: A context-sensitive value that is used if no other value is available. It is \
specific to the visualizer and the current view type.";

ui.section_collapsing_header("Visualizers")
.button(button)
.help_markdown(markdown)
.show(ui, |ui| {
visualizer_ui_impl(ctx, ui, &data_result, &active_visualizers);
});
Expand Down
11 changes: 11 additions & 0 deletions crates/re_ui/src/section_collapsing_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ impl<'a> SectionCollapsingHeader<'a> {
self
}

/// Set the help markdown tooltip to be shown in the header.
//TODO(#6191): the help button should be just another `impl ItemButton`.
#[inline]
pub fn help_markdown(mut self, help: &'a str) -> Self {
self.help = Some(Box::new(move |ui| {
ui.markdown_ui(egui::Id::new(help), help);
}));
self
}

/// Set the help UI closure to be shown in the header.
//TODO(#6191): the help button should be just another `impl ItemButton`.
#[inline]
pub fn help_ui(mut self, help: impl FnOnce(&mut egui::Ui) + 'a) -> Self {
self.help = Some(Box::new(help));
Expand Down
Loading