Skip to content

Commit

Permalink
UI changes (#36)
Browse files Browse the repository at this point in the history
* fixed wrong timestamp in xlink plot

* WIP add support for tof (oak d sr poe)

* Accommodate new sdk, make tof stream show up, more or less properly. Still need to fix a few gui bugs.

* UI changes

* device setting ui changes

* xlink timestamp fix

* dependency installer ui respect style

* more information when downloading blobs fails

* fix formatting

---------

Co-authored-by: Tomáš Kubíček <[email protected]>
Co-authored-by: zrezke <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2023
1 parent 32c3f49 commit a4ea0a1
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 157 deletions.
28 changes: 20 additions & 8 deletions crates/re_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ pub struct ReUi {
impl ReUi {
/// Create [`ReUi`] and apply style to the given egui context.
pub fn load_and_apply(egui_ctx: &egui::Context) -> Self {
Self {
let re_ui = Self {
egui_ctx: egui_ctx.clone(),
design_tokens: DesignTokens::load_and_apply(egui_ctx),
static_image_cache: Arc::new(Mutex::new(StaticImageCache::default())),
delayed_drag_values: Default::default(),
}
};
//This is probably not the best place to set the visuals but it will do for now
let mut visuals = egui::Visuals::dark();

visuals.selection.bg_fill = Color32::from_rgb(88, 12, 236);
re_ui.egui_ctx.set_visuals(visuals);
re_ui
}

pub fn rerun_logo(&self) -> Arc<egui_extras::RetainedImage> {
Expand Down Expand Up @@ -169,6 +175,7 @@ impl ReUi {
menu_contents: impl FnOnce(&mut egui::Ui) -> R,
) {
let align = egui::Align::Center;
let text_color = ui.style().visuals.weak_text_color();
let layout = if left_to_right {
egui::Layout::left_to_right(align)
} else {
Expand All @@ -177,7 +184,7 @@ impl ReUi {

ui.with_layout(layout, |ui| {
if left_to_right {
ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900));
ui.label(egui::RichText::new(label).color(text_color));
}
if wrap {
ui.add_sized(
Expand All @@ -203,12 +210,13 @@ impl ReUi {
}

if !left_to_right {
ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900));
ui.label(egui::RichText::new(label).color(text_color));
}
});
}

pub fn labeled_checkbox(&self, ui: &mut egui::Ui, label: &str, value: &mut bool) {
let text_color = ui.style().visuals.weak_text_color();
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_sized(
[Self::box_width(), Self::box_height()],
Expand All @@ -219,7 +227,7 @@ impl ReUi {
.response
},
);
ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900));
ui.label(egui::RichText::new(label).color(text_color));
});
}

Expand Down Expand Up @@ -283,6 +291,7 @@ impl ReUi {
Num: egui::emath::Numeric,
{
let mut borrow_map = self.delayed_drag_values.borrow_mut();
let text_color = ui.style().visuals.weak_text_color();
let state = borrow_map.entry(id).or_insert(DelayedDragState {
delay_ms: delay.unwrap_or(0.0),
last_update: instant::Instant::now(),
Expand All @@ -294,7 +303,7 @@ impl ReUi {
[Self::box_width(), Self::box_height()],
egui::DragValue::new(&mut state.value).clamp_range(range),
);
ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900));
ui.label(egui::RichText::new(label).color(text_color));
response
})
.inner;
Expand All @@ -308,6 +317,7 @@ impl ReUi {
}

pub fn labeled_toggle_switch(&self, ui: &mut egui::Ui, label: &str, value: &mut bool) {
let text_color = ui.style().visuals.weak_text_color();
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_sized(
[Self::box_width(), Self::box_height()],
Expand All @@ -318,16 +328,18 @@ impl ReUi {
.response
},
);
ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900));
ui.label(egui::RichText::new(label).color(text_color));
});
}

