// Copyright (c) 2026 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT // A background Rectangle + Label, structurally a re-skinned Button -- // "active" (which content tab is currently shown) plays the same role // Button's "highlighted" plays, so setHighlighted() is how a Menu drives // it: a tab strip's Menu treats "cursor is here" and "this tab's content // is showing" as the same thing, matching the old widget's behavior. class Tab extends UIElement { init() { this.background = new Rectangle(); this.background.width = 80; this.background.height = 24; this.add(this.background); this.label = new Label(); this.label.x = 4; this.label.y = 4; this.add(this.label); this.active = false; this._refresh(); } get text() { return this.label.text; } set text(value) { this.label.text = value; } setHighlighted(active) { this.active = active; this._refresh(); } _refresh() { this.background.color = this.active ? Tab.COLOR_ACTIVE : Tab.COLOR_INACTIVE; } } Tab.COLOR_ACTIVE = { r: 0, g: 160, b: 0, a: 255 }; Tab.COLOR_INACTIVE = { r: 160, g: 0, b: 0, a: 255 }; module.exports = Tab;