lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
51 lines • 1.36 kB
JavaScript
import { PassthroughWidget } from './PassthroughWidget.js';
/**
* A {@link PassthroughWidget} which changes the theme of its child and
* completely ignores inherited themes.
*
* Can be constrained to a specific type of children.
*
* Since the new theme replaces the inherited theme, children of the child will
* also inherit this theme since inherited themes are propagated down the widget
* tree.
*
* @category Widget
*/
export class ThemeScope extends PassthroughWidget {
constructor(child, theme, properties) {
super(child, properties);
this._scopeTheme = theme;
super.inheritedTheme = theme;
}
set inheritedTheme(_theme) {
super.inheritedTheme = this._scopeTheme;
}
get inheritedTheme() {
return this._scopeTheme;
}
set scopeTheme(scopeTheme) {
if (this._scopeTheme === scopeTheme) {
return;
}
this._scopeTheme = scopeTheme;
super.inheritedTheme = this._scopeTheme;
}
get scopeTheme() {
return this._scopeTheme;
}
}
ThemeScope.autoXML = {
name: 'theme-scope',
inputConfig: [
{
mode: 'widget',
name: 'child'
},
{
mode: 'value',
name: 'theme',
validator: 'theme'
}
]
};
//# sourceMappingURL=ThemeScope.js.map