From aafddf5acbaecd0ccab8f9d9a75ebf4974802502 Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Wed, 18 Sep 2024 16:04:38 -0700 Subject: [PATCH] debug: add crate features which enable egui DebugOptions --features debug-widget-callstack Show callstack for the current widget on hover if all modifier keys are pressed down --features debug-interactive-widgets Show an overlay on all interactive widgets Notes: - debug-widget-callstack asserts `egui:callstack` feature when enabled - Only works in debug builds, compile error w/ release builds --- Cargo.lock | 1 + Cargo.toml | 2 ++ src/app_style.rs | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e310aaf..9be33cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1112,6 +1112,7 @@ source = "git+https://github.com/emilk/egui?rev=fcb7764e48ce00f8f8e58da10f937410 dependencies = [ "accesskit", "ahash", + "backtrace", "emath", "epaint", "log", diff --git a/Cargo.toml b/Cargo.toml index 237c6d7..83709be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,6 +67,8 @@ security-framework = "2.11.0" [features] default = [] profiling = ["puffin", "puffin_egui", "eframe/puffin"] +debug-widget-callstack = ["egui/callstack"] +debug-interactive-widgets = [] [profile.small] inherits = 'release' diff --git a/src/app_style.rs b/src/app_style.rs index 6387c9b..d5763ee 100644 --- a/src/app_style.rs +++ b/src/app_style.rs @@ -69,6 +69,19 @@ pub fn create_custom_style(ctx: &Context, font_size: fn(&NotedeckTextStyle) -> f ..Interaction::default() }; + // debug: show callstack for the current widget on hover if all + // modifier keys are pressed down. + #[cfg(feature = "debug-widget-callstack")] + { + style.debug.debug_on_hover_with_all_modifiers = true; + } + + // debug: show an overlay on all interactive widgets + #[cfg(feature = "debug-interactive-widgets")] + { + style.debug.show_interactive_widgets = true; + } + style }