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 (debug-only) style panel #2914

Merged
merged 2 commits into from
Aug 7, 2023
Merged
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
12 changes: 12 additions & 0 deletions crates/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub enum UICommand {
ToggleSelectionPanel,
ToggleTimePanel,

#[cfg(debug_assertions)]
ToggleStylePanel,

#[cfg(not(target_arch = "wasm32"))]
ToggleFullscreen,
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -105,6 +108,12 @@ impl UICommand {
UICommand::ToggleSelectionPanel => ("Toggle Selection Panel", "Toggle the right panel"),
UICommand::ToggleTimePanel => ("Toggle Time Panel", "Toggle the bottom panel"),

#[cfg(debug_assertions)]
UICommand::ToggleStylePanel => (
"Toggle Style Panel",
"View and change global egui style settings",
),

#[cfg(not(target_arch = "wasm32"))]
UICommand::ToggleFullscreen => (
"Toggle fullscreen",
Expand Down Expand Up @@ -192,6 +201,9 @@ impl UICommand {
UICommand::ToggleSelectionPanel => Some(ctrl_shift(Key::S)),
UICommand::ToggleTimePanel => Some(ctrl_shift(Key::T)),

#[cfg(debug_assertions)]
UICommand::ToggleStylePanel => Some(ctrl_shift(Key::U)),

#[cfg(not(target_arch = "wasm32"))]
UICommand::ToggleFullscreen => Some(key(Key::F11)),
#[cfg(not(target_arch = "wasm32"))]
Expand Down
23 changes: 23 additions & 0 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub struct App {
memory_panel: crate::memory_panel::MemoryPanel,
memory_panel_open: bool,

style_panel_open: bool,

pub(crate) latest_queue_interest: web_time::Instant,

/// Measures how long a frame takes to paint
Expand Down Expand Up @@ -202,6 +204,8 @@ impl App {
memory_panel: Default::default(),
memory_panel_open: false,

style_panel_open: false,

latest_queue_interest: web_time::Instant::now(), // TODO(emilk): `Instant::MIN` when we have our own `Instant` that supports it.

frame_time_history: egui::util::History::new(1..100, 0.5),
Expand Down Expand Up @@ -358,6 +362,11 @@ impl App {
}
UICommand::ToggleTimePanel => app_blueprint.toggle_time_panel(&self.command_sender),

#[cfg(debug_assertions)]
UICommand::ToggleStylePanel => {
self.style_panel_open ^= true;
}

#[cfg(not(target_arch = "wasm32"))]
UICommand::ToggleFullscreen => {
_frame.set_fullscreen(!_frame.info().window_info.fullscreen);
Expand Down Expand Up @@ -488,6 +497,18 @@ impl App {
});
}

fn style_panel_ui(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) {
egui::SidePanel::left("style_panel")
.default_width(300.0)
.resizable(true)
.frame(self.re_ui.top_panel_frame())
.show_animated_inside(ui, self.style_panel_open, |ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
ctx.settings_ui(ui);
});
});
}

/// Top-level ui function.
///
/// Shows the viewer ui.
Expand Down Expand Up @@ -524,6 +545,8 @@ impl App {

self.memory_panel_ui(ui, gpu_resource_stats, store_stats);

self.style_panel_ui(egui_ctx, ui);

if let Some(store_view) = store_context {
// TODO(jleibs): We don't necessarily want to show the wait
// screen just because we're missing a recording. If we've
Expand Down
3 changes: 3 additions & 0 deletions crates/re_viewer/src/ui/rerun_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ impl App {
UICommand::OpenProfiler.menu_button_ui(ui, &self.command_sender);

UICommand::ToggleMemoryPanel.menu_button_ui(ui, &self.command_sender);

#[cfg(debug_assertions)]
UICommand::ToggleStylePanel.menu_button_ui(ui, &self.command_sender);
}

ui.add_space(spacing);
Expand Down