Merge pull request #173 from nodegui/refactor/rename-children

Renaming `children` to `nodeChildren`
This commit is contained in:
Atul R 2019-11-03 19:45:33 +01:00 committed by GitHub
commit a5d0c78ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 25 additions and 25 deletions

View File

@ -18,7 +18,7 @@ export class QCheckBox extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setText.bind(this);
this.setChecked.bind(this);

View File

@ -23,7 +23,7 @@ export class QDial extends QAbstractSlider {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setNotchesVisible.bind(this);
this.notchesVisible.bind(this);

View File

@ -9,17 +9,17 @@ export class QGridLayout extends NodeLayout {
super();
if (parent) {
this.native = new addon.QGridLayout(parent.native);
this.parent = parent;
this.nodeParent = parent;
} else {
this.native = new addon.QGridLayout();
}
}
addWidget = (widget: NodeWidget) => {
this.native.addWidget(widget.native);
this.children.add(widget);
this.nodeChildren.add(widget);
};
removeWidget = (widget: NodeWidget) => {
this.native.removeWidget(widget.native);
this.children.delete(widget);
this.nodeChildren.delete(widget);
};
}

View File

@ -19,7 +19,7 @@ export class QLabel extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
}
setWordWrap(on: boolean) {
this.native.setWordWrap(on);

View File

@ -25,7 +25,7 @@ export class QLineEdit extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setText.bind(this);
this.text.bind(this);

View File

@ -22,7 +22,7 @@ export class QMainWindow extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setCentralWidget.bind(this);
this.setLayout = (parentLayout: NodeLayout) => {

View File

@ -19,7 +19,7 @@ export class QMenu extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
this.actions = new Set();
}
setTitle(title: string) {

View File

@ -26,7 +26,7 @@ export class QMenuBar extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
}
addMenu(menu: QMenu) {

View File

@ -33,7 +33,7 @@ export class QPlainTextEdit extends QAbstractScrollArea {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setPlainText.bind(this);
this.setPlaceholderText.bind(this);

View File

@ -18,7 +18,7 @@ export class QProgressBar extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setValue.bind(this);
this.setMinimum.bind(this);

View File

@ -22,7 +22,7 @@ export class QPushButton extends NodeWidget {
native = new addon.QPushButton();
}
super(native);
this.parent = parent;
this.nodeParent = parent;
this.native = native;
// bind member functions
this.setText.bind(this);

View File

@ -17,7 +17,7 @@ export class QRadioButton extends NodeWidget {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setText.bind(this);
}

View File

@ -19,7 +19,7 @@ export class QScrollArea extends QAbstractScrollArea {
}
super(native);
this.native = native;
this.parent = parent;
this.nodeParent = parent;
// bind member functions
this.setWidget.bind(this);
this.takeWidget.bind(this);

View File

@ -19,7 +19,7 @@ export class QSpinBox extends NodeWidget {
native = new addon.QSpinBox();
}
super(native);
this.parent = parent;
this.nodeParent = parent;
this.native = native;
// bind member functions
this.setPrefix.bind(this);

View File

@ -23,14 +23,14 @@ export class QTabWidget extends NodeWidget {
native = new addon.QTabWidget();
}
super(native);
this.parent = parent;
this.nodeParent = parent;
this.native = native;
// bind member functions
this.addTab.bind(this);
}
addTab(page: NodeWidget, icon: QIcon, label: string) {
this.children.add(page);
this.nodeChildren.add(page);
this.native.addTab(page.native, icon.native, label);
}

View File

@ -166,7 +166,7 @@ export class QWidget extends NodeWidget {
native = new addon.QWidget();
}
super(native);
this.parent = parent;
this.nodeParent = parent;
this.native = native;
}
}

View File

@ -1,6 +1,6 @@
export type NativeElement = { type: "native"; [key: string]: any };
export abstract class Component {
protected children = new Set<Component>();
protected parent?: Component;
protected nodeChildren = new Set<Component>();
protected nodeParent?: Component;
abstract native: NativeElement;
}

View File

@ -10,7 +10,7 @@ export class FlexLayout extends NodeLayout {
addWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
const childYogaNode = childFlexNode || childWidget.getFlexNode();
this.children.add(childWidget);
this.nodeChildren.add(childWidget);
this.native.addWidget(childWidget.native, childYogaNode);
};
@ -23,7 +23,7 @@ export class FlexLayout extends NodeLayout {
const childYogaNode = childFlexNode || childWidget.getFlexNode();
const beforeChildYogaNode =
beforeChildFlexNode || beforeChildWidget.getFlexNode();
this.children.add(childWidget); // No orderer required yet, so just inserting at the end.
this.nodeChildren.add(childWidget); // No orderer required yet, so just inserting at the end.
this.native.insertChildBefore(
childWidget.native,
beforeChildYogaNode,
@ -32,11 +32,11 @@ export class FlexLayout extends NodeLayout {
};
removeWidget = (childWidget: NodeWidget, childFlexNode?: FlexNode) => {
if (!this.children.has(childWidget)) {
if (!this.nodeChildren.has(childWidget)) {
return;
}
const childYogaNode = childFlexNode || childWidget.getFlexNode();
this.children.delete(childWidget);
this.nodeChildren.delete(childWidget);
this.native.removeWidget(childWidget.native, childYogaNode);
};