Skip to content

Ghidrust provides a hyper fast, AI native reverse engineering platform built in Rust, inspired by Ghidra. Includes experimental GPU kernels to rapidly decompile large files, a decryption suite, and network monitor for packet to binary reverse engineering.

Enhance theme and UI components with Material 3 design tokens.

oofz4d402fbb8722
diff --git a/crates/ghidrust-core/src/lib.rs b/crates/ghidrust-core/src/lib.rs
index 28ddfc7..2794fb4 100644
--- a/crates/ghidrust-core/src/lib.rs
+++ b/crates/ghidrust-core/src/lib.rs
@@ -121,7 +121,11 @@ pub use rtti_catalog::{
RttiQueryResult,
};
pub use section_notes::{section_notes_for, SectionNote};
-pub use theme::{m3_tokens, theme_tokens, AppearanceTheme, M3Tokens, ThemeMode};
+pub use theme::{
+ m3_tokens, theme_spec, theme_tokens, ActiveFg, ActiveFill, AppearanceTheme, ElevationShadow,
+ FibScale, HoverFill, M3Tokens, ThemeDensity, ThemeElevation, ThemeMode, ThemeMotion,
+ ThemeSemantics, ThemeSpec, ThemeStateLayers,
+};
pub use tree_index::{list_tree, TreeEntry, TreeListOpts, TreeListResult};
pub use xrefs::{
calls_callees, instruction_targets, operand_addresses, rip_relative_targets, xrefs_from,
diff --git a/crates/ghidrust-core/src/theme.rs b/crates/ghidrust-core/src/theme.rs
index a483dc2..930451f 100644
--- a/crates/ghidrust-core/src/theme.rs
+++ b/crates/ghidrust-core/src/theme.rs
@@ -1,9 +1,21 @@
-//! Appearance themes + color tokens (shared for docs/tests; GUI applies via egui).
+//! Appearance themes as swappable **ThemeSpec** packs (Material 3 structure).
//!
//! Families:
-//! - **Classic Ghidrust** — frozen historical Ghidrust palette (M3-inspired).
-//! - **Modern** — Google Material 3 baseline roles (light + dark).
-//! - **Future Console** — Amber Console design tokens ported 1:1 (see module notes).
+//! - **Classic Ghidrust** — historical purple seed + derived M3 surface ladder.
+//! - **Modern** — Google Material 3 baseline color roles (light + dark).
+//! - **Future Console** — Amber Console CRT / neon tokens (see module notes).
+//!
+//! Design model (industry-standard token layers):
+//! 1. **Color scheme** — M3 roles (`M3Tokens`)
+//! 2. **Shape** — corner radius + stroke (on color scheme for caller compat)
+//! 3. **Density** — spacing / padding
+//! 4. **State layers** — hover / pressed / selection (data, not GUI `match` arms)
+//! 5. **Elevation** — popup shadow level
+//! 6. **Motion** — animation duration
+//! 7. **Semantics** — status + syntax accents for panes
+//!
+//! Swap a design by editing a pack in [`theme_spec`]; the GUI compiles any pack
+//! through one Style/Visuals path.
use serde::{Deserialize, Serialize};
@@ -93,11 +105,11 @@ impl AppearanceTheme {
}
}
-/// Shared sRGB 0–255 tokens consumed by the GUI (`apply_theme` + pane accents).
+/// Shared sRGB 0–255 Material 3 color roles (+ shape hints).
///
-/// Core roles always filled. Extended Material 3 roles are populated for Modern;
-/// Classic / Future Console alias them onto the core set so callers stay uniform.
-#[derive(Debug, Clone, Copy, Serialize)]
+/// Core roles always filled. Extended M3 roles are fully populated for Modern;
+/// Classic / Future Console fill the same fields so callers stay uniform.
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
pub struct M3Tokens {
pub mode: ThemeMode,
pub appearance: AppearanceTheme,
@@ -130,114 +142,463 @@ pub struct M3Tokens {
pub inverse_surface: [u8; 3],
pub inverse_on_surface: [u8; 3],
pub inverse_primary: [u8; 3],
- /// Corner radius hint for egui (Classic ≈ 4; Modern ≈ 12; Future Console = 8).
+ /// M3 shape corner radius hint for egui (Classic = 5; Modern = 13; Future = 8).
pub corner_radius: u8,
- /// Stroke width hint (Future Console uses 2px soft-key borders).
+ /// Outline stroke width (Future Console uses 2px soft-key borders).
pub stroke_width: f32,
}
-/// Resolve tokens for an appearance family + mode.
-pub fn theme_tokens(appearance: AppearanceTheme, mode: ThemeMode) -> M3Tokens {
+/// Strict Fibonacci spacing scale (px). All chrome sizes resolve from these steps.
+///
+/// Sequence: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987.
+pub struct FibScale;
+
+impl FibScale {
+ pub const HAIR: f32 = 1.0;
+ pub const XXS: f32 = 2.0;
+ pub const XS: f32 = 3.0;
+ pub const SM: f32 = 5.0;
+ pub const MD: f32 = 8.0;
+ pub const LG: f32 = 13.0;
+ pub const XL: f32 = 21.0;
+ pub const XL2: f32 = 34.0;
+ pub const XL3: f32 = 55.0;
+ pub const XL4: f32 = 89.0;
+ pub const XL5: f32 = 144.0;
+ pub const XL6: f32 = 233.0;
+ pub const XL7: f32 = 377.0;
+ pub const XL8: f32 = 610.0;
+ pub const XL9: f32 = 987.0;
+}
+
+/// Fibonacci-backed density pack (egui Spacing + chrome defaults + window tiers).
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+pub struct ThemeDensity {
+ pub item_spacing: [f32; 2],
+ pub button_padding: [f32; 2],
+ pub window_margin: [f32; 2],
+ pub menu_margin: [f32; 2],
+ pub indent: f32,
+ pub resize_grab_radius: f32,
+ pub control_min_height: f32,
+ pub icon_sm: f32,
+ pub icon_md: f32,
+ pub space_xs: f32,
+ pub space_sm: f32,
+ pub space_md: f32,
+ pub space_lg: f32,
+ pub space_xl: f32,
+ pub panel_project: f32,
+ pub panel_program: f32,
+ pub panel_symbol: f32,
+ pub panel_symbol_min: f32,
+ pub console_default: f32,
+ pub console_min: f32,
+ pub console_grip: f32,
+ pub console_handle_w: f32,
+ pub scroll_sm: f32,
+ pub scroll_md: f32,
+ pub scroll_lg: f32,
+ /// TextEdit / column field width tiers (Fibonacci).
+ pub field_micro: f32,
+ pub field_narrow: f32,
+ pub field_compact: f32,
+ pub field_std: f32,
+ pub field_wide: f32,
+ pub field_xwide: f32,
+ /// Window default size tiers: `[width, height]`.
+ pub win_xs: [f32; 2],
+ pub win_sm: [f32; 2],
+ pub win_md: [f32; 2],
+ pub win_lg: [f32; 2],
+ pub win_xl: [f32; 2],
+}
+
+impl ThemeDensity {
+ const fn shared_chrome(button_padding: [f32; 2]) -> Self {
+ Self {
+ item_spacing: [FibScale::MD, FibScale::MD],
+ button_padding,
+ window_margin: [FibScale::LG, FibScale::LG],
+ menu_margin: [FibScale::MD, FibScale::SM],
+ indent: FibScale::LG,
+ resize_grab_radius: FibScale::LG,
+ control_min_height: FibScale::XL2,
+ icon_sm: FibScale::LG,
+ icon_md: FibScale::XL,
+ space_xs: FibScale::XS,
+ space_sm: FibScale::SM,
+ space_md: FibScale::MD,
+ space_lg: FibScale::LG,
+ space_xl: FibScale::XL,
+ panel_project: FibScale::XL6,
+ panel_program: FibScale::XL6,
+ panel_symbol: FibScale::XL6,
+ panel_symbol_min: FibScale::XL5,
+ console_default: FibScale::XL6,
+ console_min: FibScale::XL5,
+ console_grip: FibScale::LG,
+ console_handle_w: FibScale::XL3,
+ scroll_sm: FibScale::XL6,
+ scroll_md: FibScale::XL7,
+ scroll_lg: FibScale::XL8,
+ field_micro: FibScale::XL3,
+ field_narrow: FibScale::XL4,
+ field_compact: FibScale::XL5,
+ field_std: FibScale::XL6,
+ field_wide: FibScale::XL7,
+ field_xwide: FibScale::XL8,
+ win_xs: [FibScale::XL7, FibScale::XL6],
+ win_sm: [FibScale::XL7, FibScale::XL7],
+ win_md: [FibScale::XL8, FibScale::XL7],
+ win_lg: [FibScale::XL8, FibScale::XL8],
+ win_xl: [FibScale::XL9, FibScale::XL8],
+ }
+ }
+
+ /// Classic + Modern comfortable Fib desktop density.
+ pub const FIB_DESKTOP: Self = Self::shared_chrome([FibScale::LG, FibScale::MD]);
+
+ /// Future Console — same Fib ladder, larger soft-key padding.
+ pub const FIB_CONSOLE: Self = Self::shared_chrome([FibScale::XL, FibScale::LG]);
+}
+
+/// Hover fill recipe (M3 state-layer approximation for egui fills).
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum HoverFill {
+ /// `primary` with egui `gamma_multiply`.
+ PrimaryGamma(f32),
+ /// `primary_container` with egui `gamma_multiply`.
+ PrimaryContainerGamma(f32),
+ /// Raised surface (console / tonal hover).
+ SurfaceBright,
+}
+
+/// Pressed / active fill recipe.
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum ActiveFill {
+ Primary,
+ PrimaryGamma(f32),
+}
+
+/// Ink on active controls.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum ActiveFg {
+ OnPrimary,
+ OnSurface,
+}
+
+/// Interactive state layers (Material state-layer model, pack-driven).
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+pub struct ThemeStateLayers {
+ pub hover: HoverFill,
+ pub active: ActiveFill,
+ pub active_fg: ActiveFg,
+ /// Selection highlight: `primary` × gamma.
+ pub selection_primary_gamma: f32,
+}
+
+/// Popup / menu elevation (M3 elevation mapped to egui shadows).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum ElevationShadow {
+ /// No shadow (flat CRT / neon panel).
+ None,
+ /// Soft ambient (≈ M3 level 2): offset (0,2), blur 8, black α40.
+ Level2,
+ /// Keep egui `Visuals::dark/light` stock popup shadow.
+ Stock,
+}
+
+/// Elevation tokens for floating surfaces.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+pub struct ThemeElevation {
+ pub popup_shadow: ElevationShadow,
+}
+
+/// Motion tokens (Material duration scale, seconds).
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+pub struct ThemeMotion {
+ /// Typical UI animation length (`Style::animation_time`).
+ pub animation_time: f32,
+}
+
+impl ThemeMotion {
+ /// Material short-2 ≈ 150ms — standard control feedback.
+ pub const SHORT2: Self = Self {
+ animation_time: 0.15,
+ };
+ /// Material medium-1 ≈ 200ms — slightly softer chrome.
+ pub const MEDIUM1: Self = Self {
+ animation_time: 0.20,
+ };
+}
+
+/// Semantic / syntax accents (not M3 core roles; app-specific extensions).
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+pub struct ThemeSemantics {
+ pub ok: [u8; 3],
+ pub warn: [u8; 3],
+ pub muted: [u8; 3],
+ pub syntax_keyword: [u8; 3],
+ pub syntax_function: [u8; 3],
+ pub syntax_label: [u8; 3],
+ pub syntax_address: [u8; 3],
+ pub syntax_constant: [u8; 3],
+ pub syntax_comment: [u8; 3],
+}
+
+impl ThemeSemantics {
+ /// Dark-scheme syntax (Material-ish accents used historically in the decompiler).
+ pub const DARK_CODE: Self = Self {
+ ok: [0x4C, 0xAF, 0x50],
+ warn: [0xFB, 0xC0, 0x2D],
+ muted: [0x9E, 0x9E, 0x9E],
+ syntax_keyword: [0x64, 0xB5, 0xF6],
+ syntax_function: [0xFF, 0xB7, 0x4D],
+ syntax_label: [0xBA, 0x68, 0xC8],
+ syntax_address: [0x4D, 0xD0, 0xE1],
+ syntax_constant: [0x80, 0xDE, 0xEA],
+ syntax_comment: [0x81, 0xC7, 0x84],
+ };
+
+ /// Light-scheme syntax — deeper chroma for contrast on pale surfaces.
+ pub const LIGHT_CODE: Self = Self {
+ ok: [0x2E, 0x7D, 0x32],
+ warn: [0xF5, 0x7C, 0x00],
+ muted: [0x75, 0x75, 0x75],
+ syntax_keyword: [0x15, 0x65, 0xC0],
+ syntax_function: [0xE6, 0x51, 0x00],
+ syntax_label: [0x7B, 0x1F, 0xA2],
+ syntax_address: [0x00, 0x83, 0x8F],
+ syntax_constant: [0x00, 0x83, 0x8F],
+ syntax_comment: [0x2E, 0x7D, 0x32],
+ };
+
+ /// Amber Console: keep hue family (no foreign greens/blues).
+ pub const CONSOLE: Self = Self {
+ ok: [0xFF, 0xAE, 0x1E],
+ warn: [0xFF, 0xD0, 0x52],
+ muted: [0xAB, 0x45, 0x00],
+ syntax_keyword: [0xFF, 0xA8, 0x6D],
+ syntax_function: [0xFF, 0x6B, 0x08],
+ syntax_label: [0xFF, 0xD0, 0x52],
+ syntax_address: [0xDD, 0x58, 0x00],
+ syntax_constant: [0xFF, 0xA8, 0x6D],
+ syntax_comment: [0xAB, 0x45, 0x00],
+ };
+}
+
+/// Complete swappable theme pack — edit this (or add a pack) to change a design.
+#[derive(Debug, Clone, Copy, PartialEq, Serialize)]
+pub struct ThemeSpec {
+ pub colors: M3Tokens,
+ /// Prefer egui dark Visuals base (Future Console is always dark CRT).
+ pub dark_base: bool,
+ pub density: ThemeDensity,
+ pub state_layers: ThemeStateLayers,
+ pub elevation: ThemeElevation,
+ pub motion: ThemeMotion,
+ pub semantics: ThemeSemantics,
+}
+
+/// Resolve a full theme pack for an appearance family + mode.
+pub fn theme_spec(appearance: AppearanceTheme, mode: ThemeMode) -> ThemeSpec {
match appearance {
- AppearanceTheme::ClassicGhidrust => classic_tokens(mode),
- AppearanceTheme::Modern => modern_tokens(mode),
- AppearanceTheme::FutureConsole => future_console_tokens(mode),
+ AppearanceTheme::ClassicGhidrust => classic_spec(mode),
+ AppearanceTheme::Modern => modern_spec(mode),
+ AppearanceTheme::FutureConsole => future_console_spec(mode),
}
}
+/// Resolve color tokens for an appearance family + mode.
+pub fn theme_tokens(appearance: AppearanceTheme, mode: ThemeMode) -> M3Tokens {
+ theme_spec(appearance, mode).colors
+}
+
/// Backward-compatible Classic Ghidrust tokens (mode only).
pub fn m3_tokens(mode: ThemeMode) -> M3Tokens {
theme_tokens(AppearanceTheme::ClassicGhidrust, mode)
}
-fn fill_aliases(
- mode: ThemeMode,
- appearance: AppearanceTheme,
- primary: [u8; 3],
- on_primary: [u8; 3],
- surface: [u8; 3],
- surface_container: [u8; 3],
- on_surface: [u8; 3],
- on_surface_variant: [u8; 3],
- outline: [u8; 3],
- error: [u8; 3],
- corner_radius: u8,
- stroke_width: f32,
-) -> M3Tokens {
- M3Tokens {
- mode,
- appearance,
- primary,
- on_primary,
- primary_container: surface_container,
- on_primary_container: on_surface,
- secondary: on_surface_variant,
- on_secondary: surface,
- secondary_container: surface_container,
- on_secondary_container: on_surface,
- tertiary: primary,
- on_tertiary: on_primary,
- tertiary_container: surface_container,
- on_tertiary_container: on_surface,
- surface,
- surface_dim: surface,
- surface_bright: surface_container,
- surface_container_lowest: surface,
- surface_container_low: surface_container,
- surface_container,
- surface_container_high: surface_container,
- surface_container_highest: surface_container,
- on_surface,
- on_surface_variant,
- outline,
- outline_variant: outline,
- error,
- on_error: on_primary,
- inverse_surface: on_surface,
- inverse_on_surface: surface,
- inverse_primary: primary,
- corner_radius,
- stroke_width,
+// ---------------------------------------------------------------------------
+// Packs
+// ---------------------------------------------------------------------------
+
+fn classic_spec(mode: ThemeMode) -> ThemeSpec {
+ ThemeSpec {
+ colors: classic_colors(mode),
+ dark_base: matches!(mode, ThemeMode::Dark),
+ density: ThemeDensity::FIB_DESKTOP,
+ state_layers: ThemeStateLayers {
+ hover: HoverFill::PrimaryGamma(0.25),
+ active: ActiveFill::PrimaryGamma(0.35),
+ active_fg: ActiveFg::OnSurface,
+ selection_primary_gamma: 0.40,
+ },
+ elevation: ThemeElevation {
+ popup_shadow: ElevationShadow::Level2,
+ },
+ motion: ThemeMotion::SHORT2,
+ semantics: match mode {
+ ThemeMode::Dark => ThemeSemantics::DARK_CODE,
+ ThemeMode::Light => ThemeSemantics::LIGHT_CODE,
+ },
}
}
-/// Classic Ghidrust — exact historical values (do not retune).
-fn classic_tokens(mode: ThemeMode) -> M3Tokens {
+fn modern_spec(mode: ThemeMode) -> ThemeSpec {
+ ThemeSpec {
+ colors: modern_colors(mode),
+ dark_base: matches!(mode, ThemeMode::Dark),
+ density: ThemeDensity::FIB_DESKTOP,
+ state_layers: ThemeStateLayers {
+ hover: HoverFill::PrimaryContainerGamma(0.55),
+ active: ActiveFill::PrimaryGamma(0.45),
+ active_fg: ActiveFg::OnSurface,
+ selection_primary_gamma: 0.40,
+ },
+ elevation: ThemeElevation {
+ popup_shadow: ElevationShadow::Level2,
+ },
+ motion: ThemeMotion::MEDIUM1,
+ semantics: match mode {
+ ThemeMode::Dark => ThemeSemantics::DARK_CODE,
+ ThemeMode::Light => ThemeSemantics::LIGHT_CODE,
+ },
+ }
+}
+
+fn future_console_spec(mode: ThemeMode) -> ThemeSpec {
+ ThemeSpec {
+ colors: future_console_colors(mode),
+ // CRT / neon panel is always a dark egui base (both gases).
+ dark_base: true,
+ density: ThemeDensity::FIB_CONSOLE,
+ state_layers: ThemeStateLayers {
+ hover: HoverFill::SurfaceBright,
+ active: ActiveFill::Primary,
+ active_fg: ActiveFg::OnPrimary,
+ selection_primary_gamma: 0.55,
+ },
+ elevation: ThemeElevation {
+ popup_shadow: ElevationShadow::None,
+ },
+ motion: ThemeMotion::SHORT2,
+ semantics: ThemeSemantics::CONSOLE,
+ }
+}
+
+/// Lift/darken an sRGB triplet by a uniform channel delta (simple tonal step).
+fn tonal_step(rgb: [u8; 3], delta: i16) -> [u8; 3] {
+ [
+ (i16::from(rgb[0]) + delta).clamp(0, 255) as u8,
+ (i16::from(rgb[1]) + delta).clamp(0, 255) as u8,
+ (i16::from(rgb[2]) + delta).clamp(0, 255) as u8,
+ ]
+}
+
+/// Classic — frozen brand seeds with a derived M3 surface container ladder.
+fn classic_colors(mode: ThemeMode) -> M3Tokens {
match mode {
- ThemeMode::Dark => fill_aliases(
- mode,
- AppearanceTheme::ClassicGhidrust,
- [0xD0, 0xBC, 0xFF],
- [0x38, 0x1E, 0x72],
- [0x14, 0x14, 0x18],
- [0x1C, 0x1B, 0x1F],
- [0xE6, 0xE1, 0xE5],
- [0xCA, 0xC4, 0xD0],
- [0x93, 0x8F, 0x99],
- [0xF2, 0xB8, 0xB5],
- 4,
- 1.0,
- ),
- ThemeMode::Light => fill_aliases(
- mode,
- AppearanceTheme::ClassicGhidrust,
- [0x67, 0x50, 0xA4],
- [0xFF, 0xFF, 0xFF],
- [0xFF, 0xFB, 0xFE],
- [0xF3, 0xED, 0xF7],
- [0x1C, 0x1B, 0x1F],
- [0x49, 0x45, 0x4F],
- [0x79, 0x74, 0x7E],
- [0xB3, 0x26, 0x1E],
- 4,
- 1.0,
- ),
+ ThemeMode::Dark => {
+ let primary = [0xD0, 0xBC, 0xFF];
+ let on_primary = [0x38, 0x1E, 0x72];
+ let surface = [0x14, 0x14, 0x18];
+ let surface_container = [0x1C, 0x1B, 0x1F];
+ let on_surface = [0xE6, 0xE1, 0xE5];
+ let on_surface_variant = [0xCA, 0xC4, 0xD0];
+ let outline = [0x93, 0x8F, 0x99];
+ let error = [0xF2, 0xB8, 0xB5];
+ M3Tokens {
+ mode,
+ appearance: AppearanceTheme::ClassicGhidrust,
+ primary,
+ on_primary,
+ primary_container: [0x4F, 0x37, 0x8B],
+ on_primary_container: [0xEA, 0xDD, 0xFF],
+ secondary: on_surface_variant,
+ on_secondary: surface,
+ secondary_container: tonal_step(surface_container, 6),
+ on_secondary_container: on_surface,
+ tertiary: primary,
+ on_tertiary: on_primary,
+ tertiary_container: tonal_step(surface_container, 10),
+ on_tertiary_container: on_surface,
+ surface,
+ surface_dim: tonal_step(surface, -4),
+ surface_bright: tonal_step(surface_container, 18),
+ surface_container_lowest: tonal_step(surface, -5),
+ surface_container_low: tonal_step(surface, 4),
+ surface_container,
+ surface_container_high: tonal_step(surface_container, 10),
+ surface_container_highest: tonal_step(surface_container, 18),
+ on_surface,
+ on_surface_variant,
+ outline,
+ outline_variant: [0x49, 0x45, 0x4F],
+ error,
+ on_error: on_primary,
+ inverse_surface: on_surface,
+ inverse_on_surface: surface,
+ inverse_primary: [0x67, 0x50, 0xA4],
+ corner_radius: 5,
+ stroke_width: 1.0,
+ }
+ }
+ ThemeMode::Light => {
+ let primary = [0x67, 0x50, 0xA4];
+ let on_primary = [0xFF, 0xFF, 0xFF];
+ let surface = [0xFF, 0xFB, 0xFE];
+ let surface_container = [0xF3, 0xED, 0xF7];
+ let on_surface = [0x1C, 0x1B, 0x1F];
+ let on_surface_variant = [0x49, 0x45, 0x4F];
+ let outline = [0x79, 0x74, 0x7E];
+ let error = [0xB3, 0x26, 0x1E];
+ M3Tokens {
+ mode,
+ appearance: AppearanceTheme::ClassicGhidrust,
+ primary,
+ on_primary,
+ primary_container: [0xEA, 0xDD, 0xFF],
+ on_primary_container: [0x21, 0x00, 0x5D],
+ secondary: on_surface_variant,
+ on_secondary: surface,
+ secondary_container: tonal_step(surface_container, -6),
+ on_secondary_container: on_surface,
+ tertiary: primary,
+ on_tertiary: on_primary,
+ tertiary_container: tonal_step(surface_container, -10),
+ on_tertiary_container: on_surface,
+ surface,
+ surface_dim: tonal_step(surface_container, -12),
+ surface_bright: surface,
+ surface_container_lowest: [0xFF, 0xFF, 0xFF],
+ surface_container_low: tonal_step(surface_container, 4),
+ surface_container,
+ surface_container_high: tonal_step(surface_container, -6),
+ surface_container_highest: tonal_step(surface_container, -12),
+ on_surface,
+ on_surface_variant,
+ outline,
+ outline_variant: [0xCA, 0xC4, 0xD0],
+ error,
+ on_error: on_primary,
+ inverse_surface: on_surface,
+ inverse_on_surface: surface,
+ inverse_primary: [0xD0, 0xBC, 0xFF],
+ corner_radius: 5,
+ stroke_width: 1.0,
+ }
+ }
}
}
/// Google Material 3 baseline scheme (seed / primary40 `#6750A4`).
-/// Role hexes match Material Components Android baseline tonal assignments.
-fn modern_tokens(mode: ThemeMode) -> M3Tokens {
+fn modern_colors(mode: ThemeMode) -> M3Tokens {
match mode {
ThemeMode::Light => M3Tokens {
mode,
@@ -271,7 +632,7 @@ fn modern_tokens(mode: ThemeMode) -> M3Tokens {
inverse_surface: [0x32, 0x2F, 0x35],
inverse_on_surface: [0xF5, 0xEF, 0xF7],
inverse_primary: [0xD0, 0xBC, 0xFF],
- corner_radius: 12,
+ corner_radius: 13,
stroke_width: 1.0,
},
ThemeMode::Dark => M3Tokens {
@@ -306,90 +667,82 @@ fn modern_tokens(mode: ThemeMode) -> M3Tokens {
inverse_surface: [0xE6, 0xE0, 0xE9],
inverse_on_surface: [0x32, 0x2F, 0x35],
inverse_primary: [0x67, 0x50, 0xA4],
- corner_radius: 12,
+ corner_radius: 13,
stroke_width: 1.0,
},
}
}
-/// Future Console — Amber Console tokens copied 1:1 from
+/// Future Console — Amber Console tokens from
/// `https://github.com/DutchDiederik/AmberConsole` `src/tokens/colors.css`.
///
/// Copyright (c) 2026, Diederik — https://diederik.blog
/// Licensed under the BSD 3-Clause License (see Amber Console LICENSE).
///
/// Mapping:
-/// - `ThemeMode::Dark` → `data-ac-gas="neon"` (default pulsed neon panel)
-/// - `ThemeMode::Light` → `data-ac-gas="amber"` (classic P3 amber CRT phosphor)
-///
-/// Not vendored as a git submodule; design tokens transcribed for egui.
-fn future_console_tokens(mode: ThemeMode) -> M3Tokens {
- // Exact hex from colors.css — neon block / amber block.
+/// - `ThemeMode::Dark` → `data-ac-gas="neon"`
+/// - `ThemeMode::Light` → `data-ac-gas="amber"`
+fn future_console_colors(mode: ThemeMode) -> M3Tokens {
let (screen, screen_raised, screen_well, amber_100, amber_90, amber_70, amber_50, amber_30, on_fill) =
match mode {
- // [data-ac-gas="neon"]
ThemeMode::Dark => (
- [0x10, 0x06, 0x00], // --screen: #100600
- [0x1B, 0x0C, 0x02], // --screen-raised: #1b0c02
- [0x06, 0x02, 0x00], // --screen-well: #060200
- [0xFF, 0xA8, 0x6D], // --amber-100: #ffa86d
- [0xFF, 0x6B, 0x08], // --amber-90: #ff6b08
- [0xDD, 0x58, 0x00], // --amber-70: #dd5800
- [0xAB, 0x45, 0x00], // --amber-50: #ab4500
- [0x5B, 0x25, 0x00], // --amber-30: #5b2500
- [0x1E, 0x0C, 0x00], // --on-fill: #1e0c00
+ [0x10, 0x06, 0x00],
+ [0x1B, 0x0C, 0x02],
+ [0x06, 0x02, 0x00],
+ [0xFF, 0xA8, 0x6D],
+ [0xFF, 0x6B, 0x08],
+ [0xDD, 0x58, 0x00],
+ [0xAB, 0x45, 0x00],
+ [0x5B, 0x25, 0x00],
+ [0x1E, 0x0C, 0x00],
),
- // [data-ac-gas="amber"]
ThemeMode::Light => (
- [0x0D, 0x07, 0x00], // --screen: #0d0700
- [0x17, 0x0E, 0x02], // --screen-raised: #170e02
- [0x06, 0x02, 0x00], // --screen-well: #060200
- [0xFF, 0xD0, 0x52], // --amber-100: #ffd052
- [0xFF, 0xAE, 0x1E], // --amber-90: #ffae1e
- [0xCD, 0x88, 0x17], // --amber-70: #cd8817
- [0x8D, 0x5B, 0x10], // --amber-50: #8d5b10
- [0x4A, 0x2F, 0x08], // --amber-30: #4a2f08
- [0x1A, 0x0E, 0x00], // --on-fill: #1a0e00
+ [0x0D, 0x07, 0x00],
+ [0x17, 0x0E, 0x02],
+ [0x06, 0x02, 0x00],
+ [0xFF, 0xD0, 0x52],
+ [0xFF, 0xAE, 0x1E],
+ [0xCD, 0x88, 0x17],
+ [0x8D, 0x5B, 0x10],
+ [0x4A, 0x2F, 0x08],
+ [0x1A, 0x0E, 0x00],
),
};
- // Aliases from colors.css `:root` block:
- // --ink = amber-90, --ink-bright = amber-100, --ink-dim = amber-70,
- // --ink-faint = amber-50, --fill = amber-90, --stroke = amber-90.
M3Tokens {
mode,
appearance: AppearanceTheme::FutureConsole,
- primary: amber_90, // --ink / --fill / --stroke
- on_primary: on_fill, // --on-fill
- primary_container: amber_70, // --ink-dim
+ primary: amber_90,
+ on_primary: on_fill,
+ primary_container: amber_70,
on_primary_container: on_fill,
- secondary: amber_100, // --ink-bright
+ secondary: amber_100,
on_secondary: on_fill,
- secondary_container: amber_50, // --ink-faint / --stroke-dim
+ secondary_container: amber_50,
on_secondary_container: screen,
- tertiary: amber_30, // --ink-trace
+ tertiary: amber_30,
on_tertiary: amber_100,
tertiary_container: screen_well,
on_tertiary_container: amber_70,
- surface: screen, // --screen
- surface_dim: screen_well, // --screen-well
- surface_bright: screen_raised, // --screen-raised
+ surface: screen,
+ surface_dim: screen_well,
+ surface_bright: screen_raised,
surface_container_lowest: screen_well,
surface_container_low: screen,
surface_container: screen_raised,
surface_container_high: amber_30,
surface_container_highest: amber_50,
- on_surface: amber_90, // --ink
- on_surface_variant: amber_70, // --ink-dim
- outline: amber_90, // --stroke
- outline_variant: amber_50, // --stroke-dim
- error: amber_100, // Amber Console: alarm = inverse/blink, never a new hue
+ on_surface: amber_90,
+ on_surface_variant: amber_70,
+ outline: amber_90,
+ outline_variant: amber_50,
+ error: amber_100,
on_error: on_fill,
inverse_surface: amber_90,
inverse_on_surface: on_fill,
inverse_primary: amber_100,
- corner_radius: 8, // --radius: 8px
- stroke_width: 2.0, // --border-w: 2px
+ corner_radius: 8,
+ stroke_width: 2.0,
}
}
@@ -414,7 +767,15 @@ mod tests {
assert_eq!(classic.primary, modern.primary);
assert_ne!(classic.surface_container, modern.surface_container);
assert_eq!(modern.primary_container, [0x4F, 0x37, 0x8B]);
- assert_eq!(modern.corner_radius, 12);
+ assert_eq!(modern.corner_radius, 13);
+ }
+
+ #[test]
+ fn classic_has_surface_ladder() {
+ let c = theme_tokens(AppearanceTheme::ClassicGhidrust, ThemeMode::Dark);
+ assert_ne!(c.surface, c.surface_container_high);
+ assert_ne!(c.surface_container, c.surface_container_highest);
+ assert_ne!(c.surface_dim, c.surface_bright);
}
#[test]
@@ -439,4 +800,44 @@ mod tests {
assert!(!a.display_name().is_empty());
}
}
+
+ #[test]
+ fn theme_spec_packs_drive_chrome_without_gui_forks() {
+ let classic = theme_spec(AppearanceTheme::ClassicGhidrust, ThemeMode::Dark);
+ let modern = theme_spec(AppearanceTheme::Modern, ThemeMode::Dark);
+ let future = theme_spec(AppearanceTheme::FutureConsole, ThemeMode::Light);
+
+ assert!(classic.dark_base);
+ assert!(!theme_spec(AppearanceTheme::Modern, ThemeMode::Light).dark_base);
+ assert!(future.dark_base); // CRT always dark base
+
+ assert_eq!(classic.density, ThemeDensity::FIB_DESKTOP);
+ assert_eq!(modern.density, ThemeDensity::FIB_DESKTOP);
+ assert_eq!(future.density, ThemeDensity::FIB_CONSOLE);
+ assert_eq!(classic.density.button_padding, [FibScale::LG, FibScale::MD]);
+ assert_eq!(future.density.button_padding, [FibScale::XL, FibScale::LG]);
+ assert_eq!(classic.density.win_md, [FibScale::XL8, FibScale::XL7]);
+
+ assert!(matches!(classic.state_layers.hover, HoverFill::PrimaryGamma(_)));
+ assert!(matches!(
+ modern.state_layers.hover,
+ HoverFill::PrimaryContainerGamma(_)
+ ));
+ assert!(matches!(future.state_layers.hover, HoverFill::SurfaceBright));
+ assert!(matches!(future.elevation.popup_shadow, ElevationShadow::None));
+ assert!(matches!(
+ classic.elevation.popup_shadow,
+ ElevationShadow::Level2
+ ));
+
+ assert_eq!(theme_tokens(AppearanceTheme::Modern, ThemeMode::Dark), modern.colors);
+ }
+
+ #[test]
+ fn semantics_follow_mode_for_classic() {
+ let dark = theme_spec(AppearanceTheme::ClassicGhidrust, ThemeMode::Dark);
+ let light = theme_spec(AppearanceTheme::ClassicGhidrust, ThemeMode::Light);
+ assert_eq!(dark.semantics, ThemeSemantics::DARK_CODE);
+ assert_eq!(light.semantics, ThemeSemantics::LIGHT_CODE);
+ }
}
diff --git a/crates/ghidrust-gui/src/agent_pane.rs b/crates/ghidrust-gui/src/agent_pane.rs
index 3551f2b..f69d9f3 100644
--- a/crates/ghidrust-gui/src/agent_pane.rs
+++ b/crates/ghidrust-gui/src/agent_pane.rs
@@ -43,6 +43,8 @@ pub struct GrokPaneState {
pub skill_wired_root: Option<PathBuf>,
/// Fail-loud skill wire error (shown above the checklist when auto-install fails).
pub skill_wire_error: Option<String>,
+ /// Start checklist drawer open (pre-session only; hidden once Grok runs).
+ pub checklist_drawer_open: bool,
}
impl GrokPaneState {
@@ -59,6 +61,7 @@ impl GrokPaneState {
request_term_focus: false,
skill_wired_root: None,
skill_wire_error: None,
+ checklist_drawer_open: true,
}
}
@@ -190,7 +193,10 @@ pub fn render_grok_pane(
state.stop_session();
let (cols, rows) = (100u16, 28u16);
match on_start(cols, rows) {
- Ok(()) => state.status = None,
+ Ok(()) => {
+ state.status = None;
+ state.checklist_drawer_open = false;
+ }
Err(e) => {
state.last_error = Some(e);
}
@@ -206,6 +212,8 @@ pub fn render_grok_pane(
Ok(()) => {
state.last_error = None;
state.status = None;
+ // Drawer vanishes with the session; keep it closed for Stop.
+ state.checklist_drawer_open = false;
}
Err(e) => state.last_error = Some(e),
}
@@ -238,17 +246,19 @@ pub fn render_grok_pane(
ui.separator();
- // Start checklist — fail-loud rows for mcp/skill/agents/context so a
- // broken setup is visible immediately instead of a silently toolless agent.
+ // Pre-session only: auto-wire skill + Start checklist drawer. Once Grok is
+ // running the drawer disappears so the TUI owns the pane.
if let Some(root) = project_root {
// Auto-place embedded skill as soon as a project is visible in the Grok
// pane (not only on Start). Idempotent; fail-loud on write errors.
ensure_skill_for_project(state, root, None);
- if let Some(err) = &state.skill_wire_error {
- ui.colored_label(Color32::from_rgb(0xE5, 0x39, 0x35), err);
+ if state.session.is_none() {
+ if let Some(err) = &state.skill_wire_error {
+ ui.colored_label(Color32::from_rgb(0xE5, 0x39, 0x35), err);
+ }
+ render_start_checklist_drawer(ui, state, root, muted);
+ ui.separator();
}
- render_start_checklist(ui, root, muted);
- ui.separator();
}
if state.session.is_none() {
@@ -342,23 +352,40 @@ pub fn ensure_skill_for_project(
}
}
-/// Render the Start checklist as fail-loud rows (red text + actionable detail
-/// on failure) so a broken Grok session setup is visible before the user
-/// wonders why the agent has no MCP tools.
-pub fn render_start_checklist(ui: &mut Ui, project_root: &Path, muted: Color32) {
- ui.small(RichText::new("Start checklist").color(muted).strong());
- for row in pane_start_checklist(project_root) {
- let color = if row.ok {
- Color32::from_rgb(0x66, 0xBB, 0x6A)
- } else {
- Color32::from_rgb(0xE5, 0x39, 0x35)
- };
- ui.horizontal(|ui| {
- ui.label(if row.ok { "✓" } else { "✗" });
- ui.label(RichText::new(&row.label).color(color));
- ui.small(RichText::new(&row.detail).color(muted));
+/// Render the Start checklist as a collapsible drawer of fail-loud rows
+/// (red text + actionable detail on failure). Caller must only invoke this
+/// when no Grok session is running — the drawer disappears after Start.
+pub fn render_start_checklist_drawer(
+ ui: &mut Ui,
+ state: &mut GrokPaneState,
+ project_root: &Path,
+ muted: Color32,
+) {
+ let rows = pane_start_checklist(project_root);
+ let fail_n = rows.iter().filter(|r| !r.ok).count();
+ let title = if fail_n == 0 {
+ "Start checklist".to_string()
+ } else {
+ format!("Start checklist ({fail_n} failing)")
+ };
+ let resp = egui::CollapsingHeader::new(RichText::new(title).color(muted).strong())
+ .id_salt("grok_start_checklist_drawer")
+ .default_open(state.checklist_drawer_open)
+ .show(ui, |ui| {
+ for row in &rows {
+ let color = if row.ok {
+ Color32::from_rgb(0x66, 0xBB, 0x6A)
+ } else {
+ Color32::from_rgb(0xE5, 0x39, 0x35)
+ };
+ ui.horizontal(|ui| {
+ ui.label(if row.ok { "✓" } else { "✗" });
+ ui.label(RichText::new(&row.label).color(color));
+ ui.small(RichText::new(&row.detail).color(muted));
+ });
+ }
});
- }
+ state.checklist_drawer_open = resp.fully_open();
}
/// Attempt to spawn the platform's official Grok Build installer.
diff --git a/crates/ghidrust-gui/src/app/center_panes.rs b/crates/ghidrust-gui/src/app/center_panes.rs
index cda4ee6..1180f05 100644
--- a/crates/ghidrust-gui/src/app/center_panes.rs
+++ b/crates/ghidrust-gui/src/app/center_panes.rs
@@ -2,6 +2,8 @@
//!
//! Extracted per demonolith Wave 5.
+use ghidrust_core::FibScale;
+use crate::layout_tokens::{FieldWidth, WinTier};
use super::{
first_address_hint, first_scalar_hint, token_style, GhidrustApp,
NewTypeKind,
@@ -21,7 +23,7 @@ use crate::menu_actions::{
use crate::nav::NavLocation;
use crate::panes::{BookmarkKind, PaneKind};
use eframe::egui::{self, Color32};
-use ghidrust_core::{CommentKind, BUILTIN_TYPES};
+use ghidrust_core::{CommentKind, BUILTIN_TYPES, ThemeDensity};
use std::collections::BTreeMap;
impl GhidrustApp {
@@ -64,17 +66,17 @@ impl GhidrustApp {
.color(muted),
);
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
ui.horizontal(|ui| {
let card = |ui: &mut egui::Ui, title: &str, value: String| {
ui.group(|ui| {
- ui.set_min_width(120.0);
+ ui.set_min_width(FibScale::XL4);
ui.label(egui::RichText::new(title).small().color(muted));
ui.label(
egui::RichText::new(value)
.strong()
.color(primary)
- .size(18.0),
+ .size(FibScale::XL),
);
});
};
@@ -89,7 +91,7 @@ impl GhidrustApp {
card(ui, "Sections", format!("{}", prog.sections.len()));
});
- ui.add_space(10.0);
+ ui.add_space(FibScale::LG);
if !self.last_analyzers_run.is_empty() {
ui.label(egui::RichText::new("Analyzers last run / saved").strong());
ui.horizontal_wrapped(|ui| {
@@ -102,14 +104,14 @@ impl GhidrustApp {
}
if !self.rtti.notes.is_empty() {
- ui.add_space(6.0);
+ ui.add_space(FibScale::SM);
ui.label(egui::RichText::new("RTTI notes").strong());
for n in &self.rtti.notes {
ui.small(n);
}
}
- ui.add_space(12.0);
+ ui.add_space(FibScale::LG);
ui.separator();
ui.label(egui::RichText::new("What to do next").strong());
ui.label("• Symbol Tree (right): expand Classes / RTTI, type a filter, scroll the list.");
@@ -127,10 +129,10 @@ impl GhidrustApp {
// Sample of first few RTTI hits for confidence without opening the full drawer
if !self.rtti.classes.is_empty() {
- ui.add_space(10.0);
+ ui.add_space(FibScale::LG);
ui.label(egui::RichText::new("RTTI sample (first 12)").strong());
egui::ScrollArea::vertical()
- .max_height(160.0)
+ .max_height(FibScale::XL5)
.show(ui, |ui| {
for c in self.rtti.classes.iter().take(12) {
let va = c
@@ -148,6 +150,7 @@ impl GhidrustApp {
/// draw all edit dialogs (rename / retype / comment / signature / new type).
pub(crate) fn draw_edit_dialogs(&mut self, ctx: &egui::Context) {
+ let d = self.theme_spec().density;
// Rename dialog .
if self.show_rename_dialog {
let mut close = false;
@@ -248,7 +251,7 @@ impl GhidrustApp {
.id(egui::Id::new("dialog_comment"))
.collapsible(false)
.resizable(true)
- .default_width(420.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
if let Some(va) = va {
@@ -328,7 +331,7 @@ impl GhidrustApp {
.id(egui::Id::new("dialog_fn_sig"))
.collapsible(false)
.resizable(true)
- .default_width(520.0)
+ .default_width(WinTier::Md.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
if let Some(entry) = entry {
@@ -391,7 +394,7 @@ impl GhidrustApp {
.id(egui::Id::new("dialog_new_type"))
.collapsible(false)
.resizable(true)
- .default_width(560.0)
+ .default_width(WinTier::Md.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
ui.label("Name:");
@@ -436,7 +439,7 @@ impl GhidrustApp {
.id(egui::Id::new("dialog_edit_type"))
.collapsible(false)
.resizable(true)
- .default_width(560.0)
+ .default_width(WinTier::Md.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
ui.label("Name:");
@@ -489,7 +492,7 @@ impl GhidrustApp {
.id(egui::Id::new("dialog_type_chooser"))
.collapsible(false)
.resizable(true)
- .default_width(420.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
if let Some(va) = va {
@@ -501,7 +504,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.type_chooser_filter)
- .desired_width(240.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Type name…"),
);
});
@@ -513,7 +516,7 @@ impl GhidrustApp {
.unwrap_or_default();
egui::ScrollArea::vertical()
.id_salt("type_chooser_scroll")
- .max_height(280.0)
+ .max_height(d.scroll_sm)
.show(ui, |ui| {
for name in BUILTIN_TYPES {
if !q.is_empty() && !name.to_ascii_lowercase().contains(&q) {
@@ -598,7 +601,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.dtm_filter)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Type name…"),
);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
@@ -1521,6 +1524,7 @@ impl GhidrustApp {
// Render tokenised lines.
let visuals = ui.visuals().clone();
let text_color = visuals.text_color();
+ let syntax = self.theme_spec().semantics;
let cross_line = self.decomp_cross_line;
let highlight_text = self.decomp_highlight_text.clone();
let mut clicked_addr: Option<u64> = None;
@@ -1559,7 +1563,7 @@ impl GhidrustApp {
.selectable(false),
);
for tok in &line.tokens {
- let (color, italic) = token_style(&tok.kind, text_color);
+ let (color, italic) = token_style(&tok.kind, text_color, &syntax);
let highlighted = highlight_text
.as_deref()
.map(|h| h == tok.text)
diff --git a/crates/ghidrust-gui/src/app/dialogs.rs b/crates/ghidrust-gui/src/app/dialogs.rs
index ad50d47..399ec96 100644
--- a/crates/ghidrust-gui/src/app/dialogs.rs
+++ b/crates/ghidrust-gui/src/app/dialogs.rs
@@ -3,15 +3,17 @@
//! Extracted per demonolith Wave 7. Nested under `app` for private field access.
use super::{ConfigureSection, GhidrustApp};
+use crate::layout_tokens::{FieldWidth, WinTier};
use crate::listing::ui_options_dialog;
use crate::menu_actions::{parse_address, processor_info};
use crate::panes::BookmarkKind;
use eframe::egui::{self, Color32};
-use ghidrust_core::{analyzer_supports_gpu, AppearanceTheme, ThemeMode};
+use ghidrust_core::{analyzer_supports_gpu, AppearanceTheme, ThemeMode, ThemeDensity};
impl GhidrustApp {
/// Draw configure/layouts/goto/search/analysis/GPU dialogs.
pub(crate) fn draw_shell_dialogs(&mut self, ctx: &egui::Context) {
+ let d = self.theme_spec().density;
if self.show_search_address_tables_dialog {
let mut open = true;
@@ -80,13 +82,13 @@ impl GhidrustApp {
egui::Window::new("Configure")
.id(egui::Id::new("dialog_configure"))
.resizable(true)
- .default_size(egui::vec2(760.0, 520.0))
+ .default_size(WinTier::Lg.size(&d))
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.vertical(|ui| {
- ui.set_min_width(140.0);
+ ui.set_min_width(d.panel_symbol_min);
ui.strong("Configure");
- ui.add_space(6.0);
+ ui.add_space(d.space_sm);
if ui
.selectable_label(
next_section == ConfigureSection::Appearance,
@@ -114,7 +116,7 @@ impl GhidrustApp {
ui.label(
"Select a theme family. Classic Ghidrust is the historical default.",
);
- ui.add_space(8.0);
+ ui.add_space(d.space_md);
for theme in AppearanceTheme::ALL {
let selected = next_appearance == *theme;
if ui
@@ -131,7 +133,7 @@ impl GhidrustApp {
});
}
}
- ui.add_space(12.0);
+ ui.add_space(d.space_lg);
ui.separator();
ui.horizontal(|ui| {
let mode_caption = match next_appearance {
@@ -182,7 +184,7 @@ impl GhidrustApp {
ui.separator();
egui::ScrollArea::vertical()
.id_salt("configure_scroll")
- .max_height(360.0)
+ .max_height(d.scroll_md)
.show(ui, |ui| {
egui::Grid::new("configure_grid")
.num_columns(4)
@@ -236,7 +238,7 @@ impl GhidrustApp {
egui::Window::new("Tool Layouts")
.id(egui::Id::new("dialog_layouts"))
.resizable(true)
- .default_size(egui::vec2(480.0, 360.0))
+ .default_size(WinTier::Md.size(&d))
.show(ctx, |ui| {
ui.label("Save / restore CodeBrowser tool layouts (pane visibility + docks).");
ui.small(
@@ -250,7 +252,7 @@ impl GhidrustApp {
ui.label("Name:");
ui.add(
egui::TextEdit::singleline(&mut self.layouts_new_name)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("MyCodeBrowser"),
);
if ui
@@ -270,7 +272,7 @@ impl GhidrustApp {
} else {
egui::ScrollArea::vertical()
.id_salt("layouts_scroll")
- .max_height(180.0)
+ .max_height(d.scroll_sm)
.show(ui, |ui| {
for name in &self.layouts_cached {
ui.horizontal(|ui| {
@@ -412,7 +414,7 @@ impl GhidrustApp {
egui::Window::new("Search Memory")
.collapsible(false)
.resizable(true)
- .default_width(420.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
ui.label("Byte pattern (hex; ?? = wildcard):");
@@ -440,7 +442,7 @@ impl GhidrustApp {
egui::Window::new("Search Program Text")
.collapsible(false)
.resizable(true)
- .default_width(420.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
ui.label("Query (listing / symbols / functions / memory text):");
@@ -501,7 +503,7 @@ impl GhidrustApp {
egui::Window::new("Search Instruction Patterns")
.collapsible(false)
.resizable(true)
- .default_width(420.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
ui.small("Matches against decoded listing rows. Empty field = don't filter.");
@@ -601,7 +603,7 @@ impl GhidrustApp {
egui::Window::new("Search Results")
.collapsible(true)
.resizable(true)
- .default_width(480.0)
+ .default_width(WinTier::Md.width(&d))
.default_height(280.0)
.show(ctx, |ui| {
if ui.button("Close").clicked() {
@@ -653,7 +655,7 @@ impl GhidrustApp {
egui::Window::new("Processor Options")
.collapsible(false)
.resizable(true)
- .default_width(440.0)
+ .default_width(WinTier::Sm.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
if let Some(prog) = &self.program {
@@ -675,7 +677,7 @@ impl GhidrustApp {
ui.separator();
ui.label("Sections:");
egui::ScrollArea::vertical()
- .max_height(160.0)
+ .max_height(d.panel_symbol_min)
.show(ui, |ui| {
for s in &prog.sections {
ui.monospace(format!(
@@ -707,7 +709,7 @@ impl GhidrustApp {
egui::Window::new("GPU Decompile")
.collapsible(false)
.resizable(true)
- .default_width(560.0)
+ .default_width(WinTier::Md.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
crate::tool_panes::ui_gpu_decompile_dialog_header(
@@ -744,7 +746,7 @@ impl GhidrustApp {
egui::Window::new("Analysis options")
.collapsible(false)
.resizable(true)
- .default_width(460.0)
+ .default_width(WinTier::Md.width(&d))
.anchor(egui::Align2::CENTER_CENTER, [0.0, 0.0])
.show(ctx, |ui| {
if let Some(ref id) = self.pending_analyze_file_id {
@@ -759,7 +761,7 @@ impl GhidrustApp {
.strong()
.color(primary),
);
- ui.add_space(4.0);
+ ui.add_space(d.space_xs);
}
ui.label("Select analyzers (labels):");
ui.horizontal(|ui| {
@@ -780,7 +782,7 @@ impl GhidrustApp {
}
});
egui::ScrollArea::vertical()
- .max_height(320.0)
+ .max_height(d.scroll_md)
.show(ui, |ui| {
for (i, info) in self.analyzer_infos.iter().enumerate() {
ui.horizontal(|ui| {
@@ -841,7 +843,7 @@ impl GhidrustApp {
Large images are multi-dispatch chunked (≤65535 workgroups). \
Falls back to CPU on failure. GPU decompile is a separate tool.",
);
- ui.add_space(8.0);
+ ui.add_space(d.space_md);
ui.horizontal(|ui| {
let can_run = self.analyzer_enabled.iter().any(|e| *e)
&& (self.program.is_some() || self.pending_analyze_file_id.is_some());
diff --git a/crates/ghidrust-gui/src/app/menus.rs b/crates/ghidrust-gui/src/app/menus.rs
index 85be29c..246b6c8 100644
--- a/crates/ghidrust-gui/src/app/menus.rs
+++ b/crates/ghidrust-gui/src/app/menus.rs
@@ -500,14 +500,13 @@ impl GhidrustApp {
}
});
ui.menu_button("Window", |ui| {
- // Docked panels (long-standing).
+ // Keep the open menu short — providers live in hover submenus.
ui.label(egui::RichText::new("Docked").small().weak());
ui.checkbox(&mut self.show_project_tree, "Project Tree (dock)");
ui.checkbox(&mut self.show_program_tree, "Program Tree (dock)");
ui.checkbox(&mut self.show_symbol_tree, "Symbol Tree (dock)");
ui.checkbox(&mut self.show_console, "Console (dock)");
ui.separator();
- // Center dock tabs (Listing/Decompiler prefer side-by-side).
ui.label(egui::RichText::new("Center Tabs").small().weak());
if ui
.selectable_label(self.center == CenterPane::Overview, "Overview")
@@ -534,46 +533,34 @@ impl GhidrustApp {
self.focus_center_tab(DockTab::DataTypes);
}
ui.separator();
- // Full provider catalog (floating windows).
- // Sorted alphabetically by title to mirror Window menu.
- ui.label(
- egui::RichText::new("All Providers (catalog)")
- .small()
- .weak(),
- );
- let mut providers: Vec<PaneKind> = PaneKind::ALL.to_vec();
- providers.sort_by_key(|k| k.title());
- for k in providers {
- // Skip providers that are already covered by a dock/checkbox above
- // to avoid double-toggles (Project/Program/Symbol Tree, Console).
- if matches!(
- k,
- PaneKind::ProjectTree
- | PaneKind::ProgramTree
- | PaneKind::SymbolTree
- | PaneKind::Console
- | PaneKind::Overview
- | PaneKind::Listing
- | PaneKind::DecompiledView
- | PaneKind::DataTypeManager
- ) {
- continue;
- }
- if k == PaneKind::AgentConsole {
- if ui.button("Grok").clicked() {
- self.show_console = true;
- self.grok_pane.tab = crate::agent_pane::BottomTab::Grok;
- }
- continue;
- }
- let mut open = self.is_pane_open(k);
- if ui.checkbox(&mut open, k.title()).changed() {
- self.toggle_pane(k, open);
+ ui.menu_button("Providers", |ui| {
+ for group in PaneKind::WINDOW_MENU_GROUPS {
+ ui.menu_button(*group, |ui| {
+ let mut providers: Vec<PaneKind> = PaneKind::ALL
+ .iter()
+ .copied()
+ .filter(|k| k.window_menu_group() == Some(*group))
+ .collect();
+ providers.sort_by_key(|k| k.title());
+ for k in providers {
+ if k == PaneKind::AgentConsole {
+ if ui.button("Grok").clicked() {
+ self.show_console = true;
+ self.grok_pane.tab =
+ crate::agent_pane::BottomTab::Grok;
+ ui.close_menu();
+ }
+ continue;
+ }
+ let mut open = self.is_pane_open(k);
+ if ui.checkbox(&mut open, k.title()).changed() {
+ self.toggle_pane(k, open);
+ }
+ }
+ });
}
- }
+ });
ui.separator();
- // Single tabbed Debugger host.
- ui.label(egui::RichText::new("Debugger tool").small().weak());
let mut dbg_open = self.debugger.host_open;
if ui.checkbox(&mut dbg_open, "Debugger").changed() {
self.debugger.host_open = dbg_open;
@@ -585,18 +572,17 @@ impl GhidrustApp {
}
}
if self.debugger.host_open {
- ui.indent("dbg_tab_focus", |ui| {
+ ui.menu_button("Debugger tabs", |ui| {
for p in DebuggerPane::TAB_ORDER {
let selected = self.debugger.active_tab == *p;
- if ui.selectable_label(selected, p.short_title()).clicked() {
+ if ui.selectable_label(selected, p.short_title()).clicked()
+ {
self.debugger.focus_tab(*p);
+ ui.close_menu();
}
}
});
}
- ui.separator();
- // Single tabbed Network (Ghidnet) host.
- ui.label(egui::RichText::new("Network tool (Ghidnet)").small().weak());
let mut net_open = self.network.host_open;
if ui.checkbox(&mut net_open, "Network").changed() {
self.network.host_open = net_open;
@@ -605,17 +591,18 @@ impl GhidrustApp {
}
}
if self.network.host_open {
- ui.indent("net_tab_focus", |ui| {
+ ui.menu_button("Network tabs", |ui| {
for p in NetworkPane::TAB_ORDER {
let selected = self.network.active_tab == *p;
- if ui.selectable_label(selected, p.short_title()).clicked() {
+ if ui.selectable_label(selected, p.short_title()).clicked()
+ {
self.network.focus_tab(*p);
+ ui.close_menu();
}
}
});
}
ui.separator();
- // layout tools.
if ui.button("Configure plugins…").clicked() {
self.show_configure_dialog = true;
self.configure_section = ConfigureSection::Plugins;
diff --git a/crates/ghidrust-gui/src/app/mod.rs b/crates/ghidrust-gui/src/app/mod.rs
index 2537a16..0bbe051 100644
--- a/crates/ghidrust-gui/src/app/mod.rs
+++ b/crates/ghidrust-gui/src/app/mod.rs
@@ -30,6 +30,7 @@ use ghidrust_core::{
analyzer_catalog, set_preferred_bulk_mode, AnalysisRunReport, AnalyzerInfo,
AppearanceTheme, BulkScanMode, CommentKind, CryptConstantHit, CryptoCapabilityHit,
FoundString, Instruction, ObfuscatedStringHit, Program, Project, RttiReport, ThemeMode,
+ ThemeSemantics,
};
use crate::graphs::{
expand_tree_node, CallTreeNode, GraphPaneState,
@@ -535,24 +536,21 @@ pub(crate) fn first_address_hint(operands: &str) -> Option<String> {
Some(format!("target addr {va:#x}"))
}
-/// ``- syntax colour picker for the Decompiler pane.
-pub(crate) fn token_style(kind: &TokenKind, base: Color32) -> (Color32, bool) {
+/// Decompiler syntax colors from the active theme pack's semantic accents.
+pub(crate) fn token_style(
+ kind: &TokenKind,
+ base: Color32,
+ sem: &ThemeSemantics,
+) -> (Color32, bool) {
+ let rgb = |c: [u8; 3]| Color32::from_rgb(c[0], c[1], c[2]);
match kind {
- // Keywords: cyan .
- TokenKind::Keyword => (Color32::from_rgb(0x64, 0xB5, 0xF6), false),
- // Function names: warm orange.
- TokenKind::Function => (Color32::from_rgb(0xFF, 0xB7, 0x4D), false),
- // Variables: white/text default.
+ TokenKind::Keyword => (rgb(sem.syntax_keyword), false),
+ TokenKind::Function => (rgb(sem.syntax_function), false),
TokenKind::Variable => (base, false),
- // Block labels: purple.
- TokenKind::Label => (Color32::from_rgb(0xBA, 0x68, 0xC8), false),
- // Addresses: cyan for click-hint.
- TokenKind::Address => (Color32::from_rgb(0x4D, 0xD0, 0xE1), false),
- // Constants: lighter cyan.
- TokenKind::Constant => (Color32::from_rgb(0x80, 0xDE, 0xEA), false),
- // Comments: green italics.
- TokenKind::Comment => (Color32::from_rgb(0x81, 0xC7, 0x84), true),
- // Syntax / whitespace / newline: dimmed text.
+ TokenKind::Label => (rgb(sem.syntax_label), false),
+ TokenKind::Address => (rgb(sem.syntax_address), false),
+ TokenKind::Constant => (rgb(sem.syntax_constant), false),
+ TokenKind::Comment => (rgb(sem.syntax_comment), true),
TokenKind::Syntax => (base.gamma_multiply(0.85), false),
TokenKind::Whitespace => (base, false),
}
@@ -659,7 +657,7 @@ impl GhidrustApp {
path_input: String::new(),
project_dir_input: String::new(),
project_name_input: "MyProject".into(),
- status: "Ready — File → New/Open Project, then Import binary".into(),
+ status: "Ready — File → New/Open Project, then File → Import binary".into(),
console: vec!["Ghidrust CodeBrowser started.".into()],
theme: ThemeMode::Dark,
project: None,
@@ -683,7 +681,7 @@ impl GhidrustApp {
show_program_tree: true,
show_symbol_tree: true,
show_console: true,
- console_height: 280.0,
+ console_height: ghidrust_core::ThemeDensity::FIB_DESKTOP.console_default,
show_analysis_dialog: false,
use_gpu_experimental: false,
pending_analyze_file_id: None,
@@ -881,18 +879,19 @@ impl eframe::App for GhidrustApp {
// Detect Grok TUI child exit before paint.
self.grok_pane.poll();
let screen_h = ctx.screen_rect().height();
+ let d = self.theme_spec().density;
// Own the height ourselves + paint a real drag grip. Built-in
// `resizable(true)` on TopBottomPanel is unreliable here (snaps
// back when content doesn't expand — egui #581 / 0.31).
- let max_h = (screen_h - 160.0).max(220.0);
- let min_h = 140.0;
+ let max_h = (screen_h - d.panel_symbol_min).max(d.scroll_sm);
+ let min_h = d.console_min;
self.console_height = self.console_height.clamp(min_h, max_h);
egui::TopBottomPanel::bottom("console")
.exact_height(self.console_height)
.show_separator_line(false)
.show(ctx, |ui| {
// Full-width drag strip at the top of the dock.
- let grip_h = 10.0;
+ let grip_h = d.console_grip;
let (grip_rect, grip_resp) = ui.allocate_exact_size(
egui::vec2(ui.available_width(), grip_h),
egui::Sense::drag(),
@@ -906,11 +905,13 @@ impl eframe::App for GhidrustApp {
};
ui.painter().rect_filled(grip_rect, 0.0, grip_color);
// Center handle bar.
- let bar =
- egui::Rect::from_center_size(grip_rect.center(), egui::vec2(48.0, 3.0));
+ let bar = egui::Rect::from_center_size(
+ grip_rect.center(),
+ egui::vec2(d.console_handle_w, d.space_xs),
+ );
ui.painter().rect_filled(
bar,
- 1.5,
+ d.space_xs / 2.0,
ui.visuals().widgets.noninteractive.fg_stroke.color,
);
if grip_resp.hovered() || grip_resp.dragged() {
@@ -1031,7 +1032,7 @@ impl eframe::App for GhidrustApp {
let primary = Color32::from_rgb(t.primary[0], t.primary[1], t.primary[2]);
let ok = Color32::from_rgb(0x4C, 0xAF, 0x50);
ui.horizontal(|ui| {
- m3_icon(ui, M3Icon::CheckCircle, 18.0, ok);
+ m3_icon(ui, M3Icon::CheckCircle, self.theme_spec().density.icon_md, ok);
ui.label(egui::RichText::new(banner).color(primary).strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("Dismiss").clicked() {
@@ -1083,7 +1084,7 @@ impl eframe::App for GhidrustApp {
.anchor(egui::Align2::CENTER_BOTTOM, [0.0, -48.0])
.title_bar(true)
.show(ctx, |ui| {
- ui.set_min_width(360.0);
+ ui.set_min_width(self.theme_spec().density.scroll_md);
if let Some(job) = &self.analysis_job {
let n = job.names.len().max(1);
let step = (job.index + 1).min(n);
@@ -1102,9 +1103,9 @@ impl eframe::App for GhidrustApp {
ui.small("GPU experimental bulk path enabled");
}
}
- ui.add_space(6.0);
+ ui.add_space(self.theme_spec().density.space_sm);
m3_linear_progress(ui, frac, primary, track);
- ui.add_space(2.0);
+ ui.add_space(ghidrust_core::FibScale::XXS);
ui.small(format!("{:.0}%", frac * 100.0));
});
}
diff --git a/crates/ghidrust-gui/src/app/provider_panes.rs b/crates/ghidrust-gui/src/app/provider_panes.rs
index 0b850f2..d34a221 100644
--- a/crates/ghidrust-gui/src/app/provider_panes.rs
+++ b/crates/ghidrust-gui/src/app/provider_panes.rs
@@ -2,6 +2,7 @@
//!
//! Extracted per demonolith Wave 4.
+use ghidrust_core::ThemeDensity;
use super::{render_call_tree_node, GhidrustApp};
use crate::dock_tabs::DockTab;
use crate::graphs::{
@@ -9,6 +10,7 @@ use crate::graphs::{
layout_function_graph, render_call_graph, render_function_graph, FunctionGraphLayout,
};
use crate::menu_actions::STAGE0_MAX_INSNS;
+use crate::layout_tokens::WinTier;
use crate::panes::{BookmarkKind, PaneKind};
use crate::scripts::{
render_mcp_repl, render_script_manager, render_text_editor, TextEditorRequest,
@@ -25,6 +27,7 @@ impl GhidrustApp {
/// pending" empty state that names the analyzer/model responsible for filling
/// them. See `crate::panes::empty_state` for the shared template.
pub(crate) fn draw_provider_panes(&mut self, ctx: &egui::Context) {
+ let d = self.theme_spec().density;
let t = self.tokens();
let muted = Color32::from_rgb(
t.on_surface_variant[0],
@@ -48,7 +51,7 @@ impl GhidrustApp {
.id(id)
.open(&mut open)
.resizable(true)
- .default_size(egui::vec2(520.0, 360.0));
+ .default_size(WinTier::Md.size(&d));
match kind {
PaneKind::Bookmarks => {
@@ -174,53 +177,53 @@ impl GhidrustApp {
}
// Graphs & maps.
PaneKind::FunctionGraph => {
- win.default_size(egui::vec2(760.0, 520.0))
+ win.default_size(WinTier::Lg.size(&d))
.show(ctx, |ui| self.ui_function_graph_pane(ui, muted, primary));
}
PaneKind::FunctionCallGraph => {
- win.default_size(egui::vec2(760.0, 480.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
self.ui_function_call_graph_pane(ui, muted, primary)
});
}
PaneKind::FunctionCallTrees => {
- win.default_size(egui::vec2(760.0, 460.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
self.ui_function_call_trees_pane(ui, muted, primary)
});
}
PaneKind::Entropy => {
- win.default_size(egui::vec2(680.0, 220.0))
+ win.default_size(WinTier::Md.size(&d))
.show(ctx, |ui| self.ui_entropy_pane(ui, muted, primary));
}
PaneKind::Overview => {
- win.default_size(egui::vec2(680.0, 340.0))
+ win.default_size(WinTier::Md.size(&d))
.show(ctx, |ui| self.ui_overview(ui));
}
PaneKind::RegisterManager => {
- win.default_size(egui::vec2(560.0, 520.0))
+ win.default_size(WinTier::Lg.size(&d))
.show(ctx, |ui| self.ui_register_manager_pane(ui, muted, primary));
}
// Scripts & interpreters.
PaneKind::ScriptManager => {
- win.default_size(egui::vec2(760.0, 480.0))
+ win.default_size(WinTier::Lg.size(&d))
.show(ctx, |ui| self.ui_script_manager_pane(ui, muted, primary));
}
PaneKind::TextEditor => {
- win.default_size(egui::vec2(720.0, 520.0))
+ win.default_size(WinTier::Lg.size(&d))
.show(ctx, |ui| self.ui_text_editor_pane(ui, muted, primary));
}
PaneKind::Python => {
- win.default_size(egui::vec2(640.0, 420.0))
+ win.default_size(WinTier::Md.size(&d))
.show(ctx, |ui| self.ui_mcp_repl_pane(ui, muted, primary));
}
// Agent Friction Closure §13 — tool panes (real backends).
PaneKind::Il2cppMetadata => {
- win.default_size(egui::vec2(720.0, 560.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_il2cpp_metadata(ui, &mut self.tool_panes.il2cpp_meta, muted);
});
}
PaneKind::Il2cppMethods => {
let prog = self.program.as_ref();
- win.default_size(egui::vec2(760.0, 560.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Xl.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_il2cpp_methods(
ui,
&mut self.tool_panes.il2cpp_methods,
@@ -231,7 +234,7 @@ impl GhidrustApp {
}
PaneKind::Il2cppIcalls => {
let prog = self.program.as_ref();
- win.default_size(egui::vec2(760.0, 560.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Xl.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_il2cpp_icalls(
ui,
&mut self.tool_panes.il2cpp_icalls,
@@ -242,7 +245,7 @@ impl GhidrustApp {
}
PaneKind::Il2cppTouchMap => {
let prog = self.program.as_ref();
- win.default_size(egui::vec2(760.0, 560.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Xl.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_il2cpp_touch_map(
ui,
&mut self.tool_panes.il2cpp_touch_map,
@@ -253,7 +256,7 @@ impl GhidrustApp {
}
PaneKind::Il2cppStubs => {
let prog = self.program.as_ref();
- win.default_size(egui::vec2(760.0, 560.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Xl.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_il2cpp_stubs(
ui,
&mut self.tool_panes.il2cpp_stubs,
@@ -263,7 +266,7 @@ impl GhidrustApp {
});
}
PaneKind::UnityInventory => {
- win.default_size(egui::vec2(760.0, 520.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_unity_inventory(
ui,
&mut self.tool_panes.unity_inventory,
@@ -272,7 +275,7 @@ impl GhidrustApp {
});
}
PaneKind::InstallInventory => {
- win.default_size(egui::vec2(760.0, 520.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_install_inventory(
ui,
&mut self.tool_panes.install_inventory,
@@ -281,7 +284,7 @@ impl GhidrustApp {
});
}
PaneKind::FileSystemBrowser => {
- win.default_size(egui::vec2(720.0, 520.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Lg.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_file_system_browser(
ui,
&mut self.tool_panes.fs_browser,
@@ -290,7 +293,7 @@ impl GhidrustApp {
});
}
PaneKind::AnalysisArtifacts => {
- win.default_size(egui::vec2(820.0, 520.0)).show(ctx, |ui| {
+ win.default_size(WinTier::Xl.size(&d)).show(ctx, |ui| {
crate::tool_panes::ui_analysis_artifacts(
ui,
&mut self.tool_panes.artifacts,
@@ -554,7 +557,7 @@ impl GhidrustApp {
let mut goto: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("calltrees_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
ui.columns(2, |cols| {
cols[0].label(egui::RichText::new("Incoming (callers / refs to)").strong());
@@ -634,7 +637,7 @@ impl GhidrustApp {
));
let clicked_e =
crate::entropy::render_entropy_strip(ui, &samples, muted, self.listing_focus_va, primary);
- ui.add_space(6.0);
+ ui.add_space(ThemeDensity::FIB_DESKTOP.space_sm);
ui.label(egui::RichText::new("Overview").strong().color(muted));
let clicked_o = crate::entropy::render_overview_strip(
ui,
diff --git a/crates/ghidrust-gui/src/app/session_api.rs b/crates/ghidrust-gui/src/app/session_api.rs
index 3a4c7e8..9cb43cc 100644
--- a/crates/ghidrust-gui/src/app/session_api.rs
+++ b/crates/ghidrust-gui/src/app/session_api.rs
@@ -1269,6 +1269,11 @@ impl GhidrustApp {
crate::theme::tokens(self.appearance, self.theme)
}
+ /// Resolve the full swappable theme pack (colors + chrome + semantics).
+ pub fn theme_spec(&self) -> ghidrust_core::ThemeSpec {
+ crate::theme::spec(self.appearance, self.theme)
+ }
+
pub fn apply_theme(&self, ctx: &egui::Context) {
crate::theme::apply(ctx, self.appearance, self.theme)
}
diff --git a/crates/ghidrust-gui/src/app/shell_chrome.rs b/crates/ghidrust-gui/src/app/shell_chrome.rs
index ccbc804..16488af 100644
--- a/crates/ghidrust-gui/src/app/shell_chrome.rs
+++ b/crates/ghidrust-gui/src/app/shell_chrome.rs
@@ -1,4 +1,7 @@
-//! Shell chrome — nav toolbar, main toolbar, status bar.
+//! Shell chrome — nav toolbar and status bar.
+//!
+//! Project / binary open-import-load-analyze-save live in File / Analysis menus
+//! (and Project Tree), not duplicated under the menubar.
//!
//! Extracted per demonolith Wave 3. Nested under `app` for private field access.
@@ -8,7 +11,7 @@ use crate::panes::{BookmarkKind, PaneKind};
use eframe::egui::{self, Color32};
impl GhidrustApp {
- /// Draw nav toolbar, main toolbar, and status bar panels.
+ /// Draw nav toolbar and status bar panels.
pub(crate) fn draw_shell_chrome(&mut self, ctx: &egui::Context) {
egui::TopBottomPanel::top("nav_toolbar").show(ctx, |ui| {
ui.horizontal(|ui| {
@@ -97,140 +100,6 @@ impl GhidrustApp {
});
});
- egui::TopBottomPanel::top("toolbar").show(ctx, |ui| {
- ui.horizontal(|ui| {
- ui.label("Project dir:");
- ui.add(
- egui::TextEdit::singleline(&mut self.project_dir_input)
- .desired_width(240.0)
- .hint_text("folder for New/Open project"),
- );
- if ui
- .button("Browse…")
- .on_hover_text("Choose project folder")
- .clicked()
- {
- self.browse_project_dir();
- }
- ui.label("Name:");
- ui.add(
- egui::TextEdit::singleline(&mut self.project_name_input).desired_width(100.0),
- );
- if ui
- .button("New")
- .on_hover_text("Create project (browse if dir empty)")
- .clicked()
- {
- if self.project_dir_input.trim().is_empty() {
- self.browse_and_create_project();
- } else if let Err(e) = self.create_project() {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- if ui
- .button("Open")
- .on_hover_text("Open project (browse if dir empty)")
- .clicked()
- {
- if self.project_dir_input.trim().is_empty() {
- self.browse_and_open_project();
- } else if let Err(e) = self.open_project() {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- });
- ui.horizontal(|ui| {
- ui.label("Binary:");
- ui.add(
- egui::TextEdit::singleline(&mut self.path_input)
- .desired_width(320.0)
- .hint_text("PE/ELF — or use Browse"),
- );
- if ui
- .button("Browse…")
- .on_hover_text("Choose binary file")
- .clicked()
- {
- self.browse_binary_path();
- }
- if ui
- .button("Import")
- .on_hover_text("Import into project (browse if empty)")
- .clicked()
- {
- if self.path_input.trim().is_empty() {
- self.browse_and_import();
- } else if let Err(e) = self.import_into_project() {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- if ui
- .button("Load")
- .on_hover_text("Load binary without project (browse if empty)")
- .clicked()
- {
- if self.path_input.trim().is_empty() {
- self.browse_and_load_binary();
- } else {
- let p = self.path_input.clone();
- if let Err(e) = self.load_binary(p) {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- }
- if ui
- .button("Analyze…")
- .on_hover_text("Open analysis options (analyzers + GPU)")
- .clicked()
- {
- self.pending_analyze_file_id = self.active_file_id.clone();
- self.show_analysis_dialog = true;
- }
- if ui.button("Save").clicked() {
- if let Err(e) = self.save_results() {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- });
- let file_chips: Vec<(String, String, String)> = self
- .project
- .as_ref()
- .map(|p| {
- let pname = p.meta.name.clone();
- let files = p
- .meta
- .files
- .iter()
- .map(|f| (f.id.clone(), f.display_name.clone()))
- .collect::<Vec<_>>();
- files
- .into_iter()
- .map(|(id, name)| (pname.clone(), id, name))
- .collect()
- })
- .unwrap_or_default();
- if !file_chips.is_empty() {
- let pname = file_chips[0].0.clone();
- ui.horizontal(|ui| {
- ui.label(format!("Open: {pname} | files:"));
- for (_, id, name) in &file_chips {
- let selected = self.active_file_id.as_deref() == Some(id.as_str());
- if ui.selectable_label(selected, name).clicked() {
- if let Err(e) = self.open_project_file(id) {
- self.status = format!("error: {e}");
- self.log(self.status.clone());
- }
- }
- }
- });
- }
- });
-
egui::TopBottomPanel::bottom("status").show(ctx, |ui| {
if let Some(frac) = self.analysis_progress_fraction() {
let t = self.tokens();
diff --git a/crates/ghidrust-gui/src/app/side_trees.rs b/crates/ghidrust-gui/src/app/side_trees.rs
index c249ea7..f7a4b9c 100644
--- a/crates/ghidrust-gui/src/app/side_trees.rs
+++ b/crates/ghidrust-gui/src/app/side_trees.rs
@@ -11,12 +11,13 @@ use std::collections::{BTreeMap, BTreeSet};
impl GhidrustApp {
/// Draw left/right tree side panels.
pub(crate) fn draw_side_trees(&mut self, ctx: &egui::Context) {
+ let d = self.theme_spec().density;
// Project Window–style dock: Project → binaries (upgraded badges + actions)
if self.show_project_tree {
egui::SidePanel::left("project_tree")
.resizable(true)
- .default_width(240.0)
+ .default_width(d.panel_project)
.show(ctx, |ui| {
ui.heading("Project");
ui.small(
@@ -40,7 +41,7 @@ impl GhidrustApp {
);
let ok_green = Color32::from_rgb(0x4C, 0xAF, 0x50);
ui.horizontal(|ui| {
- m3_icon(ui, M3Icon::Folder, 18.0, primary);
+ m3_icon(ui, M3Icon::Folder, d.icon_md, primary);
ui.strong(&model.project_name);
});
// Fill remaining panel height and scroll when files overflow
@@ -53,7 +54,7 @@ impl GhidrustApp {
.default_open(self.project_tree_expanded)
.show(ui, |ui| {
ui.small(egui::RichText::new(&model.project_root).weak());
- ui.add_space(4.0);
+ ui.add_space(d.space_xs);
if model.files.is_empty() {
ui.weak("Empty — Import a binary.");
}
@@ -73,11 +74,11 @@ impl GhidrustApp {
m3_icon(
ui,
M3Icon::PlayArrow,
- 14.0,
+ d.icon_sm,
primary,
);
} else {
- ui.add_space(14.0);
+ ui.add_space(d.icon_sm);
}
let resp = ui.selectable_label(
selected || viewing,
@@ -152,7 +153,7 @@ impl GhidrustApp {
.italics(),
);
});
- ui.add_space(2.0);
+ ui.add_space(d.space_xs);
}
(open_id, analyze_id, delete_id, select_id)
})
@@ -198,7 +199,7 @@ impl GhidrustApp {
Deletes the imported copy and saved analysis for this file.\n\
This cannot be undone."
));
- ui.add_space(8.0);
+ ui.add_space(d.space_md);
ui.horizontal(|ui| {
if ui.button("Cancel").clicked() {
self.cancel_delete_file();
@@ -223,7 +224,7 @@ impl GhidrustApp {
if self.show_program_tree {
egui::SidePanel::left("program_tree")
.resizable(true)
- .default_width(220.0)
+ .default_width(d.panel_program)
.show(ctx, |ui| {
ui.heading("Program Trees");
ui.small(egui::RichText::new("ProgramTreePlugin · modules/fragments").weak());
@@ -257,7 +258,7 @@ impl GhidrustApp {
self.tokens().primary[1],
self.tokens().primary[2],
);
- m3_icon(ui, M3Icon::Folder, 16.0, primary);
+ m3_icon(ui, M3Icon::Folder, d.icon_sm, primary);
ui.strong(&root_name);
});
ui.small(
@@ -417,8 +418,8 @@ impl GhidrustApp {
if self.show_symbol_tree {
egui::SidePanel::right("symbol_tree")
.resizable(true)
- .default_width(280.0)
- .min_width(200.0)
+ .default_width(d.panel_symbol)
+ .min_width(d.panel_symbol_min)
.show(ctx, |ui| {
let t = self.tokens();
let primary = Color32::from_rgb(t.primary[0], t.primary[1], t.primary[2]);
@@ -547,7 +548,7 @@ impl GhidrustApp {
let mut clicked_fn: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("fn_scroll")
- .max_height(220.0)
+ .max_height(d.scroll_sm)
.show_rows(ui, row_h, n, |ui, range| {
for i in range {
let (va, name) = &rows[i];
@@ -613,7 +614,7 @@ impl GhidrustApp {
let mut clicked_va: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("labels_scroll")
- .max_height(220.0)
+ .max_height(d.scroll_sm)
.show_rows(ui, row_h, n, |ui, range| {
for i in range {
let (va, name) = &labels[i];
@@ -687,7 +688,7 @@ impl GhidrustApp {
egui::ScrollArea::vertical()
.id_salt("rtti_scroll")
.auto_shrink([false, false])
- .max_height(220.0)
+ .max_height(d.scroll_sm)
.show_rows(ui, row_h, idxs.len(), |ui, range| {
for i in range {
let c = &self.rtti.classes[idxs[i]];
@@ -791,7 +792,7 @@ impl GhidrustApp {
let row_h = ui.text_style_height(&egui::TextStyle::Monospace);
egui::ScrollArea::vertical()
.id_salt("str_scroll")
- .max_height(200.0)
+ .max_height(d.scroll_sm)
.show_rows(ui, row_h, str_n.min(5000), |ui, range| {
for i in range {
if let Some(s) = self.strings.get(i) {
diff --git a/crates/ghidrust-gui/src/app/table_panes.rs b/crates/ghidrust-gui/src/app/table_panes.rs
index 4906236..bebfca3 100644
--- a/crates/ghidrust-gui/src/app/table_panes.rs
+++ b/crates/ghidrust-gui/src/app/table_panes.rs
@@ -3,6 +3,9 @@
//! Extracted per demonolith Wave 7. New pane bodies land here (or provider_panes),
//! not in `mod.rs`.
+use ghidrust_core::FibScale;
+use ghidrust_core::ThemeDensity;
+use crate::layout_tokens::{card_frame, chip_frame, sized_button_height, FieldWidth};
use super::GhidrustApp;
use crate::checksum::ChecksumMode;
use crate::decrypt_ui::DecryptTab;
@@ -66,6 +69,7 @@ impl GhidrustApp {
pub(crate) fn ui_startup_picker(&mut self, ctx: &egui::Context) {
let t = self.tokens();
+ let d = self.theme_spec().density;
let primary = Color32::from_rgb(t.primary[0], t.primary[1], t.primary[2]);
let muted = Color32::from_rgb(
t.on_surface_variant[0],
@@ -78,63 +82,74 @@ impl GhidrustApp {
t.surface_container[2],
);
- // Fixed card size — never wider than the window, never stretch off-screen.
- let card_w = 440.0_f32.min(ctx.screen_rect().width() - 48.0).max(280.0);
+ // Fib card width — clamp to viewport with Fib chrome insets.
+ let card_w = d
+ .field_wide
+ .min(ctx.screen_rect().width() - d.console_handle_w)
+ .max(d.scroll_sm);
egui::CentralPanel::default().show(ctx, |ui| {
ui.vertical_centered(|ui| {
- ui.add_space(32.0);
- ui.heading(egui::RichText::new("Ghidrust").size(26.0).color(primary));
+ ui.add_space(FibScale::XL2);
+ ui.heading(
+ egui::RichText::new("Ghidrust")
+ .size(d.control_min_height - FibScale::MD)
+ .color(primary),
+ );
if let Some(tex) = self.logo_texture.as_ref() {
- ui.add_space(10.0);
- let logo_h = 112.0_f32;
+ ui.add_space(FibScale::LG);
+ let logo_h = d.field_narrow + FibScale::XL2; // 89+34 = 123 ≈ prior 112
let size = tex.size_vec2();
- let logo_w = (logo_h * size.x / size.y).clamp(64.0, 160.0);
+ let logo_w = (logo_h * size.x / size.y).clamp(d.field_micro + FibScale::SM, d.field_compact);
ui.add(egui::Image::new(tex).fit_to_exact_size(egui::vec2(logo_w, logo_h)));
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
} else {
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
}
ui.label(
egui::RichText::new("Open a project to reverse engineer")
.color(muted)
- .size(14.0),
+ .size(FibScale::LG),
);
- ui.add_space(20.0);
+ ui.add_space(FibScale::XL);
- egui::Frame::group(ui.style())
+ card_frame(ui, &d)
.fill(surface)
- .inner_margin(egui::Margin::same(16))
- .corner_radius(egui::CornerRadius::same(8))
.show(ui, |ui| {
ui.set_width(card_w);
ui.set_max_width(card_w);
// ── Recent projects (IDE-style list) ──
- ui.label(egui::RichText::new("Recent projects").strong().size(13.0));
- ui.add_space(6.0);
+ ui.label(
+ egui::RichText::new("Recent projects")
+ .strong()
+ .size(FibScale::LG),
+ );
+ ui.add_space(FibScale::SM);
let recents = self.recent_projects.clone();
- let list_h = if recents.is_empty() { 48.0 } else { 200.0 };
+ let list_h = if recents.is_empty() {
+ d.console_handle_w
+ } else {
+ d.field_std
+ };
- egui::Frame::NONE
+ chip_frame(ui, &d)
.stroke(ui.visuals().widgets.noninteractive.bg_stroke)
- .inner_margin(egui::Margin::same(4))
- .corner_radius(egui::CornerRadius::same(4))
.show(ui, |ui| {
- ui.set_width(card_w - 8.0);
+ ui.set_width(card_w - d.space_md);
egui::ScrollArea::vertical()
.id_salt("startup_recent")
.max_height(list_h)
.auto_shrink([false, false])
.show(ui, |ui| {
- ui.set_min_width(card_w - 24.0);
+ ui.set_min_width(card_w - FibScale::XL);
if recents.is_empty() {
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
ui.weak(
"No recent projects — open or create one below.",
);
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
} else {
let mut open_path: Option<String> = None;
for path in &recents {
@@ -143,8 +158,8 @@ impl GhidrustApp {
.map(|s| s.to_string_lossy().into_owned())
.unwrap_or_else(|| path.clone());
// IDE-style row: project name + path, full-width click
- let row_w = (card_w - 24.0).max(200.0);
- let row_h = 44.0;
+ let row_w = (card_w - FibScale::XL).max(d.field_std);
+ let row_h = sized_button_height(&d) + FibScale::LG;
let (rect, resp) = ui.allocate_exact_size(
egui::vec2(row_w, row_h),
egui::Sense::click(),
@@ -152,14 +167,14 @@ impl GhidrustApp {
if resp.hovered() || resp.has_focus() {
ui.painter().rect_filled(
rect,
- egui::CornerRadius::same(4),
+ egui::CornerRadius::same(FibScale::SM as u8),
primary.gamma_multiply(0.15),
);
}
let mut child = ui.new_child(
egui::UiBuilder::new()
.max_rect(
- rect.shrink2(egui::vec2(10.0, 6.0)),
+ rect.shrink2(egui::vec2(FibScale::LG, FibScale::SM)),
)
.layout(egui::Layout::top_down(
egui::Align::LEFT,
@@ -169,7 +184,7 @@ impl GhidrustApp {
egui::RichText::new(&name)
.strong()
.color(primary)
- .size(14.0),
+ .size(FibScale::LG),
);
child.label(
egui::RichText::new(path).small().color(muted),
@@ -191,14 +206,15 @@ impl GhidrustApp {
});
});
- ui.add_space(14.0);
+ ui.add_space(FibScale::LG);
ui.separator();
- ui.add_space(10.0);
+ ui.add_space(FibScale::LG);
// Buttons fit card width only (no off-screen stretch)
- let btn_w = card_w - 8.0;
+ let btn_w = card_w - d.space_md;
+ let btn_h = sized_button_height(&d);
if ui
- .add_sized([btn_w, 32.0], egui::Button::new("Open existing project…"))
+ .add_sized([btn_w, btn_h], egui::Button::new("Open existing project…"))
.clicked()
{
self.browse_and_open_project();
@@ -206,18 +222,20 @@ impl GhidrustApp {
self.show_startup_picker = true;
}
}
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
ui.horizontal(|ui| {
ui.label("Name:");
ui.add(
egui::TextEdit::singleline(&mut self.project_name_input)
- .desired_width((btn_w - 56.0).max(120.0))
+ .desired_width(
+ (btn_w - d.field_micro).max(FieldWidth::Compact.px(&d)),
+ )
.hint_text("MyProject"),
);
});
- ui.add_space(4.0);
+ ui.add_space(FibScale::XS);
if ui
- .add_sized([btn_w, 32.0], egui::Button::new("Create new project…"))
+ .add_sized([btn_w, btn_h], egui::Button::new("Create new project…"))
.clicked()
{
self.browse_and_create_project();
@@ -225,13 +243,14 @@ impl GhidrustApp {
self.show_startup_picker = true;
}
}
- ui.add_space(12.0);
+ ui.add_space(FibScale::LG);
if ui.link("Continue without a project").clicked() {
self.show_startup_picker = false;
self.status =
- "No project — Browse/Load a binary, or File → Open Project".into();
+ "No project — File → Open / Load binary, or File → Open Project"
+ .into();
}
- ui.add_space(4.0);
+ ui.add_space(FibScale::XS);
ui.small(
egui::RichText::new(
"Click a recent project name to open it. Analysis uses analysis.bin for fast load.",
@@ -342,7 +361,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.bookmark_filter)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("category or description"),
);
if ui
@@ -390,7 +409,7 @@ impl GhidrustApp {
egui::ScrollArea::vertical()
.id_salt("bookmarks_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("bookmarks_grid")
.num_columns(5)
@@ -455,17 +474,17 @@ impl GhidrustApp {
ui.label("Add block:");
ui.add(
egui::TextEdit::singleline(&mut self.memory_map_new_name)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("name"),
);
ui.add(
egui::TextEdit::singleline(&mut self.memory_map_new_va)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("VA (0x…)"),
);
ui.add(
egui::TextEdit::singleline(&mut self.memory_map_new_size)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("size (0x…)"),
);
ui.checkbox(&mut self.memory_map_new_r, "R");
@@ -556,7 +575,7 @@ impl GhidrustApp {
for (i, (name, va, size, r, w, x)) in blocks.iter().enumerate() {
let mut editable = name.clone();
if ui
- .add(egui::TextEdit::singleline(&mut editable).desired_width(120.0))
+ .add(egui::TextEdit::singleline(&mut editable).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)))
.changed()
{
rename = Some((i, editable));
@@ -651,7 +670,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.functions_window_filter)
- .desired_width(300.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Function name…"),
);
});
@@ -667,7 +686,7 @@ impl GhidrustApp {
let focus = self.decomp_entry;
egui::ScrollArea::vertical()
.id_salt("fnwin_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("functions_window_grid")
.num_columns(4)
@@ -720,7 +739,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.symbol_table_filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Symbol name…"),
);
});
@@ -741,7 +760,7 @@ impl GhidrustApp {
let mut show_refs: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("symtable_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("symbol_table_grid")
.num_columns(4)
@@ -925,7 +944,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.defined_strings_filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Substring…"),
);
ui.label("Encoding:");
@@ -949,7 +968,7 @@ impl GhidrustApp {
ui.small(format!("{} / {} strings", rows.len(), self.strings.len()));
egui::ScrollArea::vertical()
.id_salt("defstr_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("defined_strings_grid")
.num_columns(3)
@@ -1074,7 +1093,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.comment_window_filter)
- .desired_width(240.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Text / address / kind…"),
);
ui.label("Kind:");
@@ -1138,7 +1157,7 @@ impl GhidrustApp {
rows.sort_by_key(|(_, va, _)| *va);
egui::ScrollArea::vertical()
.id_salt("comment_window_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("comments_grid")
.num_columns(3)
@@ -1229,7 +1248,7 @@ impl GhidrustApp {
let mut goto: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("defined_data_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("defined_data_grid")
.num_columns(3)
@@ -1295,7 +1314,7 @@ impl GhidrustApp {
ui.horizontal(|ui| {
ui.label("VA:");
let mut input = format!("{base_va:#x}");
- let resp = ui.add(egui::TextEdit::singleline(&mut input).desired_width(140.0));
+ let resp = ui.add(egui::TextEdit::singleline(&mut input).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
if resp.lost_focus() {
if let Ok(v) = parse_address(&input) {
self.bytes_pane_va = Some(v);
@@ -1336,7 +1355,7 @@ impl GhidrustApp {
let mut nav: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("bytes_scroll")
- .max_height(420.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
for row in 0..self.bytes_pane_rows {
let row_va = base_va.wrapping_add((row * bpr) as u64);
@@ -1405,7 +1424,7 @@ impl GhidrustApp {
ui.label("Target:");
let resp = ui.add(
egui::TextEdit::singleline(&mut input)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("VA…"),
);
if resp.lost_focus() {
@@ -1414,7 +1433,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.symbol_refs_filter)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Substring…"),
);
if ui.button("Use cursor").clicked() {
@@ -1480,7 +1499,7 @@ impl GhidrustApp {
let mut goto: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("symrefs_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("symbol_refs_grid")
.num_columns(5)
@@ -1529,7 +1548,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.equates_filter)
- .desired_width(220.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Name / value…"),
);
if ui.button("Add equate at cursor…").clicked() {
@@ -1562,7 +1581,7 @@ impl GhidrustApp {
cols[0].separator();
egui::ScrollArea::vertical()
.id_salt("equates_left_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[0], |ui| {
egui::Grid::new("equates_groups_grid")
.num_columns(3)
@@ -1601,7 +1620,7 @@ impl GhidrustApp {
};
egui::ScrollArea::vertical()
.id_salt("equates_right_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[1], |ui| {
if refs.is_empty() {
ui.weak("Select an equate on the left to see its references.");
@@ -1699,7 +1718,7 @@ impl GhidrustApp {
ui.label("New:");
ui.add(
egui::TextEdit::singleline(&mut self.function_tags_new_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Tag name…"),
);
if ui.button("Add").clicked() {
@@ -1718,7 +1737,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.function_tags_filter)
- .desired_width(180.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Substring…"),
);
});
@@ -1726,7 +1745,7 @@ impl GhidrustApp {
let q = self.function_tags_filter.to_ascii_lowercase();
egui::ScrollArea::vertical()
.id_salt("all_tags_scroll")
- .max_height(320.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[1], |ui| {
egui::Grid::new("all_tags_grid")
.num_columns(3)
@@ -1785,7 +1804,7 @@ impl GhidrustApp {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut self.external_programs_filter)
- .desired_width(220.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Name / VA…"),
);
});
@@ -1800,7 +1819,7 @@ impl GhidrustApp {
let mut goto: Option<u64> = None;
egui::ScrollArea::vertical()
.id_salt("ext_progs_scroll")
- .max_height(400.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
ui.strong("Imports");
egui::Grid::new("ext_imports_grid")
@@ -1827,7 +1846,7 @@ impl GhidrustApp {
ui.end_row();
}
});
- ui.add_space(8.0);
+ ui.add_space(FibScale::MD);
ui.strong("Exports");
egui::Grid::new("ext_exports_grid")
.num_columns(3)
diff --git a/crates/ghidrust-gui/src/debugger.rs b/crates/ghidrust-gui/src/debugger.rs
index 65ebbbd..4516898 100644
--- a/crates/ghidrust-gui/src/debugger.rs
+++ b/crates/ghidrust-gui/src/debugger.rs
@@ -4,6 +4,8 @@
//! (same APIs as MCP/CLI). Mode **observe** (default) = read-only; **debug**
//! enables break/step/registers/stack.
+use crate::layout_tokens::{FieldWidth, WinTier};
+use ghidrust_core::ThemeDensity;
use eframe::egui::{self, Color32, RichText, Ui};
use ghidrust_core::process::{
process_attach_opts, process_break_clear, process_break_list, process_break_set,
@@ -1066,8 +1068,8 @@ pub fn draw_host(ctx: &egui::Context, state: &mut DebuggerState, muted: Color32)
.id(egui::Id::new(HOST_EGUI_ID))
.open(&mut open)
.resizable(true)
- .default_size(egui::vec2(720.0, 520.0))
- .min_size(egui::vec2(420.0, 280.0))
+ .default_size(WinTier::Lg.size(&ThemeDensity::FIB_DESKTOP))
+ .min_size(WinTier::Lg.min_size(&ThemeDensity::FIB_DESKTOP))
.show(ctx, |ui| {
// Fill the resized window so vertical growth isn't clamped by content.
let avail = ui.available_size();
@@ -1092,7 +1094,7 @@ pub fn draw_launch_dialog(ctx: &egui::Context, state: &mut DebuggerState, muted:
.open(&mut open)
.collapsible(false)
.resizable(true)
- .default_width(520.0)
+ .default_width(WinTier::Md.width(&ThemeDensity::FIB_DESKTOP))
.show(ctx, |ui| {
ui.small(
RichText::new(
@@ -1105,7 +1107,7 @@ pub fn draw_launch_dialog(ctx: &egui::Context, state: &mut DebuggerState, muted:
ui.label("Image:");
ui.add(
egui::TextEdit::singleline(&mut state.launch_image)
- .desired_width(360.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text(r"C:\path\to\app.exe"),
);
if ui.button("Browse…").clicked() {
@@ -1126,7 +1128,7 @@ pub fn draw_launch_dialog(ctx: &egui::Context, state: &mut DebuggerState, muted:
ui.label("Args:");
ui.add(
egui::TextEdit::singleline(&mut state.launch_args)
- .desired_width(400.0)
+ .desired_width(FieldWidth::XWide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("optional"),
);
});
@@ -1134,7 +1136,7 @@ pub fn draw_launch_dialog(ctx: &egui::Context, state: &mut DebuggerState, muted:
ui.label("Cwd:");
ui.add(
egui::TextEdit::singleline(&mut state.launch_cwd)
- .desired_width(360.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("optional working directory"),
);
if ui.button("Browse…").clicked() {
@@ -1342,7 +1344,7 @@ fn render_targets(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut state.targets_filter)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("process name…"),
);
});
@@ -1357,7 +1359,7 @@ fn render_targets(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("PID:");
ui.add(
egui::TextEdit::singleline(&mut state.attach_pid_input)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("1234"),
);
if ui
@@ -1445,7 +1447,7 @@ fn render_modules(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut state.modules_filter)
- .desired_width(180.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("module name…"),
);
});
@@ -1534,13 +1536,13 @@ fn render_modules(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("Module:");
ui.add(
egui::TextEdit::singleline(&mut state.static_map_module_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("game.exe"),
);
ui.label("RVA:");
ui.add(
egui::TextEdit::singleline(&mut state.static_map_rva_input)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x1000"),
);
if ui.button("Resolve").clicked() {
@@ -1616,13 +1618,13 @@ fn render_memory_bytes(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("VA:");
ui.add(
egui::TextEdit::singleline(&mut state.mem_bytes_va_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x140001000"),
);
ui.label("Size:");
ui.add(
egui::TextEdit::singleline(&mut state.mem_bytes_size_input)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("256"),
);
if ui.button("Read").clicked() {
@@ -1711,7 +1713,7 @@ fn render_breakpoints(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("Address:");
ui.add(
egui::TextEdit::singleline(&mut state.bp_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x7ff…"),
);
ui.checkbox(&mut state.bp_oneshot, "oneshot");
@@ -1791,7 +1793,7 @@ fn render_watches(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("Expr:");
ui.add(
egui::TextEdit::singleline(&mut state.watch_input)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("game.exe+0x1234->*+0x10"),
);
ui.checkbox(&mut state.watch_matrix_heuristic, "matrix heuristic");
@@ -1812,13 +1814,13 @@ fn render_watches(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
ui.label("AOB:");
ui.add(
egui::TextEdit::singleline(&mut state.scan_aob)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("48 8b ?? 90"),
);
ui.label("String:");
ui.add(
egui::TextEdit::singleline(&mut state.scan_string)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Camera"),
);
if ui.button("Scan").clicked() {
@@ -1861,7 +1863,7 @@ fn render_watches(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
let mut goto = None;
egui::ScrollArea::vertical()
.id_salt("dbg_scan_hits")
- .max_height(100.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.field_narrow)
.show(ui, |ui| {
for h in state.scan_hits.iter().take(64) {
if ui
@@ -2033,7 +2035,7 @@ fn render_registers(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
.or_insert_with(String::new);
let resp = ui.add(
egui::TextEdit::singleline(entry)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.font(egui::TextStyle::Monospace),
);
if resp.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
@@ -2140,7 +2142,7 @@ fn render_console(state: &mut DebuggerState, ui: &mut Ui, muted: Color32) {
egui::ScrollArea::vertical()
.id_salt("dbg_console")
.stick_to_bottom(true)
- .max_height(280.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
if state.console_log.is_empty() {
ui.weak("No events yet — type a command below.");
diff --git a/crates/ghidrust-gui/src/decrypt_ui.rs b/crates/ghidrust-gui/src/decrypt_ui.rs
index e26426d..43ed11b 100644
--- a/crates/ghidrust-gui/src/decrypt_ui.rs
+++ b/crates/ghidrust-gui/src/decrypt_ui.rs
@@ -1,9 +1,10 @@
//! Decrypt / crypto-result pane helpers for egui.
+use crate::layout_tokens::FieldWidth;
use eframe::egui::{self, Color32, Ui};
use ghidrust_core::{
bake, extract_iocs, magic, suggest_recipe_for_hint, BakeOp, CryptConstantHit,
- CryptoCapabilityHit, ObfuscatedStringHit, Program,
+ CryptoCapabilityHit, ObfuscatedStringHit, Program, ThemeDensity,
};
use std::cell::RefCell;
@@ -334,7 +335,7 @@ pub fn ui_crypto_constants(
return;
}
egui::ScrollArea::vertical()
- .max_height(420.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("crypt_const_grid")
.num_columns(4)
@@ -379,7 +380,7 @@ pub fn ui_recovered_strings(
return;
}
egui::ScrollArea::vertical()
- .max_height(420.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("recovered_str_grid")
.num_columns(5)
@@ -432,7 +433,7 @@ pub fn ui_crypto_capabilities(
return;
}
egui::ScrollArea::vertical()
- .max_height(420.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("crypto_cap_grid")
.num_columns(4)
@@ -595,7 +596,7 @@ fn ui_bake_tab(
ui.small(format!("Input source: {}", state.input_source));
ui.horizontal(|ui| {
ui.label("VA:");
- ui.add(egui::TextEdit::singleline(&mut state.va_input).desired_width(120.0));
+ ui.add(egui::TextEdit::singleline(&mut state.va_input).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
ui.label("Length:");
ui.add(egui::DragValue::new(&mut state.va_len).range(1..=0x10000));
if ui.button("Load VA").clicked() {
@@ -613,7 +614,7 @@ fn ui_bake_tab(
});
ui.horizontal(|ui| {
ui.label("File:");
- ui.add(egui::TextEdit::singleline(&mut state.file_path).desired_width(280.0));
+ ui.add(egui::TextEdit::singleline(&mut state.file_path).desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP)));
if ui.button("Load file").clicked() {
match std::fs::read(&state.file_path) {
Ok(bytes) => {
@@ -633,9 +634,9 @@ fn ui_bake_tab(
);
ui.horizontal(|ui| {
ui.label("Key hex:");
- ui.add(egui::TextEdit::singleline(&mut state.key_hex).desired_width(180.0));
+ ui.add(egui::TextEdit::singleline(&mut state.key_hex).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
ui.label("IV hex:");
- ui.add(egui::TextEdit::singleline(&mut state.iv_hex).desired_width(180.0));
+ ui.add(egui::TextEdit::singleline(&mut state.iv_hex).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
});
ui.horizontal(|ui| {
ui.label("Mode:");
@@ -647,9 +648,9 @@ fn ui_bake_tab(
}
});
ui.label("Nonce:");
- ui.add(egui::TextEdit::singleline(&mut state.nonce_hex).desired_width(130.0));
+ ui.add(egui::TextEdit::singleline(&mut state.nonce_hex).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
ui.label("Counter:");
- ui.add(egui::TextEdit::singleline(&mut state.counter).desired_width(55.0));
+ ui.add(egui::TextEdit::singleline(&mut state.counter).desired_width(FieldWidth::Micro.px(&ThemeDensity::FIB_DESKTOP)));
});
ui.horizontal(|ui| {
ui.label("Operation:");
@@ -670,7 +671,7 @@ fn ui_bake_tab(
});
ui.horizontal(|ui| {
ui.label("Magic crib:");
- ui.add(egui::TextEdit::singleline(&mut state.crib).desired_width(180.0));
+ ui.add(egui::TextEdit::singleline(&mut state.crib).desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP)));
if ui.button("Magic").clicked() {
state.bake_preset("magic");
}
diff --git a/crates/ghidrust-gui/src/icons.rs b/crates/ghidrust-gui/src/icons.rs
index b88c162..88e4913 100644
--- a/crates/ghidrust-gui/src/icons.rs
+++ b/crates/ghidrust-gui/src/icons.rs
@@ -2,6 +2,7 @@
//! Source paths: https://github.com/google/material-design-icons (Apache-2.0).
//! No emoji. No extra icon crates — paths are inlined and stroked/filled via Painter.
+use ghidrust_core::FibScale;
use eframe::egui::{self, Color32, Pos2, Rect, Sense, Stroke, Ui, Vec2};
/// Material Icons 24dp viewBox.
@@ -90,33 +91,34 @@ fn paint_icon(painter: &egui::Painter, rect: Rect, icon: M3Icon, color: Color32)
/// Material 3 linear progress indicator (4dp track + primary fill).
pub fn m3_linear_progress(ui: &mut Ui, fraction: f32, primary: Color32, track: Color32) {
- let height = 4.0;
- let width = ui.available_width().max(40.0);
+ let height = FibScale::SM;
+ let width = ui.available_width().max(FibScale::XL3);
let (rect, _) = ui.allocate_exact_size(Vec2::new(width, height), Sense::hover());
ui.painter()
- .rect_filled(rect, egui::CornerRadius::same(2), track);
+ .rect_filled(rect, egui::CornerRadius::same(FibScale::XXS as u8), track);
let f = fraction.clamp(0.0, 1.0);
if f > 0.0 {
let mut fill = rect;
- fill.set_width((rect.width() * f).max(if f > 0.0 { 2.0 } else { 0.0 }));
+ fill.set_width((rect.width() * f).max(if f > 0.0 { FibScale::XXS } else { 0.0 }));
ui.painter()
- .rect_filled(fill, egui::CornerRadius::same(2), primary);
+ .rect_filled(fill, egui::CornerRadius::same(FibScale::XXS as u8), primary);
}
}
/// Status row: Material check_circle or radio_button_unchecked + label text (no emoji).
pub fn status_badge(ui: &mut Ui, analyzed: bool, analyzed_color: Color32, muted: Color32) {
+ use ghidrust_core::FibScale;
ui.horizontal(|ui| {
- ui.spacing_mut().item_spacing.x = 4.0;
+ ui.spacing_mut().item_spacing.x = FibScale::SM;
if analyzed {
- m3_icon(ui, M3Icon::CheckCircle, 14.0, analyzed_color);
+ m3_icon(ui, M3Icon::CheckCircle, FibScale::LG, analyzed_color);
ui.label(
egui::RichText::new("Analyzed")
.small()
.color(analyzed_color),
);
} else {
- m3_icon(ui, M3Icon::RadioUnchecked, 14.0, muted);
+ m3_icon(ui, M3Icon::RadioUnchecked, FibScale::LG, muted);
ui.label(egui::RichText::new("Not analyzed").small().color(muted));
}
});
diff --git a/crates/ghidrust-gui/src/layout_tokens.rs b/crates/ghidrust-gui/src/layout_tokens.rs
new file mode 100644
index 0000000..c341569
--- /dev/null
+++ b/crates/ghidrust-gui/src/layout_tokens.rs
@@ -0,0 +1,266 @@
+//! Fibonacci layout helpers over [`ThemeDensity`].
+//!
+//! Call sites pick a [`WinTier`], [`FieldWidth`], or scroll/space token — never raw chrome literals.
+
+use eframe::egui::{self, Frame, Margin, Ui, Vec2};
+use ghidrust_core::ThemeDensity;
+
+/// Dialog / floating-window size tier (values from the active density pack).
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum WinTier {
+ /// Tiny forms (rename, confirm).
+ Xs,
+ /// Search / goto / single-column edit.
+ Sm,
+ /// Options / layouts / medium tools.
+ Md,
+ /// Configure / debugger / default providers.
+ Lg,
+ /// Network host / large tool hosts.
+ Xl,
+}
+
+impl WinTier {
+ /// Default `[width, height]` for this tier.
+ pub fn size(self, d: &ThemeDensity) -> Vec2 {
+ let wh = match self {
+ WinTier::Xs => d.win_xs,
+ WinTier::Sm => d.win_sm,
+ WinTier::Md => d.win_md,
+ WinTier::Lg => d.win_lg,
+ WinTier::Xl => d.win_xl,
+ };
+ Vec2::new(wh[0], wh[1])
+ }
+
+ /// Minimum size — one Fib window step down from the default tier.
+ pub fn min_size(self, d: &ThemeDensity) -> Vec2 {
+ match self {
+ WinTier::Xs => Vec2::new(d.scroll_sm, d.panel_symbol_min),
+ WinTier::Sm => WinTier::Xs.size(d),
+ WinTier::Md => WinTier::Sm.size(d),
+ WinTier::Lg => WinTier::Xs.size(d),
+ WinTier::Xl => WinTier::Md.size(d),
+ }
+ }
+
+ pub fn width(self, d: &ThemeDensity) -> f32 {
+ self.size(d).x
+ }
+
+ #[allow(dead_code)]
+ pub fn height(self, d: &ThemeDensity) -> f32 {
+ self.size(d).y
+ }
+}
+
+/// TextEdit / table column width tier (Fibonacci).
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum FieldWidth {
+ /// 55 — tiny status / port columns.
+ Micro,
+ /// 89 — short codes / small numeric.
+ Narrow,
+ /// 144 — addresses / medium labels.
+ Compact,
+ /// 233 — paths / names.
+ Std,
+ /// 377 — long paths / filters.
+ Wide,
+ /// 610 — very wide editors.
+ XWide,
+}
+
+impl FieldWidth {
+ pub fn px(self, d: &ThemeDensity) -> f32 {
+ match self {
+ FieldWidth::Micro => d.field_micro,
+ FieldWidth::Narrow => d.field_narrow,
+ FieldWidth::Compact => d.field_compact,
+ FieldWidth::Std => d.field_std,
+ FieldWidth::Wide => d.field_wide,
+ FieldWidth::XWide => d.field_xwide,
+ }
+ }
+}
+
+/// Card / group frame: Fib inner margin + style corner radius.
+pub fn card_frame(ui: &Ui, d: &ThemeDensity) -> Frame {
+ Frame::group(ui.style()).inner_margin(Margin::same(d.space_lg as i8))
+}
+
+/// Nested chip / inset frame.
+pub fn chip_frame(_ui: &Ui, d: &ThemeDensity) -> Frame {
+ Frame::NONE
+ .inner_margin(Margin::same(d.space_xs as i8))
+ .corner_radius(egui::CornerRadius::same(d.space_sm as u8))
+}
+
+/// Min height for explicitly sized buttons.
+pub fn sized_button_height(d: &ThemeDensity) -> f32 {
+ d.control_min_height
+}
+
+/// Convenience accessors matching density field names.
+#[allow(dead_code)]
+pub trait DensityExt {
+ fn density(&self) -> &ThemeDensity;
+
+ fn space_xs(&self) -> f32 {
+ self.density().space_xs
+ }
+ fn space_sm(&self) -> f32 {
+ self.density().space_sm
+ }
+ fn space_md(&self) -> f32 {
+ self.density().space_md
+ }
+ fn space_lg(&self) -> f32 {
+ self.density().space_lg
+ }
+ fn space_xl(&self) -> f32 {
+ self.density().space_xl
+ }
+ fn scroll_sm(&self) -> f32 {
+ self.density().scroll_sm
+ }
+ fn scroll_md(&self) -> f32 {
+ self.density().scroll_md
+ }
+ fn scroll_lg(&self) -> f32 {
+ self.density().scroll_lg
+ }
+ fn icon_sm(&self) -> f32 {
+ self.density().icon_sm
+ }
+ fn icon_md(&self) -> f32 {
+ self.density().icon_md
+ }
+ fn win(&self, tier: WinTier) -> Vec2 {
+ tier.size(self.density())
+ }
+ fn field(&self, w: FieldWidth) -> f32 {
+ w.px(self.density())
+ }
+}
+
+impl DensityExt for ThemeDensity {
+ fn density(&self) -> &ThemeDensity {
+ self
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use ghidrust_core::{FibScale, ThemeDensity};
+ use std::fs;
+ use std::path::PathBuf;
+
+ #[test]
+ fn win_tiers_are_fib() {
+ let d = ThemeDensity::FIB_DESKTOP;
+ assert_eq!(WinTier::Xs.size(&d), Vec2::new(377.0, 233.0));
+ assert_eq!(WinTier::Sm.size(&d), Vec2::new(377.0, 377.0));
+ assert_eq!(WinTier::Md.size(&d), Vec2::new(610.0, 377.0));
+ assert_eq!(WinTier::Lg.size(&d), Vec2::new(610.0, 610.0));
+ assert_eq!(WinTier::Xl.size(&d), Vec2::new(987.0, 610.0));
+ assert_eq!(WinTier::Md.height(&d), 377.0);
+ assert_eq!(d.scroll_md(), 377.0);
+ assert_eq!(d.win(WinTier::Lg), Vec2::new(610.0, 610.0));
+ }
+
+ #[test]
+ fn field_widths_are_fib() {
+ let d = ThemeDensity::FIB_DESKTOP;
+ assert_eq!(FieldWidth::Micro.px(&d), FibScale::XL3);
+ assert_eq!(FieldWidth::Narrow.px(&d), FibScale::XL4);
+ assert_eq!(FieldWidth::Compact.px(&d), FibScale::XL5);
+ assert_eq!(FieldWidth::Std.px(&d), FibScale::XL6);
+ assert_eq!(FieldWidth::Wide.px(&d), FibScale::XL7);
+ assert_eq!(FieldWidth::XWide.px(&d), FibScale::XL8);
+ assert_eq!(d.field(FieldWidth::Std), d.field_std);
+ assert_eq!(sized_button_height(&d), FibScale::XL2);
+ }
+
+ #[test]
+ fn no_raw_chrome_literals() {
+ let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src");
+ let mut violations = Vec::new();
+ walk_rs(&root, &mut |path, src| {
+ let rel = path
+ .strip_prefix(&root)
+ .unwrap_or(path)
+ .to_string_lossy()
+ .replace('\\', "/");
+ if is_allowlisted(&rel) {
+ return;
+ }
+ for (line_no, line) in src.lines().enumerate() {
+ let trimmed = line.trim();
+ if trimmed.starts_with("//") || trimmed.starts_with("///") {
+ continue;
+ }
+ if let Some(reason) = chrome_literal_reason(trimmed) {
+ violations.push(format!("{rel}:{}: {reason}: {trimmed}", line_no + 1));
+ }
+ }
+ });
+ assert!(
+ violations.is_empty(),
+ "raw chrome numeric literals found (use ThemeDensity / FieldWidth / WinTier / FibScale):\n{}",
+ violations.join("\n")
+ );
+ }
+
+ fn is_allowlisted(rel: &str) -> bool {
+ rel == "graphs.rs"
+ || rel.starts_with("grok_term/")
+ || rel.starts_with("app/tests.rs")
+ || rel.ends_with("/tests.rs")
+ || rel == "layout_tokens.rs" // this file's lint patterns are documentation
+ }
+
+ fn chrome_literal_reason(line: &str) -> Option<&'static str> {
+ // icons.rs: allow path paint coords; forbid chrome helpers with numeric literals.
+ let patterns: &[(&str, &str)] = &[
+ (r"max_height(", "max_height numeric"),
+ (r"min_height(", "min_height numeric"),
+ (r"default_width(", "default_width numeric"),
+ (r"default_size(egui::vec2(", "default_size numeric"),
+ (r"min_size(egui::vec2(", "min_size numeric"),
+ (r"min_width(", "min_width numeric"),
+ (r"add_space(", "add_space numeric"),
+ (r"desired_width(", "desired_width numeric"),
+ (r"Margin::same(", "Margin::same numeric"),
+ (r"CornerRadius::same(", "CornerRadius::same numeric"),
+ ];
+ for (needle, reason) in patterns {
+ if let Some(idx) = line.find(needle) {
+ let after = &line[idx + needle.len()..];
+ let after = after.trim_start();
+ if after.starts_with(|c: char| c.is_ascii_digit()) {
+ // Allow FibScale / density references — those don't start with a digit.
+ return Some(reason);
+ }
+ }
+ }
+ None
+ }
+
+ fn walk_rs(dir: &std::path::Path, f: &mut dyn FnMut(&std::path::Path, &str)) {
+ let Ok(entries) = fs::read_dir(dir) else {
+ return;
+ };
+ for entry in entries.flatten() {
+ let path = entry.path();
+ if path.is_dir() {
+ walk_rs(&path, f);
+ } else if path.extension().and_then(|e| e.to_str()) == Some("rs") {
+ if let Ok(src) = fs::read_to_string(&path) {
+ f(&path, &src);
+ }
+ }
+ }
+ }
+}
diff --git a/crates/ghidrust-gui/src/lib.rs b/crates/ghidrust-gui/src/lib.rs
index d86ffd7..811de14 100644
--- a/crates/ghidrust-gui/src/lib.rs
+++ b/crates/ghidrust-gui/src/lib.rs
@@ -17,6 +17,7 @@ mod graphs;
mod grok_term;
mod icons;
mod layouts;
+mod layout_tokens;
mod listing;
mod menu_actions;
mod nav;
diff --git a/crates/ghidrust-gui/src/listing/options.rs b/crates/ghidrust-gui/src/listing/options.rs
index 17253f4..512ba91 100644
--- a/crates/ghidrust-gui/src/listing/options.rs
+++ b/crates/ghidrust-gui/src/listing/options.rs
@@ -1,5 +1,6 @@
//! Full decode options dialog (arch/mode and engine options).
+use ghidrust_core::ThemeDensity;
use super::model::DecodeUiOpts;
use super::processor::ui_processor_selectors;
use ghidrust_core::Program;
@@ -18,7 +19,7 @@ pub fn ui_options_dialog(
egui::Window::new("Decode Options")
.collapsible(false)
.resizable(true)
- .default_width(480.0)
+ .default_width(ThemeDensity::FIB_DESKTOP.win_md[0])
.show(ctx, |ui| {
ui_processor_selectors(ui, opts, prog);
ui.separator();
diff --git a/crates/ghidrust-gui/src/listing/search.rs b/crates/ghidrust-gui/src/listing/search.rs
index 4cd1646..546f483 100644
--- a/crates/ghidrust-gui/src/listing/search.rs
+++ b/crates/ghidrust-gui/src/listing/search.rs
@@ -1,7 +1,8 @@
//! Filter listing rows by mnemonic / instruction id / group.
+use crate::layout_tokens::FieldWidth;
use ghidrust_core::ghidrust_decode::{group_name, insn_name};
-use ghidrust_core::{Arch, Instruction};
+use ghidrust_core::{Arch, Instruction, ThemeDensity};
/// User-entered listing filter (all fields are substring / prefix matches).
#[derive(Debug, Clone)]
@@ -69,17 +70,17 @@ pub fn ui_search_bar(ui: &mut egui::Ui, search: &mut ListingSearch) {
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut search.mnemonic)
- .desired_width(90.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("mnemonic"),
);
ui.add(
egui::TextEdit::singleline(&mut search.insn_id)
- .desired_width(70.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("id"),
);
ui.add(
egui::TextEdit::singleline(&mut search.group)
- .desired_width(90.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("group"),
);
if search.is_active() && ui.small_button("Clear").clicked() {
diff --git a/crates/ghidrust-gui/src/network.rs b/crates/ghidrust-gui/src/network.rs
index 16882ca..ce6b3a6 100644
--- a/crates/ghidrust-gui/src/network.rs
+++ b/crates/ghidrust-gui/src/network.rs
@@ -3,6 +3,8 @@
//! Investigation-first: Connections → Capture/Flows → Alerts → Dig.
//! Panes call `ghidrust-net-*` (same APIs as CLI/MCP). Not a packet browser.
+use crate::layout_tokens::{FieldWidth, WinTier};
+use ghidrust_core::ThemeDensity;
use eframe::egui::{self, Color32, RichText, Ui};
use ghidrust_net_attr::{list_connections, owner_for_pid, ConnFilter};
use ghidrust_net_capture::{
@@ -869,14 +871,19 @@ pub fn draw_host(ctx: &egui::Context, state: &mut NetworkState, muted: Color32)
ctx.request_repaint_after(Duration::from_millis(500));
}
+ let dens = ThemeDensity::FIB_DESKTOP;
let mut open = true;
let title = state.window_title();
+ let frame = egui::Frame::window(&ctx.style()).inner_margin(egui::Margin::same(
+ dens.space_sm as i8,
+ ));
egui::Window::new(title)
.id(egui::Id::new(HOST_EGUI_ID))
.open(&mut open)
.resizable(true)
- .default_size(egui::vec2(780.0, 560.0))
- .min_size(egui::vec2(440.0, 300.0))
+ .frame(frame)
+ .default_size(WinTier::Xl.size(&dens))
+ .min_size(WinTier::Xl.min_size(&dens))
.show(ctx, |ui| {
let avail = ui.available_size();
ui.set_min_size(avail);
@@ -888,40 +895,42 @@ pub fn draw_host(ctx: &egui::Context, state: &mut NetworkState, muted: Color32)
}
fn render_host_body(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
+ let dens = ThemeDensity::FIB_DESKTOP;
+ // Content-first: shrink host chrome so tables keep vertical space.
+ {
+ let s = ui.spacing_mut();
+ s.item_spacing = egui::vec2(dens.space_sm, dens.space_xs);
+ s.button_padding = egui::vec2(dens.space_sm, dens.space_xs);
+ s.interact_size.y = dens.space_xl;
+ }
+
let info = network_info();
let inline_on = inline_block_allowed();
ui.horizontal(|ui| {
- ui.label(
+ ui.small(
RichText::new(format!(
- "Ghidnet · wave={} · native={} · capture={} · inline={}",
- info.wave, info.native, info.capture, if inline_on { "on" } else { "off" }
+ "w{} · n={} · cap={} · {}",
+ info.wave,
+ info.native,
+ info.capture,
+ if inline_on { "inline" } else { "inline off" }
))
- .strong(),
- );
- ui.small(
- RichText::new(format!("caps: {}", info.caps.join(",")))
- .color(muted),
- );
- });
- ui.horizontal(|ui| {
- ui.label(RichText::new(state.status_line()).color(muted));
+ .color(muted),
+ )
+ .on_hover_text(format!("caps: {}", info.caps.join(",")));
+ ui.small(RichText::new(state.status_line()).color(muted));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let inline_resp = ui
- .add_enabled(inline_on, egui::Button::new("Inline block").small())
+ .add_enabled(inline_on, egui::Button::new("Inline").small())
.on_hover_text(inline_block_reason());
if inline_resp.clicked() {
state.status = inline_block_reason().into();
}
- if !inline_on {
- ui.small(RichText::new("inline off").color(muted))
- .on_hover_text(inline_block_reason());
- }
});
});
if let Some(e) = state.last_error.clone() {
ui.colored_label(Color32::from_rgb(0xE5, 0x39, 0x35), e);
}
- ui.separator();
egui::ScrollArea::horizontal()
.id_salt("net_tab_strip")
@@ -929,7 +938,11 @@ fn render_host_body(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.horizontal(|ui| {
for tab in NetworkPane::TAB_ORDER {
let selected = state.active_tab == *tab;
- if ui.selectable_label(selected, tab.short_title()).clicked() {
+ if ui
+ .selectable_label(selected, RichText::new(tab.short_title()).small())
+ .on_hover_text(tab.plugin())
+ .clicked()
+ {
state.active_tab = *tab;
}
}
@@ -938,8 +951,6 @@ fn render_host_body(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.separator();
let pane = state.active_tab;
- ui.small(RichText::new(format!("Provider · {}", pane.plugin())).color(muted));
- ui.separator();
match pane {
NetworkPane::Connections => render_connections(state, ui, muted),
NetworkPane::Capture => render_capture(state, ui, muted),
@@ -950,42 +961,43 @@ fn render_host_body(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
}
fn render_connections(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
- ui.small(
- RichText::new("Owner-first sockets — Dig fills NetHint from the selected row.")
- .color(muted),
- );
+ let dens = ThemeDensity::FIB_DESKTOP;
ui.horizontal(|ui| {
- if ui.button("Refresh").clicked() {
+ if ui
+ .small_button("Refresh")
+ .on_hover_text("Owner-first sockets — Dig fills NetHint from the selected row.")
+ .clicked()
+ {
state.refresh_connections();
}
- ui.label("pid");
+ ui.small("pid");
ui.add(
egui::TextEdit::singleline(&mut state.conn_filter_pid)
- .desired_width(56.0)
+ .desired_width(FieldWidth::Micro.px(&dens))
.hint_text("any"),
);
- ui.label("path");
+ ui.small("path");
ui.add(
egui::TextEdit::singleline(&mut state.conn_filter_path)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&dens))
.hint_text("substr"),
);
- ui.label("proto");
+ ui.small("proto");
ui.add(
egui::TextEdit::singleline(&mut state.conn_filter_proto)
- .desired_width(48.0)
+ .desired_width(FieldWidth::Micro.px(&dens))
.hint_text("tcp"),
);
ui.checkbox(&mut state.conn_listening_only, "listening");
- ui.label("max");
+ ui.small("max");
ui.add(
egui::TextEdit::singleline(&mut state.conn_max)
- .desired_width(40.0)
+ .desired_width(FieldWidth::Micro.px(&dens))
.hint_text("256"),
);
let dig_en = state.selected_conn.is_some();
if ui
- .add_enabled(dig_en, egui::Button::new("Dig"))
+ .add_enabled(dig_en, egui::Button::new("Dig").small())
.on_hover_text("Compile dig hint from selection")
.clicked()
{
@@ -995,24 +1007,27 @@ fn render_connections(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
}
});
+ // Leave a thin owner strip; give the rest of the host to the table.
+ let owner_reserve = dens.space_xl + dens.space_lg;
+ let table_h = (ui.available_height() - owner_reserve).max(dens.scroll_md);
egui::ScrollArea::vertical()
.id_salt("net_conn_table")
- .max_height(280.0)
+ .max_height(table_h)
.show(ui, |ui| {
egui::Grid::new("net_conn_grid")
.num_columns(7)
.striped(true)
.show(ui, |ui| {
- ui.strong("Proto");
- ui.strong("Local");
- ui.strong("Remote");
- ui.strong("State");
- ui.strong("PID");
- ui.strong("Image");
- ui.strong("Conf");
+ ui.small(RichText::new("Proto").strong());
+ ui.small(RichText::new("Local").strong());
+ ui.small(RichText::new("Remote").strong());
+ ui.small(RichText::new("State").strong());
+ ui.small(RichText::new("PID").strong());
+ ui.small(RichText::new("Image").strong());
+ ui.small(RichText::new("Conf").strong());
ui.end_row();
if state.connections.is_empty() {
- ui.label(RichText::new("(empty — Refresh)").color(muted));
+ ui.label(RichText::new("(empty — Refresh)").small().color(muted));
ui.end_row();
}
let rows: Vec<(usize, ConnectionView)> = state
@@ -1023,15 +1038,17 @@ fn render_connections(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
.collect();
for (i, c) in rows {
let selected = state.selected_conn == Some(i);
- let resp = ui.selectable_label(selected, &c.proto);
+ let resp = ui.selectable_label(selected, RichText::new(&c.proto).small());
if resp.clicked() {
state.select_connection(i);
}
- ui.monospace(&c.local);
- ui.monospace(&c.remote);
- ui.label(&c.state);
- ui.label(c.pid.to_string());
- ui.monospace(c.image_path.as_deref().unwrap_or("—"));
+ ui.monospace(RichText::new(&c.local).small());
+ ui.monospace(RichText::new(&c.remote).small());
+ ui.small(&c.state);
+ ui.small(c.pid.to_string());
+ ui.monospace(
+ RichText::new(c.image_path.as_deref().unwrap_or("—")).small(),
+ );
ui.small(format!(
"{}/{}",
conf_badge(c.pid_confidence),
@@ -1043,17 +1060,16 @@ fn render_connections(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
});
ui.separator();
- ui.label(RichText::new("Owner detail").strong());
if let Some(o) = &state.selected_owner {
- ui.monospace(format!(
- "pid={} image={} pid_conf={} image_conf={}",
+ ui.small(format!(
+ "owner pid={} image={} conf={}/{}",
o.pid,
o.image_path.as_deref().unwrap_or("—"),
conf_badge(o.pid_confidence),
conf_badge(o.image_confidence)
));
} else {
- ui.small(RichText::new("Select a connection row.").color(muted));
+ ui.small(RichText::new("Select a row for owner detail.").color(muted));
}
}
@@ -1079,13 +1095,13 @@ fn render_capture(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("filter");
ui.add(
egui::TextEdit::singleline(&mut state.capture_filter)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("optional"),
);
ui.label("pid");
ui.add(
egui::TextEdit::singleline(&mut state.capture_pid)
- .desired_width(48.0)
+ .desired_width(FieldWidth::Micro.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("opt"),
);
});
@@ -1093,13 +1109,13 @@ fn render_capture(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("path");
ui.add(
egui::TextEdit::singleline(&mut state.capture_path_substr)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("owner substr"),
);
ui.label("replay");
ui.add(
egui::TextEdit::singleline(&mut state.capture_replay)
- .desired_width(180.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("path.grncap"),
);
if ui.button("Browse…").clicked() {
@@ -1113,7 +1129,7 @@ fn render_capture(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("out");
ui.add(
egui::TextEdit::singleline(&mut state.capture_out_dir)
- .desired_width(120.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("temp"),
);
});
@@ -1226,7 +1242,7 @@ fn render_capture(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label(RichText::new("Flows").strong());
egui::ScrollArea::vertical()
.id_salt("net_flows_table")
- .max_height(240.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
egui::Grid::new("net_flows_grid")
.num_columns(6)
@@ -1314,7 +1330,7 @@ fn render_alerts(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
egui::ScrollArea::vertical()
.id_salt("net_alerts_table")
- .max_height(220.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
egui::Grid::new("net_alerts_grid")
.num_columns(6)
@@ -1364,7 +1380,7 @@ fn render_alerts(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
if let Some(a) = state.alerts.get(i) {
egui::ScrollArea::vertical()
.id_salt("net_alert_detail")
- .max_height(140.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.console_min)
.show(ui, |ui| {
ui.monospace(format!("id={} sid={} sev={}", a.id, a.sid, a.severity));
ui.label(&a.msg);
@@ -1407,7 +1423,7 @@ fn render_rules(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("path");
ui.add(
egui::TextEdit::singleline(&mut state.rules_path)
- .desired_width(360.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("rules/ghidrust-minimal.rules"),
);
if ui.button("Browse…").clicked() {
@@ -1441,7 +1457,7 @@ fn render_rules(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label(RichText::new(format!("Rules ({})", rs.rules.len())).strong());
egui::ScrollArea::vertical()
.id_salt("net_rules_list")
- .max_height(280.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
for r in &rs.rules {
rule_row(ui, r, muted);
@@ -1468,7 +1484,7 @@ fn render_dig(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("path");
ui.add(
egui::TextEdit::singleline(&mut state.dig_path)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("image path"),
);
if ui.button("Browse…").clicked() {
@@ -1482,7 +1498,7 @@ fn render_dig(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("pid");
ui.add(
egui::TextEdit::singleline(&mut state.dig_pid)
- .desired_width(56.0)
+ .desired_width(FieldWidth::Micro.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("opt"),
);
});
@@ -1490,25 +1506,25 @@ fn render_dig(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label("host");
ui.add(
egui::TextEdit::singleline(&mut state.dig_host)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("dns/ip"),
);
ui.label("ioc");
ui.add(
egui::TextEdit::singleline(&mut state.dig_ioc)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("opt"),
);
ui.label("alert");
ui.add(
egui::TextEdit::singleline(&mut state.dig_alert_id)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("id"),
);
ui.label("flow");
ui.add(
egui::TextEdit::singleline(&mut state.dig_flow_ref)
- .desired_width(80.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("ref"),
);
});
@@ -1537,7 +1553,7 @@ fn render_dig(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.small(RichText::new(&plan.rationale).color(muted));
egui::ScrollArea::vertical()
.id_salt("net_dig_steps")
- .max_height(140.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.console_min)
.show(ui, |ui| {
for (i, s) in plan.steps.iter().enumerate() {
ui.monospace(format!("{}. {} {}", i + 1, s.tool, s.args));
@@ -1556,7 +1572,7 @@ fn render_dig(state: &mut NetworkState, ui: &mut Ui, muted: Color32) {
ui.label(RichText::new(format!("Result · {}", result.status)).strong());
egui::ScrollArea::vertical()
.id_salt("net_dig_findings")
- .max_height(160.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.panel_symbol_min)
.show(ui, |ui| {
for f in &result.findings {
ui.label(format!("[{}] {}", f.kind, f.detail));
diff --git a/crates/ghidrust-gui/src/panes.rs b/crates/ghidrust-gui/src/panes.rs
index f5d6a34..0c15c4f 100644
--- a/crates/ghidrust-gui/src/panes.rs
+++ b/crates/ghidrust-gui/src/panes.rs
@@ -7,6 +7,7 @@
//!
//! Source anchors: see internal UI notes § 1.1 and § 1.2.
+use ghidrust_core::FibScale;
use eframe::egui::{Color32, RichText, Ui};
/// One provider (window / dockable pane).
@@ -135,6 +136,73 @@ impl PaneKind {
PaneKind::AnalysisArtifacts,
];
+ /// Hover-submenu groups under Window → Providers (order = menu order).
+ pub const WINDOW_MENU_GROUPS: &'static [&'static str] = &[
+ "Program",
+ "Crypto",
+ "Graphs",
+ "Scripts",
+ "IL2CPP / Unity",
+ "Tools",
+ ];
+
+ /// Window → Providers submenu for floating panes. `None` = docked/center (listed separately).
+ pub const fn window_menu_group(self) -> Option<&'static str> {
+ match self {
+ PaneKind::ProjectTree
+ | PaneKind::ProgramTree
+ | PaneKind::SymbolTree
+ | PaneKind::Console
+ | PaneKind::Overview
+ | PaneKind::Listing
+ | PaneKind::DecompiledView
+ | PaneKind::DataTypeManager => None,
+
+ PaneKind::FunctionsWindow
+ | PaneKind::SymbolTable
+ | PaneKind::SymbolReferences
+ | PaneKind::MemoryMap
+ | PaneKind::DefinedStrings
+ | PaneKind::DefinedData
+ | PaneKind::Bytes
+ | PaneKind::CommentWindow
+ | PaneKind::Bookmarks
+ | PaneKind::RelocationTable
+ | PaneKind::EquatesTable
+ | PaneKind::FunctionTags
+ | PaneKind::DisassembledView
+ | PaneKind::ExternalPrograms
+ | PaneKind::DataTypePreview => Some("Program"),
+
+ PaneKind::Decrypt
+ | PaneKind::CryptoConstants
+ | PaneKind::CryptoCapabilities
+ | PaneKind::RecoveredStrings => Some("Crypto"),
+
+ PaneKind::FunctionGraph
+ | PaneKind::FunctionCallGraph
+ | PaneKind::FunctionCallTrees
+ | PaneKind::Entropy => Some("Graphs"),
+
+ PaneKind::ScriptManager
+ | PaneKind::TextEditor
+ | PaneKind::Python
+ | PaneKind::AgentConsole => Some("Scripts"),
+
+ PaneKind::Il2cppMetadata
+ | PaneKind::Il2cppMethods
+ | PaneKind::Il2cppIcalls
+ | PaneKind::Il2cppTouchMap
+ | PaneKind::Il2cppStubs
+ | PaneKind::UnityInventory
+ | PaneKind::InstallInventory
+ | PaneKind::FileSystemBrowser
+ | PaneKind::AnalysisArtifacts => Some("IL2CPP / Unity"),
+
+ PaneKind::ChecksumGenerator | PaneKind::RegisterManager => Some("Tools"),
+ }
+ }
+
/// display title (Window menu label / provider `TITLE`).
pub const fn title(self) -> &'static str {
match self {
@@ -398,13 +466,13 @@ pub fn empty_state(ui: &mut Ui, kind: PaneKind, muted: Color32) {
ui.heading(kind.title());
ui.small(RichText::new(format!("Provider · {}", kind.plugin())).color(muted));
ui.separator();
- ui.add_space(4.0);
+ ui.add_space(FibScale::XS);
ui.label(
RichText::new(backend_pending_message(kind))
.color(muted)
.italics(),
);
- ui.add_space(4.0);
+ ui.add_space(FibScale::XS);
ui.small(
RichText::new(
"Pane is present in the shell catalog. Backing analysis \
@@ -480,6 +548,41 @@ mod tests {
}
}
+ #[test]
+ fn window_menu_groups_cover_all_floating_providers() {
+ for k in PaneKind::ALL {
+ match k.window_menu_group() {
+ None => assert!(
+ matches!(
+ k,
+ PaneKind::ProjectTree
+ | PaneKind::ProgramTree
+ | PaneKind::SymbolTree
+ | PaneKind::Console
+ | PaneKind::Overview
+ | PaneKind::Listing
+ | PaneKind::DecompiledView
+ | PaneKind::DataTypeManager
+ ),
+ "{:?} missing Window menu group",
+ k
+ ),
+ Some(g) => assert!(
+ PaneKind::WINDOW_MENU_GROUPS.contains(&g),
+ "{:?} group {:?} not in WINDOW_MENU_GROUPS",
+ k,
+ g
+ ),
+ }
+ }
+ for g in PaneKind::WINDOW_MENU_GROUPS {
+ assert!(
+ PaneKind::ALL.iter().any(|k| k.window_menu_group() == Some(*g)),
+ "empty Window menu group {g}"
+ );
+ }
+ }
+
#[test]
fn ghidra_default_toolbar_providers_present() {
// 28 default `.tool` providers must all be enumerated.
diff --git a/crates/ghidrust-gui/src/register_manager.rs b/crates/ghidrust-gui/src/register_manager.rs
index 3cfe239..43ac74e 100644
--- a/crates/ghidrust-gui/src/register_manager.rs
+++ b/crates/ghidrust-gui/src/register_manager.rs
@@ -14,6 +14,9 @@
//! Extracted per internal modularization notes — new UI panes land here
//! instead of piling into `main.rs`.
+use crate::layout_tokens::FieldWidth;
+use ghidrust_core::FibScale;
+use ghidrust_core::ThemeDensity;
use eframe::egui::{self, Color32, Ui};
use ghidrust_core::process::RegisterSet;
use std::collections::BTreeMap;
@@ -607,21 +610,21 @@ pub fn render(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut state.filter)
- .desired_width(220.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Register name…"),
);
if ui.button("Clear filter").clicked() {
state.filter.clear();
}
});
- ui.add_space(4.0);
+ ui.add_space(FibScale::XS);
let filt = state.filter.to_ascii_lowercase();
let groups = group_by_kind();
egui::ScrollArea::vertical()
.id_salt("regmgr_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
for kind in RegisterKind::ALL {
let Some(rs) = groups.get(kind) else {
@@ -658,19 +661,19 @@ pub fn render(
ui.label("Start VA:");
ui.add(
egui::TextEdit::singleline(&mut state.input_start)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x140001000"),
);
ui.label("End VA:");
ui.add(
egui::TextEdit::singleline(&mut state.input_end)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x140001100"),
);
ui.label("Value:");
ui.add(
egui::TextEdit::singleline(&mut state.input_value)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0"),
);
let can_add = state.selected.is_some()
@@ -698,7 +701,7 @@ pub fn render(
}
});
- ui.add_space(6.0);
+ ui.add_space(FibScale::SM);
ui.label(egui::RichText::new("Values").strong());
if state.values.is_empty() {
ui.weak("No user-set register values.");
diff --git a/crates/ghidrust-gui/src/scripts.rs b/crates/ghidrust-gui/src/scripts.rs
index e96c64e..84d412f 100644
--- a/crates/ghidrust-gui/src/scripts.rs
+++ b/crates/ghidrust-gui/src/scripts.rs
@@ -5,6 +5,8 @@
//! - **Text Editor** — multi-tab in-memory editor for scripts on disk.
//! - **MCP REPL** — line-oriented `tool_name` / `tool_name {json}` → MCP/CLI.
+use crate::layout_tokens::FieldWidth;
+use ghidrust_core::ThemeDensity;
use crate::mcp_host::{
invoke_tool, invoke_tool_with_session, parse_tool_line, McpStdioSession,
};
@@ -470,7 +472,7 @@ pub fn render_script_manager(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut state.filter)
- .desired_width(220.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("name / description"),
);
ui.label("Category:");
@@ -508,7 +510,7 @@ pub fn render_script_manager(
let mut requested_run: Option<String> = None;
egui::ScrollArea::vertical()
.id_salt("scriptmgr_scroll")
- .max_height(280.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
egui::Grid::new("scriptmgr_grid")
.num_columns(5)
@@ -570,7 +572,7 @@ pub fn render_script_manager(
);
egui::ScrollArea::vertical()
.id_salt("scriptmgr_result")
- .max_height(180.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
ui.monospace(egui::RichText::new(&state.last_result).color(muted));
});
@@ -669,7 +671,7 @@ pub fn render_text_editor(
let before = tab.body.clone();
egui::ScrollArea::vertical()
.id_salt("texted_body")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
ui.add(
egui::TextEdit::multiline(&mut tab.body)
@@ -703,7 +705,7 @@ pub fn render_mcp_repl(
egui::ScrollArea::vertical()
.id_salt("mcp_repl_transcript")
.stick_to_bottom(true)
- .max_height(300.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
for line in &state.transcript {
if line.prompt {
diff --git a/crates/ghidrust-gui/src/theme.rs b/crates/ghidrust-gui/src/theme.rs
index 7c617db..38b29d2 100644
--- a/crates/ghidrust-gui/src/theme.rs
+++ b/crates/ghidrust-gui/src/theme.rs
@@ -1,29 +1,38 @@
-//! egui theme application for Ghidrust appearance + mode.
+//! egui Style/Visuals compiler for [`ghidrust_core::ThemeSpec`] packs.
+//!
+//! One path for every appearance — swap designs by editing packs in
+//! `ghidrust_core::theme_spec`, not by forking this file.
-use eframe::egui::{self, Color32, Visuals};
-use ghidrust_core::{theme_tokens, AppearanceTheme, ThemeMode};
+use eframe::egui::{self, Color32, Margin, Shadow, Visuals};
+use ghidrust_core::{
+ theme_spec, theme_tokens, ActiveFg, ActiveFill, AppearanceTheme, ElevationShadow, HoverFill,
+ M3Tokens, ThemeMode, ThemeSpec,
+};
/// Resolve color tokens for the given appearance + mode.
-pub fn tokens(appearance: AppearanceTheme, theme: ThemeMode) -> ghidrust_core::M3Tokens {
+pub fn tokens(appearance: AppearanceTheme, theme: ThemeMode) -> M3Tokens {
theme_tokens(appearance, theme)
}
+/// Resolve the full theme pack (colors + density + state layers + elevation + motion).
+pub fn spec(appearance: AppearanceTheme, theme: ThemeMode) -> ThemeSpec {
+ theme_spec(appearance, theme)
+}
+
/// Whether egui should start from dark visuals for this appearance + mode.
-///
-/// Future Console is always a dark CRT/neon panel (both gases).
pub fn prefers_dark_visuals(appearance: AppearanceTheme, theme: ThemeMode) -> bool {
- match (appearance, theme) {
- (AppearanceTheme::FutureConsole, _) => true,
- (_, ThemeMode::Dark) => true,
- (_, ThemeMode::Light) => false,
- }
+ theme_spec(appearance, theme).dark_base
}
-/// Apply Material / console visuals and spacing to the egui context.
-pub fn apply(ctx: &egui::Context, appearance: AppearanceTheme, theme: ThemeMode) {
- let t = tokens(appearance, theme);
- // Future Console is always a dark CRT/neon panel (both gases).
- let mut v = if prefers_dark_visuals(appearance, theme) {
+fn margin_xy(xy: [f32; 2]) -> Margin {
+ Margin::symmetric(xy[0] as i8, xy[1] as i8)
+}
+
+/// Compile a [`ThemeSpec`] into egui visuals + spacing (appearance-agnostic).
+pub fn apply_spec(ctx: &egui::Context, spec: &ThemeSpec) {
+ let t = &spec.colors;
+ let d = &spec.density;
+ let mut v = if spec.dark_base {
Visuals::dark()
} else {
Visuals::light()
@@ -31,6 +40,7 @@ pub fn apply(ctx: &egui::Context, appearance: AppearanceTheme, theme: ThemeMode)
let rgb = |c: [u8; 3]| Color32::from_rgb(c[0], c[1], c[2]);
let corner = egui::CornerRadius::same(t.corner_radius);
let stroke = egui::Stroke::new(t.stroke_width, rgb(t.outline));
+
v.override_text_color = Some(rgb(t.on_surface));
v.widgets.noninteractive.bg_fill = rgb(t.surface_container);
v.widgets.noninteractive.fg_stroke = egui::Stroke::new(1.0, rgb(t.on_surface));
@@ -39,65 +49,74 @@ pub fn apply(ctx: &egui::Context, appearance: AppearanceTheme, theme: ThemeMode)
v.widgets.inactive.fg_stroke = egui::Stroke::new(1.0, rgb(t.on_surface));
v.widgets.inactive.bg_stroke = stroke;
v.widgets.inactive.corner_radius = corner;
- v.widgets.hovered.bg_fill = match appearance {
- AppearanceTheme::FutureConsole => rgb(t.surface_bright),
- AppearanceTheme::Modern => rgb(t.primary_container).gamma_multiply(0.55),
- AppearanceTheme::ClassicGhidrust => rgb(t.primary).gamma_multiply(0.25),
+
+ v.widgets.hovered.bg_fill = match spec.state_layers.hover {
+ HoverFill::PrimaryGamma(g) => rgb(t.primary).gamma_multiply(g),
+ HoverFill::PrimaryContainerGamma(g) => rgb(t.primary_container).gamma_multiply(g),
+ HoverFill::SurfaceBright => rgb(t.surface_bright),
};
v.widgets.hovered.bg_stroke = egui::Stroke::new(t.stroke_width, rgb(t.secondary));
v.widgets.hovered.corner_radius = corner;
- v.widgets.active.bg_fill = match appearance {
- AppearanceTheme::FutureConsole => rgb(t.primary),
- AppearanceTheme::Modern => rgb(t.primary).gamma_multiply(0.45),
- AppearanceTheme::ClassicGhidrust => rgb(t.primary).gamma_multiply(0.35),
+
+ v.widgets.active.bg_fill = match spec.state_layers.active {
+ ActiveFill::Primary => rgb(t.primary),
+ ActiveFill::PrimaryGamma(g) => rgb(t.primary).gamma_multiply(g),
};
v.widgets.active.fg_stroke = egui::Stroke::new(
1.0,
- match appearance {
- AppearanceTheme::FutureConsole => rgb(t.on_primary),
- _ => rgb(t.on_surface),
+ match spec.state_layers.active_fg {
+ ActiveFg::OnPrimary => rgb(t.on_primary),
+ ActiveFg::OnSurface => rgb(t.on_surface),
},
);
v.widgets.active.corner_radius = corner;
v.widgets.open.bg_fill = rgb(t.surface_container_high);
v.widgets.open.corner_radius = corner;
+
v.panel_fill = rgb(t.surface);
v.window_fill = rgb(t.surface_container);
+ v.window_stroke = egui::Stroke::new(t.stroke_width, rgb(t.outline_variant));
v.extreme_bg_color = rgb(t.surface_dim);
v.faint_bg_color = rgb(t.surface_container_low);
- v.selection.bg_fill = match appearance {
- AppearanceTheme::FutureConsole => rgb(t.primary).gamma_multiply(0.55),
- _ => rgb(t.primary).gamma_multiply(0.4),
- };
+ v.code_bg_color = rgb(t.surface_container_lowest);
+ v.selection.bg_fill = rgb(t.primary).gamma_multiply(spec.state_layers.selection_primary_gamma);
v.hyperlink_color = rgb(t.primary);
v.warn_fg_color = rgb(t.error);
+ v.error_fg_color = rgb(t.error);
v.window_corner_radius = corner;
v.menu_corner_radius = corner;
- v.popup_shadow = match appearance {
- AppearanceTheme::FutureConsole => egui::Shadow::NONE,
- AppearanceTheme::Modern => egui::Shadow {
+
+ v.popup_shadow = match spec.elevation.popup_shadow {
+ ElevationShadow::None => Shadow::NONE,
+ ElevationShadow::Level2 => Shadow {
offset: [0, 2],
blur: 8,
spread: 0,
color: Color32::from_black_alpha(40),
},
- AppearanceTheme::ClassicGhidrust => v.popup_shadow,
+ ElevationShadow::Stock => v.popup_shadow,
};
+
ctx.set_visuals(v);
- // Wider side/top grab for resizable panels (bottom console drag).
- // Future Console: 4px half-cell spacing (Amber Console --space-1).
ctx.style_mut(|s| {
- s.interaction.resize_grab_radius_side = 12.0;
- if appearance == AppearanceTheme::FutureConsole {
- s.spacing.item_spacing = egui::vec2(8.0, 8.0);
- s.spacing.button_padding = egui::vec2(22.0, 10.0);
- } else if appearance == AppearanceTheme::Modern {
- s.spacing.item_spacing = egui::vec2(8.0, 8.0);
- s.spacing.button_padding = egui::vec2(16.0, 8.0);
- }
+ s.interaction.resize_grab_radius_side = d.resize_grab_radius;
+ s.spacing.item_spacing = egui::vec2(d.item_spacing[0], d.item_spacing[1]);
+ s.spacing.button_padding = egui::vec2(d.button_padding[0], d.button_padding[1]);
+ s.spacing.window_margin = margin_xy(d.window_margin);
+ s.spacing.menu_margin = margin_xy(d.menu_margin);
+ s.spacing.indent = d.indent;
+ s.spacing.interact_size.y = d.control_min_height;
+ s.spacing.icon_width = d.icon_sm;
+ s.spacing.icon_spacing = d.space_sm;
+ s.animation_time = spec.motion.animation_time;
});
}
+/// Apply the theme pack for `appearance` + `theme` to the egui context.
+pub fn apply(ctx: &egui::Context, appearance: AppearanceTheme, theme: ThemeMode) {
+ apply_spec(ctx, &spec(appearance, theme));
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -141,4 +160,20 @@ mod tests {
ThemeMode::Light
));
}
+
+ #[test]
+ fn apply_spec_is_appearance_agnostic() {
+ let _ = spec(AppearanceTheme::ClassicGhidrust, ThemeMode::Dark);
+ let _ = spec(AppearanceTheme::Modern, ThemeMode::Light);
+ let _ = spec(AppearanceTheme::FutureConsole, ThemeMode::Dark);
+ }
+
+ #[test]
+ fn density_fib_values_wired() {
+ let d = spec(AppearanceTheme::ClassicGhidrust, ThemeMode::Dark).density;
+ assert_eq!(d.window_margin, [13.0, 13.0]);
+ assert_eq!(d.menu_margin, [8.0, 5.0]);
+ assert_eq!(d.indent, 13.0);
+ assert_eq!(d.resize_grab_radius, 13.0);
+ }
}
diff --git a/crates/ghidrust-gui/src/tool_panes.rs b/crates/ghidrust-gui/src/tool_panes.rs
index e467c93..2982d2e 100644
--- a/crates/ghidrust-gui/src/tool_panes.rs
+++ b/crates/ghidrust-gui/src/tool_panes.rs
@@ -6,6 +6,8 @@
//! though IL2CPP Methods / ICalls prefer the currently-loaded `Program`
//! when the user hasn't pointed at a separate binary.
+use crate::layout_tokens::FieldWidth;
+use ghidrust_core::ThemeDensity;
use eframe::egui::{self, Color32, RichText, Ui};
use ghidrust_core::{
artifact_get, artifact_query, list_artifacts, ArtifactEnvelope, ArtifactMeta, PeInventory,
@@ -62,7 +64,7 @@ pub fn ui_il2cpp_metadata(ui: &mut Ui, s: &mut Il2cppMetaState, muted: Color32)
ui.label("Path:");
ui.add(
egui::TextEdit::singleline(&mut s.path_input)
- .desired_width(360.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("global-metadata.dat"),
);
if ui.button("Browse…").clicked() {
@@ -108,14 +110,14 @@ pub fn ui_il2cpp_metadata(ui: &mut Ui, s: &mut Il2cppMetaState, muted: Color32)
.show(ui, |ui| {
ui.add(
egui::TextEdit::singleline(&mut s.type_filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("filter Namespace.Type…"),
);
let rows = meta.filter_types(&s.type_filter);
ui.small(format!("{} / {} types", rows.len(), meta.types.len()));
egui::ScrollArea::vertical()
.id_salt("il2cpp_types_scroll")
- .max_height(220.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
for t in rows.iter().take(2000) {
ui.monospace(format!(
@@ -133,14 +135,14 @@ pub fn ui_il2cpp_metadata(ui: &mut Ui, s: &mut Il2cppMetaState, muted: Color32)
.show(ui, |ui| {
ui.add(
egui::TextEdit::singleline(&mut s.method_filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("filter method name…"),
);
let rows = meta.filter_methods(&s.method_filter);
ui.small(format!("{} / {} methods", rows.len(), meta.methods.len()));
egui::ScrollArea::vertical()
.id_salt("il2cpp_methods_scroll_meta")
- .max_height(220.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
for m in rows.iter().take(2000) {
ui.monospace(format!(
@@ -220,7 +222,7 @@ pub fn ui_il2cpp_methods(
ui.label("Binary:");
ui.add(
egui::TextEdit::singleline(&mut s.binary_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("GameAssembly.dll / binary path"),
);
if ui.button("Browse…").clicked() {
@@ -237,7 +239,7 @@ pub fn ui_il2cpp_methods(
ui.label("Metadata:");
ui.add(
egui::TextEdit::singleline(&mut s.meta_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("global-metadata.dat"),
);
if ui.button("Browse…").clicked() {
@@ -316,7 +318,7 @@ pub fn ui_il2cpp_methods(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("method name…"),
);
});
@@ -331,7 +333,7 @@ pub fn ui_il2cpp_methods(
egui::ScrollArea::vertical()
.id_salt("il2cpp_methods_scroll")
.auto_shrink([false, false])
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show_rows(ui, row_h, rows.len(), |ui, range| {
for i in range {
let e = rows[i];
@@ -392,7 +394,7 @@ pub fn ui_il2cpp_icalls(
ui.label("Binary:");
ui.add(
egui::TextEdit::singleline(&mut s.binary_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("UnityPlayer.dll / engine binary path"),
);
if ui.button("Browse…").clicked() {
@@ -444,7 +446,7 @@ pub fn ui_il2cpp_icalls(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(280.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("icall name…"),
);
});
@@ -454,7 +456,7 @@ pub fn ui_il2cpp_icalls(
egui::ScrollArea::vertical()
.id_salt("il2cpp_icalls_scroll")
.auto_shrink([false, false])
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show_rows(ui, row_h, hits.len(), |ui, range| {
for i in range {
let (ti, e) = &hits[i];
@@ -521,7 +523,7 @@ pub fn ui_il2cpp_touch_map(
ui.label("Metadata:");
ui.add(
egui::TextEdit::singleline(&mut s.meta_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("global-metadata.dat"),
);
if ui.button("Browse…").clicked() {
@@ -542,7 +544,7 @@ pub fn ui_il2cpp_touch_map(
ui.label("Binary:");
ui.add(
egui::TextEdit::singleline(&mut s.binary_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("GameAssembly.dll (optional)"),
);
if ui.button("Browse…").clicked() {
@@ -561,7 +563,7 @@ pub fn ui_il2cpp_touch_map(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(240.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("substring…"),
);
let can_run = !s.meta_path_input.trim().is_empty() && !s.filter.trim().is_empty();
@@ -614,7 +616,7 @@ pub fn ui_il2cpp_touch_map(
egui::ScrollArea::vertical()
.id_salt("il2cpp_touch_map_scroll")
.auto_shrink([false, false])
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show_rows(ui, row_h, report.rows.len(), |ui, range| {
for i in range {
let r = &report.rows[i];
@@ -682,7 +684,7 @@ pub fn ui_il2cpp_stubs(
ui.label("Binary:");
ui.add(
egui::TextEdit::singleline(&mut s.binary_path_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("GameAssembly.dll / il2cpp binary"),
);
if ui.button("Browse…").clicked() {
@@ -703,7 +705,7 @@ pub fn ui_il2cpp_stubs(
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(200.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("icall name…"),
);
ui.label("Max scan:");
@@ -754,7 +756,7 @@ pub fn ui_il2cpp_stubs(
egui::ScrollArea::vertical()
.id_salt("il2cpp_stubs_scroll")
.auto_shrink([false, false])
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show_rows(ui, row_h, s.stubs.len(), |ui, range| {
for i in range {
let st = &s.stubs[i];
@@ -792,7 +794,7 @@ pub fn ui_unity_inventory(ui: &mut Ui, s: &mut UnityInventoryState, muted: Color
ui.label("Game folder:");
ui.add(
egui::TextEdit::singleline(&mut s.root_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("Unity player install root…"),
);
if ui.button("Browse…").clicked() {
@@ -902,7 +904,7 @@ pub fn ui_install_inventory(ui: &mut Ui, s: &mut InstallInventoryState, muted: C
ui.label("Folder:");
ui.add(
egui::TextEdit::singleline(&mut s.root_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("install folder…"),
);
if ui.button("Browse…").clicked() {
@@ -949,7 +951,7 @@ pub fn ui_install_inventory(ui: &mut Ui, s: &mut InstallInventoryState, muted: C
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(260.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("path / product name…"),
);
});
@@ -971,7 +973,7 @@ pub fn ui_install_inventory(ui: &mut Ui, s: &mut InstallInventoryState, muted: C
ui.small(format!("{} / {} shown", rows.len(), inv.entries.len()));
egui::ScrollArea::vertical()
.id_salt("install_inventory_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(ui, |ui| {
egui::Grid::new("install_inventory_grid")
.num_columns(5)
@@ -1041,7 +1043,7 @@ pub fn ui_file_system_browser(ui: &mut Ui, s: &mut FileSystemBrowserState, muted
ui.label("Folder:");
ui.add(
egui::TextEdit::singleline(&mut s.root_input)
- .desired_width(320.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("folder to browse…"),
);
if ui.button("Browse…").clicked() {
@@ -1057,13 +1059,13 @@ pub fn ui_file_system_browser(ui: &mut Ui, s: &mut FileSystemBrowserState, muted
ui.label("Extensions:");
ui.add(
egui::TextEdit::singleline(&mut s.extensions_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("exe,dll (blank = all)"),
);
ui.label("Name glob:");
ui.add(
egui::TextEdit::singleline(&mut s.name_glob_input)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("*.dll"),
);
ui.label("Max depth:");
@@ -1125,7 +1127,7 @@ pub fn ui_file_system_browser(ui: &mut Ui, s: &mut FileSystemBrowserState, muted
ui.label("Filter:");
ui.add(
egui::TextEdit::singleline(&mut s.filter)
- .desired_width(260.0)
+ .desired_width(FieldWidth::Wide.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("path substring…"),
);
});
@@ -1140,7 +1142,7 @@ pub fn ui_file_system_browser(ui: &mut Ui, s: &mut FileSystemBrowserState, muted
egui::ScrollArea::vertical()
.id_salt("fs_browser_scroll")
.auto_shrink([false, false])
- .max_height(380.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show_rows(ui, row_h, rows.len(), |ui, range| {
for i in range {
let e = rows[i];
@@ -1221,7 +1223,7 @@ pub fn ui_analysis_artifacts(ui: &mut Ui, s: &mut AnalysisArtifactsState, muted:
let mut clicked: Option<String> = None;
egui::ScrollArea::vertical()
.id_salt("artifacts_left_scroll")
- .max_height(380.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[0], |ui| {
for a in &s.artifacts {
let sel = s.selected_id.as_deref() == Some(a.id.as_str());
@@ -1268,7 +1270,7 @@ pub fn ui_analysis_artifacts(ui: &mut Ui, s: &mut AnalysisArtifactsState, muted:
);
egui::ScrollArea::vertical()
.id_salt("artifacts_full_scroll")
- .max_height(360.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[1], |ui| {
ui.add(
egui::TextEdit::multiline(full)
@@ -1318,7 +1320,7 @@ pub fn ui_analysis_artifacts(ui: &mut Ui, s: &mut AnalysisArtifactsState, muted:
}
egui::ScrollArea::vertical()
.id_salt("artifacts_right_scroll")
- .max_height(320.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_md)
.show(&mut cols[1], |ui| {
ui.add(
egui::TextEdit::multiline(&mut pretty)
@@ -1420,13 +1422,13 @@ pub fn ui_gpu_decompile_dialog_header(
ui.label("Address:");
ui.add(
egui::TextEdit::singleline(&mut s.addr_input)
- .desired_width(160.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x140001000 (blank = entry)"),
);
ui.label("Max bytes:");
ui.add(
egui::TextEdit::singleline(&mut s.max_bytes_input)
- .desired_width(100.0)
+ .desired_width(FieldWidth::Narrow.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("256"),
);
});
@@ -1468,7 +1470,7 @@ pub fn ui_gpu_decompile_dialog_result(ui: &mut Ui, s: &GpuDecompileDialogState,
.default_open(true)
.show(ui, |ui| {
egui::ScrollArea::vertical()
- .max_height(220.0)
+ .max_height(ThemeDensity::FIB_DESKTOP.scroll_sm)
.show(ui, |ui| {
ui.monospace(&sum.pseudo_c_preview);
});
diff --git a/crates/ghidrust-gui/src/wire_dialogs.rs b/crates/ghidrust-gui/src/wire_dialogs.rs
index b47a223..fba2488 100644
--- a/crates/ghidrust-gui/src/wire_dialogs.rs
+++ b/crates/ghidrust-gui/src/wire_dialogs.rs
@@ -1,6 +1,8 @@
//! Small dialogs kept out of `app.rs` so menu-heavy agents can edit menus
//! without merge conflicts on dialog bodies.
+use crate::layout_tokens::FieldWidth;
+use ghidrust_core::ThemeDensity;
use eframe::egui::{self, Color32, Ui};
/// State for Data Type Manager → Apply at address (button path; DnD not required).
@@ -52,7 +54,7 @@ pub fn ui_apply_type_at_address(
ui.label("Address:");
ui.add(
egui::TextEdit::singleline(&mut state.addr_input)
- .desired_width(180.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x140001000"),
);
});
@@ -60,7 +62,7 @@ pub fn ui_apply_type_at_address(
ui.label("Type:");
ui.add(
egui::TextEdit::singleline(&mut state.type_name)
- .desired_width(220.0)
+ .desired_width(FieldWidth::Std.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("dword / MyStruct…"),
);
});
@@ -110,7 +112,7 @@ pub fn ui_dtm_apply_bar(
ui.label("Apply at:");
ui.add(
egui::TextEdit::singleline(addr_input)
- .desired_width(140.0)
+ .desired_width(FieldWidth::Compact.px(&ThemeDensity::FIB_DESKTOP))
.hint_text("0x…"),
);
let typ = selected_type.unwrap_or("");