pub fn top_panel_frame(&self) -> egui::Frame {
let mut frame = egui::Frame {
inner_margin: Self::top_bar_margin(),
fill: self.design_tokens.top_bar_color,
fill: self.egui_ctx.style().visuals.panel_fill,
// fill: self.design_tokens.top_bar_color,
..Default::default()
};

if CUSTOM_WINDOW_DECORATIONS {
frame.rounding.nw = Self::native_window_rounding();
frame.rounding.ne = Self::native_window_rounding();
Expand Down
35 changes: 18 additions & 17 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ impl eframe::App for App {

file_saver_progress_ui(egui_ctx, self); // toasts for background file saver

let mut main_panel_frame = egui::Frame::default();
let mut main_panel_frame = egui::Frame::default().fill(egui_ctx.style().visuals.panel_fill);

if re_ui::CUSTOM_WINDOW_DECORATIONS {
// Add some margin so that we can later paint an outline around it all.
main_panel_frame.inner_margin = 1.0.into();
Expand Down Expand Up @@ -1424,22 +1425,22 @@ fn top_bar_ui(
let extra_margin = (ui.available_height() - 24.0) / 2.0;
ui.add_space(extra_margin);
}
let mut blueprint_panel_expanded = blueprint.blueprint_panel_expanded;
if app
.re_ui
.medium_icon_toggle_button(
ui,
&re_ui::icons::LEFT_PANEL_TOGGLE,
&mut blueprint_panel_expanded,
)
.on_hover_text(format!(
"Toggle Blueprint View{}",
Command::ToggleBlueprintPanel.format_shortcut_tooltip_suffix(ui.ctx())
))
.clicked()
{
app.pending_commands.push(Command::ToggleBlueprintPanel);
}
// let mut blueprint_panel_expanded = blueprint.blueprint_panel_expanded;
// if app
// .re_ui
// .medium_icon_toggle_button(
// ui,
// &re_ui::icons::LEFT_PANEL_TOGGLE,
// &mut blueprint_panel_expanded,
// )
// .on_hover_text(format!(
// "Toggle Blueprint View{}",
// Command::ToggleBlueprintPanel.format_shortcut_tooltip_suffix(ui.ctx())
// ))
// .clicked()
// {
// app.pending_commands.push(Command::ToggleBlueprintPanel);
// }

if cfg!(debug_assertions) && app.state.app_options.show_metrics {
ui.vertical_centered(|ui| {
Expand Down
67 changes: 39 additions & 28 deletions crates/re_viewer/src/depthai/dependency_installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ impl DependencyInstaller {
}

pub fn show(&mut self, re_ui: &re_ui::ReUi, ui: &mut egui::Ui) {
let panel_color = ui.style().visuals.panel_fill;
let frame = egui::Frame::default()
.fill(egui::Color32::WHITE)
.fill(panel_color)
.stroke(egui::Stroke::new(1.0, egui::Color32::GRAY))
.inner_margin(egui::Margin::symmetric(16.0, 0.0))
.rounding(8.0);
Expand All @@ -202,11 +203,13 @@ impl DependencyInstaller {
.resizable(true)
.default_height(600.0)
.show(ui.ctx(), |ui| {
let frame = egui::Frame::default().inner_margin(egui::Margin {
top: 24.0,
bottom: 4.0,
..0.0.into()
});
let frame = egui::Frame::default()
.fill(panel_color)
.inner_margin(egui::Margin {
top: 24.0,
bottom: 4.0,
..0.0.into()
});
egui::TopBottomPanel::top("header")
.frame(frame)
.show_separator_line(false)
Expand Down Expand Up @@ -248,33 +251,41 @@ impl DependencyInstaller {
.show_inside(ui, |_| ());

let frame = egui::Frame::default()
.fill(egui::Color32::WHITE)
.fill(panel_color)
.rounding(4.0)
.stroke(egui::Stroke::new(1.0, re_ui.design_tokens.gray_400))
.inner_margin(egui::Margin::same(12.0));

egui::CollapsingHeader::new("Details").default_open(true).show_unindented(ui, |ui| {
egui::CentralPanel::default()
.frame(frame)
.show_inside(ui, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
if re_ui.small_icon_button(ui, &re_ui::icons::COPY).clicked() {
crate::misc::Clipboard::with(|clipboard| {
clipboard.set_text(self.stdio.clone());
});
}
egui::CollapsingHeader::new("Details")
.default_open(true)
.show_unindented(ui, |ui| {
egui::CentralPanel::default()
.frame(frame)
.show_inside(ui, |ui| {
ui.with_layout(
egui::Layout::right_to_left(egui::Align::TOP),
|ui| {
if re_ui
.small_icon_button(ui, &re_ui::icons::COPY)
.clicked()
{
crate::misc::Clipboard::with(|clipboard| {
clipboard.set_text(self.stdio.clone());
});
}
},
);
re_ui.styled_scrollbar(
ui,
re_ui::ScrollAreaDirection::Both,
[false; 2],
true,
|ui| {
ui.label(&self.stdio);
},
);
});
re_ui.styled_scrollbar(
ui,
re_ui::ScrollAreaDirection::Both,
[false; 2],
true,
|ui| {
ui.label(&self.stdio);
},
);
});
});
});
});
}

Expand Down
45 changes: 22 additions & 23 deletions crates/re_viewer/src/native.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use re_log_types::LogMsg;
use crate::APPLICATION_NAME;
use re_log_types::LogMsg;

type AppCreator = Box<
dyn FnOnce(&eframe::CreationContext<'_>, re_ui::ReUi) -> Box<dyn eframe::App>
>;
type AppCreator =
Box<dyn FnOnce(&eframe::CreationContext<'_>, re_ui::ReUi) -> Box<dyn eframe::App>>;

// NOTE: the name of this function is hard-coded in `crates/rerun/src/crash_handler.rs`!
pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> {
Expand All @@ -18,9 +17,13 @@ pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> {
decorated: !re_ui::CUSTOM_WINDOW_DECORATIONS,
// To have rounded corners we need transparency:
transparent: re_ui::CUSTOM_WINDOW_DECORATIONS,

// icon_data: Some(eframe::IconData {
// rgba: re_ui::icons::APP_ICON.png_bytes.to_vec(),
// width: 96,
// height: 96,
// }),
follow_system_theme: false,
default_theme: eframe::Theme::Light,
default_theme: eframe::Theme::Dark,

renderer: eframe::Renderer::Wgpu,
wgpu_options: crate::wgpu_options(),
Expand All @@ -36,33 +39,29 @@ pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> {
Box::new(move |cc| {
let re_ui = crate::customize_eframe(cc);
app_creator(cc, re_ui)
})
}),
)
}

pub fn run_native_viewer_with_messages(
build_info: re_build_info::BuildInfo,
app_env: crate::AppEnvironment,
startup_options: crate::StartupOptions,
log_messages: Vec<LogMsg>
log_messages: Vec<LogMsg>,
) -> eframe::Result<()> {
let (tx, rx) = re_smart_channel::smart_channel(re_smart_channel::Source::Sdk);
for log_msg in log_messages {
tx.send(log_msg).ok();
}
run_native_app(
Box::new(move |cc, re_ui| {
Box::new(
crate::App::from_receiver(
build_info,
&app_env,
startup_options,
re_ui,
cc.storage,
rx,
std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false))
)
)
})
)
run_native_app(Box::new(move |cc, re_ui| {
Box::new(crate::App::from_receiver(
build_info,
&app_env,
startup_options,
re_ui,
cc.storage,
rx,
std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
))
}))
}
3 changes: 1 addition & 2 deletions crates/re_viewer/src/ui/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Blueprint {
pub fn new(egui_ctx: &egui::Context) -> Self {
let screen_size = egui_ctx.screen_rect().size();
Self {
blueprint_panel_expanded: true,
blueprint_panel_expanded: false,
selection_panel_expanded: true,
time_panel_expanded: screen_size.y > 600.0,
viewport: Default::default(),
Expand All @@ -27,7 +27,6 @@ impl Blueprint {

pub fn blueprint_panel_and_viewport(&mut self, ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) {
crate::profile_function!();

let spaces_info = SpaceInfoCollection::new(&ctx.log_db.entity_db);

self.viewport.on_frame_start(ctx, &spaces_info);
Expand Down
Loading

0 comments on commit a4ea0a1

Please sign in to comment.