Add debug-widget-callstack and debug-interactive-widgets features

- they need to be separate, both on at once is too much

    --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
This commit is contained in:
Ken Sedgwick
2024-12-19 14:22:30 -08:00
parent eeab1666e7
commit 2d7de8fdc0
3 changed files with 22 additions and 2 deletions

1
Cargo.lock generated
View File

@@ -1050,6 +1050,7 @@ checksum = "53eafabcce0cb2325a59a98736efe0bf060585b437763f8c476957fb274bb974"
dependencies = [
"accesskit",
"ahash",
"backtrace",
"emath",
"epaint",
"log",

View File

@@ -42,6 +42,8 @@ path = "src/preview.rs"
[features]
default = []
profiling = ["notedeck_columns/puffin", "puffin", "puffin_egui"]
debug-widget-callstack = ["egui/callstack"]
debug-interactive-widgets = []
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11.1"

View File

@@ -124,9 +124,26 @@ pub fn add_custom_style(is_mobile: bool, style: &mut Style) {
..Interaction::default()
};
#[cfg(debug_assertions)]
// debug: show callstack for the current widget on hover if all
// modifier keys are pressed down.
#[cfg(feature = "debug-widget-callstack")]
{
style.debug.show_interactive_widgets = true;
#[cfg(not(debug_assertions))]
compile_error!(
"The `debug-widget-callstack` feature requires a debug build, \
release builds are unsupported."
);
style.debug.debug_on_hover_with_all_modifiers = true;
}
// debug: show an overlay on all interactive widgets
#[cfg(feature = "debug-interactive-widgets")]
{
#[cfg(not(debug_assertions))]
compile_error!(
"The `debug-interactive-widgets` feature requires a debug build, \
release builds are unsupported."
);
style.debug.show_interactive_widgets = true;
}
}