4.6 KiB
4.6 KiB
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
- Icon loading: use
include_bytes!("../../../assets/icons/hcie-icon.png")insidepanels.rsandimage::load_from_memoryto create anegui::ColorImage/egui::ImageSource. Cache the loaded handle inHcieAppto avoid decoding every frame. - Version string: use
env!("CARGO_PKG_VERSION")when building the title. - Window controls: update
draw_window_controlssignature to acceptbar_hand usebtn_h = bar_h,btn_w = 32.0. - 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. - Native decorations: when
show_native_decorations == false, the custom controls are shown. Whentrue, 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 becomesfalseso the single custom bar is the out-of-box experience. - Extensible button area: add a
Vecor small helper inHcieAppto register future custom title-bar buttons; for this plan implement only the panel-list toggle.
Validation
cargo build -p hcie-gui-eguisucceeds.- Launching the app shows one 25 px bar at the top with icon, menus, search, centered title, panel toggle, and window controls.
- Title truncates when the window is very narrow.
- Dragging the bar moves the window; double-click maximizes/restores.
- Panel-list toggle opens/closes the panel list.
- 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).