-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out Container and SpaceView specialization from api.py
- Loading branch information
Showing
6 changed files
with
158 additions
and
150 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from .api import Container, SpaceView | ||
from .components import ColumnShareArrayLike, RowShareArrayLike | ||
from .components.container_kind import ContainerKind | ||
|
||
|
||
class Horizontal(Container): | ||
"""A horizontal container.""" | ||
|
||
def __init__(self, *contents: Container | SpaceView, column_shares: Optional[ColumnShareArrayLike] = None): | ||
""" | ||
Construct a new horizontal container. | ||
Parameters | ||
---------- | ||
*contents: | ||
All positional arguments are the contents of the container, which may be either other containers or space views. | ||
column_shares | ||
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each | ||
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`. | ||
""" | ||
super().__init__(*contents, kind=ContainerKind.Horizontal, column_shares=column_shares) | ||
|
||
|
||
class Vertical(Container): | ||
"""A vertical container.""" | ||
|
||
def __init__(self, *contents: Container | SpaceView, row_shares: Optional[RowShareArrayLike] = None): | ||
""" | ||
Construct a new vertical container. | ||
Parameters | ||
---------- | ||
*contents: | ||
All positional arguments are the contents of the container, which may be either other containers or space views. | ||
row_shares | ||
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each | ||
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`. | ||
""" | ||
super().__init__(*contents, kind=ContainerKind.Vertical, row_shares=row_shares) | ||
|
||
|
||
class Grid(Container): | ||
"""A grid container.""" | ||
|
||
def __init__( | ||
self, | ||
*contents: Container | SpaceView, | ||
column_shares: Optional[ColumnShareArrayLike] = None, | ||
row_shares: Optional[RowShareArrayLike] = None, | ||
grid_columns: Optional[int] = None, | ||
): | ||
""" | ||
Construct a new grid container. | ||
Parameters | ||
---------- | ||
*contents: | ||
All positional arguments are the contents of the container, which may be either other containers or space views. | ||
column_shares | ||
The layout shares of the columns in the container. The share is used to determine what fraction of the total width each | ||
column should take up. The column with index `i` will take up the fraction `shares[i] / total_shares`. | ||
row_shares | ||
The layout shares of the rows in the container. The share is used to determine what fraction of the total height each | ||
row should take up. The ros with index `i` will take up the fraction `shares[i] / total_shares`. | ||
grid_columns | ||
The number of columns in the grid. | ||
""" | ||
super().__init__( | ||
*contents, | ||
kind=ContainerKind.Grid, | ||
column_shares=column_shares, | ||
row_shares=row_shares, | ||
grid_columns=grid_columns, | ||
) | ||
|
||
|
||
class Tabs(Container): | ||
"""A tab container.""" | ||
|
||
def __init__(self, *contents: Container | SpaceView): | ||
""" | ||
Construct a new tab container. | ||
Parameters | ||
---------- | ||
*contents: | ||
All positional arguments are the contents of the container, which may be either other containers or space views. | ||
""" | ||
super().__init__(*contents, kind=ContainerKind.Tabs) |
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,54 @@ | ||
from __future__ import annotations | ||
|
||
from ..datatypes import EntityPathLike, Utf8Like | ||
from .api import SpaceView, SpaceViewContentsLike | ||
|
||
|
||
class Spatial3D(SpaceView): | ||
"""A Spatial 3D space view.""" | ||
|
||
def __init__( | ||
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None | ||
): | ||
""" | ||
Construct a blueprint for a new 3D space view. | ||
Parameters | ||
---------- | ||
origin | ||
The `EntityPath` to use as the origin of this space view. All other entities will be transformed | ||
to be displayed relative to this origin. | ||
contents | ||
The contents of the space view. Most commonly specified as a query expression. The individual | ||
sub-expressions must either be newline separate, or provided as a list of strings. | ||
See: [rerun.blueprint.components.QueryExpression][]. | ||
name | ||
The name of the space view. | ||
""" | ||
super().__init__(class_identifier="3D", origin=origin, contents=contents, name=name) | ||
|
||
|
||
class Spatial2D(SpaceView): | ||
"""A Spatial 2D space view.""" | ||
|
||
def __init__( | ||
self, *, origin: EntityPathLike = "/", contents: SpaceViewContentsLike = "/**", name: Utf8Like | None = None | ||
): | ||
""" | ||
Construct a blueprint for a new 2D space view. | ||
Parameters | ||
---------- | ||
origin | ||
The `EntityPath` to use as the origin of this space view. All other entities will be transformed | ||
to be displayed relative to this origin. | ||
contents | ||
The contents of the space view. Most commonly specified as a query expression. The individual | ||
sub-expressions must either be newline separate, or provided as a list of strings. | ||
See: [rerun.blueprint.components.QueryExpression][]. | ||
name | ||
The name of the space view. | ||
""" | ||
super().__init__(class_identifier="2D", origin=origin, contents=contents, name=name) |
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