The animation tab's Fit frames the preview, and the separate Centre button is gone (#111)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc14988338
commit
4c92a9478f
5 files changed
+23
-16
No files matched your search
@@ -15,11 +15,14 @@ import {
|
||||
} from '../ui';
|
||||
import type { EditorState } from './state';
|
||||
|
||||
/** The canvas each tab wraps: the header's Fit button and the tab's own plumbing need this much. */
|
||||
/**
|
||||
* The canvas each tab wraps: the header's Fit button and the tab's own plumbing need this much.
|
||||
* A canvas without `fit` belongs to a tab whose Fit frames something else (see `AssetTabEditor.fit`).
|
||||
*/
|
||||
export interface TabCanvas {
|
||||
readonly currentAssetId: string;
|
||||
show(assetId: string): void;
|
||||
fit(): void;
|
||||
fit?(): void;
|
||||
}
|
||||
|
||||
export interface AssetTabOptions {
|
||||
@@ -39,6 +42,7 @@ export abstract class AssetTabEditor<
|
||||
> extends VStack {
|
||||
/** Public for the check scripts. */
|
||||
readonly picker: Dropdown;
|
||||
readonly fitButton: Button;
|
||||
protected readonly info: Label;
|
||||
/** Assigned by `mount`. Public because the check hooks and the play loop reach for it. */
|
||||
canvas!: C;
|
||||
@@ -50,6 +54,7 @@ export abstract class AssetTabEditor<
|
||||
) {
|
||||
super();
|
||||
this.picker = new Dropdown('—', { width: 200, onClick: () => this.openPicker() });
|
||||
this.fitButton = new Button('Fit', { onClick: () => this.fit() });
|
||||
this.info = new Label('', { style: 'small', align: 'right' });
|
||||
this.info.minWidth = options.infoWidth;
|
||||
}
|
||||
@@ -63,7 +68,7 @@ export abstract class AssetTabEditor<
|
||||
header.add(new Label(this.options.noun, { style: 'muted' }));
|
||||
header.add(this.picker);
|
||||
for (const widget of extras) header.add(widget);
|
||||
header.add(new Button('Fit', { onClick: () => this.canvas.fit() }));
|
||||
header.add(this.fitButton);
|
||||
header.add(new Spacer(), 1);
|
||||
header.add(this.info);
|
||||
|
||||
@@ -103,6 +108,11 @@ export abstract class AssetTabEditor<
|
||||
return canvas;
|
||||
}
|
||||
|
||||
/** What the header's Fit button frames. Override when the tab has more than one view. */
|
||||
protected fit(): void {
|
||||
this.canvas.fit?.();
|
||||
}
|
||||
|
||||
/** Enable/disable whatever `extras` the subclass passed to `mount`. */
|
||||
protected syncExtras(_asset: A | null): void {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user