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

Add Rerun.io link/text in top bar #2540

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 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,35 @@ 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));
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
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