Trim needless comments and fix the picker width
Remove comments that only restate the code, keeping the section banners and the notes that carry a reason, a measured fact or an external contract. ButtonOptions.width claimed to be a fixed width but only set minWidth, so the Graph and Texture pickers grew with the name they showed. It is now what it promises, with a separate minWidth for the buttons that have two forms. Narrow buttons shrink their padding, otherwise a 24px icon button had 8px left for its glyph and truncate dropped it entirely. __gm.labelsDropped() guards that class: the overflow guard only saw text that was too wide, never a label truncated to nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f16801aef3
commit
4d84231b9f
115 files changed
+707
-1564
No files matched your search
+4
-13
@@ -15,20 +15,13 @@ export interface MenuItem {
|
||||
}
|
||||
|
||||
export interface MenuOptions {
|
||||
/**
|
||||
* Adds a search box above the entries that filters them as you type; Enter picks the first
|
||||
* match. For menus that can grow with the project (the parent picker lists every object).
|
||||
*/
|
||||
/** Adds a search box above the entries that filters as you type; Enter picks the first match. */
|
||||
searchable?: boolean;
|
||||
}
|
||||
|
||||
/** How tall the entry list gets before it starts scrolling. */
|
||||
const MAX_LIST_HEIGHT = 320;
|
||||
|
||||
/**
|
||||
* A vertical list of clickable actions. Picking one closes the menu before it runs.
|
||||
* Entries read as a list: left-aligned, scrolled once they no longer fit on screen.
|
||||
*/
|
||||
/** A vertical list of clickable actions. Picking one closes the menu before it runs. */
|
||||
export class Menu extends Popup {
|
||||
private readonly entries: { button: Button; haystack: string }[] = [];
|
||||
private readonly list = new VStack({ gap: 2 });
|
||||
@@ -72,7 +65,6 @@ export class Menu extends Popup {
|
||||
if (this.search) ui().focus.focus(this.search);
|
||||
}
|
||||
|
||||
/** Shows the entries matching the search box and resizes the menu around them. */
|
||||
private filter(): void {
|
||||
const query = this.search?.value.trim().toLowerCase() ?? '';
|
||||
let matches = 0;
|
||||
@@ -88,9 +80,8 @@ export class Menu extends Popup {
|
||||
this.scroll.minHeight = Math.min(size.h, MAX_LIST_HEIGHT);
|
||||
this.scroll.scrollTo(0);
|
||||
this.refreshLayout();
|
||||
// Both calls are needed: a resize alone re-lays out only when the size actually changed,
|
||||
// and two different filters can leave the list exactly as tall as before while showing
|
||||
// an entirely different set of entries.
|
||||
// Both are needed: a resize re-lays out only on an actual size change, and two filters can
|
||||
// leave the list exactly as tall while showing different entries.
|
||||
this.scroll.relayoutContent();
|
||||
this.list.relayout();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user