@dark-engine/platform-desktop
Version:
Dark renderer to desktop platforms like Windows, Linux, macOS via Nodegui and Qt
58 lines (57 loc) • 1.93 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.QDarkBoxLayout = exports.BoxLayout = void 0;
const nodegui_1 = require('@nodegui/nodegui');
const core_1 = require('@dark-engine/core');
const factory_1 = require('../factory');
const dialog_1 = require('./dialog');
const dom_1 = require('../dom');
const BoxLayout = (0, core_1.component)(props => (0, factory_1.qBoxLayout)(props), {
displayName: 'BoxLayout',
});
exports.BoxLayout = BoxLayout;
class QDarkBoxLayout extends nodegui_1.QWidget {
boxLayout = new nodegui_1.QBoxLayout(nodegui_1.Direction.LeftToRight);
constructor() {
super();
this.setLayout(this.boxLayout);
}
detectIsContainer() {
return true;
}
getBoxLayout() {
return this.boxLayout;
}
setDirection(value) {
this.boxLayout.setDirection(value);
}
setSpacing(value) {
(0, dom_1.runAtTheEndOfCommit)(() => this.boxLayout.setSpacing(value));
}
setMargin(value) {
if ((0, core_1.detectIsNumber)(value)) {
(0, dom_1.runAtTheEndOfCommit)(() => this.boxLayout.setContentsMargins(value, value, value, value));
} else if ((0, core_1.detectIsArray)(value)) {
const [left, top, right, bottom] = value;
(0, dom_1.runAtTheEndOfCommit)(() => this.boxLayout.setContentsMargins(left, top, right, bottom));
}
}
setStretch(value) {
(0, dom_1.runAtTheEndOfCommit)(() => value.forEach((x, idx) => this.boxLayout.setStretch(idx, x)));
}
appendChild(child) {
if ((0, dialog_1.detectIsDialog)(child)) return;
this.boxLayout.addWidget(child);
}
insertBefore(child, _, idx) {
if ((0, dialog_1.detectIsDialog)(child)) return;
this.boxLayout.insertWidget(idx, child);
}
removeChild(child) {
if ((0, dialog_1.detectIsDialog)(child)) return;
this.boxLayout.removeWidget(child);
child.close();
}
}
exports.QDarkBoxLayout = QDarkBoxLayout;
//# sourceMappingURL=box-layout.js.map