Skip to content

Commit

Permalink
Replace MarkerShape with code-generated enum type (#5336)
Browse files Browse the repository at this point in the history
### What
* Closes #3384

Also replaces `Corner2D` and `ContainerKind`, but those are blueprint
only and thus not user facing (yet).

The user-facing code should stay mostly the same.

I also improved the generated documentation for all components and
datatypes

### 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)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5336/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5336/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5336/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5336)
- [Docs
preview](https://rerun.io/preview/5819de7329032052d5291e1696706667009c8fc7/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/5819de7329032052d5291e1696706667009c8fc7/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

---------

Co-authored-by: Clement Rey <[email protected]>
  • Loading branch information
emilk and teh-cmc authored Feb 29, 2024
1 parent 33d5639 commit 588eb3c
Show file tree
Hide file tree
Showing 185 changed files with 2,406 additions and 3,024 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// Python
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
// Rust:
{
"name": "Lauch C++ minimal example",
"type": "cppdbg",
Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/editors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn edit_marker_shape_ui(

let mut edit_marker = current_marker;

let marker_text = edit_marker.as_str();
let marker_text = edit_marker.to_string();

egui::ComboBox::from_id_source("marker_shape")
.selected_text(marker_text) // TODO(emilk): Show marker shape in the selected text
Expand All @@ -270,8 +270,8 @@ fn edit_marker_shape_ui(
.with_max_x(ui.max_rect().max.x + ui.spacing().menu_margin.right),
);

for marker in MarkerShape::all_markers() {
let list_item = re_ui::list_item::ListItem::new(ctx.re_ui, marker.as_str())
for marker in MarkerShape::ALL {
let list_item = re_ui::list_item::ListItem::new(ctx.re_ui, marker.to_string())
.with_icon_fn(|_re_ui, ui, rect, visuals| {
paint_marker(ui, marker.into(), rect, visuals.text_color());
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/re_types/definitions/fbs/attributes.fbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace fbs.attributes;

/// The default variant of an `enum`.
attribute "default";

/// Mandatory attribute that applies to all kinds of objects: structs, enums, unions and even the
/// fields within.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace rerun.blueprint.archetypes;
/// The top-level description of the Viewport.
table ContainerBlueprint (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default",
"attr.rust.override_crate": "re_viewport"
) {
// --- Required ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,14 @@ include "rerun/attributes.fbs";
namespace rerun.blueprint.components;


// TODO(#3384)
/*
enum ContainerKind: byte {
Tabs = 1
Horizontal = 2,
Vertical = 3,
Grid = 4
}
*/

// ---

/// The kind of a blueprint container.
table ContainerKind (
/// The kind of a blueprint container (tabs, grid, …).
enum ContainerKind: byte (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.override_crate": "re_viewport"
"attr.rust.override_crate": "re_viewport",
"attr.docs.unreleased"
) {
/// Which kind of container this is.
///
/// Allowed values:
/// - Tabs = 1
/// - Horizontal = 2
/// - Vertical = 3
/// - Grid = 4
kind: ubyte (order: 100);
Tabs,
Horizontal,
Vertical,
Grid,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,13 @@ include "rust/attributes.fbs";

namespace rerun.blueprint.components;

// TODO(#3384)
/*
enum LegendPosition: byte {
LeftTop = 1,
RightTop = 2,
LeftBottom = 3,
RightBottom = 4
}
*/

/// One of four 2D corners, typically used to align objects.
table Corner2D (
"attr.arrow.transparent",
enum Corner2D: byte (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.tuple_struct"
"attr.rust.derive": "Copy, PartialEq, Eq"
) {
/// Where should the legend be located.
///
/// Allowed values:
/// - LeftTop = 1,
/// - RightTop = 2,
/// - LeftBottom = 3,
/// - RightBottom = 4
location: ubyte (order: 200);
LeftTop,
RightTop,
LeftBottom,
RightBottom (default),
}
2 changes: 2 additions & 0 deletions crates/re_types/definitions/rerun/components.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ include "./components/vector2d.fbs";
include "./components/vector3d.fbs";
include "./components/view_coordinates.fbs";
include "./components/visualizer_overrides.fbs";

include "./testing/components/enum_test.fbs";
34 changes: 12 additions & 22 deletions crates/re_types/definitions/rerun/components/marker_shape.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,18 @@ include "rerun/attributes.fbs";

namespace rerun.components;

// TODO(#3384)
/*
enum MarkerShape: byte {
Circle = 1,
Diamond = 2,
Square = 3,
Cross = 4,
Plus = 5,
Up = 6,
Down = 7,
Left = 8,
Right = 9,
Asterisk = 10,
}
*/

/// Shape of a marker.
struct MarkerShape (
"attr.python.aliases": "int, str",
"attr.python.array_aliases": "int, str",
"attr.rust.derive": "PartialEq, Eq, PartialOrd, Copy",
"attr.rust.repr": "transparent"
enum MarkerShape: byte (
"attr.docs.unreleased"
) {
shape: ubyte (order: 100);
Circle (default),
Diamond,
Square,
Cross,
Plus,
Up,
Down,
Left,
Right,
Asterisk,
}
2 changes: 0 additions & 2 deletions crates/re_types/definitions/rerun/datatypes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ include "./datatypes/vec2d.fbs";
include "./datatypes/vec3d.fbs";
include "./datatypes/vec4d.fbs";

include "./testing/datatypes/enum.fbs";

namespace rerun.datatypes;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace rerun.testing.datatypes;
namespace rerun.testing.components;

/// A test of the enum type.
enum EnumTest: byte {
Expand All @@ -9,7 +9,7 @@ enum EnumTest: byte {
Down,

/// Correct.
Right,
Right (default),

/// It's what's remaining.
Left,
Expand Down
11 changes: 5 additions & 6 deletions crates/re_types/src/blueprint/components/column_shares.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 588eb3c

Please sign in to comment.