lexgui 0.1.31 → 0.1.33
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/build/components/timeline.js +2619 -1677
- package/build/components/videoeditor.js +630 -0
- package/build/lexgui.css +110 -4
- package/build/lexgui.js +335 -282
- package/build/lexgui.module.js +307 -232
- package/changelog.md +18 -0
- package/examples/index.html +2 -1
- package/examples/timeline.html +294 -0
- package/examples/video_editor.html +52 -0
- package/examples/video_editor2.html +118 -0
- package/package.json +1 -1
package/build/lexgui.js
CHANGED
|
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
var LX = global.LX = {
|
|
15
|
-
version: "0.1.
|
|
15
|
+
version: "0.1.33",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -746,6 +746,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
746
746
|
if(overlay)
|
|
747
747
|
{
|
|
748
748
|
this.root.classList.add("overlay-" + overlay);
|
|
749
|
+
|
|
750
|
+
if( options.draggable )
|
|
751
|
+
makeDraggable( root );
|
|
752
|
+
|
|
753
|
+
if( options.resizeable ) {
|
|
754
|
+
root.classList.add("resizeable");
|
|
755
|
+
}
|
|
749
756
|
|
|
750
757
|
if(options.resize)
|
|
751
758
|
{
|
|
@@ -2373,11 +2380,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2373
2380
|
console.warn("Can't get value of " + this.typeName());
|
|
2374
2381
|
}
|
|
2375
2382
|
|
|
2376
|
-
set( value ) {
|
|
2383
|
+
set( value, skipCallback = false ) {
|
|
2377
2384
|
|
|
2378
2385
|
if( this.onSetValue )
|
|
2379
|
-
return this.onSetValue( value );
|
|
2380
|
-
|
|
2386
|
+
return this.onSetValue( value, skipCallback );
|
|
2387
|
+
|
|
2381
2388
|
console.warn("Can't set value of " + this.typeName());
|
|
2382
2389
|
}
|
|
2383
2390
|
|
|
@@ -2454,11 +2461,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2454
2461
|
widget.onGetValue = () => {
|
|
2455
2462
|
return instance;
|
|
2456
2463
|
};
|
|
2457
|
-
widget.onSetValue = (
|
|
2458
|
-
instance =
|
|
2464
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
2465
|
+
instance = newValue;
|
|
2459
2466
|
refresh_widget();
|
|
2460
|
-
element.querySelector(".lexcustomitems").toggleAttribute('hidden', false);
|
|
2461
|
-
this._trigger( new IEvent(name, instance, null), callback );
|
|
2467
|
+
element.querySelector( ".lexcustomitems" ).toggleAttribute( 'hidden', false );
|
|
2468
|
+
if( !skipCallback ) this._trigger( new IEvent( name, instance, null ), callback );
|
|
2462
2469
|
};
|
|
2463
2470
|
|
|
2464
2471
|
let element = widget.domEl;
|
|
@@ -3231,6 +3238,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3231
3238
|
{
|
|
3232
3239
|
let domName = document.createElement('div');
|
|
3233
3240
|
domName.className = "lexwidgetname";
|
|
3241
|
+
if( options.justifyName )
|
|
3242
|
+
{
|
|
3243
|
+
domName.classList.add( "float-" + options.justifyName );
|
|
3244
|
+
}
|
|
3234
3245
|
domName.innerHTML = name || "";
|
|
3235
3246
|
domName.title = options.title ?? domName.innerHTML;
|
|
3236
3247
|
domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
|
|
@@ -3410,11 +3421,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3410
3421
|
}
|
|
3411
3422
|
|
|
3412
3423
|
_trigger( event, callback ) {
|
|
3413
|
-
if(callback)
|
|
3414
|
-
callback.call(this, event.value, event.domEvent, event.name);
|
|
3415
3424
|
|
|
3416
|
-
if(
|
|
3417
|
-
|
|
3425
|
+
if( callback )
|
|
3426
|
+
callback.call( this, event.value, event.domEvent, event.name );
|
|
3427
|
+
|
|
3428
|
+
if( this.onevent )
|
|
3429
|
+
this.onevent.call( this, event );
|
|
3418
3430
|
}
|
|
3419
3431
|
|
|
3420
3432
|
/**
|
|
@@ -3535,19 +3547,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3535
3547
|
* placeholder: Add input placeholder
|
|
3536
3548
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3537
3549
|
* inputWidth: Width of the text input
|
|
3538
|
-
* float: Justify text
|
|
3539
3550
|
* skipReset: Don't add the reset value button when value changes
|
|
3540
|
-
|
|
3551
|
+
* float: Justify input text content
|
|
3552
|
+
* justifyName: Justify name content
|
|
3553
|
+
*/
|
|
3541
3554
|
|
|
3542
3555
|
addText( name, value, callback, options = {} ) {
|
|
3543
3556
|
|
|
3544
3557
|
let widget = this.create_widget( name, Widget.TEXT, options );
|
|
3558
|
+
|
|
3545
3559
|
widget.onGetValue = () => {
|
|
3546
3560
|
return wValue.value;
|
|
3547
3561
|
};
|
|
3548
|
-
widget.onSetValue = newValue => {
|
|
3562
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
3549
3563
|
this.disabled ? wValue.innerText = newValue : wValue.value = newValue;
|
|
3550
|
-
Panel._dispatch_event( wValue, "focusout" );
|
|
3564
|
+
Panel._dispatch_event( wValue, "focusout", skipCallback );
|
|
3551
3565
|
};
|
|
3552
3566
|
|
|
3553
3567
|
let element = widget.domEl;
|
|
@@ -3583,9 +3597,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3583
3597
|
wValue.setAttribute( "placeholder", options.placeholder );
|
|
3584
3598
|
|
|
3585
3599
|
var resolve = ( function( val, event ) {
|
|
3600
|
+
const skipCallback = event.detail;
|
|
3586
3601
|
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
3587
3602
|
if( btn ) btn.style.display = ( val != wValue.iValue ? "block" : "none" );
|
|
3588
|
-
this._trigger( new IEvent( name, val, event ), callback );
|
|
3603
|
+
if( !skipCallback ) this._trigger( new IEvent( name, val, event ), callback );
|
|
3589
3604
|
}).bind( this );
|
|
3590
3605
|
|
|
3591
3606
|
const trigger = options.trigger ?? 'default';
|
|
@@ -3662,45 +3677,48 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3662
3677
|
|
|
3663
3678
|
addTextArea( name, value, callback, options = {} ) {
|
|
3664
3679
|
|
|
3665
|
-
let widget = this.create_widget(name, Widget.TEXTAREA, options);
|
|
3680
|
+
let widget = this.create_widget( name, Widget.TEXTAREA, options );
|
|
3681
|
+
|
|
3666
3682
|
widget.onGetValue = () => {
|
|
3667
3683
|
return wValue.value;
|
|
3668
3684
|
};
|
|
3669
|
-
widget.onSetValue = (
|
|
3670
|
-
wValue.value =
|
|
3671
|
-
Panel._dispatch_event(wValue, "focusout");
|
|
3685
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
3686
|
+
wValue.value = newValue;
|
|
3687
|
+
Panel._dispatch_event( wValue, "focusout", skipCallback );
|
|
3672
3688
|
};
|
|
3689
|
+
|
|
3673
3690
|
let element = widget.domEl;
|
|
3674
3691
|
|
|
3675
3692
|
// Add reset functionality
|
|
3676
|
-
if(widget.name && !(options.skipReset ?? false)) {
|
|
3677
|
-
Panel._add_reset_property(element.domName, function() {
|
|
3693
|
+
if( widget.name && !( options.skipReset ?? false ) ) {
|
|
3694
|
+
Panel._add_reset_property( element.domName, function() {
|
|
3678
3695
|
wValue.value = wValue.iValue;
|
|
3679
3696
|
this.style.display = "none";
|
|
3680
|
-
Panel._dispatch_event(wValue, "focusout");
|
|
3697
|
+
Panel._dispatch_event( wValue, "focusout" );
|
|
3681
3698
|
});
|
|
3682
3699
|
}
|
|
3683
3700
|
|
|
3684
3701
|
// Add widget value
|
|
3685
3702
|
|
|
3686
|
-
let container = document.createElement('div');
|
|
3703
|
+
let container = document.createElement( 'div' );
|
|
3687
3704
|
container.className = "lextextarea";
|
|
3688
3705
|
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " )";
|
|
3689
3706
|
container.style.height = options.height;
|
|
3690
3707
|
container.style.display = "flex";
|
|
3691
3708
|
|
|
3692
|
-
let wValue = document.createElement('textarea');
|
|
3709
|
+
let wValue = document.createElement( 'textarea' );
|
|
3693
3710
|
wValue.value = wValue.iValue = value || "";
|
|
3694
3711
|
wValue.style.width = "100%";
|
|
3695
|
-
Object.assign(wValue.style, options.style ?? {});
|
|
3712
|
+
Object.assign( wValue.style, options.style ?? {} );
|
|
3696
3713
|
|
|
3697
|
-
if(options.disabled ?? false) wValue.setAttribute("disabled", true);
|
|
3698
|
-
if(options.placeholder) wValue.setAttribute("placeholder", options.placeholder);
|
|
3714
|
+
if( options.disabled ?? false ) wValue.setAttribute("disabled", true);
|
|
3715
|
+
if( options.placeholder ) wValue.setAttribute("placeholder", options.placeholder);
|
|
3699
3716
|
|
|
3700
|
-
var resolve = (function(val, event) {
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3717
|
+
var resolve = (function( val, event ) {
|
|
3718
|
+
const skipCallback = event.detail;
|
|
3719
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
3720
|
+
if( btn ) btn.style.display = ( val != wValue.iValue ? "block" : "none" );
|
|
3721
|
+
if( !skipCallback ) this._trigger( new IEvent( name, val, event ), callback );
|
|
3704
3722
|
}).bind(this);
|
|
3705
3723
|
|
|
3706
3724
|
const trigger = options.trigger ?? 'default';
|
|
@@ -3777,10 +3795,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3777
3795
|
widget.onGetValue = () => {
|
|
3778
3796
|
return wValue.innerText;
|
|
3779
3797
|
};
|
|
3780
|
-
widget.onSetValue = (
|
|
3798
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
3781
3799
|
wValue.innerHTML =
|
|
3782
3800
|
(options.icon ? "<a class='" + options.icon + "'></a>" :
|
|
3783
|
-
( options.img ? "<img src='" + options.img + "'>" : "<span>" + (
|
|
3801
|
+
( options.img ? "<img src='" + options.img + "'>" : "<span>" + (newValue || "") + "</span>" ));
|
|
3784
3802
|
};
|
|
3785
3803
|
|
|
3786
3804
|
let element = widget.domEl;
|
|
@@ -3798,10 +3816,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3798
3816
|
( options.img ? "<img src='" + options.img + "'>" : "<span>" + (value || "") + "</span>" ));
|
|
3799
3817
|
|
|
3800
3818
|
wValue.style.width = "calc( 100% - " + (options.nameWidth ?? LX.DEFAULT_NAME_WIDTH) + ")";
|
|
3801
|
-
|
|
3819
|
+
|
|
3802
3820
|
if(options.disabled)
|
|
3803
3821
|
wValue.setAttribute("disabled", true);
|
|
3804
|
-
|
|
3822
|
+
|
|
3805
3823
|
wValue.addEventListener("click", e => {
|
|
3806
3824
|
if( options.selectable ) {
|
|
3807
3825
|
if( options.parent )
|
|
@@ -3812,7 +3830,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3812
3830
|
});
|
|
3813
3831
|
|
|
3814
3832
|
element.appendChild(wValue);
|
|
3815
|
-
|
|
3833
|
+
|
|
3816
3834
|
// Remove branch padding and margins
|
|
3817
3835
|
if(!widget.name) {
|
|
3818
3836
|
wValue.className += " noname";
|
|
@@ -4019,12 +4037,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4019
4037
|
widget.onGetValue = () => {
|
|
4020
4038
|
return element.querySelector("li.selected").getAttribute('value');
|
|
4021
4039
|
};
|
|
4022
|
-
widget.onSetValue = (
|
|
4040
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4023
4041
|
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4024
|
-
if(btn) btn.style.display = (
|
|
4025
|
-
value =
|
|
4042
|
+
if(btn) btn.style.display = (newValue != wValue.iValue ? "block" : "none");
|
|
4043
|
+
value = newValue;
|
|
4026
4044
|
list.querySelectorAll('li').forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
|
|
4027
|
-
this._trigger( new IEvent(name, value, null), callback );
|
|
4045
|
+
if( !skipCallback ) this._trigger( new IEvent(name, value, null), callback );
|
|
4028
4046
|
};
|
|
4029
4047
|
|
|
4030
4048
|
let element = widget.domEl;
|
|
@@ -4220,12 +4238,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4220
4238
|
widget.onGetValue = () => {
|
|
4221
4239
|
return JSON.parse(JSON.stringify(curve_instance.element.value));
|
|
4222
4240
|
};
|
|
4223
|
-
widget.onSetValue = (
|
|
4241
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4224
4242
|
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4225
|
-
if(btn) btn.style.display = (
|
|
4226
|
-
curve_instance.element.value = JSON.parse(JSON.stringify(
|
|
4243
|
+
if(btn) btn.style.display = (newValue != curve_instance.element.value ? "block" : "none");
|
|
4244
|
+
curve_instance.element.value = JSON.parse(JSON.stringify(newValue));
|
|
4227
4245
|
curve_instance.redraw();
|
|
4228
|
-
that._trigger( new IEvent(name, curve_instance.element.value, null), callback );
|
|
4246
|
+
if( !skipCallback ) that._trigger( new IEvent(name, curve_instance.element.value, null), callback );
|
|
4229
4247
|
};
|
|
4230
4248
|
|
|
4231
4249
|
let element = widget.domEl;
|
|
@@ -4285,12 +4303,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4285
4303
|
widget.onGetValue = () => {
|
|
4286
4304
|
return element.value;
|
|
4287
4305
|
};
|
|
4288
|
-
widget.onSetValue = (
|
|
4306
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4289
4307
|
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4290
|
-
if(btn) btn.style.display = (
|
|
4291
|
-
value = element.value =
|
|
4308
|
+
if(btn) btn.style.display = (newValue != defaultValue ? "block" : "none");
|
|
4309
|
+
value = element.value = newValue;
|
|
4292
4310
|
setLayers();
|
|
4293
|
-
that._trigger( new IEvent(name, value), callback );
|
|
4311
|
+
if( !skipCallback ) that._trigger( new IEvent(name, value), callback );
|
|
4294
4312
|
};
|
|
4295
4313
|
|
|
4296
4314
|
let element = widget.domEl;
|
|
@@ -4382,11 +4400,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4382
4400
|
values.push( v.value );
|
|
4383
4401
|
return values;
|
|
4384
4402
|
};
|
|
4385
|
-
widget.onSetValue = (
|
|
4386
|
-
values =
|
|
4403
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4404
|
+
values = newValue;
|
|
4387
4405
|
updateItems();
|
|
4388
|
-
this._trigger( new IEvent(name, values, null), callback );
|
|
4406
|
+
if( !skipCallback ) this._trigger( new IEvent(name, values, null), callback );
|
|
4389
4407
|
};
|
|
4408
|
+
|
|
4390
4409
|
let element = widget.domEl;
|
|
4391
4410
|
element.style.flexWrap = "wrap";
|
|
4392
4411
|
|
|
@@ -4500,14 +4519,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4500
4519
|
widget.onGetValue = () => {
|
|
4501
4520
|
return value;
|
|
4502
4521
|
};
|
|
4503
|
-
|
|
4504
|
-
widget.onSetValue = ( newValue ) => {
|
|
4522
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4505
4523
|
listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
|
|
4506
4524
|
const idx = values.indexOf( newValue );
|
|
4507
4525
|
if( idx == -1 ) return;
|
|
4508
4526
|
listContainer.children[ idx ].classList.toggle( 'selected' );
|
|
4509
4527
|
value = newValue;
|
|
4510
|
-
this._trigger( new IEvent( name, newValue ), callback );
|
|
4528
|
+
if( !skipCallback ) this._trigger( new IEvent( name, newValue ), callback );
|
|
4511
4529
|
};
|
|
4512
4530
|
|
|
4513
4531
|
widget.updateValues = ( newValues ) => {
|
|
@@ -4572,18 +4590,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4572
4590
|
|
|
4573
4591
|
addTags( name, value, callback, options = {} ) {
|
|
4574
4592
|
|
|
4575
|
-
value = value.replace(/\s/g, '').split(',');
|
|
4576
|
-
let defaultValue = [].concat(value);
|
|
4577
|
-
let widget = this.create_widget(name, Widget.TAGS, options);
|
|
4593
|
+
value = value.replace( /\s/g, '' ).split( ',' );
|
|
4594
|
+
let defaultValue = [].concat( value );
|
|
4595
|
+
let widget = this.create_widget( name, Widget.TAGS, options );
|
|
4596
|
+
|
|
4578
4597
|
widget.onGetValue = () => {
|
|
4579
|
-
return [].concat(value);
|
|
4598
|
+
return [].concat( value );
|
|
4580
4599
|
};
|
|
4581
|
-
widget.onSetValue = (
|
|
4582
|
-
value = [].concat(
|
|
4600
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4601
|
+
value = [].concat( newValue );
|
|
4583
4602
|
create_tags();
|
|
4584
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4585
|
-
if(btn) btn.style.display = (
|
|
4586
|
-
that._trigger( new IEvent(name, value), callback );
|
|
4603
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4604
|
+
if( btn ) btn.style.display = ( newValue != defaultValue ? "block" : "none" );
|
|
4605
|
+
if( !skipCallback ) that._trigger( new IEvent( name, value ), callback );
|
|
4587
4606
|
};
|
|
4588
4607
|
|
|
4589
4608
|
let element = widget.domEl;
|
|
@@ -4609,7 +4628,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4609
4628
|
const create_tags = () => {
|
|
4610
4629
|
|
|
4611
4630
|
tags_container.innerHTML = "";
|
|
4612
|
-
|
|
4631
|
+
|
|
4613
4632
|
for( let i = 0; i < value.length; ++i )
|
|
4614
4633
|
{
|
|
4615
4634
|
let tag_name = value[i];
|
|
@@ -4617,36 +4636,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4617
4636
|
tag.className = "lextag";
|
|
4618
4637
|
tag.innerHTML = tag_name;
|
|
4619
4638
|
|
|
4620
|
-
tag.addEventListener('click', function(e) {
|
|
4639
|
+
tag.addEventListener('click', function( e ) {
|
|
4621
4640
|
this.remove();
|
|
4622
4641
|
value.splice( value.indexOf( tag_name ), 1 );
|
|
4623
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4624
|
-
if(btn) btn.style.display = (value != defaultValue ? "block" : "none");
|
|
4625
|
-
that._trigger( new IEvent(name, value, e), callback );
|
|
4642
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4643
|
+
if( btn ) btn.style.display = ( value != defaultValue ? "block" : "none" );
|
|
4644
|
+
that._trigger( new IEvent( name, value, e ), callback );
|
|
4626
4645
|
});
|
|
4627
4646
|
|
|
4628
|
-
tags_container.appendChild(tag);
|
|
4647
|
+
tags_container.appendChild( tag );
|
|
4629
4648
|
}
|
|
4630
|
-
|
|
4631
|
-
let tag_input = document.createElement('input');
|
|
4649
|
+
|
|
4650
|
+
let tag_input = document.createElement( 'input' );
|
|
4632
4651
|
tag_input.value = "";
|
|
4633
4652
|
tag_input.placeholder = "Tag...";
|
|
4634
|
-
tags_container.insertChildAtIndex(tag_input, 0);
|
|
4635
|
-
|
|
4636
|
-
tag_input.onkeydown = function(e) {
|
|
4653
|
+
tags_container.insertChildAtIndex( tag_input, 0 );
|
|
4654
|
+
|
|
4655
|
+
tag_input.onkeydown = function( e ) {
|
|
4637
4656
|
const val = this.value.replace(/\s/g, '');
|
|
4638
4657
|
if( e.key == ' ') {
|
|
4639
4658
|
e.preventDefault();
|
|
4640
4659
|
if( !val.length || value.indexOf( val ) > -1 )
|
|
4641
4660
|
return;
|
|
4642
|
-
value.push(val);
|
|
4661
|
+
value.push( val );
|
|
4643
4662
|
create_tags();
|
|
4644
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4663
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4645
4664
|
if(btn) btn.style.display = "block";
|
|
4646
|
-
that._trigger( new IEvent(name, value, e), callback );
|
|
4665
|
+
that._trigger( new IEvent( name, value, e ), callback );
|
|
4647
4666
|
}
|
|
4648
4667
|
};
|
|
4649
|
-
|
|
4668
|
+
|
|
4650
4669
|
tag_input.focus();
|
|
4651
4670
|
}
|
|
4652
4671
|
|
|
@@ -4675,24 +4694,25 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4675
4694
|
|
|
4676
4695
|
addCheckbox( name, value, callback, options = {} ) {
|
|
4677
4696
|
|
|
4678
|
-
if(!name) {
|
|
4679
|
-
throw("Set Widget Name!");
|
|
4697
|
+
if( !name ) {
|
|
4698
|
+
throw( "Set Widget Name!" );
|
|
4680
4699
|
}
|
|
4681
|
-
|
|
4682
|
-
let widget = this.create_widget(name, Widget.CHECKBOX, options);
|
|
4700
|
+
|
|
4701
|
+
let widget = this.create_widget( name, Widget.CHECKBOX, options );
|
|
4702
|
+
|
|
4683
4703
|
widget.onGetValue = () => {
|
|
4684
4704
|
return flag.value;
|
|
4685
4705
|
};
|
|
4686
|
-
widget.onSetValue = (
|
|
4687
|
-
if(flag.value !==
|
|
4688
|
-
Panel._dispatch_event(toggle, "click");
|
|
4706
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4707
|
+
if( flag.value !== newValue )
|
|
4708
|
+
Panel._dispatch_event( toggle, "click", skipCallback );
|
|
4689
4709
|
};
|
|
4690
|
-
|
|
4710
|
+
|
|
4691
4711
|
let element = widget.domEl;
|
|
4692
|
-
|
|
4712
|
+
|
|
4693
4713
|
// Add reset functionality
|
|
4694
|
-
Panel._add_reset_property(element.domName, function() {
|
|
4695
|
-
Panel._dispatch_event(toggle, "click");
|
|
4714
|
+
Panel._add_reset_property( element.domName, function() {
|
|
4715
|
+
Panel._dispatch_event( toggle, "click" );
|
|
4696
4716
|
});
|
|
4697
4717
|
|
|
4698
4718
|
// Add widget value
|
|
@@ -4723,30 +4743,35 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4723
4743
|
container.appendChild(toggle);
|
|
4724
4744
|
container.appendChild(value_name);
|
|
4725
4745
|
|
|
4726
|
-
toggle.addEventListener("click",
|
|
4727
|
-
|
|
4728
|
-
let flag = toggle.querySelector(".checkbox");
|
|
4729
|
-
if(flag.disabled)
|
|
4730
|
-
return;
|
|
4746
|
+
toggle.addEventListener( "click" , e => {
|
|
4731
4747
|
|
|
4732
|
-
let
|
|
4748
|
+
let flag = toggle.querySelector( ".checkbox" );
|
|
4749
|
+
if( flag.disabled )
|
|
4750
|
+
return;
|
|
4751
|
+
|
|
4752
|
+
const skipCallback = (e.detail.constructor == Number ? null : skipCallback);
|
|
4733
4753
|
|
|
4754
|
+
let check = toggle.querySelector( ".checkbox a" );
|
|
4755
|
+
|
|
4734
4756
|
flag.value = !flag.value;
|
|
4735
|
-
flag.className = "checkbox " + (flag.value ? "on" : "");
|
|
4757
|
+
flag.className = "checkbox " + ( flag.value ? "on" : "" );
|
|
4736
4758
|
check.style.display = flag.value ? "block" : "none";
|
|
4737
|
-
|
|
4759
|
+
|
|
4738
4760
|
// Reset button (default value)
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4761
|
+
if( !skipCallback )
|
|
4762
|
+
{
|
|
4763
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4764
|
+
if( btn ) btn.style.display = flag.value != flag.iValue ? "block": "none";
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4742
4767
|
// Open suboptions
|
|
4743
|
-
let submenu = element.querySelector(".lexcheckboxsubmenu");
|
|
4744
|
-
if(submenu) submenu.toggleAttribute('hidden', !flag.value);
|
|
4745
|
-
|
|
4746
|
-
this._trigger( new IEvent(name, flag.value, e), callback );
|
|
4768
|
+
let submenu = element.querySelector( ".lexcheckboxsubmenu" );
|
|
4769
|
+
if( submenu ) submenu.toggleAttribute( 'hidden', !flag.value );
|
|
4770
|
+
|
|
4771
|
+
if( !skipCallback ) this._trigger( new IEvent( name, flag.value, e ), callback );
|
|
4747
4772
|
});
|
|
4748
|
-
|
|
4749
|
-
element.appendChild(container);
|
|
4773
|
+
|
|
4774
|
+
element.appendChild( container );
|
|
4750
4775
|
|
|
4751
4776
|
if( options.suboptions )
|
|
4752
4777
|
{
|
|
@@ -4777,92 +4802,86 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4777
4802
|
|
|
4778
4803
|
addColor( name, value, callback, options = {} ) {
|
|
4779
4804
|
|
|
4780
|
-
if(!name) {
|
|
4781
|
-
throw("Set Widget Name!");
|
|
4805
|
+
if( !name ) {
|
|
4806
|
+
throw( "Set Widget Name!" );
|
|
4782
4807
|
}
|
|
4783
|
-
|
|
4784
|
-
let widget = this.create_widget(name, Widget.COLOR, options);
|
|
4808
|
+
|
|
4809
|
+
let widget = this.create_widget( name, Widget.COLOR, options );
|
|
4810
|
+
|
|
4785
4811
|
widget.onGetValue = () => {
|
|
4786
4812
|
return color.value;
|
|
4787
4813
|
};
|
|
4788
|
-
widget.onSetValue = (
|
|
4789
|
-
color.value =
|
|
4790
|
-
Panel._dispatch_event(color, "input");
|
|
4814
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4815
|
+
color.value = newValue;
|
|
4816
|
+
Panel._dispatch_event( color, "input", skipCallback );
|
|
4791
4817
|
};
|
|
4818
|
+
|
|
4792
4819
|
let element = widget.domEl;
|
|
4793
4820
|
let change_from_input = false;
|
|
4794
|
-
|
|
4821
|
+
|
|
4795
4822
|
// Add reset functionality
|
|
4796
|
-
Panel._add_reset_property(element.domName, function() {
|
|
4823
|
+
Panel._add_reset_property( element.domName, function() {
|
|
4797
4824
|
this.style.display = "none";
|
|
4798
4825
|
color.value = color.iValue;
|
|
4799
|
-
Panel._dispatch_event(color, "input");
|
|
4826
|
+
Panel._dispatch_event( color, "input" );
|
|
4800
4827
|
});
|
|
4801
|
-
|
|
4828
|
+
|
|
4802
4829
|
// Add widget value
|
|
4803
|
-
|
|
4804
|
-
var container = document.createElement('span');
|
|
4830
|
+
|
|
4831
|
+
var container = document.createElement( 'span' );
|
|
4805
4832
|
container.className = "lexcolor";
|
|
4806
4833
|
container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
4807
|
-
|
|
4808
|
-
let color = document.createElement('input');
|
|
4834
|
+
|
|
4835
|
+
let color = document.createElement( 'input' );
|
|
4809
4836
|
color.style.width = "calc(30% - 6px)";
|
|
4810
4837
|
color.type = 'color';
|
|
4811
4838
|
color.className = "colorinput";
|
|
4812
4839
|
color.id = "color" + simple_guidGenerator();
|
|
4813
4840
|
color.useRGB = options.useRGB ?? false;
|
|
4814
|
-
color.value = color.iValue = value.constructor === Array ? rgbToHex(value) : value;
|
|
4841
|
+
color.value = color.iValue = value.constructor === Array ? rgbToHex( value ) : value;
|
|
4815
4842
|
|
|
4816
|
-
if(options.disabled) {
|
|
4843
|
+
if( options.disabled ) {
|
|
4817
4844
|
color.disabled = true;
|
|
4818
4845
|
}
|
|
4819
|
-
|
|
4820
|
-
color.addEventListener("input", e => {
|
|
4846
|
+
|
|
4847
|
+
color.addEventListener( "input", e => {
|
|
4821
4848
|
let val = e.target.value;
|
|
4822
|
-
|
|
4849
|
+
|
|
4850
|
+
const skipCallback = e.detail;
|
|
4851
|
+
|
|
4823
4852
|
// Change value (always hex)
|
|
4824
4853
|
if( !change_from_input )
|
|
4825
|
-
text_widget.set(val);
|
|
4826
|
-
|
|
4854
|
+
text_widget.set( val );
|
|
4855
|
+
|
|
4827
4856
|
// Reset button (default value)
|
|
4828
|
-
if(
|
|
4829
|
-
|
|
4830
|
-
btn
|
|
4857
|
+
if( !skipCallback )
|
|
4858
|
+
{
|
|
4859
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4860
|
+
if( btn ) btn.style.display = val != color.iValue ? "block": "none";
|
|
4831
4861
|
}
|
|
4832
|
-
|
|
4833
|
-
if(color.useRGB)
|
|
4834
|
-
val = hexToRgb(val);
|
|
4835
|
-
|
|
4836
|
-
this._trigger( new IEvent(name, val, e), callback );
|
|
4837
|
-
}, false);
|
|
4838
|
-
|
|
4839
|
-
container.appendChild(color);
|
|
4840
|
-
|
|
4862
|
+
|
|
4863
|
+
if( color.useRGB )
|
|
4864
|
+
val = hexToRgb( val );
|
|
4865
|
+
|
|
4866
|
+
if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
|
|
4867
|
+
}, false );
|
|
4868
|
+
|
|
4869
|
+
container.appendChild( color );
|
|
4870
|
+
|
|
4841
4871
|
this.queue( container );
|
|
4842
|
-
|
|
4843
|
-
const text_widget = this.addText(null, color.value,
|
|
4872
|
+
|
|
4873
|
+
const text_widget = this.addText( null, color.value, v => {
|
|
4844
4874
|
change_from_input = true;
|
|
4845
4875
|
widget.set( v );
|
|
4846
4876
|
change_from_input = false;
|
|
4847
4877
|
}, { width: "calc(70% - 4px)" });
|
|
4848
4878
|
|
|
4849
4879
|
text_widget.domEl.style.marginLeft = "4px";
|
|
4850
|
-
|
|
4880
|
+
|
|
4851
4881
|
this.clearQueue();
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
// valueName.innerText = color.value;
|
|
4856
|
-
|
|
4857
|
-
// valueName.addEventListener("click", e => {
|
|
4858
|
-
// color.focus();
|
|
4859
|
-
// color.click();
|
|
4860
|
-
// });
|
|
4861
|
-
|
|
4862
|
-
// container.appendChild(valueName);
|
|
4863
|
-
|
|
4864
|
-
element.appendChild(container);
|
|
4865
|
-
|
|
4882
|
+
|
|
4883
|
+
element.appendChild( container );
|
|
4884
|
+
|
|
4866
4885
|
return widget;
|
|
4867
4886
|
}
|
|
4868
4887
|
|
|
@@ -4881,109 +4900,120 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4881
4900
|
|
|
4882
4901
|
addNumber( name, value, callback, options = {} ) {
|
|
4883
4902
|
|
|
4884
|
-
let widget = this.create_widget(name, Widget.NUMBER, options);
|
|
4903
|
+
let widget = this.create_widget( name, Widget.NUMBER, options );
|
|
4904
|
+
|
|
4885
4905
|
widget.onGetValue = () => {
|
|
4886
4906
|
return +vecinput.value;
|
|
4887
4907
|
};
|
|
4888
|
-
widget.onSetValue = (
|
|
4889
|
-
vecinput.value =
|
|
4890
|
-
Panel._dispatch_event(vecinput, "change");
|
|
4908
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4909
|
+
vecinput.value = newValue;
|
|
4910
|
+
Panel._dispatch_event( vecinput, "change", skipCallback );
|
|
4891
4911
|
};
|
|
4912
|
+
|
|
4892
4913
|
let element = widget.domEl;
|
|
4893
4914
|
|
|
4894
4915
|
// add reset functionality
|
|
4895
|
-
if(widget.name) {
|
|
4896
|
-
Panel._add_reset_property(element.domName, function() {
|
|
4916
|
+
if( widget.name ) {
|
|
4917
|
+
Panel._add_reset_property( element.domName, function() {
|
|
4897
4918
|
this.style.display = "none";
|
|
4898
4919
|
vecinput.value = vecinput.iValue;
|
|
4899
|
-
Panel._dispatch_event(vecinput, "change");
|
|
4920
|
+
Panel._dispatch_event( vecinput, "change" );
|
|
4900
4921
|
});
|
|
4901
4922
|
}
|
|
4902
4923
|
|
|
4903
4924
|
// add widget value
|
|
4904
4925
|
|
|
4905
|
-
var container = document.createElement('div');
|
|
4926
|
+
var container = document.createElement( 'div' );
|
|
4906
4927
|
container.className = "lexnumber";
|
|
4907
4928
|
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
4908
4929
|
|
|
4909
|
-
let box = document.createElement('div');
|
|
4930
|
+
let box = document.createElement( 'div' );
|
|
4910
4931
|
box.className = "numberbox";
|
|
4911
4932
|
|
|
4912
|
-
let vecinput = document.createElement('input');
|
|
4933
|
+
let vecinput = document.createElement( 'input' );
|
|
4913
4934
|
vecinput.className = "vecinput";
|
|
4914
4935
|
vecinput.min = options.min ?? -1e24;
|
|
4915
4936
|
vecinput.max = options.max ?? 1e24;
|
|
4916
4937
|
vecinput.step = options.step ?? "any";
|
|
4917
4938
|
vecinput.type = "number";
|
|
4918
|
-
vecinput.id = "number_"+simple_guidGenerator();
|
|
4939
|
+
vecinput.id = "number_" + simple_guidGenerator();
|
|
4919
4940
|
|
|
4920
4941
|
if( value.constructor == Number )
|
|
4921
4942
|
{
|
|
4922
|
-
value = clamp(value, +vecinput.min, +vecinput.max);
|
|
4923
|
-
value = options.precision ? round(value, options.precision) : value;
|
|
4943
|
+
value = clamp( value, +vecinput.min, +vecinput.max );
|
|
4944
|
+
value = options.precision ? round( value, options.precision ) : value;
|
|
4924
4945
|
}
|
|
4925
4946
|
|
|
4926
4947
|
vecinput.value = vecinput.iValue = value;
|
|
4927
|
-
box.appendChild(vecinput);
|
|
4948
|
+
box.appendChild( vecinput );
|
|
4928
4949
|
|
|
4929
|
-
let drag_icon = document.createElement('a');
|
|
4950
|
+
let drag_icon = document.createElement( 'a' );
|
|
4930
4951
|
drag_icon.className = "fa-solid fa-arrows-up-down drag-icon hidden";
|
|
4931
|
-
box.appendChild(drag_icon);
|
|
4952
|
+
box.appendChild( drag_icon );
|
|
4932
4953
|
|
|
4933
|
-
if(options.disabled) {
|
|
4954
|
+
if( options.disabled ) {
|
|
4934
4955
|
vecinput.disabled = true;
|
|
4935
4956
|
}
|
|
4936
4957
|
|
|
4937
4958
|
// add slider below
|
|
4938
|
-
if(!options.skipSlider && options.min !== undefined && options.max !== undefined) {
|
|
4939
|
-
let slider = document.createElement('input');
|
|
4959
|
+
if( !options.skipSlider && options.min !== undefined && options.max !== undefined ) {
|
|
4960
|
+
let slider = document.createElement( 'input' );
|
|
4940
4961
|
slider.className = "lexinputslider";
|
|
4941
4962
|
slider.step = options.step ?? 1;
|
|
4942
4963
|
slider.min = options.min;
|
|
4943
4964
|
slider.max = options.max;
|
|
4944
4965
|
slider.type = "range";
|
|
4945
4966
|
slider.value = value;
|
|
4946
|
-
slider.addEventListener("input", function(e) {
|
|
4967
|
+
slider.addEventListener( "input", function( e ) {
|
|
4947
4968
|
let new_value = +this.valueAsNumber;
|
|
4948
|
-
vecinput.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
|
|
4949
|
-
Panel._dispatch_event(vecinput, "change");
|
|
4950
|
-
}, false);
|
|
4951
|
-
box.appendChild(slider);
|
|
4969
|
+
vecinput.value = ( +new_value ).toFixed( 4 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' );
|
|
4970
|
+
Panel._dispatch_event( vecinput, "change" );
|
|
4971
|
+
}, false );
|
|
4972
|
+
box.appendChild( slider );
|
|
4952
4973
|
}
|
|
4953
4974
|
|
|
4954
4975
|
// Add wheel input
|
|
4955
4976
|
|
|
4956
|
-
vecinput.addEventListener("wheel", function(e) {
|
|
4977
|
+
vecinput.addEventListener( "wheel", function( e ) {
|
|
4957
4978
|
e.preventDefault();
|
|
4958
|
-
if(this !== document.activeElement)
|
|
4979
|
+
if( this !== document.activeElement )
|
|
4959
4980
|
return;
|
|
4960
4981
|
let mult = options.step ?? 1;
|
|
4961
|
-
if(e.shiftKey) mult *= 10;
|
|
4962
|
-
else if(e.altKey) mult *= 0.1;
|
|
4963
|
-
let new_value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1));
|
|
4964
|
-
this.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
|
|
4982
|
+
if( e.shiftKey ) mult *= 10;
|
|
4983
|
+
else if( e.altKey ) mult *= 0.1;
|
|
4984
|
+
let new_value = ( +this.valueAsNumber - mult * ( e.deltaY > 0 ? 1 : -1 ) );
|
|
4985
|
+
this.value = ( +new_value ).toFixed( 4 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' );
|
|
4965
4986
|
Panel._dispatch_event(vecinput, "change");
|
|
4966
|
-
}, {passive:false});
|
|
4987
|
+
}, { passive: false });
|
|
4988
|
+
|
|
4989
|
+
vecinput.addEventListener( "change", e => {
|
|
4967
4990
|
|
|
4968
|
-
|
|
4969
|
-
if(isNaN(e.target.valueAsNumber))
|
|
4991
|
+
if( isNaN( e.target.valueAsNumber ) )
|
|
4970
4992
|
return;
|
|
4971
|
-
|
|
4972
|
-
|
|
4993
|
+
|
|
4994
|
+
const skipCallback = e.detail;
|
|
4995
|
+
|
|
4996
|
+
let val = e.target.value = clamp( +e.target.valueAsNumber, +vecinput.min, +vecinput.max );
|
|
4997
|
+
val = options.precision ? round( val, options.precision ) : val;
|
|
4973
4998
|
// update slider!
|
|
4974
|
-
if( box.querySelector(".lexinputslider"))
|
|
4975
|
-
box.querySelector(".lexinputslider").value = val;
|
|
4999
|
+
if( box.querySelector( ".lexinputslider" ) )
|
|
5000
|
+
box.querySelector( ".lexinputslider" ).value = val;
|
|
4976
5001
|
|
|
4977
5002
|
vecinput.value = val;
|
|
5003
|
+
|
|
4978
5004
|
// Reset button (default value)
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
5005
|
+
if( !skipCallback )
|
|
5006
|
+
{
|
|
5007
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
5008
|
+
if( btn ) btn.style.display = val != vecinput.iValue ? "block": "none";
|
|
5009
|
+
}
|
|
5010
|
+
|
|
5011
|
+
if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
|
|
5012
|
+
}, { passive: false });
|
|
4983
5013
|
|
|
4984
5014
|
// Add drag input
|
|
4985
5015
|
|
|
4986
|
-
vecinput.addEventListener("mousedown", inner_mousedown);
|
|
5016
|
+
vecinput.addEventListener( "mousedown", inner_mousedown );
|
|
4987
5017
|
|
|
4988
5018
|
var that = this;
|
|
4989
5019
|
var lastY = 0;
|
|
@@ -5041,44 +5071,39 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5041
5071
|
|
|
5042
5072
|
_add_vector( num_components, name, value, callback, options = {} ) {
|
|
5043
5073
|
|
|
5044
|
-
num_components = clamp(num_components, 2, 4);
|
|
5045
|
-
value = value ?? new Array(num_components).fill(0);
|
|
5074
|
+
num_components = clamp( num_components, 2, 4 );
|
|
5075
|
+
value = value ?? new Array( num_components ).fill( 0 );
|
|
5046
5076
|
|
|
5047
|
-
if(!name) {
|
|
5048
|
-
throw("Set Widget Name!");
|
|
5077
|
+
if( !name ) {
|
|
5078
|
+
throw( "Set Widget Name!" );
|
|
5049
5079
|
}
|
|
5050
5080
|
|
|
5051
|
-
let widget = this.create_widget(name, Widget.VECTOR, options);
|
|
5081
|
+
let widget = this.create_widget( name, Widget.VECTOR, options );
|
|
5052
5082
|
|
|
5053
5083
|
widget.onGetValue = () => {
|
|
5054
|
-
let inputs = element.querySelectorAll("input");
|
|
5084
|
+
let inputs = element.querySelectorAll( "input" );
|
|
5055
5085
|
let value = [];
|
|
5056
5086
|
for( var v of inputs )
|
|
5057
5087
|
value.push( +v.value );
|
|
5058
5088
|
return value;
|
|
5059
5089
|
};
|
|
5060
|
-
widget.onSetValue = (
|
|
5061
|
-
const inputs = element.querySelectorAll(".vecinput");
|
|
5090
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
5091
|
+
const inputs = element.querySelectorAll( ".vecinput" );
|
|
5062
5092
|
for( var i = 0; i < inputs.length; ++i ) {
|
|
5063
|
-
|
|
5064
|
-
|
|
5093
|
+
let value = newValue[ i ];
|
|
5094
|
+
inputs[ i ].value = value ?? 0;
|
|
5095
|
+
Panel._dispatch_event( inputs[ i ], "change", skipCallback );
|
|
5065
5096
|
}
|
|
5066
5097
|
};
|
|
5067
|
-
widget.setValue = (new_value) => {
|
|
5068
|
-
const inputs = element.querySelectorAll(".vecinput");
|
|
5069
|
-
for( var i = 0; i < inputs.length; ++i ) {
|
|
5070
|
-
inputs[i].value = new_value[i] ?? 0;
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
5098
|
|
|
5074
5099
|
let element = widget.domEl;
|
|
5075
5100
|
|
|
5076
5101
|
// Add reset functionality
|
|
5077
|
-
Panel._add_reset_property(element.domName, function() {
|
|
5102
|
+
Panel._add_reset_property( element.domName, function() {
|
|
5078
5103
|
this.style.display = "none";
|
|
5079
|
-
for( let v of element.querySelectorAll(".vecinput") ) {
|
|
5104
|
+
for( let v of element.querySelectorAll( ".vecinput" ) ) {
|
|
5080
5105
|
v.value = v.iValue;
|
|
5081
|
-
Panel._dispatch_event(v, "change");
|
|
5106
|
+
Panel._dispatch_event( v, "change" );
|
|
5082
5107
|
}
|
|
5083
5108
|
});
|
|
5084
5109
|
|
|
@@ -5090,88 +5115,91 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5090
5115
|
|
|
5091
5116
|
for( let i = 0; i < num_components; ++i ) {
|
|
5092
5117
|
|
|
5093
|
-
let box = document.createElement('div');
|
|
5118
|
+
let box = document.createElement( 'div' );
|
|
5094
5119
|
box.className = "vecbox";
|
|
5095
|
-
box.innerHTML = "<span class='" + Panel.VECTOR_COMPONENTS[i] + "'></span>";
|
|
5120
|
+
box.innerHTML = "<span class='" + Panel.VECTOR_COMPONENTS[ i ] + "'></span>";
|
|
5096
5121
|
|
|
5097
|
-
let vecinput = document.createElement('input');
|
|
5122
|
+
let vecinput = document.createElement( 'input' );
|
|
5098
5123
|
vecinput.className = "vecinput v" + num_components;
|
|
5099
5124
|
vecinput.min = options.min ?? -1e24;
|
|
5100
5125
|
vecinput.max = options.max ?? 1e24;
|
|
5101
5126
|
vecinput.step = options.step ?? "any";
|
|
5102
5127
|
vecinput.type = "number";
|
|
5103
|
-
vecinput.id = "vec"+num_components+"_"+simple_guidGenerator();
|
|
5128
|
+
vecinput.id = "vec" + num_components + "_" + simple_guidGenerator();
|
|
5104
5129
|
vecinput.idx = i;
|
|
5105
5130
|
|
|
5106
|
-
if( value[i].constructor == Number )
|
|
5131
|
+
if( value[ i ].constructor == Number )
|
|
5107
5132
|
{
|
|
5108
|
-
value[i] = clamp(value[i], +vecinput.min, +vecinput.max);
|
|
5109
|
-
value[i] = options.precision ? round(value[i], options.precision) : value[i];
|
|
5133
|
+
value[ i ] = clamp(value[ i ], +vecinput.min, +vecinput.max);
|
|
5134
|
+
value[ i ] = options.precision ? round(value[ i ], options.precision) : value[ i ];
|
|
5110
5135
|
}
|
|
5111
5136
|
|
|
5112
|
-
vecinput.value = vecinput.iValue = value[i];
|
|
5137
|
+
vecinput.value = vecinput.iValue = value[ i ];
|
|
5113
5138
|
|
|
5114
|
-
let drag_icon = document.createElement('a');
|
|
5139
|
+
let drag_icon = document.createElement( 'a' );
|
|
5115
5140
|
drag_icon.className = "fa-solid fa-arrows-up-down drag-icon hidden";
|
|
5116
|
-
box.appendChild(drag_icon);
|
|
5141
|
+
box.appendChild( drag_icon );
|
|
5117
5142
|
|
|
5118
|
-
if(options.disabled) {
|
|
5143
|
+
if( options.disabled ) {
|
|
5119
5144
|
vecinput.disabled = true;
|
|
5120
5145
|
}
|
|
5121
5146
|
|
|
5122
5147
|
// Add wheel input
|
|
5123
5148
|
|
|
5124
|
-
vecinput.addEventListener("wheel", function(e) {
|
|
5149
|
+
vecinput.addEventListener( "wheel", function( e ) {
|
|
5125
5150
|
e.preventDefault();
|
|
5126
|
-
if(this !== document.activeElement)
|
|
5151
|
+
if( this !== document.activeElement )
|
|
5127
5152
|
return;
|
|
5128
5153
|
let mult = options.step ?? 1;
|
|
5129
|
-
if(e.shiftKey) mult = 10;
|
|
5130
|
-
else if(e.altKey) mult = 0.1;
|
|
5154
|
+
if( e.shiftKey ) mult = 10;
|
|
5155
|
+
else if( e.altKey ) mult = 0.1;
|
|
5131
5156
|
|
|
5132
5157
|
if( lock_icon.locked )
|
|
5133
5158
|
{
|
|
5134
5159
|
for( let v of element.querySelectorAll(".vecinput") ) {
|
|
5135
|
-
v.value = (+v.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1)).toPrecision(5);
|
|
5160
|
+
v.value = ( +v.valueAsNumber - mult * ( e.deltaY > 0 ? 1 : -1 ) ).toPrecision( 5 );
|
|
5136
5161
|
Panel._dispatch_event(v, "change");
|
|
5137
5162
|
}
|
|
5138
5163
|
} else {
|
|
5139
|
-
this.value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1)).toPrecision(5);
|
|
5140
|
-
Panel._dispatch_event(vecinput, "change");
|
|
5164
|
+
this.value = ( +this.valueAsNumber - mult * ( e.deltaY > 0 ? 1 : -1 ) ).toPrecision( 5 );
|
|
5165
|
+
Panel._dispatch_event( vecinput, "change" );
|
|
5141
5166
|
}
|
|
5142
|
-
}, {passive:false});
|
|
5167
|
+
}, { passive: false } );
|
|
5143
5168
|
|
|
5144
|
-
vecinput.addEventListener("change", e => {
|
|
5169
|
+
vecinput.addEventListener( "change", e => {
|
|
5145
5170
|
|
|
5146
5171
|
if( isNaN( e.target.value ) )
|
|
5147
5172
|
return;
|
|
5148
5173
|
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
val =
|
|
5152
|
-
|
|
5174
|
+
const skipCallback = e.detail;
|
|
5175
|
+
|
|
5176
|
+
let val = e.target.value = clamp( e.target.value, +vecinput.min, +vecinput.max );
|
|
5177
|
+
val = options.precision ? round( val, options.precision ) : val;
|
|
5153
5178
|
|
|
5154
5179
|
// Reset button (default value)
|
|
5155
|
-
|
|
5156
|
-
|
|
5180
|
+
if( !skipCallback )
|
|
5181
|
+
{
|
|
5182
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
5183
|
+
if( btn ) btn.style.display = val != vecinput.iValue ? "block": "none";
|
|
5184
|
+
}
|
|
5157
5185
|
|
|
5158
5186
|
if( lock_icon.locked )
|
|
5159
5187
|
{
|
|
5160
|
-
for( let v of element.querySelectorAll(".vecinput") ) {
|
|
5188
|
+
for( let v of element.querySelectorAll( ".vecinput" ) ) {
|
|
5161
5189
|
v.value = val;
|
|
5162
|
-
value[v.idx] = val;
|
|
5190
|
+
value[ v.idx ] = val;
|
|
5163
5191
|
}
|
|
5164
5192
|
} else {
|
|
5165
5193
|
vecinput.value = val;
|
|
5166
|
-
value[e.target.idx] = val;
|
|
5194
|
+
value[ e.target.idx ] = val;
|
|
5167
5195
|
}
|
|
5168
5196
|
|
|
5169
|
-
this._trigger( new IEvent(name, value, e), callback );
|
|
5170
|
-
}, false);
|
|
5197
|
+
if( !skipCallback ) this._trigger( new IEvent( name, value, e ), callback );
|
|
5198
|
+
}, false );
|
|
5171
5199
|
|
|
5172
5200
|
// Add drag input
|
|
5173
5201
|
|
|
5174
|
-
vecinput.addEventListener("mousedown", inner_mousedown);
|
|
5202
|
+
vecinput.addEventListener( "mousedown", inner_mousedown );
|
|
5175
5203
|
|
|
5176
5204
|
var that = this;
|
|
5177
5205
|
var lastY = 0;
|
|
@@ -5288,15 +5316,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5288
5316
|
throw("Set Widget Name!");
|
|
5289
5317
|
}
|
|
5290
5318
|
|
|
5291
|
-
let widget = this.create_widget(name, Widget.PROGRESS, options);
|
|
5319
|
+
let widget = this.create_widget( name, Widget.PROGRESS, options );
|
|
5320
|
+
|
|
5292
5321
|
widget.onGetValue = () => {
|
|
5293
5322
|
return progress.value;
|
|
5294
5323
|
};
|
|
5295
|
-
widget.onSetValue = (
|
|
5296
|
-
element.querySelector("meter").value =
|
|
5324
|
+
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
5325
|
+
element.querySelector("meter").value = newValue;
|
|
5297
5326
|
if( element.querySelector("span") )
|
|
5298
|
-
element.querySelector("span").innerText =
|
|
5327
|
+
element.querySelector("span").innerText = newValue;
|
|
5299
5328
|
};
|
|
5329
|
+
|
|
5300
5330
|
let element = widget.domEl;
|
|
5301
5331
|
|
|
5302
5332
|
var container = document.createElement('div');
|
|
@@ -6692,7 +6722,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6692
6722
|
static ASSET_CLONED = 4;
|
|
6693
6723
|
static ASSET_DBLCLICKED = 5;
|
|
6694
6724
|
static ENTER_FOLDER = 6;
|
|
6695
|
-
|
|
6725
|
+
static ASSET_CHECKED = 7;
|
|
6726
|
+
|
|
6696
6727
|
constructor( type, item, value ) {
|
|
6697
6728
|
this.type = type || TreeEvent.NONE;
|
|
6698
6729
|
this.item = item;
|
|
@@ -6709,6 +6740,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6709
6740
|
case AssetViewEvent.ASSET_CLONED: return "assetview_event_cloned";
|
|
6710
6741
|
case AssetViewEvent.ASSET_DBLCLICKED: return "assetview_event_dblclicked";
|
|
6711
6742
|
case AssetViewEvent.ENTER_FOLDER: return "assetview_event_enter_folder";
|
|
6743
|
+
case AssetViewEvent.ASSET_CHECKED: return "assetview_event_checked";
|
|
6712
6744
|
}
|
|
6713
6745
|
}
|
|
6714
6746
|
};
|
|
@@ -6732,7 +6764,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6732
6764
|
constructor( options = {} ) {
|
|
6733
6765
|
|
|
6734
6766
|
this.rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
6735
|
-
this.layout = AssetView.LAYOUT_CONTENT;
|
|
6767
|
+
this.layout = options.layout ?? AssetView.LAYOUT_CONTENT;
|
|
6736
6768
|
this.contentPage = 1;
|
|
6737
6769
|
|
|
6738
6770
|
if(options.root_path)
|
|
@@ -7048,35 +7080,56 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7048
7080
|
_refreshContent(search_value, filter) {
|
|
7049
7081
|
|
|
7050
7082
|
const is_content_layout = (this.layout == AssetView.LAYOUT_CONTENT); // default
|
|
7051
|
-
|
|
7083
|
+
|
|
7052
7084
|
this.filter = filter ?? (this.filter ?? "None");
|
|
7053
7085
|
this.search_value = search_value ?? (this.search_value ?? "");
|
|
7054
7086
|
this.content.innerHTML = "";
|
|
7055
7087
|
this.content.className = (is_content_layout ? "lexassetscontent" : "lexassetscontent list");
|
|
7056
7088
|
let that = this;
|
|
7057
|
-
|
|
7089
|
+
|
|
7058
7090
|
const add_item = function(item) {
|
|
7059
|
-
|
|
7091
|
+
|
|
7060
7092
|
const type = item.type.charAt(0).toUpperCase() + item.type.slice(1);
|
|
7061
7093
|
const extension = getExtension( item.id );
|
|
7062
7094
|
const is_folder = type === "Folder";
|
|
7063
|
-
|
|
7095
|
+
|
|
7064
7096
|
let itemEl = document.createElement('li');
|
|
7065
7097
|
itemEl.className = "lexassetitem " + item.type.toLowerCase();
|
|
7066
7098
|
itemEl.title = type + ": " + item.id;
|
|
7067
7099
|
itemEl.tabIndex = -1;
|
|
7068
7100
|
that.content.appendChild(itemEl);
|
|
7069
|
-
|
|
7101
|
+
|
|
7102
|
+
if(item.selected != undefined) {
|
|
7103
|
+
let span = document.createElement('span');
|
|
7104
|
+
span.className = "lexcheckbox";
|
|
7105
|
+
let checkbox_input = document.createElement('input');
|
|
7106
|
+
checkbox_input.type = "checkbox";
|
|
7107
|
+
checkbox_input.className = "checkbox";
|
|
7108
|
+
checkbox_input.checked = item.selected;
|
|
7109
|
+
checkbox_input.addEventListener('change', (e, v) => {
|
|
7110
|
+
item.selected = !item.selected;
|
|
7111
|
+
if(that.onevent) {
|
|
7112
|
+
const event = new AssetViewEvent(AssetViewEvent.ASSET_CHECKED, e.shiftKey ? [item] : item );
|
|
7113
|
+
event.multiple = !!e.shiftKey;
|
|
7114
|
+
that.onevent( event );
|
|
7115
|
+
}
|
|
7116
|
+
e.stopPropagation();
|
|
7117
|
+
e.stopImmediatePropagation();
|
|
7118
|
+
})
|
|
7119
|
+
span.appendChild(checkbox_input);
|
|
7120
|
+
itemEl.appendChild(span);
|
|
7121
|
+
|
|
7122
|
+
}
|
|
7070
7123
|
let title = document.createElement('span');
|
|
7071
7124
|
title.className = "lexassettitle";
|
|
7072
7125
|
title.innerText = item.id;
|
|
7073
7126
|
itemEl.appendChild(title);
|
|
7074
|
-
|
|
7127
|
+
|
|
7075
7128
|
if( !that.skip_preview ) {
|
|
7076
|
-
|
|
7129
|
+
|
|
7077
7130
|
let preview = null;
|
|
7078
7131
|
const has_image = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
|
|
7079
|
-
|
|
7132
|
+
|
|
7080
7133
|
if( has_image || is_folder || !is_content_layout)
|
|
7081
7134
|
{
|
|
7082
7135
|
preview = document.createElement('img');
|
|
@@ -7093,13 +7146,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7093
7146
|
let textEl = document.createElement('text');
|
|
7094
7147
|
preview.appendChild(textEl);
|
|
7095
7148
|
// If no extension, e.g. Clip, use the type...
|
|
7096
|
-
textEl.innerText = extension == item.id ? item.type.toUpperCase() : ("." + extension.toUpperCase());
|
|
7097
|
-
|
|
7149
|
+
textEl.innerText = (!extension || extension == item.id) ? item.type.toUpperCase() : ("." + extension.toUpperCase());
|
|
7150
|
+
|
|
7098
7151
|
var newLength = textEl.innerText.length;
|
|
7099
7152
|
var charsPerLine = 2.5;
|
|
7100
7153
|
var newEmSize = charsPerLine / newLength;
|
|
7101
7154
|
var textBaseSize = 64;
|
|
7102
|
-
|
|
7155
|
+
|
|
7103
7156
|
if(newEmSize < 1) {
|
|
7104
7157
|
var newFontSize = newEmSize * textBaseSize;
|
|
7105
7158
|
textEl.style.fontSize = newFontSize + "px";
|
|
@@ -7107,7 +7160,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7107
7160
|
}
|
|
7108
7161
|
}
|
|
7109
7162
|
}
|
|
7110
|
-
|
|
7163
|
+
|
|
7111
7164
|
if( !is_folder )
|
|
7112
7165
|
{
|
|
7113
7166
|
let info = document.createElement('span');
|
|
@@ -7115,13 +7168,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7115
7168
|
info.innerText = type;
|
|
7116
7169
|
itemEl.appendChild(info);
|
|
7117
7170
|
}
|
|
7118
|
-
|
|
7171
|
+
|
|
7119
7172
|
itemEl.addEventListener('click', function(e) {
|
|
7120
7173
|
e.stopImmediatePropagation();
|
|
7121
7174
|
e.stopPropagation();
|
|
7122
|
-
|
|
7175
|
+
|
|
7123
7176
|
const is_double_click = e.detail == LX.MOUSE_DOUBLE_CLICK;
|
|
7124
|
-
|
|
7177
|
+
|
|
7125
7178
|
if(!is_double_click)
|
|
7126
7179
|
{
|
|
7127
7180
|
if(!e.shiftKey)
|
|
@@ -7135,14 +7188,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7135
7188
|
that._enterFolder( item );
|
|
7136
7189
|
return;
|
|
7137
7190
|
}
|
|
7138
|
-
|
|
7191
|
+
|
|
7139
7192
|
if(that.onevent) {
|
|
7140
7193
|
const event = new AssetViewEvent(is_double_click ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
|
|
7141
7194
|
event.multiple = !!e.shiftKey;
|
|
7142
7195
|
that.onevent( event );
|
|
7143
7196
|
}
|
|
7144
7197
|
});
|
|
7145
|
-
|
|
7198
|
+
|
|
7146
7199
|
if( that.context_menu )
|
|
7147
7200
|
{
|
|
7148
7201
|
itemEl.addEventListener('contextmenu', function(e) {
|
|
@@ -7163,32 +7216,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7163
7216
|
});
|
|
7164
7217
|
});
|
|
7165
7218
|
}
|
|
7166
|
-
|
|
7219
|
+
|
|
7167
7220
|
itemEl.addEventListener("dragstart", function(e) {
|
|
7168
7221
|
e.preventDefault();
|
|
7169
7222
|
}, false );
|
|
7170
|
-
|
|
7223
|
+
|
|
7171
7224
|
return itemEl;
|
|
7172
7225
|
}
|
|
7173
|
-
|
|
7226
|
+
|
|
7174
7227
|
const fr = new FileReader();
|
|
7175
|
-
|
|
7228
|
+
|
|
7176
7229
|
const filtered_data = this.currentData.filter( _i => {
|
|
7177
7230
|
return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
|
|
7178
7231
|
_i.id.toLowerCase().includes(this.search_value.toLowerCase())
|
|
7179
7232
|
} );
|
|
7180
|
-
|
|
7233
|
+
|
|
7181
7234
|
if(filter || search_value) {
|
|
7182
7235
|
this.contentPage = 1;
|
|
7183
7236
|
}
|
|
7184
7237
|
// Show all data if using filters
|
|
7185
7238
|
const start_index = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
|
|
7186
7239
|
const end_index = Math.min( start_index + AssetView.MAX_PAGE_ELEMENTS, filtered_data.length );
|
|
7187
|
-
|
|
7240
|
+
|
|
7188
7241
|
for( let i = start_index; i < end_index; ++i )
|
|
7189
7242
|
{
|
|
7190
7243
|
let item = filtered_data[i];
|
|
7191
|
-
|
|
7244
|
+
|
|
7192
7245
|
if( item.path )
|
|
7193
7246
|
{
|
|
7194
7247
|
LX.request({ url: item.path, dataType: 'blob', success: (f) => {
|