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

re_viewer welcome screen code cleanup #8784

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6946,6 +6946,7 @@ dependencies = [
"anyhow",
"bytemuck",
"cfg-if",
"color-hex",
"eframe",
"egui",
"egui-wgpu",
Expand Down
2 changes: 2 additions & 0 deletions crates/viewer/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ grpc = ["re_data_source/grpc", "dep:re_grpc_client"]


[dependencies]
# XXX TODO FIX THIS IMPORT:
color-hex = { version = "*", default-features = false }
Comment on lines +48 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to remove this in favor of defining the needed macro in ecolor. As I said in the other comment, I should be able to do this over the weekend.

# Internal:
re_blueprint_tree.workspace = true
re_build_info.workspace = true
Expand Down
19 changes: 16 additions & 3 deletions crates/viewer/re_viewer/src/ui/welcome_screen/welcome_section.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use egui::Ui;
use egui::{Color32, Ui};

use re_ui::UiExt as _;

Expand All @@ -10,6 +10,19 @@ pub(super) const WELCOME_SCREEN_BULLET_TEXT: &[&str] = &[
"Configure the viewer interactively or through code",
];

// XXX TODO MOVE MACRO TO UTILITY MODULE OR UTILITY CRATE
macro_rules! color_from_rgb_hex {
($hex:literal) => {
match color_hex::color_from_hex!($hex).as_slice() {
[a, b, c] => Color32::from_rgb(*a, *b, *c),
_ => panic!("XXX"),
}
};
}

Comment on lines +14 to +21
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be defined in ecolor, I should be able to propose this over the weekend.

const DOC_BTN_TEXT: &str = "Go to documentation →";
const DOC_BTN_COLOR: Color32 = color_from_rgb_hex!("#60A0FF");

/// Show the welcome section.
pub(super) fn welcome_section_ui(ui: &mut egui::Ui) {
ui.vertical(|ui| {
Expand Down Expand Up @@ -55,8 +68,8 @@ pub(super) fn welcome_section_ui(ui: &mut egui::Ui) {
ui.add_space(9.0);
if ui
.button(
egui::RichText::new("Go to documentation →")
.color(egui::Color32::from_hex("#60A0FF").expect("this color is valid"))
egui::RichText::new(DOC_BTN_TEXT)
.color(DOC_BTN_COLOR)
.text_style(re_ui::DesignTokens::welcome_screen_body()),
)
.on_hover_cursor(egui::CursorIcon::PointingHand)
Expand Down
Loading