Skip to content

Commit

Permalink
Add Rerun.io link/text in top bar (#2540)
Browse files Browse the repository at this point in the history
<!--
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

Fixes  #2518

Took quite a bit of time to make it look nice. It is not centered, so it
also plays nicely with demo.rerun

Native:
<img width="235" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/7dc299e6-86ff-4013-901e-a20f35ccd41d">

Web:
<img width="207" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/98d9932a-11e7-45e4-94ff-62c214e78fdf">

Web with metrics:
<img width="304" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/4e8fabde-58eb-4c48-84b9-48f8219237f9">

Web with metrics zoomed in _a lot_:
<img width="2057" alt="image"
src="https://github.com/rerun-io/rerun/assets/1220815/61e5bca5-a72d-43e3-86a5-173096e60607">

Click!

https://github.com/rerun-io/rerun/assets/1220815/51c42221-8fa2-46c3-8710-e0d9731289ee


Test using `cargo rerun` and `cargo rerun-web`

### 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/2540

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/86d9103/docs
Examples preview: https://rerun.io/preview/86d9103/examples
<!-- pr-link-docs:end -->

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
  • Loading branch information
Wumpf and emilk authored Jun 28, 2023
1 parent e577c8b commit 4d623ba
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Binary file added crates/re_ui/data/icons/rerun_io.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions crates/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ impl Icon {
pub const RERUN_MENU: Icon =
Icon::new("rerun_menu", include_bytes!("../data/icons/rerun_menu.png"));

pub const RERUN_IO_TEXT: Icon = Icon::new("rerun_io", include_bytes!("../data/icons/rerun_io.png"));

pub const PLAY: Icon = Icon::new("play", include_bytes!("../data/icons/play.png"));
pub const FOLLOW: Icon = Icon::new("follow", include_bytes!("../data/icons/follow.png"));
pub const PAUSE: Icon = Icon::new("pause", include_bytes!("../data/icons/pause.png"));
Expand Down
35 changes: 35 additions & 0 deletions crates/re_viewer/src/ui/top_panel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use egui::NumExt as _;
use re_format::format_number;
use re_renderer::WgpuResourcePoolStatistics;
use re_ui::UICommand;
Expand Down Expand Up @@ -72,6 +73,9 @@ fn top_bar_ui(
) {
crate::ui::rerun_menu_button_ui(store_context, ui, frame, app);

ui.add_space(12.0);
website_link_ui(ui, app);

if app.app_options().show_metrics {
ui.separator();
frame_time_label_ui(ui, app);
Expand Down Expand Up @@ -153,6 +157,37 @@ fn top_bar_ui(
});
}

/// Shows clickable website link as an image (text doesn't look as nice)
fn website_link_ui(ui: &mut egui::Ui, app: &mut App) {
let icon_image = app.re_ui().icon_image(&re_ui::icons::RERUN_IO_TEXT);

let desired_height = ui.max_rect().height();
let desired_height = desired_height.at_most(28.0); // figma size 2023-02-03

let image_size = icon_image.size_vec2() * (desired_height / icon_image.size_vec2().y);
let texture_id = icon_image.texture_id(ui.ctx());
let response = ui
.add(egui::ImageButton::new(texture_id, image_size))
.on_hover_cursor(egui::CursorIcon::PointingHand);
let url = "https://rerun.io/";
if response.clicked() {
let modifiers = ui.ctx().input(|i| i.modifiers);
ui.ctx().output_mut(|o| {
o.open_url = Some(egui::output::OpenUrl {
url: url.to_owned(),
new_tab: modifiers.any(),
});
});
} else if response.middle_clicked() {
ui.ctx().output_mut(|o| {
o.open_url = Some(egui::output::OpenUrl {
url: url.to_owned(),
new_tab: true,
});
});
}
}

fn frame_time_label_ui(ui: &mut egui::Ui, app: &App) {
if let Some(frame_time) = app.frame_time_history.average() {
let ms = frame_time * 1e3;
Expand Down

0 comments on commit 4d623ba

Please sign in to comment.