Makes flexNode optional in addWidget

This commit is contained in:
Atul R 2019-06-27 23:13:12 +02:00
parent e2a4046a34
commit fcb2bdccee
2 changed files with 5 additions and 2 deletions

View File

@ -1,8 +1,10 @@
import { Component } from "../../core/Component";
import { NodeWidget } from "../../QtGui/QWidget";
// All Layouts should extend this abstract class.
export abstract class NodeLayout extends Component {
type: string = "layout";
abstract addWidget: (childWidget: NodeWidget, ...args: any[]) => void;
}
// export class QLayout extends NodeLayout { //Dont need QLayout for now

View File

@ -8,9 +8,10 @@ export class FlexLayout extends NodeLayout {
native: NativeElement = new addon.FlexLayout();
protected flexNode?: FlexNode;
addWidget = (childWidget: NodeWidget, childFlexNode: FlexNode) => {
addWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
const childYogaNode = childFlexNode || childWidget.getFlexNode();
this.children.add(childWidget);
this.native.addWidget(childWidget.native, childFlexNode);
this.native.addWidget(childWidget.native, childYogaNode);
};
setFlexNode = (flexNode: FlexNode) => {
this.flexNode = flexNode;