diff --git a/crates/re_ui/data/icons/rerun_io.png b/crates/re_ui/data/icons/rerun_io.png new file mode 100644 index 000000000000..0e3c0e0d287a Binary files /dev/null and b/crates/re_ui/data/icons/rerun_io.png differ diff --git a/crates/re_ui/src/icons.rs b/crates/re_ui/src/icons.rs index 118adb8d6dd6..26d95eb78c41 100644 --- a/crates/re_ui/src/icons.rs +++ b/crates/re_ui/src/icons.rs @@ -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")); diff --git a/crates/re_viewer/src/ui/top_panel.rs b/crates/re_viewer/src/ui/top_panel.rs index d69e08e59722..a67d5d11074c 100644 --- a/crates/re_viewer/src/ui/top_panel.rs +++ b/crates/re_viewer/src/ui/top_panel.rs @@ -1,3 +1,4 @@ +use egui::NumExt as _; use re_format::format_number; use re_renderer::WgpuResourcePoolStatistics; use re_ui::UICommand; @@ -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); @@ -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;