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

Allow hiding top panel via blueprint #6409

Merged
merged 10 commits into from
May 27, 2024
2 changes: 1 addition & 1 deletion crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ impl App {

crate::ui::mobile_warning_ui(&self.re_ui, ui);

if app_blueprint.top_panel_state != PanelState::Hidden {
if app_blueprint.top_panel_state == PanelState::Expanded {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is to align with behavior in #6419

crate::ui::top_panel(
frame,
self,
Expand Down
22 changes: 20 additions & 2 deletions rerun_py/rerun_sdk/rerun/blueprint/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ def __init__(self, *, expanded: bool | None = None, state: PanelStateLike | None
state:
Whether the panel is expanded, collapsed, or hidden.

Collapsed and hidden both fully hide the top panel.

"""
super().__init__(blueprint_path="top_panel", expanded=expanded, state=state)

Expand All @@ -335,6 +337,8 @@ def __init__(self, *, expanded: bool | None = None, state: PanelStateLike | None
state:
Whether the panel is expanded, collapsed, or hidden.

Collapsed and hidden both fully hide the top panel.
jprochazk marked this conversation as resolved.
Show resolved Hide resolved

"""
super().__init__(blueprint_path="blueprint_panel", expanded=expanded, state=state)

Expand All @@ -353,6 +357,8 @@ def __init__(self, *, expanded: bool | None = None, state: PanelStateLike | None
state:
Whether the panel is expanded, collapsed, or hidden.

Collapsed and hidden both fully hide the top panel.
jprochazk marked this conversation as resolved.
Show resolved Hide resolved

"""
super().__init__(blueprint_path="selection_panel", expanded=expanded, state=state)

Expand All @@ -371,6 +377,9 @@ def __init__(self, *, expanded: bool | None = None, state: PanelStateLike | None
state:
Whether the panel is expanded, collapsed, or hidden.

Expanded fully shows the panel, collapsed shows a simplified panel,
hidden fully hides the panel.

"""
super().__init__(blueprint_path="time_panel", expanded=expanded, state=state)

Expand All @@ -383,7 +392,7 @@ def __init__(self, *, expanded: bool | None = None, state: PanelStateLike | None
helper classes.
"""

BlueprintPart = Union[ContainerLike, BlueprintPanel, SelectionPanel, TimePanel]
BlueprintPart = Union[ContainerLike, TopPanel, BlueprintPanel, SelectionPanel, TimePanel]
"""
The types that make up a blueprint.
"""
Expand Down Expand Up @@ -430,7 +439,9 @@ def __init__(
Defaults to `False` unless no Containers or SpaceViews are provided, in which case it defaults to `True`.
If you want to create a completely empty Blueprint, you must explicitly set this to `False`.
collapse_panels:
Whether to collapse the panels in the viewer. Defaults to `False`.
Whether to collapse panels in the viewer. Defaults to `False`.

This fully hides the blueprint/selection panels, and shows the simplified time panel.

"""
from .containers import Tabs
Expand All @@ -442,6 +453,10 @@ def __init__(
for part in parts:
if isinstance(part, (Container, SpaceView)):
contents.append(part)
elif isinstance(part, TopPanel):
if hasattr(self, "top_panel"):
raise ValueError("Only one top panel can be provided")
self.top_panel = part
elif isinstance(part, BlueprintPanel):
if hasattr(self, "blueprint_panel"):
raise ValueError("Only one blueprint panel can be provided")
Expand Down Expand Up @@ -492,6 +507,9 @@ def _log_to_stream(self, stream: RecordingStream) -> None:

stream.log("viewport", viewport_arch) # type: ignore[attr-defined]

if hasattr(self, "top_panel"):
self.top_panel._log_to_stream(stream)

if hasattr(self, "blueprint_panel"):
self.blueprint_panel._log_to_stream(stream)
elif self.collapse_panels:
Expand Down
Loading