uil 1.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +57 -0
  2. package/build/uil.js +7040 -4199
  3. package/build/uil.min.js +6 -4
  4. package/build/uil.module.js +7200 -2761
  5. package/examples/js/BufferGeometryUtils.js +921 -0
  6. package/examples/js/SimplexNoise.js +324 -0
  7. package/examples/js/controls/OrbitControls.js +1215 -0
  8. package/examples/js/controls/OrbitControls_.js +1042 -0
  9. package/examples/js/libs/sea3d.min.js +373 -0
  10. package/examples/js/libs/three.min.js +6 -0
  11. package/examples/js/math.js +447 -0
  12. package/examples/js/objects/Landscape.js +778 -0
  13. package/examples/js/objects/Lensflare.js +372 -0
  14. package/examples/js/objects/SuperSky.js +297 -0
  15. package/examples/js/objects/Water.js +329 -0
  16. package/package.json +56 -54
  17. package/src/Uil.js +2 -17
  18. package/src/Uil_dev.js +15 -0
  19. package/src/core/Gui.js +601 -299
  20. package/src/core/Proto.js +490 -220
  21. package/src/core/Roots.js +864 -0
  22. package/src/core/Tools.js +591 -140
  23. package/src/core/V2.js +131 -0
  24. package/src/core/add.js +52 -57
  25. package/src/proto/Bool.js +117 -52
  26. package/src/proto/Button.js +286 -146
  27. package/src/proto/Circular.js +162 -130
  28. package/src/proto/Color.js +331 -289
  29. package/src/proto/Empty.js +15 -0
  30. package/src/proto/Fps.js +232 -159
  31. package/src/proto/Graph.js +310 -0
  32. package/src/proto/Grid.js +297 -0
  33. package/src/proto/Group.js +334 -160
  34. package/src/proto/Item.js +120 -0
  35. package/src/proto/Joystick.js +159 -185
  36. package/src/proto/Knob.js +210 -91
  37. package/src/proto/List.js +661 -249
  38. package/src/proto/Numeric.js +329 -162
  39. package/src/proto/Pad2D.js +268 -0
  40. package/src/proto/Rubric.js +0 -0
  41. package/src/proto/Select.js +178 -0
  42. package/src/proto/Selector.js +13 -0
  43. package/src/proto/Slide.js +191 -185
  44. package/src/proto/TextInput.js +149 -59
  45. package/src/proto/Title.js +40 -31
@@ -1,256 +1,430 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
3
- //import { add } from '../core/Gui';
4
- import { add } from '../core/add';
5
1
 
