@@ -5,7 +5,13 @@ import {
55 RendererStyleFlags2 ,
66 RendererType2
77} from '@angular/core' ;
8- import { QWidget , QPushButton , QLabel , FlexLayout } from '@nodegui/nodegui' ;
8+ import {
9+ QWidget ,
10+ QPushButton ,
11+ QLabel ,
12+ FlexLayout ,
13+ QMainWindow
14+ } from '@nodegui/nodegui' ;
915import { QWindowService } from './window' ;
1016import { TextField } from './nodes' ;
1117
@@ -33,35 +39,37 @@ export class NodeguiRenderer implements Renderer2 {
3339 constructor ( private window : QWindowService ) { }
3440
3541 createElement ( name : string , namespace ?: string | null ) : any {
36- const button = new QPushButton ( ) ;
37- button . setObjectName ( 'button' ) ;
38- return button ;
42+ switch ( name ) {
43+ case 'button' :
44+ return new QPushButton ( ) ;
45+ case 'window' :
46+ return new FlexLayout ( ) ;
47+ case 'text' :
48+ return new QLabel ( ) ;
49+ }
3950 }
4051
4152 createText ( value : string ) : any {
42- // may be use Qwidget? need for set button to text
43-
44- // const label = new QLabel();
45- // label.setText(value);
46- // label.setInlineStyle(`
47- // color: red;
48- // `);
4953 return new TextField ( value ) ;
5054 }
5155
5256 selectRootElement ( ) : any {
53- return this . window . rootLayout ;
57+ return this . window . window ;
5458 }
5559
5660 addClass ( el : any , name : string ) : void {
5761 console . log ( el , name ) ;
5862 }
5963
6064 appendChild ( parent : FlexLayout , newChild : any ) : void {
61- // console.log(parent, newChild);
62-
6365 if ( newChild ) {
64- if ( parent instanceof FlexLayout && newChild instanceof TextField ) {
66+ if ( parent instanceof QMainWindow && newChild instanceof FlexLayout ) {
67+ this . window . centralWidget . setLayout ( newChild ) ;
68+ this . window . window . setCentralWidget ( this . window . centralWidget ) ;
69+ } else if (
70+ parent instanceof FlexLayout &&
71+ newChild instanceof TextField
72+ ) {
6573 const label = new QLabel ( ) ;
6674 newChild . parent = label ;
6775 label . setText ( newChild . value ) ;
@@ -72,6 +80,11 @@ export class NodeguiRenderer implements Renderer2 {
7280 ) {
7381 newChild . parent = parent ;
7482 parent . setText ( newChild . value ) ;
83+ } else if ( newChild instanceof QLabel ) {
84+ parent . addWidget ( newChild ) ;
85+ } else if ( parent instanceof QLabel && newChild instanceof TextField ) {
86+ newChild . parent = parent ;
87+ parent . setText ( newChild . value ) ;
7588 } else {
7689 parent . addWidget ( newChild ) ;
7790 }
@@ -114,7 +127,9 @@ export class NodeguiRenderer implements Renderer2 {
114127 value : string ,
115128 namespace ?: string | null
116129 ) : void {
117- el [ name ] = value ;
130+ if ( el instanceof FlexLayout && name === 'title' ) {
131+ this . window . window . setWindowTitle ( value ) ;
132+ }
118133 }
119134
120135 setProperty ( el : any , name : string , value : any ) : void {
@@ -138,6 +153,8 @@ export class NodeguiRenderer implements Renderer2 {
138153 }
139154
140155 setValue ( node : any , value : string ) : void {
156+ // console.log('setValue', node, value);
157+
141158 if ( node instanceof TextField ) {
142159 node . parent . setText ( value ) ;
143160 } else {
0 commit comments