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.
- package/README.md +57 -0
- package/build/uil.js +7040 -4199
- package/build/uil.min.js +6 -4
- package/build/uil.module.js +7200 -2761
- package/examples/js/BufferGeometryUtils.js +921 -0
- package/examples/js/SimplexNoise.js +324 -0
- package/examples/js/controls/OrbitControls.js +1215 -0
- package/examples/js/controls/OrbitControls_.js +1042 -0
- package/examples/js/libs/sea3d.min.js +373 -0
- package/examples/js/libs/three.min.js +6 -0
- package/examples/js/math.js +447 -0
- package/examples/js/objects/Landscape.js +778 -0
- package/examples/js/objects/Lensflare.js +372 -0
- package/examples/js/objects/SuperSky.js +297 -0
- package/examples/js/objects/Water.js +329 -0
- package/package.json +56 -54
- package/src/Uil.js +2 -17
- package/src/Uil_dev.js +15 -0
- package/src/core/Gui.js +601 -299
- package/src/core/Proto.js +490 -220
- package/src/core/Roots.js +864 -0
- package/src/core/Tools.js +591 -140
- package/src/core/V2.js +131 -0
- package/src/core/add.js +52 -57
- package/src/proto/Bool.js +117 -52
- package/src/proto/Button.js +286 -146
- package/src/proto/Circular.js +162 -130
- package/src/proto/Color.js +331 -289
- package/src/proto/Empty.js +15 -0
- package/src/proto/Fps.js +232 -159
- package/src/proto/Graph.js +310 -0
- package/src/proto/Grid.js +297 -0
- package/src/proto/Group.js +334 -160
- package/src/proto/Item.js +120 -0
- package/src/proto/Joystick.js +159 -185
- package/src/proto/Knob.js +210 -91
- package/src/proto/List.js +661 -249
- package/src/proto/Numeric.js +329 -162
- package/src/proto/Pad2D.js +268 -0
- package/src/proto/Rubric.js +0 -0
- package/src/proto/Select.js +178 -0
- package/src/proto/Selector.js +13 -0
- package/src/proto/Slide.js +191 -185
- package/src/proto/TextInput.js +149 -59
- package/src/proto/Title.js +40 -31
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { Proto } from '../core/Proto.js';
|
|
2
|
+
import { V2 } from '../core/V2.js';
|
|
3
|
+
|
|
4
|
+
export class Graph extends Proto {
|
|
5
|
+
|
|
6
|
+
constructor( o = {} ) {
|
|
7
|
+
|
|
8
|
+
super( o );
|
|
9
|
+
|
|
10
|
+
this.value = o.value !== undefined ? o.value : [0,0,0];
|
|
11
|
+
this.lng = this.value.length;
|
|
12
|
+
|
|
13
|
+
this.precision = o.precision !== undefined ? o.precision : 2;
|
|
14
|
+
this.multiplicator = o.multiplicator || 1;
|
|
15
|
+
this.neg = o.neg || false;
|
|
16
|
+
|
|
17
|
+
this.line = o.line !== undefined ? o.line : true;
|
|
18
|
+
|
|
19
|
+
//if(this.neg)this.multiplicator*=2;
|
|
20
|
+
|
|
21
|
+
this.autoWidth = o.autoWidth !== undefined ? o.autoWidth : true;
|
|
22
|
+
this.isNumber = false;
|
|
23
|
+
|
|
24
|
+
this.isDown = false;
|
|
25
|
+
|
|
26
|
+
this.h = o.h || 128 + 10;
|
|
27
|
+
this.rh = this.h - 10;
|
|
28
|
+
this.top = 0;
|
|
29
|
+
|
|
30
|
+
this.c[0].style.width = this.w +'px';
|
|
31
|
+
|
|
32
|
+
if( this.c[1] !== undefined ) { // with title
|
|
33
|
+
|
|
34
|
+
this.c[1].style.width = this.w +'px';
|
|
35
|
+
|
|
36
|
+
if(!this.autoWidth){
|
|
37
|
+
this.c[1].style.width = '100%';
|
|
38
|
+
this.c[1].style.justifyContent = 'center'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
//this.c[1].style.background = '#ff0000';
|
|
43
|
+
//this.c[1].style.textAlign = 'center';
|
|
44
|
+
this.top = 10;
|
|
45
|
+
this.h += 10;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.gh = this.rh - 28;
|
|
50
|
+
this.gw = this.w - 28;
|
|
51
|
+
|
|
52
|
+
//this.c[2] = this.dom( 'div', this.css.txt + 'justify-content:center; text-align: justify; column-count:'+this.lng+'; top:'+(this.h-20)+'px; width:100%; color:'+ this.colors.text );
|
|
53
|
+
|
|
54
|
+
//let colum = 'column-count:'+this.lng+'; column:'+this.lng+'; break-inside: column; top:'
|
|
55
|
+
this.c[2] = this.dom( 'div', this.css.txt + 'display:block; text-align:center; padding:0px 0px; top:'+(this.h-20)+'px; left:14px; width:'+this.gw+'px; color:'+ this.colors.text );
|
|
56
|
+
|
|
57
|
+
//this.c[2].textContent = this.value;
|
|
58
|
+
this.c[2].innerHTML = this.valueToHtml();
|
|
59
|
+
|
|
60
|
+
let svg = this.dom( 'svg', this.css.basic , { viewBox:'0 0 '+this.w+' '+this.rh, width:this.w, height:this.rh, preserveAspectRatio:'none' } );
|
|
61
|
+
this.setCss( svg, { width:this.w, height:this.rh, left:0, top:this.top });
|
|
62
|
+
|
|
63
|
+
this.dom( 'path', '', { d:'', stroke:this.colors.text, 'stroke-width':2, fill:'none', 'stroke-linecap':'butt' }, svg );
|
|
64
|
+
this.dom( 'rect', '', { x:10, y:10, width:this.gw+8, height:this.gh+8, stroke:'rgba(0,0,0,0.3)', 'stroke-width':1 , fill:'none'}, svg );
|
|
65
|
+
|
|
66
|
+
this.iw = ((this.gw-(4*(this.lng-1)))/this.lng);
|
|
67
|
+
let t = [];
|
|
68
|
+
this.cMode = [];
|
|
69
|
+
|
|
70
|
+
this.v = [];
|
|
71
|
+
|
|
72
|
+
for( let i = 0; i < this.lng; i++ ){
|
|
73
|
+
|
|
74
|
+
t[i] = [ 14 + (i*this.iw) + (i*4), this.iw ];
|
|
75
|
+
t[i][2] = t[i][0] + t[i][1];
|
|
76
|
+
this.cMode[i] = 0;
|
|
77
|
+
|
|
78
|
+
if( this.neg ) this.v[i] = ((1+(this.value[i] / this.multiplicator))*0.5);
|
|
79
|
+
else this.v[i] = this.value[i] / this.multiplicator;
|
|
80
|
+
|
|
81
|
+
this.dom( 'rect', '', { x:t[i][0], y:14, width:t[i][1], height:1, fill:this.colors.text, 'fill-opacity':0.3 }, svg );
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.tmp = t;
|
|
86
|
+
this.c[3] = svg;
|
|
87
|
+
|
|
88
|
+
//console.log(this.w)
|
|
89
|
+
|
|
90
|
+
this.init();
|
|
91
|
+
|
|
92
|
+
if( this.c[1] !== undefined ){
|
|
93
|
+
this.c[1].style.top = 0 +'px';
|
|
94
|
+
this.c[1].style.height = 20 +'px';
|
|
95
|
+
this.s[1].lineHeight = (20-5)+'px'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.update( false );
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setValue ( value ) {
|
|
103
|
+
|
|
104
|
+
this.value = value;
|
|
105
|
+
this.lng = this.value.length;
|
|
106
|
+
for (var i = 0; i < this.lng; i++) {
|
|
107
|
+
if (this.neg) this.v[i] = (1 + value[i] / this.multiplicator) * 0.5;
|
|
108
|
+
else this.v[i] = value[i] / this.multiplicator;
|
|
109
|
+
}
|
|
110
|
+
this.update();
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
valueToHtml() {
|
|
115
|
+
|
|
116
|
+
let i = this.lng, n=0, r = '<table style="width:100%;"><tr>'
|
|
117
|
+
let w = 100 / this.lng
|
|
118
|
+
let style = 'width:'+ w +'%;'//' text-align:center;'
|
|
119
|
+
while(i--){
|
|
120
|
+
if(n===this.lng-1) r += '<td style='+style+'>' + this.value[n] + '</td></tr></table>'
|
|
121
|
+
else r += '<td style='+style+'>' + this.value[n] + '</td>'
|
|
122
|
+
n++
|
|
123
|
+
}
|
|
124
|
+
return r
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
updateSVG () {
|
|
128
|
+
|
|
129
|
+
if( this.line ) this.setSvg( this.c[3], 'd', this.makePath(), 0 );
|
|
130
|
+
|
|
131
|
+
for(let i = 0; i<this.lng; i++ ){
|
|
132
|
+
|
|
133
|
+
this.setSvg( this.c[3], 'height', this.v[i]*this.gh, i+2 );
|
|
134
|
+
this.setSvg( this.c[3], 'y', 14 + (this.gh - this.v[i]*this.gh), i+2 );
|
|
135
|
+
if( this.neg ) this.value[i] = ( ((this.v[i]*2)-1) * this.multiplicator ).toFixed( this.precision ) * 1;
|
|
136
|
+
else this.value[i] = ( (this.v[i] * this.multiplicator) ).toFixed( this.precision ) * 1;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//this.c[2].textContent = this.value;
|
|
141
|
+
this.c[2].innerHTML = this.valueToHtml();
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
testZone ( e ) {
|
|
146
|
+
|
|
147
|
+
let l = this.local;
|
|
148
|
+
if( l.x === -1 && l.y === -1 ) return '';
|
|
149
|
+
|
|
150
|
+
let i = this.lng;
|
|
151
|
+
let t = this.tmp;
|
|
152
|
+
|
|
153
|
+
if( l.y>this.top && l.y<this.h-20 ){
|
|
154
|
+
while( i-- ){
|
|
155
|
+
if( l.x>t[i][0] && l.x<t[i][2] ) return i;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return ''
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
mode ( n, name ) {
|
|
164
|
+
|
|
165
|
+
if( n === this.cMode[name] ) return false;
|
|
166
|
+
|
|
167
|
+
let a;
|
|
168
|
+
|
|
169
|
+
switch(n){
|
|
170
|
+
case 0: a=0.3; break;
|
|
171
|
+
case 1: a=0.6; break;
|
|
172
|
+
case 2: a=1; break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.reset();
|
|
176
|
+
|
|
177
|
+
this.setSvg( this.c[3], 'fill-opacity', a, name + 2 );
|
|
178
|
+
this.cMode[name] = n;
|
|
179
|
+
|
|
180
|
+
return true;
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ----------------------
|
|
187
|
+
// EVENTS
|
|
188
|
+
// ----------------------
|
|
189
|
+
|
|
190
|
+
reset () {
|
|
191
|
+
|
|
192
|
+
let nup = false;
|
|
193
|
+
//this.isDown = false;
|
|
194
|
+
|
|
195
|
+
let i = this.lng;
|
|
196
|
+
while(i--){
|
|
197
|
+
if( this.cMode[i] !== 0 ){
|
|
198
|
+
this.cMode[i] = 0;
|
|
199
|
+
this.setSvg( this.c[3], 'fill-opacity', 0.3, i + 2 );
|
|
200
|
+
nup = true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return nup;
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
mouseup ( e ) {
|
|
209
|
+
|
|
210
|
+
this.isDown = false;
|
|
211
|
+
if( this.current !== -1 ) return this.reset();
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
mousedown ( e ) {
|
|
216
|
+
|
|
217
|
+
this.isDown = true;
|
|
218
|
+
return this.mousemove( e );
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
mousemove ( e ) {
|
|
223
|
+
|
|
224
|
+
let nup = false;
|
|
225
|
+
|
|
226
|
+
let name = this.testZone(e);
|
|
227
|
+
|
|
228
|
+
if( name === '' ){
|
|
229
|
+
|
|
230
|
+
nup = this.reset();
|
|
231
|
+
//this.cursor();
|
|
232
|
+
|
|
233
|
+
} else {
|
|
234
|
+
|
|
235
|
+
nup = this.mode( this.isDown ? 2 : 1, name );
|
|
236
|
+
//this.cursor( this.current !== -1 ? 'move' : 'pointer' );
|
|
237
|
+
if(this.isDown){
|
|
238
|
+
this.v[name] = this.clamp( 1 - (( e.clientY - this.zone.y - this.top - 10 ) / this.gh) , 0, 1 );
|
|
239
|
+
this.update( true );
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return nup;
|
|
245
|
+
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// ----------------------
|
|
249
|
+
|
|
250
|
+
update ( up ) {
|
|
251
|
+
|
|
252
|
+
this.updateSVG();
|
|
253
|
+
|
|
254
|
+
if( up ) this.send();
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
makePath () {
|
|
259
|
+
|
|
260
|
+
let p = "", h, w, wn, wm, ow, oh;
|
|
261
|
+
//let g = this.iw*0.5
|
|
262
|
+
|
|
263
|
+
for(let i = 0; i<this.lng; i++ ){
|
|
264
|
+
|
|
265
|
+
h = 14 + (this.gh - this.v[i]*this.gh);
|
|
266
|
+
w = (14 + (i*this.iw) + (i*4));
|
|
267
|
+
|
|
268
|
+
wm = w + this.iw*0.5;
|
|
269
|
+
wn = w + this.iw;
|
|
270
|
+
|
|
271
|
+
if(i===0) p+='M '+w+' '+ h + ' T ' + wm +' '+ h;
|
|
272
|
+
else p += ' C ' + ow +' '+ oh + ',' + w +' '+ h + ',' + wm +' '+ h;
|
|
273
|
+
if(i === this.lng-1) p+=' T ' + wn +' '+ h;
|
|
274
|
+
|
|
275
|
+
ow = wn
|
|
276
|
+
oh = h
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return p;
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
rSize () {
|
|
285
|
+
|
|
286
|
+
super.rSize();
|
|
287
|
+
|
|
288
|
+
let s = this.s;
|
|
289
|
+
if( this.c[1] !== undefined ) s[1].width = this.w + 'px';
|
|
290
|
+
s[3].width = this.w + 'px';
|
|
291
|
+
|
|
292
|
+
let gw = this.w - 28;
|
|
293
|
+
let iw = ((gw-(4*(this.lng-1)))/this.lng);
|
|
294
|
+
|
|
295
|
+
let t = [];
|
|
296
|
+
|
|
297
|
+
s[2].width = gw + 'px'
|
|
298
|
+
|
|
299
|
+
for( let i = 0; i < this.lng; i++ ){
|
|
300
|
+
|
|
301
|
+
t[i] = [ 14 + (i*iw) + (i*4), iw ];
|
|
302
|
+
t[i][2] = t[i][0] + t[i][1];
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
this.tmp = t;
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Proto } from '../core/Proto.js';
|
|
2
|
+
import { Button } from './Button.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class Grid extends Proto {
|
|
6
|
+
|
|
7
|
+
constructor( o = {} ) {
|
|
8
|
+
|
|
9
|
+
super( o );
|
|
10
|
+
|
|
11
|
+
this.values = o.values || [];
|
|
12
|
+
|
|
13
|
+
if( typeof this.values === 'string' ) this.values = [ this.values ];
|
|
14
|
+
this.lng = this.values.length;
|
|
15
|
+
|
|
16
|
+
this.value = o.value || null;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
this.isSelectable = o.selectable || false;
|
|
20
|
+
this.spaces = o.spaces || [5,3];
|
|
21
|
+
this.bsize = o.bsize || [90,20];
|
|
22
|
+
|
|
23
|
+
if(o.h) this.bsize[1] = o.h;
|
|
24
|
+
this.bsizeMax = this.bsize[0];
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
this.tmp = [];
|
|
28
|
+
this.stat = [];
|
|
29
|
+
this.grid = [ 2, Math.round( this.lng * 0.5 ) ];
|
|
30
|
+
this.h = this.grid[1] * ( this.bsize[1] + this.spaces[1] ) + this.spaces[1];
|
|
31
|
+
|
|
32
|
+
this.c[1].textContent = '';
|
|
33
|
+
this.c[2] = this.dom( 'table', this.css.basic + 'width:100%; top:'+(this.spaces[1]-2)+'px; height:auto; border-collapse:separate; border:none; border-spacing: '+(this.spaces[0]-2)+'px '+(this.spaces[1]-2)+'px;' );
|
|
34
|
+
|
|
35
|
+
let n = 0, b, mid, td, tr, sel;
|
|
36
|
+
|
|
37
|
+
this.res = -1
|
|
38
|
+
this.isDown = false
|
|
39
|
+
this.neverlock = true
|
|
40
|
+
|
|
41
|
+
this.buttons = [];
|
|
42
|
+
this.stat = [];
|
|
43
|
+
this.tmpX = [];
|
|
44
|
+
this.tmpY = [];
|
|
45
|
+
|
|
46
|
+
let cc = this.colors;
|
|
47
|
+
|
|
48
|
+
for( let i = 0; i < this.grid[1]; i++ ){
|
|
49
|
+
|
|
50
|
+
tr = this.c[2].insertRow();
|
|
51
|
+
tr.style.cssText = 'pointer-events:none;';
|
|
52
|
+
for( let j = 0; j < this.grid[0]; j++ ){
|
|
53
|
+
|
|
54
|
+
td = tr.insertCell();
|
|
55
|
+
td.style.cssText = 'pointer-events:none;';
|
|
56
|
+
|
|
57
|
+
if( this.values[n] ){
|
|
58
|
+
|
|
59
|
+
sel = false;
|
|
60
|
+
if( this.values[n] === this.value && this.isSelectable ) sel = true;
|
|
61
|
+
|
|
62
|
+
b = document.createElement( 'div' );
|
|
63
|
+
b.style.cssText = this.css.txt + this.css.button + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; border:'+cc.borderSize+'px solid '+cc.border+'; left:auto; right:auto; border-radius:'+this.radius+'px;';
|
|
64
|
+
b.style.background = sel ? cc.select : cc.button;
|
|
65
|
+
b.style.color = sel ? cc.textSelect : cc.text;
|
|
66
|
+
b.innerHTML = this.values[n];
|
|
67
|
+
td.appendChild( b );
|
|
68
|
+
|
|
69
|
+
this.buttons.push(b);
|
|
70
|
+
this.stat.push(1);
|
|
71
|
+
|
|
72
|
+
} else {
|
|
73
|
+
|
|
74
|
+
b = document.createElement( 'div' );
|
|
75
|
+
b.style.cssText = this.css.txt + 'position:static; width:'+this.bsize[0]+'px; height:'+this.bsize[1]+'px; text-align:center; left:auto; right:auto; background:none;';
|
|
76
|
+
td.appendChild( b );
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if(j===0) b.style.cssText += 'float:right;';
|
|
81
|
+
else b.style.cssText += 'float:left;';
|
|
82
|
+
|
|
83
|
+
n++;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.init();
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
testZone ( e ) {
|
|
93
|
+
|
|
94
|
+
let l = this.local;
|
|
95
|
+
if( l.x === -1 && l.y === -1 ) return -1;
|
|
96
|
+
|
|
97
|
+
let tx = this.tmpX;
|
|
98
|
+
let ty = this.tmpY;
|
|
99
|
+
|
|
100
|
+
let id = -1;
|
|
101
|
+
let c = -1;
|
|
102
|
+
let line = -1;
|
|
103
|
+
let i = this.grid[0];
|
|
104
|
+
while( i-- ){
|
|
105
|
+
if( l.x > tx[i][0] && l.x < tx[i][1] ) c = i;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
i = this.grid[1];
|
|
109
|
+
while( i-- ){
|
|
110
|
+
if( l.y > ty[i][0] && l.y < ty[i][1] ) line = i;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if(c!==-1 && line!==-1){
|
|
114
|
+
id = c + (line*2);
|
|
115
|
+
if(id>this.lng-1) id = -1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return id;
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ----------------------
|
|
123
|
+
// EVENTS
|
|
124
|
+
// ----------------------
|
|
125
|
+
|
|
126
|
+
mouseup ( e ) {
|
|
127
|
+
|
|
128
|
+
if( !this.isDown ) return false
|
|
129
|
+
|
|
130
|
+
this.isDown = false
|
|
131
|
+
if( this.res !== -1 ){
|
|
132
|
+
this.value = this.values[this.res]
|
|
133
|
+
this.send()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return this.mousemove( e )
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
mousedown ( e ) {
|
|
141
|
+
|
|
142
|
+
if( this.isDown ) return false
|
|
143
|
+
this.isDown = true
|
|
144
|
+
return this.mousemove( e )
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
mousemove ( e ) {
|
|
149
|
+
|
|
150
|
+
let up = false;
|
|
151
|
+
this.res = this.testZone( e );
|
|
152
|
+
|
|
153
|
+
if( this.res !== -1 ){
|
|
154
|
+
this.cursor('pointer');
|
|
155
|
+
up = this.modes( this.isDown ? 3 : 2, this.res );
|
|
156
|
+
} else {
|
|
157
|
+
up = this.reset();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return up;
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ----------------------
|
|
165
|
+
// MODE
|
|
166
|
+
// -----------------------
|
|
167
|
+
|
|
168
|
+
modes ( N = 1, id = -1 ) {
|
|
169
|
+
|
|
170
|
+
let i = this.lng, w, n, r = false
|
|
171
|
+
|
|
172
|
+
while( i-- ){
|
|
173
|
+
|
|
174
|
+
n = N
|
|
175
|
+
w = this.isSelectable ? this.values[ i ] === this.value : false
|
|
176
|
+
|
|
177
|
+
if( i === id ){
|
|
178
|
+
if( w && n === 2 ) n = 3
|
|
179
|
+
} else {
|
|
180
|
+
n = 1
|
|
181
|
+
if( w ) n = 4
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if( this.mode( n, i ) ) r = true
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return r
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
mode ( n, id ) {
|
|
193
|
+
|
|
194
|
+
let change = false;
|
|
195
|
+
let cc = this.colors, s = this.buttons
|
|
196
|
+
let i = id
|
|
197
|
+
|
|
198
|
+
if( this.stat[id] !== n ){
|
|
199
|
+
|
|
200
|
+
this.stat[id] = n;
|
|
201
|
+
|
|
202
|
+
switch( n ){
|
|
203
|
+
|
|
204
|
+
case 1: s[i].style.color = cc.text; s[i].style.background = cc.button; break;
|
|
205
|
+
case 2: s[i].style.color = cc.textOver; s[i].style.background = cc.overoff; break;
|
|
206
|
+
case 3: s[i].style.color = cc.textOver; s[i].style.background = cc.over; break;
|
|
207
|
+
case 4: s[i].style.color = cc.textSelect; s[i].style.background = cc.select; break;
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
change = true;
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return change;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ----------------------
|
|
220
|
+
|
|
221
|
+
reset () {
|
|
222
|
+
|
|
223
|
+
this.res = -1
|
|
224
|
+
this.cursor()
|
|
225
|
+
return this.modes()
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
label ( string, n ) {
|
|
231
|
+
|
|
232
|
+
this.buttons[n].textContent = string;
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
icon ( string, y, n ) {
|
|
237
|
+
|
|
238
|
+
this.buttons[n].style.padding = ( y || 0 ) +'px 0px';
|
|
239
|
+
this.buttons[n].innerHTML = string;
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
testW () {
|
|
244
|
+
|
|
245
|
+
let vw = this.spaces[0]*3 + this.bsizeMax*2, rz = false;
|
|
246
|
+
if( vw > this.w ) {
|
|
247
|
+
this.bsize[0] = ( this.w-(this.spaces[0]*3) ) * 0.5;
|
|
248
|
+
rz = true;
|
|
249
|
+
} else {
|
|
250
|
+
if( this.bsize[0] !== this.bsizeMax ) {
|
|
251
|
+
this.bsize[0] = this.bsizeMax;
|
|
252
|
+
rz = true;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if( !rz ) return;
|
|
257
|
+
|
|
258
|
+
let i = this.buttons.length;
|
|
259
|
+
while(i--) this.buttons[i].style.width = this.bsize[0] + 'px';
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
rSize () {
|
|
264
|
+
|
|
265
|
+
super.rSize();
|
|
266
|
+
|
|
267
|
+
this.testW();
|
|
268
|
+
|
|
269
|
+
let n = 0, b, mid;
|
|
270
|
+
|
|
271
|
+
this.tmpX = [];
|
|
272
|
+
this.tmpY = [];
|
|
273
|
+
|
|
274
|
+
for( let j = 0; j < this.grid[0]; j++ ){
|
|
275
|
+
|
|
276
|
+
if(j===0){
|
|
277
|
+
mid = ( this.w*0.5 ) - ( this.spaces[0]*0.5 );
|
|
278
|
+
this.tmpX.push( [ mid-this.bsize[0], mid ] );
|
|
279
|
+
} else {
|
|
280
|
+
mid = ( this.w*0.5 ) + ( this.spaces[0]*0.5 );
|
|
281
|
+
this.tmpX.push( [ mid, mid+this.bsize[0] ] );
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
mid = this.spaces[1];
|
|
287
|
+
|
|
288
|
+
for( let i = 0; i < this.grid[1]; i++ ){
|
|
289
|
+
|
|
290
|
+
this.tmpY.push( [ mid, mid + this.bsize[1] ] );
|
|
291
|
+
mid += this.bsize[1] + this.spaces[1];
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
}
|