Files
hcie-rust-v3.05/.kilo/plans/1748796165-custom-title-bar.md
T
2026-07-09 02:59:53 +03:00

4.6 KiB
Raw Blame History

Plan: Custom Title Bar (Revised)

Scope: title bar only. Panels/docking widths are already acceptable. Target workspace: hcie-egui-app/crates/hcie-gui-egui/

Goal

Draw a single custom title bar at the very top of the main window.

  • Height: 25 px.
  • Contains: app icon, menus, search field, centered title, customizable button area, and window controls (min/max/close).
  • No extra row below/above it.
  • Distinct colour from the main window.
  • Used to drag the main window.
  • Title shows program name, full version, and active document name (truncatable).
  • Provides an extensible area for custom buttons; default button toggles the panel list.
  • Includes a quick search box for feature access.

Decisions

Decision Chosen value
Always visible? Yes — remove the use_grimdock gate so the bar is always drawn.
Height 25 px.
Colour source Theme token: add title_bar_bg to the theme palette, defaulting to a tone clearly different from bg_panel.
App icon hcie-egui-app/assets/icons/hcie-icon.png, rendered at 16×16 px.
Title text HCIE v{full_version} — {doc_name}, 11 px, strong, truncatable. full_version comes from env!("CARGO_PKG_VERSION") of hcie-gui-egui.
Title position Centered in its own layout column.
Custom button area Separate right-of-center column; default contains only the panel-list toggle (☰/◧). Future buttons are added here.
Window controls Rightmost column, 32×25 px, right-to-left order: close, maximize, minimize (close at the far right).
Drag behaviour Drag on any empty bar area + double-click to maximize/restore. Remove the left/right grip-dot handles.
Native decorations Default false; user may still enable via Settings.

Layout (left → right)

[icon] [File] [Edit] [Tools] ... [Help] [Search…] |  [HCIE v4.0.0 — Untitled]  | [☰] [future buttons] | [_ □ ✕]
  • Left column packs to its content.
  • Center column fills remaining width, centers the title, truncates overflow.
  • Right-of-center column packs to its content.
  • Rightmost column packs to its content.

Files to modify

File Change
hcie-egui-app/crates/hcie-gui-egui/src/app/panels.rs Rewrite show_menu_bar as a 4-column layout. Add build_title helper. Remove grip-dot helpers. Load and render hcie-icon.png. Draw window controls at 32×25. Remove use_grimdock guards for icon/title/search/toggle.
hcie-egui-app/crates/hcie-gui-egui/src/app/mod.rs Add title_bar_bg to ThemeColors and resolve it in every theme preset.
hcie-egui-app/crates/hcie-gui-egui/src/app/settings.rs Default show_native_decorations to false.

Implementation notes

  1. Icon loading: use include_bytes!("../../../assets/icons/hcie-icon.png") inside panels.rs and image::load_from_memory to create an egui::ColorImage / egui::ImageSource. Cache the loaded handle in HcieApp to avoid decoding every frame.
  2. Version string: use env!("CARGO_PKG_VERSION") when building the title.
  3. Window controls: update draw_window_controls signature to accept bar_h and use btn_h = bar_h, btn_w = 32.0.
  4. Drag area: allocate the entire remaining bar rectangle with Sense::click_and_drag() (or wrap the bar content with a single invisible drag responder). Double-click toggles maximized state.
  5. Native decorations: when show_native_decorations == false, the custom controls are shown. When true, the OS draws its own bar and the custom controls are hidden, but the custom bar still contains icon/menus/search/title/custom buttons. The setting default becomes false so the single custom bar is the out-of-box experience.
  6. Extensible button area: add a Vec or small helper in HcieApp to register future custom title-bar buttons; for this plan implement only the panel-list toggle.

Validation

  1. cargo build -p hcie-gui-egui succeeds.
  2. Launching the app shows one 25 px bar at the top with icon, menus, search, centered title, panel toggle, and window controls.
  3. Title truncates when the window is very narrow.
  4. Dragging the bar moves the window; double-click maximizes/restores.
  5. Panel-list toggle opens/closes the panel list.
  6. Native decorations default is off; enabling in Settings shows the OS title bar in addition to the custom bar (documented behaviour).

Out of scope

  • Adding further custom buttons beyond the panel-list toggle (area is reserved and documented).
  • OS-level accent colour detection; kept as a theme token for determinism.
  • Changing the docking/panel minimum widths or layout (already acceptable).