Interface Explorer: compact dialog (14 rows) with mouse-wheel scrolling and scrollbar

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-24 20:58:06 -08:00
1 parent 7a37039673
commit 5b32cf9808
4 files changed
+441 -2

No files matched your search

+42 -1
View File
@@ -135,6 +135,15 @@ pub(all) struct DesktopShell {
mut screen_w : Int
mut launcher_rect : @scene.Rect
mut popup_rect : @scene.Rect
// WIT inspector state (see inspector.mbt)
mut inspect_on : Bool
mut hover_id : String
mut hover_x : Int
mut inspect_scroll : Int
mut hover_y : Int
mut panel_rect : @scene.Rect
comps : Array[(String, @scene.Rect)]
wit_cache : Map[String, String]
}
///| Apps the launcher offers, kept only if their executable exists.
@@ -167,6 +176,14 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
screen_w: 0,
launcher_rect: { x: 0, y: 0, w: 0, h: 0 },
popup_rect: { x: 0, y: 0, w: 0, h: 0 },
inspect_on: false,
hover_id: "",
hover_x: 0,
inspect_scroll: 0,
hover_y: 0,
panel_rect: { x: 0, y: 0, w: 0, h: 0 },
comps: [],
wit_cache: {},
}
}
@@ -212,6 +229,10 @@ fn DesktopShell::launch(self : DesktopShell, id : String) -> Result[Unit, String
///| wp_cursor_shape_v1 value for the shell UI under (x, y): 4 pointer (hand) over the
/// launcher button and popup entries, 9 text over the search field, else 0 (not shell-specific).
pub fn DesktopShell::cursor_at(self : DesktopShell, x : Int, y : Int) -> UInt {
if self.inspect_on {
// help cursor everywhere while inspecting; hand over the toggle itself
return if self.component_at(x, y) == "inspect" { 4U } else { 3U }
}
if inside(self.launcher_rect, x, y) {
4U
} else if self.launcher_state.open && inside(self.popup_rect, x, y) {
@@ -230,7 +251,12 @@ pub fn DesktopShell::cursor_at(self : DesktopShell, x : Int, y : Int) -> UInt {
///| Pointer press at (x, y). Returns true when the shell consumed it.
pub fn DesktopShell::pointer_down(self : DesktopShell, x : Int, y : Int) -> Bool {
let launch = fn(id : String) { self.launch(id) }
if inside(self.launcher_rect, x, y) {
if self.component_at(x, y) == "inspect" {
self.set_inspecting(!self.inspect_on)
true
} else if self.inspect_on {
true // inspecting: clicks don't reach widgets or windows
} else if inside(self.launcher_rect, x, y) {
ignore(
@launcher.handle_event(self.apps, self.launcher_state, Widget, PointerDown({ x: x - self.launcher_rect.x, y: y - self.launcher_rect.y }), launch),
)
@@ -289,15 +315,19 @@ pub fn DesktopShell::render(
let (_, _, clock_w, clock_h, clock_min) = @clock.digital_info()
let slots : Array[@panel.SlotIn] = [
{ id: "launcher", pref_w: 190, pref_h: 36, min_w: 170, stretch: false, end_align: false },
{ id: "inspect", pref_w: 132, pref_h: 36, min_w: 120, stretch: false, end_align: false },
{ id: "layout", pref_w: 96, pref_h: 36, min_w: 80, stretch: false, end_align: false },
{ id: "tasks", pref_w: 100, pref_h: 36, min_w: 0, stretch: true, end_align: false },
{ id: "clock", pref_w: clock_w, pref_h: clock_h, min_w: clock_min, stretch: false, end_align: true },
]
let panel_ops : Array[@scene.DrawOp] = []
self.comps.clear()
self.panel_rect = { x: 0, y: 0, w: 0, h: 0 }
match @panel.layout(w, h, theme.panel_height, 4, tokens.spacing.reinterpret_as_int(), slots) {
Err(_) => ()
Ok(pl) => {
let pr = @ui.rect(pl.x, pl.y, pl.w, pl.h)
self.panel_rect = { x: pl.x, y: pl.y, w: pl.w, h: pl.h }
translate(@libshell.render_panel(pr, tokens), 0, 0, panel_ops)
for p in pl.placements {
let size = @ui.size(p.w, p.h)
@@ -308,9 +338,17 @@ pub fn DesktopShell::render(
@ui.fill_rect(@ui.rect(0, 0, p.w, p.h), tokens.palette.surface_hover, radius=tokens.radius.reinterpret_as_int()),
@ui.text(p.w / 2, p.h / 2, layout_label, tokens.font_size.reinterpret_as_int() - 2, tokens.palette.foreground, align=CENTER),
]
"inspect" => {
let on = self.inspect_on
[
@ui.fill_rect(@ui.rect(0, 0, p.w, p.h), if on { tokens.palette.accent } else { tokens.palette.surface_hover }, radius=tokens.radius.reinterpret_as_int()),
@ui.text(p.w / 2, p.h / 2, "Interface Explorer", tokens.font_size.reinterpret_as_int() - 2, if on { tokens.palette.accent_foreground } else { tokens.palette.foreground }, align=CENTER, bold=true),
]
}
_ => []
}
translate(local, p.x, p.y, panel_ops)
self.comps.push((p.id, { x: p.x, y: p.y, w: p.w, h: p.h }))
if p.id == "launcher" {
self.launcher_rect = { x: p.x, y: p.y, w: p.w, h: p.h }
}
@@ -345,5 +383,8 @@ pub fn DesktopShell::render(
} else {
self.popup_rect = { x: 0, y: 0, w: 0, h: 0 }
}
if self.inspect_on {
self.render_inspector(w, h, tokens, panel_ops)
}
(bg, panel_ops)
}