6
- function Group ( o ) {
7
-
8
- Proto.call( this, o );
2
+ import { Roots } from '../core/Roots.js';
3
+ import { Proto } from '../core/Proto.js';
9
4
 
10
- this.autoHeight = true;
11
- this.isGroup = true;
5
+ export class Group extends Proto {
12
6
 
13
- //this.bg = o.bg || null;
14
-
7
+ constructor( o = {} ) {
8
+
9
+ super( o );
10
+
11
+ this.isGroup = true
12
+
13
+ this.ADD = o.add;
14
+
15
+ this.uis = [];
16
+
17
+ this.isEmpty = true;
18
+
19
+ this.autoHeight = true;
20
+ this.current = -1;
21
+ this.targetIn = null;
15
22
 
16
- //this.h = 25;
17
- this.baseH = this.h;
18
- var fltop = Math.floor(this.h*0.5)-6;
23
+ this.decal = 0;
24
+
25
+ this.baseH = this.h;
26
+
27
+ let fltop = Math.floor(this.h*0.5)-6;
28
+
29
+ this.isLine = o.line !== undefined ? o.line : false;
30
+
31
+ this.decal = 0;
32
+
33
+ if( o.group ){
34
+ this.decal = o.group.decal ? o.group.decal : 0
35
+ this.decal += 6
36
+ }
19
37
 
20
- this.isOpen = o.open || false;
38
+ this.useFlex = true
39
+ let flexible = this.useFlex ? 'display:flex; flex-flow: row wrap;' : ''
21
40
 
22
- this.isLine = o.line !== undefined ? o.line : true;
41
+ this.c[2] = this.dom( 'div', this.css.basic + flexible + 'width:100%; left:0; height:auto; overflow:hidden; top:'+this.h+'px');//
42
+ this.c[3] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; left:0; top:'+fltop+'px;', { d:this.svgs.group, fill:this.colors.text, stroke:'none'});
43
+ this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:10px; height:10px; left:'+(4+this.decal)+'px; top:'+fltop+'px;', { d:this.svgs.arrow, fill:this.colors.text, stroke:'none'});
44
+ // bottom line
45
+ if( this.isLine ) this.c[5] = this.dom( 'div', this.css.basic + 'background:rgba(255, 255, 255, 0.2); width:100%; left:0; height:1px; bottom:0px');
23
46
 
24
- this.c[2] = Tools.dom( 'div', Tools.css.basic + 'width:100%; left:0; height:auto; overflow:hidden; top:'+this.h+'px');
25
- this.c[3] = Tools.dom( 'path', Tools.css.basic + 'position:absolute; width:10px; height:10px; left:0; top:'+fltop+'px;', { d:Tools.GPATH, fill:this.fontColor, stroke:'none'});
26
- this.c[4] = Tools.dom( 'path', Tools.css.basic + 'position:absolute; width:10px; height:10px; left:4px; top:'+fltop+'px;', { d:'M 3 8 L 8 5 3 2 3 8 Z', fill:this.fontColor, stroke:'none'});
27
- // bottom line
28
- if(this.isLine) this.c[5] = Tools.dom( 'div', Tools.css.basic + 'background:rgba(255, 255, 255, 0.2); width:100%; left:0; height:1px; bottom:0px');
47
+ let s = this.s;
29
48
 
30
- var s = this.s;
31
49
 
32
- s[0].height = this.h + 'px';
33
- s[1].height = this.h + 'px';
34
- //s[1].top = 4 + 'px';
35
- //s[1].left = 4 + 'px';
36
- s[1].pointerEvents = 'auto';
37
- s[1].cursor = 'pointer';
38
- this.c[1].name = 'group';
39
50
 
40
- this.s[1].marginLeft = '10px';
41
- this.s[1].lineHeight = this.h-4;
42
- this.s[1].color = this.fontColor;
43
- this.s[1].fontWeight = 'bold';
51
+ s[0].height = this.h + 'px';
52
+ s[1].height = this.h + 'px';
53
+ this.c[1].name = 'group';
44
54
 
45
- this.uis = [];
55
+ s[1].marginLeft = (10+this.decal)+'px';
56
+ s[1].lineHeight = this.h-4;
57
+ s[1].color = this.colors.text;
58
+ s[1].fontWeight = 'bold';
46
59
 
47
- this.c[1].events = [ 'click' ];
60
+ if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px';
61
+ //if( o.border ) s[0].border = '1px solid ' + o.border;
48
62
 
49
- this.init();
50
63
 
51
- if( o.bg !== undefined ) this.setBG(o.bg);
64
+ /*if(this.decal){
65
+ s[0].boxSizing = 'border-box';
66
+ s[0].backgroundClip = 'border-box';
67
+ s[0].border = (this.decal/3)+'px solid ' + o.group.colors.background;
68
+ }*/
52
69
 
53
- if( this.isOpen ) this.open();
70
+
54
71
 
55
- };
72
+
73
+ this.init();
56
74
 
57
- Group.prototype = Object.create( Proto.prototype );
58
- Group.prototype.constructor = Group;
75
+ this.setBG( o.bg );
59
76
 
60
- Group.prototype.setBG = function( c ){
77
+ if( o.open !== undefined ) this.open();
61
78
 
62
- this.s[0].background = c;
63
79
 
64
- var i = this.uis.length;
65
- while(i--){
66
- this.uis[i].setBG( c );
80
+ //s[0].background = this.bg;
81
+
82
+ }
83
+
84
+ testZone ( e ) {
85
+
86
+ let l = this.local;
87
+ if( l.x === -1 && l.y === -1 ) return '';
88
+
89
+ let name = '';
90
+
91
+ if( l.y < this.baseH ) name = 'title';
92
+ else {
93
+ if( this.isOpen ) name = 'content';
94
+ }
95
+
96
+ return name;
97
+
67
98
  }
68
99
 
69
- };
100
+ clearTarget () {
70
101
 
71
- Group.prototype.handleEvent = function( e ) {
102
+ if( this.current === -1 ) return false;
72
103
 
73
- e.preventDefault();
74
- //e.stopPropagation();
104
+ // if(!this.targetIn ) return;
105
+ this.targetIn .uiout();
106
+ this.targetIn .reset();
107
+ this.current = -1;
108
+ this.targetIn = null;
109
+ this.cursor();
110
+ return true;
75
111
 
76
- switch( e.type ) {
77
- case 'click': this.click( e ); break;
78
112
  }
79
113
 
80
- };
114
+ reset () {
115
+
116
+ this.clearTarget();
117
+
118
+ }
81
119
 
120
+ // ----------------------
121
+ // EVENTS
122
+ // ----------------------
82
123
 
83
- Group.prototype.click = function( e ){
124
+ handleEvent ( e ) {
84
125
 
85
- if( this.isOpen ) this.close();
86
- else this.open();
126
+ let type = e.type;
87
127
 
88
- };
128
+ let change = false;
129
+ let targetChange = false;
89
130
 
90
- Group.prototype.add = function( ){
131
+ let name = this.testZone( e );
91
132
 
92
- var a = arguments;
133
+ if( !name ) return;
93
134
 
94
- if( typeof a[1] === 'object' ){
95
- a[1].isUI = this.isUI;
96
- a[1].target = this.c[2];
97
- a[1].main = this.main;
98
- } else if( typeof arguments[1] === 'string' ){
99
- if( a[2] === undefined ) [].push.call(a, { isUI:true, target:this.c[2], main:this.main });
100
- else{
101
- a[2].isUI = true;
102
- a[2].target = this.c[2];
103
- a[2].main = this.main;
135
+ switch( name ){
136
+
137
+ case 'content':
138
+ this.cursor();
139
+
140
+ if( Roots.isMobile && type === 'mousedown' ) this.getNext( e, change );
141
+
142
+ if( this.targetIn ) targetChange = this.targetIn .handleEvent( e );
143
+
144
+ //if( type === 'mousemove' ) change = this.styles('def');
145
+
146
+ if( !Roots.lock ) this.getNext( e, change );
147
+
148
+ break;
149
+ case 'title':
150
+ this.cursor('pointer');
151
+ if( type === 'mousedown' ){
152
+ if( this.isOpen ) this.close();
153
+ else this.open();
154
+ }
155
+ break;
156
+
157
+
158
+ }
159
+
160
+ if( this.isDown ) change = true;
161
+ if( targetChange ) change = true;
162
+
163
+ return change;
164
+
165
+ }
166
+
167
+ getNext ( e, change ) {
168
+
169
+ let next = Roots.findTarget( this.uis, e );
170
+
171
+ if( next !== this.current ){
172
+ this.clearTarget();
173
+ this.current = next;
174
+ change = true;
175
+ }
176
+
177
+ if( next !== -1 ){
178
+ this.targetIn = this.uis[ this.current ];
179
+ this.targetIn .uiover();
104
180
  }
181
+
105
182
  }
106
183
 
107
- var n = add.apply( this, a );
108
- this.uis.push( n );
184
+ // ----------------------
185
+
186
+ /*calcH () {
187
+
188
+ let lng = this.uis.length, i, u, h=0, px=0, tmph=0;
189
+ for( i = 0; i < lng; i++){
190
+ u = this.uis[i];
191
+ if( !u.autoWidth ){
109
192
 
110
- /*n.py = this.h;
193
+ if(px===0) h += u.h+1;
194
+ else {
195
+ if(tmph<u.h) h += u.h-tmph;
196
+ }
197
+ tmph = u.h;
111
198
 
112
- if( !n.autoWidth ){
113
- var y = n.c[0].getBoundingClientRect().top;
114
- if( this.prevY !== y ){
115
- this.calc( n.h + 1 );
116
- this.prevY = y;
199
+ //tmph = tmph < u.h ? u.h : tmph;
200
+ px += u.w;
201
+ if( px+u.w > this.w ) px = 0;
202
+
203
+ }
204
+ else h += u.h+1;
117
205
  }
118
- }else{
119
- this.prevY = -1;
120
- this.calc( n.h + 1 );
206
+
207
+ return h;
121
208
  }*/
122
209
 
123
- if( n.autoHeight ) n.parentGroup = this;
210
+
124
211
 
125
- return n;
126
212
 
127
- }
213
+ setBG ( bg ) {
128
214
 
129
- /*Group.prototype.add = function( ){
215
+ if( bg !== undefined ) this.colors.background = bg
130
216
 
131
- var a = arguments;
217
+ this.c[0].style.background = this.colors.background;
132
218
 
133
- if( typeof a[1] === 'object' ){
134
- a[1].isUI = this.isUI;
135
- a[1].target = this.c[2];
136
- } else if( typeof arguments[1] === 'string' ){
137
- if( a[2] === undefined ) [].push.call(a, { isUI:true, target:this.c[2] });
138
- else{
139
- a[2].isUI = true;
140
- a[2].target = this.c[2];
219
+ let i = this.uis.length;
220
+ while(i--){
221
+ this.uis[i].setBG( this.colors.background );
141
222
  }
223
+
142
224
  }
143
225
 
144
- //var n = Gui.prototype.add.apply( this, a );
145
- var n = Gui.prototype.add.call( this, a );
146
- //var n = add.apply( this, a );
147
- if( n.autoHeight ) n.parentGroup = this;
226
+ add () {
227
+
228
+ let a = arguments;
229
+
230
+ if( typeof a[1] === 'object' ){
231
+ a[1].isUI = this.isUI;
232
+ a[1].target = this.c[2];
233
+ a[1].main = this.main;
234
+ a[1].group = this;
235
+ } else if( typeof arguments[1] === 'string' ){
236
+ if( a[2] === undefined ) [].push.call( a, { isUI:true, target:this.c[2], main:this.main });
237
+ else{
238
+ a[2].isUI = true;
239
+ a[2].target = this.c[2];
240
+ a[2].main = this.main;
241
+ a[2].group = this;
242
+ }
243
+ }
148
244
 
149
- return n;
245
+ //let n = add.apply( this, a );
246
+ let u = this.ADD.apply( this, a );
150
247
 
151
- };*/
248
+ this.uis.push( u )
152
249
 
153
- Group.prototype.open = function(){
250
+ //this.calc()
154
251
 
155
- this.isOpen = true;
156
- Tools.setSvg( this.c[4], 'd','M 5 8 L 8 3 2 3 5 8 Z');
157
- //this.s[4].background = UIL.F1;
158
- this.rSizeContent();
159
252
 
160
- if( this.isUI ) this.main.calc( this.h - this.baseH );
161
253
 
162
- };
254
+ this.isEmpty = false;
163
255
 
164
- Group.prototype.close = function(){
256
+ return u;
165
257
 
166
- if( this.isUI ) this.main.calc(-(this.h-this.baseH ));
258
+ }
167
259
 
168
- this.isOpen = false;
169
- //this.s[4].background = UIL.F0;
170
- Tools.setSvg( this.c[4], 'd','M 3 8 L 8 5 3 2 3 8 Z');
171
- this.h = this.baseH;
260
+ // remove one node
172
261
 
173
- this.s[0].height = this.h + 'px';
262
+ remove ( n ) {
174
263
 
175
- };
264
+ if( n.clear ) n.clear();
176
265
 
177
- Group.prototype.clear = function(){
266
+ }
178
267
 
179
- this.clearGroup();
180
- if( this.isUI ) this.main.calc( -(this.h +1 ));
181
- Proto.prototype.clear.call( this );
268
+ // clear all iner
182
269
 
183
- };
270
+ empty () {
184
271
 
185
- Group.prototype.clearGroup = function(){
272
+ this.close();
186
273
 
187
- this.close();
274
+ let i = this.uis.length, item;
275
+
276
+ while( i-- ){
277
+ item = this.uis.pop();
278
+ this.c[2].removeChild( item.c[0] );
279
+ item.clear( true );
280
+
281
+ //this.uis[i].clear()
282
+ }
283
+
284
+ this.isEmpty = true;
285
+ this.h = this.baseH;
188
286
 
189
- var i = this.uis.length;
190
- while(i--){
191
- this.uis[i].clear();
192
- this.uis.pop();
193
287
  }
194
- this.uis = [];
195
288
 
196
- //if( this.isUI ) this.main.calc( -this.h+ this.baseH );
289
+ // clear one element
290
+
291
+ clearOne ( n ) {
292
+
293
+ let id = this.uis.indexOf( n );
197
294
 
198
- this.h = this.baseH;
199
- //this.s[0].height = this.h + 'px';
200
- //this.s[2].height = 0;
295
+ if ( id !== -1 ) {
296
+ this.calc( - ( this.uis[ id ].h + 1 ) );
297
+ this.c[2].removeChild( this.uis[ id ].c[0] );
298
+ this.uis.splice( id, 1 );
299
+
300
+ if( this.uis.length === 0 ){
301
+ this.isEmpty = true;
302
+ this.close();
303
+ }
304
+ }
305
+
306
+ }
201
307
 
202
308
 
203
309
 
310
+ open () {
311
+
312
+ super.open();
313
+
314
+ this.setSvg( this.c[4], 'd', this.svgs.arrowDown )
315
+ this.rSizeContent()
204
316
 
205
- //this.calc();
317
+ let t = this.h - this.baseH;
318
+
319
+ this.parentHeight()
320
+
321
+ }
206
322
 
207
- };
323
+ close () {
208
324
 
209
- Group.prototype.calc = function( y ){
325
+ super.close();
210
326
 
211
- if( !this.isOpen ) return;
327
+ let t = this.h - this.baseH;
212
328
 
213
- //this.h = this.baseH;
329
+ this.setSvg( this.c[4], 'd', this.svgs.arrow );
330
+ this.h = this.baseH;
331
+ this.s[0].height = this.h + 'px';
214
332
 
215
- if( y !== undefined ){
216
- this.h += y;
217
- if( this.isUI ) this.main.calc( y );
333
+ this.parentHeight()
218
334
 
219
335
  }
220
- else this.h = this.c[2].offsetHeight + this.baseH;
221
336
 
222
- //var total = this.c[2].offsetHeight;
223
- //this.h += total;
337
+ clear () {
224
338
 
225
- this.s[0].height = this.h + 'px';
339
+ this.empty();
340
+ if( this.isUI ) this.main.calc( -( this.h + 1 ));
341
+ Proto.prototype.clear.call( this );
226
342
 
227
- //
343
+ }
344
+
345
+ clearGroup () {
346
+
347
+ this.empty();
228
348
 
229
- };
349
+ /*this.close();
230
350
 
231
- Group.prototype.rSizeContent = function(){
351
+ let i = this.uis.length;
352
+ while(i--){
353
+ this.uis[i].clear();
354
+ }
355
+ this.uis = [];
356
+ this.h = this.baseH;*/
232
357
 
233
- var i = this.uis.length;
234
- while(i--){
235
- this.uis[i].setSize( this.width );
236
- this.uis[i].rSize();
237
358
  }
238
- this.calc();
239
359
 
240
- };
360
+ calcUis () {
361
+
362
+ if( !this.isOpen ) this.h = this.baseH;
363
+ else this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH ) + this.baseH;
241
364
 
242
- Group.prototype.rSize = function(){
365
+ this.s[0].height = this.h + 'px';
243
366
 
244
- Proto.prototype.rSize.call( this );
367
+ //console.log('G', this.h)
245
368
 
246
- var s = this.s;
369
+ //if( !this.isOpen ) return;
247
370
 
248
- s[3].left = ( this.sa + this.sb - 17 ) + 'px';
249
- s[1].width = this.width + 'px';
250
- s[2].width = this.width + 'px';
371
+ //this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH )+this.baseH;
251
372
 
252
- if(this.isOpen) this.rSizeContent();
373
+ }
253
374
 
254
- };
375
+ parentHeight ( t ) {
376
+
377
+ if ( this.group !== null ) this.group.calc( t )
378
+ else if ( this.isUI ) this.main.calc( t )
379
+
380
+ }
381
+
382
+ calc ( y ) {
383
+
384
+ if( !this.isOpen ) return;
385
+
386
+ /*
387
+
388
+ if( y !== undefined ){
389
+ this.h += y;
390
+ if( this.isUI ) this.main.calc( y );
391
+ } else {
392
+ this.h = this.calcH() + this.baseH;
393
+ }
394
+ this.s[0].height = this.h + 'px';*/
395
+
396
+ // if(this.isOpen)
397
+ if( this.isUI ) this.main.calc()
398
+ else this.calcUis()
399
+
400
+ this.s[0].height = this.h + 'px';
401
+
402
+ }
403
+
404
+ rSizeContent () {
405
+
406
+ let i = this.uis.length;
407
+ while(i--){
408
+ this.uis[i].setSize( this.w );
409
+ this.uis[i].rSize();
410
+ }
411
+
412
+ //this.calc()
413
+
414
+ }
415
+
416
+ rSize () {
417
+
418
+ super.rSize();
419
+
420
+ let s = this.s;
421
+
422
+ s[3].left = ( this.sa + this.sb - 17 ) + 'px';
423
+ s[1].width = this.w + 'px';
424
+ s[2].width = this.w + 'px';
425
+
426
+ if( this.isOpen ) this.rSizeContent();
427
+
428
+ }
255
429
 
256
- export { Group };
430
+ }