Skip to content

Refactor: factor shared debug-window scaffolding into a common DxDialog base #77

Description

@relmer

Summary

The two debug tool windows — InputDebugPanel and Disk2DebugPanel — independently re-implement a large amount of common window/dialog scaffolding. Factor the shared behavior into a common base class (proposed name DxDialog — see naming note) and derive both panels from it.

Both currently implement IChromedPanelContent and are hosted in a ChromedPanelWindow via composition (m_window). They duplicate, near-verbatim:

  • Keyboard focus management — a parallel *FocusStop enum, an m_focusStops tab-order vector rebuilt on every focus change, plus matching switches in ApplyFocus/HandleKey and hand-written SetFocusToStop(...) calls in every mouse handler. (Tracked separately below.)
  • ListView scrollbar mouse wiring — arrow/thumb/track hit-testing, thumb-drag begin/update/end, SetCapture/ReleaseCapture plumbing in OnLButtonDown/OnMouseMove/OnLButtonUp.
  • Tooltip viewport clampingSetViewportSize on layout recompute.
  • Row layout / spacing constantskRowVGap96, header gaps, etc.
  • Sticky-tail autoscroll — keep newest row visible only when already scrolled to the bottom.
  • Window title plumbingSetTitle on the chrome titlebar.

Goal

Extract a common base (DxDialog) that owns the ChromedPanelWindow, focus ring, scrollbar/mouse routing for a hosted ListView, tooltip clamping, and title handling. The two debug panels become thin subclasses that only declare their own widgets and event semantics.

Sub-task: rework focus management

As part of (or alongside) this, replace the enum-and-three-switches focus model with a focus manager over a vector<IFocusable*> tab ring:

  • Each focusable widget implements a small common interface (Blur(), HandleKey(), OnLButtonDown()/hit-test, and an IsFocusable() predicate for conditional stops like the joystick/paddle checkboxes).
  • Focus becomes an index into the vector; Tab and clicks just move the index, and the manager blurs the outgoing widget and focuses the incoming one.
  • Separate Dropdown::Blur() (lose keyboard focus) from closing the popup. They are currently the same call (SetFocused(false) also sets m_open = false), which caused the dropdown-commit bug worked around with a !IsOpen() guard. Decoupling these removes the workaround.

Naming note

DxDialog is a reasonable name, though these are non-modal chromed tool windows rather than modal dialogs — ChromedDialog, DxToolWindow, or DxPanelContent are alternatives. Pick whatever reads best against the existing ChromedPanelWindow / IChromedPanelContent vocabulary.

Not urgent

The current code is functional; this is a maintainability refactor. Land it on its own branch so the diff is reviewable in isolation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions