-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic fallback for unrecognized Space View Class, start removing …
…old ViewCategory (#2357) … <!-- Open the PR up as a draft until you feel it is ready for a proper review. Do not make PR:s from your own `main` branch, as that makes it difficult for reviewers to add their own fixes. Add any improvements to the branch as new commits to make it easier for reviewers to follow the progress. All commits will be squashed to a single commit once the PR is merged into `main`. Make sure you mention any issues that this PR closes in the description, as well as any other related issues. To get an auto-generated PR description you can put "copilot:summary" or "copilot:walkthrough" anywhere. --> ### What Add fallback "unknown" Space View Class, remove usage of old `ViewCategory` for icons and class names. The later is what I started out with, but I noticed that handling of missing space view classes got both tedious and unwanted. Instead, now when encountering a unknown space view class we always log an error (log_once) and then return the Unknown space view class which allows us to show information about what happened. ![image](https://github.com/rerun-io/rerun/assets/1220815/07b6e941-6974-4e33-874b-06657195e2e0) A (still existing) drawback of the placeholder method is that we don't get distinct class references and can't show the original name in the help text or space view content. For the later there's two workarounds I could come up with * have a special space view state that contains the name * let names themselves have an implementation of DynSpaceViewClass both solutions are fairly hacky for such a small thing. In the future however, we could do a blueprint query with the space view id to fill out the text in the space view tile which would solve this problem a bit better (still somewhat confusing since the class itself will advertise a different name) ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) <!-- This line will get updated when the PR build summary job finishes. --> PR Build Summary: https://build.rerun.io/pr/2357 <!-- pr-link-docs:start --> Docs preview: https://rerun.io/preview/4970988/docs Examples preview: https://rerun.io/preview/4970988/examples <!-- pr-link-docs:end -->
- Loading branch information
Showing
13 changed files
with
133 additions
and
130 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
crates/re_viewer_context/src/space_view/space_view_class_placeholder.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use crate::{ScenePart, ScenePartCollection, SpaceViewClass, SpaceViewClassName}; | ||
|
||
/// A placeholder space view class that can be used when the actual class is not registered. | ||
#[derive(Default)] | ||
pub struct SpaceViewClassPlaceholder; | ||
|
||
impl SpaceViewClass for SpaceViewClassPlaceholder { | ||
type State = (); | ||
type Context = (); | ||
type SceneParts = (); | ||
type ScenePartData = (); | ||
|
||
fn name(&self) -> SpaceViewClassName { | ||
"Unknown Space View Class".into() | ||
} | ||
|
||
fn icon(&self) -> &'static re_ui::Icon { | ||
&re_ui::icons::SPACE_VIEW_UNKNOWN | ||
} | ||
|
||
fn help_text(&self, _re_ui: &re_ui::ReUi, _state: &()) -> egui::WidgetText { | ||
"The Space View Class was not recognized.\nThis happens if either the Blueprint specifies an invalid Space View Class or this version of the Viewer does not know about this type.".into() | ||
} | ||
|
||
fn selection_ui( | ||
&self, | ||
_ctx: &mut crate::ViewerContext<'_>, | ||
_ui: &mut egui::Ui, | ||
_state: &mut (), | ||
_space_origin: &re_log_types::EntityPath, | ||
_space_view_id: crate::SpaceViewId, | ||
) { | ||
} | ||
|
||
fn ui( | ||
&self, | ||
ctx: &mut crate::ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
state: &mut (), | ||
_scene: &mut crate::TypedScene<Self>, | ||
_space_origin: &re_log_types::EntityPath, | ||
_space_view_id: crate::SpaceViewId, | ||
) { | ||
ui.centered_and_justified(|ui| ui.label(self.help_text(ctx.re_ui, state))); | ||
} | ||
} | ||
|
||
impl ScenePartCollection<SpaceViewClassPlaceholder> for () { | ||
fn vec_mut(&mut self) -> Vec<&mut dyn ScenePart<SpaceViewClassPlaceholder>> { | ||
Vec::new() | ||
} | ||
|
||
fn as_any(&self) -> &dyn std::any::Any { | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.