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,261 +1,267 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
1
+ import { Proto } from '../core/Proto.js';
3
2
 
4
- function Slide ( o ){
5
3
 
6
- Proto.call( this, o );
4
+ export class Slide extends Proto {
7
5
 
8
- this.setTypeNumber( o );
6
+ constructor( o = {} ) {
9
7
 
10
- this.stype = o.stype || 0;
11
- this.buttonColor = o.bColor || Tools.colors.button;
8
+ super( o );
12
9
 
13
- //this.old = this.value;
14
- this.isDown = false;
15
- this.isOver = false;
16
- this.allway = o.allway || false;
10
+ this.setTypeNumber( o );
17
11
 
18
- this.c[2] = Tools.dom( 'div', Tools.css.txtselect + 'letter-spacing:-1px; padding:2px 5px; text-align:right; cursor:pointer; width:47px; border:none; color:'+ this.fontColor );
19
- this.c[3] = Tools.dom( 'div', Tools.css.basic + 'pointer-events:auto; cursor:w-resize; top:0; height:'+this.h+'px;' );
20
- this.c[4] = Tools.dom( 'div', Tools.css.basic + 'border:1px solid '+Tools.colors.border+'; pointer-events:none; background:rgba(0,0,0,0.3); top:2px; height:'+(this.h-4)+'px;' );
21
- this.c[5] = Tools.dom( 'div', Tools.css.basic + 'left:4px; top:5px; height:'+(this.h-10)+'px; background:' + this.fontColor +';' );
22
12
 
23
- this.c[2].name = 'text';
24
- this.c[3].name = 'scroll';
13
+ this.model = o.stype || 0;
14
+ if( o.mode !== undefined ) this.model = o.mode;
25
15
 
26
- if(this.stype !== 0){
27
- if(this.stype === 1 || this.stype === 3){
28
- var h1 = 4;
29
- var h2 = 8;
30
- var ww = this.h-4;
31
- var ra = 20;
32
- }
33
-
34
- if(this.stype === 2){
35
- h1 = 2;
36
- h2 = 4;
37
- ra = 2;
38
- ww = (this.h-4)*0.5
39
- }
16
+ //this.defaultBorderColor = this.colors.hide;
40
17
 
41
- if(this.stype === 3) this.c[5].style.visible = 'none';
18
+ this.isDown = false;
19
+ this.isOver = false;
20
+ this.allway = o.allway || false;
42
21
 
43
- this.c[4].style.borderRadius = h1 + 'px';
44
- this.c[4].style.height = h2 + 'px';
45
- this.c[4].style.top = (this.h*0.5) - h1 + 'px';
46
- this.c[5].style.borderRadius = (h1*0.5) + 'px';
47
- this.c[5].style.height = h1 + 'px';
48
- this.c[5].style.top = (this.h*0.5)-(h1*0.5) + 'px';
22
+ this.isDeg = o.isDeg || false;
23
+ this.isCyclic = o.cyclic || false;
49
24
 
50
- this.c[6] = Tools.dom( 'div', Tools.css.basic + 'border-radius:'+ra+'px; margin-left:'+(-ww*0.5)+'px; border:1px solid '+Tools.colors.border+'; background:'+this.buttonColor+'; left:4px; top:2px; height:'+(this.h-4)+'px; width:'+ww+'px;' );
51
- }
25
+ this.firstImput = false;
52
26
 
53
- this.c[3].events = [ 'mouseover', 'mousedown', 'mouseout' ];
54
- this.c[2].events = [ 'keydown', 'keyup', 'mousedown', 'blur', 'focus' ];
27
+ let cc = this.colors
55
28
 
56
- this.init();
29
+ //this.c[2] = this.dom( 'div', this.css.txtselect + 'letter-spacing:-1px; text-align:right; width:47px; border:1px dashed '+this.defaultBorderColor+'; color:'+ this.colors.text );
30
+ //this.c[2] = this.dom( 'div', this.css.txtselect + 'text-align:right; width:47px; border:1px dashed '+this.defaultBorderColor+'; color:'+ this.colors.text );
31
+ this.c[2] = this.dom( 'div', this.css.txtselect + 'border:none; background:none; width:47px; color:'+ cc.text +';' );
32
+ //this.c[2] = this.dom( 'div', this.css.txtselect + 'letter-spacing:-1px; text-align:right; width:47px; color:'+ this.colors.text );
33
+ this.c[3] = this.dom( 'div', this.css.basic + ' top:0; height:'+this.h+'px;' );
34
+ this.c[4] = this.dom( 'div', this.css.basic + 'background:'+cc.back+'; top:2px; height:'+(this.h-4)+'px;' );
35
+ this.c[5] = this.dom( 'div', this.css.basic + 'left:4px; top:5px; height:'+(this.h-10)+'px; background:' + cc.text +';' );
57
36
 
58
- };
37
+ this.c[2].isNum = true;
38
+ //this.c[2].style.height = (this.h-4) + 'px';
39
+ //this.c[2].style.lineHeight = (this.h-8) + 'px';
40
+ this.c[2].style.height = (this.h-2) + 'px';
41
+ this.c[2].style.lineHeight = (this.h-10) + 'px';
59
42
 
60
- Slide.prototype = Object.create( Proto.prototype );
61
- Slide.prototype.constructor = Slide;
43
+ if(this.model !== 0){
62
44
 
63
- Slide.prototype.handleEvent = function( e ) {
45
+ let h1 = 4, h2 = 8, ww = this.h-4, ra = 20;
64
46
 
65
- //e.preventDefault();
47
+ if( this.model === 2 ){
48
+ h1 = 4;//2
49
+ h2 = 8;
50
+ ra = 2;
51
+ ww = (this.h-4)*0.5
52
+ }
66
53
 
67
- //console.log(e.target.name)
54
+ if(this.model === 3) this.c[5].style.visible = 'none';
68
55
 
69
- switch( e.type ) {
70
- case 'mouseover': this.over( e ); break;
71
- case 'mousedown': e.target.name === 'text' ? this.textdown( e ) : this.down( e ); break;
72
- case 'mouseout': this.out( e ); break;
56
+ this.c[4].style.borderRadius = h1 + 'px';
57
+ this.c[4].style.height = h2 + 'px';
58
+ this.c[4].style.top = (this.h*0.5) - h1 + 'px';
59
+ this.c[5].style.borderRadius = (h1*0.5) + 'px';
60
+ this.c[5].style.height = h1 + 'px';
61
+ this.c[5].style.top = (this.h*0.5)-(h1*0.5) + 'px';
73
62
 
74
- case 'mouseup': this.up( e ); break;
75
- case 'mousemove': if(this.isDown) this.move( e ); break;
63
+ this.c[6] = this.dom( 'div', this.css.basic + 'border-radius:'+ra+'px; margin-left:'+(-ww*0.5)+'px; border:1px solid '+cc.border+'; background:'+cc.button+'; left:4px; top:2px; height:'+(this.h-4)+'px; width:'+ww+'px;' );
64
+ }
76
65
 
77
- case 'blur': this.blur( e ); break;
78
- case 'focus': this.focus( e ); break;
79
- case 'keydown': this.keydown( e ); break;
80
- case 'keyup': this.keyup( e ); break;
81
- }
66
+ this.init();
82
67
 
83
- };
84
-
85
- Slide.prototype.mode = function( mode ){
86
-
87
- var s = this.s;
88
-
89
- switch(mode){
90
- case 0: // base
91
- s[2].color = this.fontColor;
92
- s[4].background = 'rgba(0,0,0,0.3)';
93
- s[5].background = this.fontColor;
94
- break;
95
- case 1: // over
96
- s[2].color = this.colorPlus;
97
- // if( !s[6] ) s[4].background = UIL.SlideBG;
98
- // else
99
- s[4].background = 'rgba(0,0,0,0.6)';
100
- s[5].background = this.colorPlus;
101
- break;
102
68
  }
103
- }
104
69
 
105
- Slide.prototype.over = function( e ){
70
+ testZone ( e ) {
106
71
 
107
- e.preventDefault();
108
- e.stopPropagation();
72
+ let l = this.local;
73
+ if( l.x === -1 && l.y === -1 ) return '';
74
+
75
+ if( l.x >= this.txl ) return 'text';
76
+ else if( l.x >= this.sa ) return 'scroll';
77
+ else return '';
109
78
 
110
- this.isOver = true;
111
- this.mode(1);
79
+ }
112
80
 
113
- };
81
+ // ----------------------
82
+ // EVENTS
83
+ // ----------------------
114
84
 
115
- Slide.prototype.out = function( e ){
85
+ mouseup ( e ) {
86
+
87
+ if( this.isDown ) this.isDown = false;
88
+
89
+ }
116
90
 
117
- e.preventDefault();
118
- e.stopPropagation();
91
+ mousedown ( e ) {
119
92
 
120
- this.isOver = false;
121
- if(this.isDown) return;
122
- this.mode(0);
93
+ let name = this.testZone( e );
123
94
 
124
- };
95
+ if( !name ) return false;
125
96
 
126
- Slide.prototype.up = function( e ){
97
+ if( name === 'scroll' ){
98
+ this.isDown = true;
99
+ this.old = this.value;
100
+ this.mousemove( e );
101
+
102
+ }
127
103
 
128
- e.preventDefault();
129
- e.stopPropagation();
104
+ /*if( name === 'text' ){
105
+ this.setInput( this.c[2], function(){ this.validate() }.bind(this) );
106
+ }*/
130
107
 
131
- this.isDown = false;
132
- document.removeEventListener( 'mouseup', this, false );
133
- document.removeEventListener( 'mousemove', this, false );
108
+ return true;
134
109
 
135
- if(this.isOver) this.mode(1);
136
- else this.mode(0);
110
+ }
137
111
 
138
- this.sendEnd();
139
-
140
- };
112
+ mousemove ( e ) {
141
113
 
142
- Slide.prototype.down = function( e ){
114
+ let nup = false;
143
115
 
144
- e.preventDefault();
145
- e.stopPropagation();
116
+ let name = this.testZone( e );
146
117
 
147
- this.isDown = true;
148
- document.addEventListener( 'mouseup', this, false );
149
- document.addEventListener( 'mousemove', this, false );
118
+ if( name === 'scroll' ) {
119
+ this.mode(1);
120
+ this.cursor('w-resize');
121
+ //} else if(name === 'text'){
122
+ //this.cursor('pointer');
123
+ } else {
124
+ this.cursor();
125
+ }
150
126
 
151
- this.left = this.c[3].getBoundingClientRect().left;
152
- this.old = this.value;
153
- this.move( e );
127
+ if( this.isDown ){
154
128
 
155
- };
129
+ let n = ((( e.clientX - (this.zone.x+this.sa) - 3 ) / this.ww ) * this.range + this.min ) - this.old;
130
+ if(n >= this.step || n <= this.step){
131
+ n = Math.floor( n / this.step );
132
+ this.value = this.numValue( this.old + ( n * this.step ) );
133
+ this.update( true );
134
+ this.old = this.value;
135
+ }
136
+ nup = true;
137
+ }
156
138
 
157
- Slide.prototype.move = function( e ){
139
+ return nup;
158
140
 
159
- var n = ((( e.clientX - this.left - 3 ) / this.w ) * this.range + this.min ) - this.old;
160
- if(n >= this.step || n <= this.step){
161
- n = ~~ ( n / this.step );
162
- this.value = this.numValue( this.old + ( n * this.step ) );
163
- this.update( true );
164
- this.old = this.value;
165
141
  }
166
142
 
167
- };
168
-
169
- Slide.prototype.update = function( up ){
170
-
171
- var ww = this.w * (( this.value - this.min ) / this.range );
172
-
173
- if(this.stype !== 3) this.s[5].width = ~~ ww + 'px';
174
- if(this.s[6]) this.s[6].left = ~~ (this.sa +ww + 3) + 'px';
175
- this.c[2].textContent = this.value;
176
-
177
- if( up ) this.send();
143
+ wheel ( e ) {
178
144
 
179
- };
180
-
181
- Slide.prototype.rSize = function(){
145
+ let name = this.testZone( e );
146
+
147
+ if( name === 'scroll' ) {
148
+
149
+ let v = this.value - this.step * e.delta;
150
+
151
+ if ( v > this.max ) {
152
+ v = this.isCyclic ? this.min : this.max;
153
+ } else if ( v < this.min ) {
154
+ v = this.isCyclic ? this.max : this.min;
155
+ }
156
+
157
+ this.setValue(v);
158
+ this.old = v;
159
+ this.update( true );
182
160
 
183
- Proto.prototype.rSize.call( this );
161
+ return true;
162
+
163
+ }
164
+
165
+ return false;
166
+
167
+ }
184
168
 
185
- var w = this.sb - this.sc;
186
- this.w = w - 6;
169
+ //keydown: function ( e ) { return true; },
187
170
 
188
- var tx = this.sc;
189
- if(this.isUI || !this.simple) tx = this.sc+10;
171
+ // ----------------------
190
172
 
191
- var ty = ~~(this.h * 0.5) - 8;
173
+ validate () {
174
+
175
+ let n = this.c[2].textContent;
192
176
 
193
- var s = this.s;
177
+ if(!isNaN( n )){
178
+ this.value = this.numValue( n );
179
+ this.update(true);
180
+ }
194
181
 
195
- s[2].width = (this.sc -2 )+ 'px';
196
- s[2].left = (this.width - tx +2) + 'px';
197
- s[2].top = ty + 'px';
198
- s[3].left = this.sa + 'px';
199
- s[3].width = w + 'px';
200
- s[4].left = this.sa + 'px';
201
- s[4].width = w + 'px';
202
- s[5].left = (this.sa + 3) + 'px';
182
+ else this.c[2].textContent = this.value + (this.isDeg ? '°':'');
203
183
 
204
- this.update();
184
+ }
205
185
 
206
- };
207
186
 
208
- // text
187
+ reset () {
209
188
 
210
- Slide.prototype.validate = function( e ){
189
+ //this.clearInput();
190
+ this.isDown = false;
191
+ this.mode(0);
211
192
 
212
- if(!isNaN( this.c[2].textContent )){
213
- this.value = this.numValue( this.c[2].textContent );
214
- this.update(true);
215
193
  }
216
- else this.c[2].textContent = this.value;
217
194
 
218
- };
195
+ mode ( mode ) {
196
+
197
+ let s = this.s;
198
+ let cc = this.colors
199
+
200
+ switch(mode){
201
+ case 0: // base
202
+ // s[2].border = '1px solid ' + this.colors.hide;
203
+ s[2].color = cc.text;
204
+ s[4].background = cc.back;
205
+ s[5].background = cc.text;
206
+ break;
207
+ case 1: // scroll over
208
+ //s[2].border = '1px dashed ' + this.colors.hide;
209
+ s[2].color = cc.textOver;
210
+ s[4].background = cc.back;
211
+ s[5].background = cc.textOver;
212
+ break;
213
+ /* case 2:
214
+ s[2].border = '1px solid ' + this.colors.borderSelect;
215
+ break;
216
+ case 3:
217
+ s[2].border = '1px dashed ' + this.colors.text;//this.colors.borderSelect;
218
+ break;
219
+ case 4:
220
+ s[2].border = '1px dashed ' + this.colors.hide;
221
+ break;*/
219
222
 
220
- Slide.prototype.textdown = function( e ){
221
223
 
222
- e.target.contentEditable = true;
223
- e.target.focus();
224
- this.isEdit = true;
224
+ }
225
+ }
225
226
 
226
- };
227
+ update ( up ) {
227
228
 
228
- Slide.prototype.keydown = function( e ){
229
+ let ww = Math.floor( this.ww * (( this.value - this.min ) / this.range ));
230
+
231
+ if(this.model !== 3) this.s[5].width = ww + 'px';
232
+ if(this.s[6]) this.s[6].left = ( this.sa + ww + 3 ) + 'px';
233
+ this.c[2].textContent = this.value + (this.isDeg ? '°':'');
229
234
 
230
- e.stopPropagation();
235
+ if( up ) this.send();
231
236
 
232
- if( e.keyCode === 13 ){
233
- e.preventDefault();
234
- this.validate();
235
- e.target.blur();
236
237
  }
237
238
 
238
- };
239
+ rSize () {
239
240
 
240
- Slide.prototype.keyup = function( e ){
241
-
242
- e.stopPropagation();
243
- if( this.allway ) this.validate();
241
+ super.rSize();
244
242
 
245
- };
243
+ let w = this.sb - this.sc;
244
+ this.ww = w - 6;
246
245
 
247
- Slide.prototype.blur = function( e ){
246
+ let tx = this.sc;
247
+ if(this.isUI || !this.simple) tx = this.sc+10;
248
+ this.txl = this.w - tx + 2;
248
249
 
249
- e.target.style.border = 'none';
250
- e.target.contentEditable = false;
251
- this.isEdit = false;
250
+ //let ty = Math.floor(this.h * 0.5) - 8;
252
251
 
253
- };
252
+ let s = this.s;
254
253
 
255
- Slide.prototype.focus = function( e ){
254
+ s[2].width = (this.sc -6 )+ 'px';
255
+ s[2].left = (this.txl +4) + 'px';
256
+ //s[2].top = ty + 'px';
257
+ s[3].left = this.sa + 'px';
258
+ s[3].width = w + 'px';
259
+ s[4].left = this.sa + 'px';
260
+ s[4].width = w + 'px';
261
+ s[5].left = (this.sa + 3) + 'px';
256
262
 
257
- e.target.style.border = '1px dashed ' + Tools.colors.borderSelect;
263
+ this.update();
258
264
 
259
- };
265
+ }
260
266
 
261
- export { Slide };
267
+ }