Merge pull request #173 from nodegui/refactor/rename-children
Renaming `children` to `nodeChildren`
This commit is contained in:
commit
a5d0c78ba6
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -26,7 +26,7 @@ export class QMenuBar extends NodeWidget {
|
||||
}
|
||||
super(native);
|
||||
this.native = native;
|
||||
this.parent = parent;
|
||||
this.nodeParent = parent;
|
||||
}
|
||||
|
||||
addMenu(menu: QMenu) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ export class QWidget extends NodeWidget {
|
||||
native = new addon.QWidget();
|
||||
}
|
||||
super(native);
|
||||
this.parent = parent;
|
||||
this.nodeParent = parent;
|
||||
this.native = native;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user