lexgui 0.1.43 → 0.1.44

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/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.43",
15
+ version: "0.1.44",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -74,8 +74,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
74
74
 
75
75
  function getThemeColor( colorName )
76
76
  {
77
- var r = getComputedStyle( document.querySelector( ':root' ) );
78
- return r.getPropertyValue( '--' + colorName );
77
+ const r = getComputedStyle( document.querySelector( ':root' ) );
78
+ const value = r.getPropertyValue( '--' + colorName );
79
+
80
+ if( value.includes( "light-dark" ) && window.matchMedia )
81
+ {
82
+ if( window.matchMedia( "(prefers-color-scheme: light)" ).matches )
83
+ {
84
+ return value.substring( value.indexOf( '(' ) + 1, value.indexOf( ',' ) ).replace( /\s/g, '' );
85
+ }
86
+ else
87
+ {
88
+ return value.substring( value.indexOf( ',' ) + 1, value.indexOf( ')' ) ).replace( /\s/g, '' );
89
+ }
90
+ }
91
+
92
+ return value;
79
93
  }
80
94
 
81
95
  LX.getThemeColor = getThemeColor;
@@ -618,6 +632,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
618
632
  this.main_area = new Area( { id: options.id ?? 'mainarea' } );
619
633
  }
620
634
 
635
+ window.matchMedia( "(prefers-color-scheme: dark)" ).addEventListener( "change", event => {
636
+ const newColorScheme = event.matches ? "dark" : "light";
637
+ LX.emit( "@on_new_color_scheme", newColorScheme );
638
+ });
639
+
621
640
  return this.main_area;
622
641
  }
623
642
 
@@ -747,6 +766,25 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
747
766
 
748
767
  LX.prompt = prompt;
749
768
 
769
+ /**
770
+ * @method badge
771
+ * @param {String} text
772
+ * @param {String} className
773
+ * @param {*} options
774
+ * style: Style attributes to override
775
+ */
776
+
777
+ function badge( text, className, options = {} )
778
+ {
779
+ const container = document.createElement( "div" );
780
+ container.innerHTML = text;
781
+ container.className = "lexbadge " + ( className ?? "" );
782
+ Object.assign( container.style, options.style ?? {} );
783
+ return container.outerHTML;
784
+ }
785
+
786
+ LX.badge = badge;
787
+
750
788
  /*
751
789
  * Events and Signals
752
790
  */
@@ -833,7 +871,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
833
871
  }
834
872
  else
835
873
  {
836
- obj[ signalName ].call( obj, value );
874
+ // This is a function callback!
875
+ const fn = obj;
876
+ fn( null, value );
837
877
  }
838
878
  }
839
879
  }
@@ -2628,27 +2668,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2628
2668
  static BUTTON = 3;
2629
2669
  static DROPDOWN = 4;
2630
2670
  static CHECKBOX = 5;
2631
- static COLOR = 6;
2632
- static NUMBER = 7;
2633
- static TITLE = 8;
2634
- static VECTOR = 9;
2635
- static TREE = 10;
2636
- static PROGRESS = 11;
2637
- static FILE = 12;
2638
- static LAYERS = 13;
2639
- static ARRAY = 14;
2640
- static LIST = 15;
2641
- static TAGS = 16;
2642
- static CURVE = 17;
2643
- static CARD = 18;
2644
- static IMAGE = 19;
2645
- static CONTENT = 20;
2646
- static CUSTOM = 21;
2647
- static SEPARATOR = 22;
2648
- static KNOB = 23;
2649
- static SIZE = 24;
2650
- static PAD = 25;
2651
- static FORM = 26;
2671
+ static TOGGLE = 6;
2672
+ static COLOR = 7;
2673
+ static NUMBER = 8;
2674
+ static TITLE = 9;
2675
+ static VECTOR = 10;
2676
+ static TREE = 11;
2677
+ static PROGRESS = 12;
2678
+ static FILE = 13;
2679
+ static LAYERS = 14;
2680
+ static ARRAY = 15;
2681
+ static LIST = 16;
2682
+ static TAGS = 17;
2683
+ static CURVE = 18;
2684
+ static CARD = 19;
2685
+ static IMAGE = 20;
2686
+ static CONTENT = 21;
2687
+ static CUSTOM = 22;
2688
+ static SEPARATOR = 23;
2689
+ static KNOB = 24;
2690
+ static SIZE = 25;
2691
+ static PAD = 26;
2692
+ static FORM = 27;
2693
+ static DIAL = 28;
2652
2694
 
2653
2695
  static NO_CONTEXT_TYPES = [
2654
2696
  Widget.BUTTON,
@@ -2721,6 +2763,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2721
2763
  case Widget.BUTTON: return "Button";
2722
2764
  case Widget.DROPDOWN: return "Dropdown";
2723
2765
  case Widget.CHECKBOX: return "Checkbox";
2766
+ case Widget.TOGGLE: return "Toggle";
2724
2767
  case Widget.COLOR: return "Color";
2725
2768
  case Widget.NUMBER: return "Number";
2726
2769
  case Widget.VECTOR: return "Vector";
@@ -2736,8 +2779,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2736
2779
  case Widget.SIZE: return "Size";
2737
2780
  case Widget.PAD: return "Pad";
2738
2781
  case Widget.FORM: return "Form";
2782
+ case Widget.DIAL: return "Dial";
2739
2783
  case Widget.CUSTOM: return this.customName;
2740
2784
  }
2785
+
2786
+ console.error( `Unknown Widget type: ${ this.type }` );
2741
2787
  }
2742
2788
 
2743
2789
  refresh() {
@@ -3909,41 +3955,50 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3909
3955
  /**
3910
3956
  * @method addTitle
3911
3957
  * @param {String} name Title name
3958
+ * @param {*} options:
3959
+ * link: Href in case title is an hyperlink
3960
+ * target: Target name of the iframe (if any)
3961
+ * icon: FA class of the icon (if any)
3962
+ * iconColor: Color of title icon (if any)
3963
+ * style: CSS to override
3912
3964
  */
3913
3965
 
3914
3966
  addTitle( name, options = {} ) {
3915
3967
 
3916
- if(!name) {
3917
- throw("Set Widget Name!");
3968
+ if( !name )
3969
+ {
3970
+ throw( "Can't create Title without text!" );
3918
3971
  }
3919
3972
 
3920
- let widget = this.create_widget(null, Widget.TITLE, options);
3973
+ let widget = this.create_widget( null, Widget.TITLE, options );
3921
3974
  let element = widget.domEl;
3922
3975
  element.className = "lextitle";
3923
3976
 
3924
- if(options.icon) {
3925
- let icon = document.createElement('a');
3977
+ if( options.icon )
3978
+ {
3979
+ let icon = document.createElement( 'a' );
3926
3980
  icon.className = options.icon;
3927
- icon.style.color = options.icon_color || "";
3928
- element.appendChild(icon);
3981
+ icon.style.color = options.iconColor || "";
3982
+ element.appendChild( icon );
3929
3983
  }
3930
3984
 
3931
- let text = document.createElement('span');
3985
+ let text = document.createElement( "span");
3932
3986
  text.innerText = name;
3933
- element.appendChild(text);
3987
+ element.appendChild( text );
3934
3988
 
3935
- Object.assign(element.style, options.style ?? {});
3989
+ Object.assign( element.style, options.style ?? {} );
3936
3990
 
3937
- if(options.link != undefined)
3991
+ if( options.link != undefined )
3938
3992
  {
3939
- let link_el = document.createElement('a');
3940
- link_el.innerText = name;
3941
- link_el.href = options.link;
3942
- link_el.target = options.target ?? "";
3943
- link_el.className = "lextitle link";
3944
- Object.assign(link_el.style, options.style ?? {});
3945
- element.replaceWith(link_el);
3993
+ let linkDom = document.createElement('a');
3994
+ linkDom.innerText = name;
3995
+ linkDom.href = options.link;
3996
+ linkDom.target = options.target ?? "";
3997
+ linkDom.className = "lextitle link";
3998
+ Object.assign( linkDom.style, options.style ?? {} );
3999
+ element.replaceWith( linkDom );
3946
4000
  }
4001
+
3947
4002
  return element;
3948
4003
  }
3949
4004
 
@@ -3992,6 +4047,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3992
4047
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " )";
3993
4048
  container.style.display = "flex";
3994
4049
 
4050
+ if( options.textClass )
4051
+ {
4052
+ container.classList.add( options.textClass );
4053
+ }
4054
+
3995
4055
  this.disabled = ( options.disabled || options.warning ) ?? ( options.url ? true : false );
3996
4056
  let wValue = null;
3997
4057
 
@@ -4457,7 +4517,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4457
4517
 
4458
4518
  for( let entry in data )
4459
4519
  {
4460
- const entryData = data[ entry ];
4520
+ let entryData = data[ entry ];
4521
+
4522
+ if( entryData.constructor != Object )
4523
+ {
4524
+ entryData = { };
4525
+ }
4526
+
4527
+ entryData.placeholder = entryData.placeholder ?? entry;
4528
+ entryData.width = "calc(100% - 10px)";
4529
+
4530
+ this.addLabel( entry, { textClass: "formlabel" } );
4531
+
4461
4532
  this.addText( entry, entryData.constructor == Object ? entryData.value : entryData, ( value ) => {
4462
4533
  container.formData[ entry ] = value;
4463
4534
  }, entryData );
@@ -4465,12 +4536,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4465
4536
  container.formData[ entry ] = entryData.constructor == Object ? entryData.value : entryData;
4466
4537
  }
4467
4538
 
4539
+ this.addBlank( );
4540
+
4468
4541
  this.addButton( null, options.actionName ?? "Submit", ( value, event ) => {
4469
4542
  if( callback )
4470
4543
  {
4471
4544
  callback( container.formData, event );
4472
4545
  }
4473
- } );
4546
+ }, { buttonClass: "accept", width: "calc(100% - 10px)" } );
4474
4547
 
4475
4548
  this.clearQueue();
4476
4549
 
@@ -4486,16 +4559,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4486
4559
 
4487
4560
  /**
4488
4561
  * @method addContent
4489
- * @param {HTMLElement} element
4562
+ * @param {HTMLElement/String} element
4490
4563
  */
4491
4564
 
4492
4565
  addContent( element, options = {} ) {
4493
4566
 
4494
4567
  if( !element )
4495
- return;
4568
+ {
4569
+ return;
4570
+ }
4571
+
4572
+ if( element.constructor == String )
4573
+ {
4574
+ const tmp = document.createElement( "div" );
4575
+ tmp.innerHTML = element;
4576
+ if( tmp.childElementCount > 1 )
4577
+ {
4578
+ element = tmp;
4579
+ }
4580
+ else
4581
+ {
4582
+ element = tmp.firstElementChild;
4583
+ }
4584
+ }
4496
4585
 
4497
- let widget = this.create_widget(null, Widget.CONTENT, options);
4498
- widget.domEl.appendChild(element);
4586
+ let widget = this.create_widget( null, Widget.CONTENT, options );
4587
+ widget.domEl.appendChild( element );
4499
4588
  return widget;
4500
4589
  }
4501
4590
 
@@ -4600,7 +4689,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4600
4689
  const iString = String( i );
4601
4690
  maxWidth = Math.max( iString.length, maxWidth );
4602
4691
  }
4603
- return maxWidth * 9;
4692
+ return Math.max( maxWidth * 10, 80 );
4604
4693
  };
4605
4694
 
4606
4695
  let selectedOption = this.addButton( null, buttonName, ( value, event ) => {
@@ -4843,6 +4932,86 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4843
4932
  return widget;
4844
4933
  }
4845
4934
 
4935
+ /**
4936
+ * @method addDial
4937
+ * @param {String} name Widget name
4938
+ * @param {Array of Array} values Array of 2N Arrays of each value of the dial
4939
+ * @param {Function} callback Callback function on change
4940
+ * @param {*} options:
4941
+ * skipReset: Don't add the reset value button when value changes
4942
+ * bgColor: Widget background color
4943
+ * pointsColor: Curve points color
4944
+ * lineColor: Curve line color
4945
+ * noOverlap: Points do not overlap, replacing themselves if necessary
4946
+ * allowAddValues: Support adding values on click
4947
+ * smooth: Curve smoothness
4948
+ * moveOutAction: Clamp or delete points moved out of the curve (LX.CURVE_MOVEOUT_CLAMP, LX.CURVE_MOVEOUT_DELETE)
4949
+ */
4950
+
4951
+ addDial( name, values, callback, options = {} ) {
4952
+
4953
+ let that = this;
4954
+ let widget = this.create_widget(name, Widget.DIAL, options);
4955
+
4956
+ widget.onGetValue = () => {
4957
+ return JSON.parse(JSON.stringify(curveInstance.element.value));
4958
+ };
4959
+
4960
+ widget.onSetValue = ( newValue, skipCallback ) => {
4961
+ let btn = element.querySelector( ".lexwidgetname .lexicon" );
4962
+ if( btn ) btn.style.display = ( newValue != curveInstance.element.value ? "block" : "none" );
4963
+ curveInstance.element.value = JSON.parse( JSON.stringify( newValue ) );
4964
+ curveInstance.redraw();
4965
+ if( !skipCallback ) that._trigger( new IEvent( name, curveInstance.element.value, null ), callback );
4966
+ };
4967
+
4968
+ let element = widget.domEl;
4969
+ let defaultValues = JSON.parse( JSON.stringify( values ) );
4970
+
4971
+ // Add reset functionality
4972
+ if( widget.name && !(options.skipReset ?? false) )
4973
+ {
4974
+ Panel._add_reset_property(element.domName, function(e) {
4975
+ this.style.display = "none";
4976
+ curveInstance.element.value = JSON.parse( JSON.stringify( defaultValues ) );
4977
+ curveInstance.redraw();
4978
+ that._trigger( new IEvent( name, curveInstance.element.value, e ), callback );
4979
+ });
4980
+ }
4981
+
4982
+ // Add widget value
4983
+
4984
+ var container = document.createElement( 'div' );
4985
+ container.className = "lexcurve";
4986
+ container.style.width = widget.name ? "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")" : '100%';
4987
+
4988
+ options.callback = (v, e) => {
4989
+ let btn = element.querySelector(".lexwidgetname .lexicon");
4990
+ if(btn) btn.style.display = (v != defaultValues ? "block" : "none");
4991
+ that._trigger( new IEvent(name, v, e), callback );
4992
+ };
4993
+
4994
+ options.name = name;
4995
+
4996
+ let curveInstance = new Dial( this, values, options );
4997
+ container.appendChild( curveInstance.element );
4998
+ element.appendChild( container );
4999
+
5000
+ // Resize
5001
+ widget.onresize = curveInstance.redraw.bind( curveInstance );
5002
+ widget.curveInstance = curveInstance;
5003
+
5004
+ doAsync(() => {
5005
+ curveInstance.element.style.height = curveInstance.element.offsetWidth + "px";
5006
+ curveInstance.canvas.width = curveInstance.element.offsetWidth;
5007
+ container.style.width = curveInstance.element.offsetWidth + "px";
5008
+ curveInstance.canvas.height = curveInstance.canvas.width;
5009
+ curveInstance.redraw();
5010
+ });
5011
+
5012
+ return widget;
5013
+ }
5014
+
4846
5015
  /**
4847
5016
  * @method addLayers
4848
5017
  * @param {String} name Widget name
@@ -5250,29 +5419,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5250
5419
  * @param {*} options:
5251
5420
  * disabled: Make the widget disabled [false]
5252
5421
  * suboptions: Callback to add widgets in case of TRUE value
5422
+ * className: Customize colors
5253
5423
  */
5254
5424
 
5255
5425
  addCheckbox( name, value, callback, options = {} ) {
5256
5426
 
5257
- if( !name ) {
5427
+ if( !name )
5428
+ {
5258
5429
  throw( "Set Widget Name!" );
5259
5430
  }
5260
5431
 
5261
5432
  let widget = this.create_widget( name, Widget.CHECKBOX, options );
5262
5433
 
5263
5434
  widget.onGetValue = () => {
5264
- return flag.value;
5435
+ return checkbox.checked;
5265
5436
  };
5437
+
5266
5438
  widget.onSetValue = ( newValue, skipCallback ) => {
5267
- if( flag.value !== newValue )
5268
- Panel._dispatch_event( toggle, "click", skipCallback );
5439
+ if( checkbox.checked !== newValue )
5440
+ {
5441
+ checkbox.checked = newValue;
5442
+ Panel._dispatch_event( checkbox, "change", skipCallback );
5443
+ }
5269
5444
  };
5270
5445
 
5271
5446
  let element = widget.domEl;
5272
5447
 
5273
5448
  // Add reset functionality
5274
5449
  Panel._add_reset_property( element.domName, function() {
5275
- Panel._dispatch_event( toggle, "click" );
5450
+ checkbox.checked = !checkbox.checked;
5451
+ Panel._dispatch_event( checkbox, "change" );
5276
5452
  });
5277
5453
 
5278
5454
  // Add widget value
@@ -5280,55 +5456,132 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5280
5456
  var container = document.createElement('div');
5281
5457
  container.className = "lexcheckboxcont";
5282
5458
 
5283
- let toggle = document.createElement('span');
5284
- toggle.className = "lexcheckbox";
5459
+ let checkbox = document.createElement('input');
5460
+ checkbox.type = "checkbox";
5461
+ checkbox.className = "lexcheckbox " + ( options.className ?? "" );
5462
+ checkbox.checked = value;
5463
+ checkbox.iValue = value;
5464
+ checkbox.disabled = options.disabled ?? false;
5285
5465
 
5286
- let flag = document.createElement('span');
5287
- flag.value = flag.iValue = value || false;
5288
- flag.className = "checkbox " + (flag.value ? "on" : "");
5289
- flag.id = "checkbox"+simple_guidGenerator();
5290
- flag.innerHTML = "<a class='fa-solid fa-check' style='display: " + (flag.value ? "block" : "none") + "'></a>";
5466
+ let valueName = document.createElement( 'span' );
5467
+ valueName.className = "checkboxtext";
5468
+ valueName.innerHTML = "On";
5291
5469
 
5292
- if( options.disabled ) {
5293
- flag.disabled = true;
5294
- toggle.className += " disabled";
5470
+ container.appendChild( checkbox );
5471
+ container.appendChild( valueName );
5472
+
5473
+ checkbox.addEventListener( "change" , e => {
5474
+
5475
+ const skipCallback = ( e.detail?.constructor == Number ? null : e.detail );
5476
+
5477
+ // Reset button (default value)
5478
+ if( !skipCallback )
5479
+ {
5480
+ let btn = element.querySelector( ".lexwidgetname .lexicon" );
5481
+ if( btn ) btn.style.display = checkbox.checked != checkbox.iValue ? "block": "none";
5482
+ }
5483
+
5484
+ // Open suboptions
5485
+ let submenu = element.querySelector( ".lexcheckboxsubmenu" );
5486
+ if( submenu ) submenu.toggleAttribute( 'hidden', !checkbox.checked );
5487
+
5488
+ if( !skipCallback ) this._trigger( new IEvent( name, checkbox.checked, e ), callback );
5489
+ });
5490
+
5491
+ element.appendChild( container );
5492
+
5493
+ if( options.suboptions )
5494
+ {
5495
+ element.style.flexWrap = "wrap";
5496
+ let suboptions = document.createElement('div');
5497
+ suboptions.className = "lexcheckboxsubmenu";
5498
+ suboptions.toggleAttribute( 'hidden', !checkbox.checked );
5499
+
5500
+ this.queue( suboptions );
5501
+ options.suboptions.call(this, this);
5502
+ this.clearQueue();
5503
+
5504
+ element.appendChild( suboptions );
5295
5505
  }
5296
5506
 
5297
- toggle.appendChild( flag );
5507
+ return widget;
5508
+ }
5298
5509
 
5299
- let value_name = document.createElement( 'span' );
5300
- value_name.id = "checkboxtext";
5301
- value_name.innerHTML = "On";
5510
+ /**
5511
+ * @method addToggle
5512
+ * @param {String} name Widget name
5513
+ * @param {Boolean} value Value of the checkbox
5514
+ * @param {Function} callback Callback function on change
5515
+ * @param {*} options:
5516
+ * disabled: Make the widget disabled [false]
5517
+ * suboptions: Callback to add widgets in case of TRUE value
5518
+ * className: Customize colors
5519
+ */
5302
5520
 
5303
- container.appendChild( toggle );
5304
- container.appendChild( value_name );
5521
+ addToggle( name, value, callback, options = {} ) {
5305
5522
 
5306
- toggle.addEventListener( "click" , e => {
5523
+ if( !name )
5524
+ {
5525
+ throw( "Set Widget Name!" );
5526
+ }
5307
5527
 
5308
- let flag = toggle.querySelector( ".checkbox" );
5309
- if( flag.disabled )
5310
- return;
5528
+ let widget = this.create_widget( name, Widget.TOGGLE, options );
5529
+
5530
+ widget.onGetValue = () => {
5531
+ return toggle.checked;
5532
+ };
5533
+
5534
+ widget.onSetValue = ( newValue, skipCallback ) => {
5535
+ if( toggle.checked !== newValue )
5536
+ {
5537
+ toggle.checked = newValue;
5538
+ Panel._dispatch_event( toggle, "change", skipCallback );
5539
+ }
5540
+ };
5541
+
5542
+ let element = widget.domEl;
5543
+
5544
+ // Add reset functionality
5545
+ Panel._add_reset_property( element.domName, function() {
5546
+ toggle.checked = !toggle.checked;
5547
+ Panel._dispatch_event( toggle, "change" );
5548
+ });
5549
+
5550
+ // Add widget value
5311
5551
 
5312
- const skipCallback = ( e.detail.constructor == Number ? null : e.detail );
5552
+ var container = document.createElement('div');
5553
+ container.className = "lextogglecont";
5554
+
5555
+ let toggle = document.createElement('input');
5556
+ toggle.type = "checkbox";
5557
+ toggle.className = "lextoggle " + ( options.className ?? "" );
5558
+ toggle.checked = value;
5559
+ toggle.iValue = value;
5560
+ toggle.disabled = options.disabled ?? false;
5561
+
5562
+ let valueName = document.createElement( 'span' );
5563
+ valueName.className = "toggletext";
5564
+ valueName.innerHTML = "On";
5565
+
5566
+ container.appendChild( toggle );
5567
+ container.appendChild( valueName );
5313
5568
 
5314
- let check = toggle.querySelector( ".checkbox a" );
5569
+ toggle.addEventListener( "change" , e => {
5315
5570
 
5316
- flag.value = !flag.value;
5317
- flag.className = "checkbox " + ( flag.value ? "on" : "" );
5318
- check.style.display = flag.value ? "block" : "none";
5571
+ const skipCallback = ( e.detail?.constructor == Number ? null : e.detail );
5319
5572
 
5320
5573
  // Reset button (default value)
5321
5574
  if( !skipCallback )
5322
5575
  {
5323
5576
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
5324
- if( btn ) btn.style.display = flag.value != flag.iValue ? "block": "none";
5577
+ if( btn ) btn.style.display = toggle.checked != toggle.iValue ? "block": "none";
5325
5578
  }
5326
5579
 
5327
5580
  // Open suboptions
5328
- let submenu = element.querySelector( ".lexcheckboxsubmenu" );
5329
- if( submenu ) submenu.toggleAttribute( 'hidden', !flag.value );
5581
+ let submenu = element.querySelector( ".lextogglesubmenu" );
5582
+ if( submenu ) submenu.toggleAttribute( 'hidden', !toggle.checked );
5330
5583
 
5331
- if( !skipCallback ) this._trigger( new IEvent( name, flag.value, e ), callback );
5584
+ if( !skipCallback ) this._trigger( new IEvent( name, toggle.checked, e ), callback );
5332
5585
  });
5333
5586
 
5334
5587
  element.appendChild( container );
@@ -5337,14 +5590,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5337
5590
  {
5338
5591
  element.style.flexWrap = "wrap";
5339
5592
  let suboptions = document.createElement('div');
5340
- suboptions.className = "lexcheckboxsubmenu";
5341
- suboptions.toggleAttribute('hidden', !flag.value);
5593
+ suboptions.className = "lextogglesubmenu";
5594
+ suboptions.toggleAttribute( 'hidden', !toggle.checked );
5342
5595
 
5343
5596
  this.queue( suboptions );
5344
5597
  options.suboptions.call(this, this);
5345
5598
  this.clearQueue();
5346
5599
 
5347
- element.appendChild(suboptions);
5600
+ element.appendChild( suboptions );
5348
5601
  }
5349
5602
 
5350
5603
  return widget;
@@ -5573,7 +5826,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5573
5826
  };
5574
5827
  }
5575
5828
 
5576
- // Add wheel input
5829
+ vecinput.addEventListener( "input", function( e ) {
5830
+ let new_value = +this.valueAsNumber;
5831
+ vecinput.value = round( new_value, options.precision );
5832
+ if( options.units )
5833
+ {
5834
+ vecinput.unitSpan.style.left = measureRealWidth( vecinput.value ) + "px";
5835
+ }
5836
+ }, false );
5577
5837
 
5578
5838
  vecinput.addEventListener( "wheel", function( e ) {
5579
5839
  e.preventDefault();
@@ -6267,10 +6527,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6267
6527
  widget.onGetValue = () => {
6268
6528
  return progress.value;
6269
6529
  };
6530
+
6270
6531
  widget.onSetValue = ( newValue, skipCallback ) => {
6271
6532
  element.querySelector("meter").value = newValue;
6533
+ _updateColor();
6272
6534
  if( element.querySelector("span") )
6535
+ {
6273
6536
  element.querySelector("span").innerText = newValue;
6537
+ }
6274
6538
  };
6275
6539
 
6276
6540
  let element = widget.domEl;
@@ -6287,14 +6551,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6287
6551
  progress.step = "any";
6288
6552
  progress.min = options.min ?? 0;
6289
6553
  progress.max = options.max ?? 1;
6554
+ progress.low = options.low ?? progress.low;
6555
+ progress.high = options.high ?? progress.high;
6556
+ progress.optimum = options.optimum ?? progress.optimum;
6290
6557
  progress.value = value;
6291
6558
 
6292
- if( options.low )
6293
- progress.low = options.low;
6294
- if( options.high )
6295
- progress.high = options.high;
6296
- if( options.optimum )
6297
- progress.optimum = options.optimum;
6559
+ const _updateColor = () => {
6560
+
6561
+ let backgroundColor = LX.getThemeColor( "global-selected" );
6562
+
6563
+ if( progress.low != undefined && progress.value < progress.low )
6564
+ {
6565
+ backgroundColor = LX.getThemeColor( "global-color-error" );
6566
+ }
6567
+ else if( progress.high != undefined && progress.value < progress.high )
6568
+ {
6569
+ backgroundColor = LX.getThemeColor( "global-color-warning" );
6570
+ }
6571
+
6572
+ progress.style.background = `color-mix(in oklab, ${backgroundColor} 20%, transparent)`;
6573
+ };
6298
6574
 
6299
6575
  container.appendChild( progress );
6300
6576
  element.appendChild( container );
@@ -6360,6 +6636,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6360
6636
  }
6361
6637
  }
6362
6638
 
6639
+ _updateColor();
6640
+
6363
6641
  return widget;
6364
6642
  }
6365
6643
 
@@ -6369,6 +6647,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6369
6647
  * @param {Function} callback Callback function on change
6370
6648
  * @param {*} options:
6371
6649
  * local: Ask for local file
6650
+ * disabled: Make the widget disabled [false]
6372
6651
  * read: Return the file itself (False) or the contents (True)
6373
6652
  * type: type to read as [text (Default), buffer, bin, url]
6374
6653
  */
@@ -6389,8 +6668,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6389
6668
 
6390
6669
  // Create hidden input
6391
6670
  let input = document.createElement( 'input' );
6671
+ input.className = "lexfileinput";
6392
6672
  input.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " - 10%)";
6393
6673
  input.type = 'file';
6674
+ input.disabled = options.disabled ?? false;
6394
6675
 
6395
6676
  if( options.placeholder )
6396
6677
  {
@@ -7203,8 +7484,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7203
7484
 
7204
7485
  this.root = document.createElement('div');
7205
7486
  this.root.className = "lexcontextmenubox";
7206
- this.root.style.left = (event.x - 48) + "px";
7207
- this.root.style.top = (event.y - 8) + "px";
7487
+ this.root.style.left = (event.x - 48 + document.scrollingElement.scrollLeft) + "px";
7488
+ this.root.style.top = (event.y - 8 + document.scrollingElement.scrollTop) + "px";
7208
7489
 
7209
7490
  this.root.addEventListener("mouseleave", function() {
7210
7491
  this.remove();
@@ -7493,7 +7774,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7493
7774
  element.style.minWidth = "50px";
7494
7775
  element.style.minHeight = "20px";
7495
7776
 
7496
- element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
7777
+ element.bgcolor = options.bgColor || LX.getThemeColor( "global-intense-background" );
7497
7778
  element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
7498
7779
  element.linecolor = options.lineColor || "#555";
7499
7780
  element.value = value || [];
@@ -7508,6 +7789,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7508
7789
  element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
7509
7790
  element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
7510
7791
 
7792
+ LX.addSignal( "@on_new_color_scheme", (el, value) => {
7793
+ element.bgcolor = options.bgColor || LX.getThemeColor( "global-intense-background" );
7794
+ element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
7795
+ this.redraw();
7796
+ } );
7797
+
7511
7798
  this.element = element;
7512
7799
 
7513
7800
  let canvas = document.createElement( "canvas" );
@@ -7811,42 +8098,371 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7811
8098
 
7812
8099
  LX.Curve = Curve;
7813
8100
 
7814
- class AssetViewEvent {
7815
-
7816
- static NONE = 0;
7817
- static ASSET_SELECTED = 1;
7818
- static ASSET_DELETED = 2;
7819
- static ASSET_RENAMED = 3;
7820
- static ASSET_CLONED = 4;
7821
- static ASSET_DBLCLICKED = 5;
7822
- static ENTER_FOLDER = 6;
7823
- static ASSET_CHECKED = 7;
8101
+ /**
8102
+ * @class Dial
8103
+ */
7824
8104
 
7825
- constructor( type, item, value ) {
7826
- this.type = type || TreeEvent.NONE;
7827
- this.item = item;
7828
- this.value = value;
7829
- this.multiple = false; // Multiple selection
7830
- }
8105
+ class Dial {
7831
8106
 
7832
- string() {
7833
- switch(this.type) {
7834
- case AssetViewEvent.NONE: return "assetview_event_none";
7835
- case AssetViewEvent.ASSET_SELECTED: return "assetview_event_selected";
7836
- case AssetViewEvent.ASSET_DELETED: return "assetview_event_deleted";
7837
- case AssetViewEvent.ASSET_RENAMED: return "assetview_event_renamed";
7838
- case AssetViewEvent.ASSET_CLONED: return "assetview_event_cloned";
7839
- case AssetViewEvent.ASSET_DBLCLICKED: return "assetview_event_dblclicked";
7840
- case AssetViewEvent.ENTER_FOLDER: return "assetview_event_enter_folder";
7841
- case AssetViewEvent.ASSET_CHECKED: return "assetview_event_checked";
7842
- }
7843
- }
7844
- };
8107
+ constructor( panel, value, options = {} ) {
7845
8108
 
7846
- LX.AssetViewEvent = AssetViewEvent;
8109
+ let element = document.createElement( "div" );
8110
+ element.className = "dial " + ( options.className ? options.className : "" );
8111
+ element.style.width = element.style.height = options.size || "100%";
8112
+ element.style.minWidth = element.style.minHeight = "50px";
7847
8113
 
7848
- /**
7849
- * @class AssetView
8114
+ element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
8115
+ element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
8116
+ element.linecolor = options.lineColor || "#555";
8117
+ element.value = value || [];
8118
+ element.xrange = options.xrange || [ 0, 1 ]; // min, max
8119
+ element.yrange = options.yrange || [ 0, 1 ]; // min, max
8120
+ element.defaulty = options.defaulty != null ? options.defaulty : 0.0;
8121
+ element.no_overlap = options.noOverlap || false;
8122
+ element.show_samples = options.showSamples || 0;
8123
+ element.allow_add_values = options.allowAddValues ?? true;
8124
+ element.draggable_x = options.draggableX ?? true;
8125
+ element.draggable_y = options.draggableY ?? true;
8126
+ element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
8127
+ element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
8128
+
8129
+ this.element = element;
8130
+
8131
+ let canvas = document.createElement( "canvas" );
8132
+ canvas.width = canvas.height = options.size || 200;
8133
+ element.appendChild( canvas );
8134
+ this.canvas = canvas;
8135
+
8136
+ element.addEventListener( "mousedown", onmousedown );
8137
+
8138
+ element.getValueAt = function( x ) {
8139
+
8140
+ if( x < element.xrange[ 0 ] || x > element.xrange[ 1 ] )
8141
+ {
8142
+ return element.defaulty;
8143
+ }
8144
+
8145
+ var last = [ element.xrange[ 0 ], element.defaulty ];
8146
+ var f = 0;
8147
+ for( var i = 0; i < element.value.length; i += 1 )
8148
+ {
8149
+ var v = element.value[ i ];
8150
+ if( x == v[ 0 ] ) return v[ 1 ];
8151
+ if( x < v[ 0 ] )
8152
+ {
8153
+ f = ( x - last[ 0 ] ) / (v[ 0 ] - last[ 0 ]);
8154
+ return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
8155
+ }
8156
+
8157
+ last = v;
8158
+ }
8159
+
8160
+ v = [ element.xrange[ 1 ], element.defaulty ];
8161
+ f = (x - last[ 0 ]) / (v[ 0 ] - last[ 0 ]);
8162
+ return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
8163
+ }
8164
+
8165
+ element.resample = function( samples ) {
8166
+
8167
+ var r = [];
8168
+ var dx = (element.xrange[1] - element.xrange[ 0 ]) / samples;
8169
+ for(var i = element.xrange[0]; i <= element.xrange[1]; i += dx)
8170
+ {
8171
+ r.push( element.getValueAt(i) );
8172
+ }
8173
+ return r;
8174
+ }
8175
+
8176
+ element.addValue = function(v) {
8177
+
8178
+ for(var i = 0; i < element.value; i++) {
8179
+ var value = element.value[i];
8180
+ if(value[0] < v[0]) continue;
8181
+ element.value.splice(i,0,v);
8182
+ redraw();
8183
+ return;
8184
+ }
8185
+
8186
+ element.value.push(v);
8187
+ redraw();
8188
+ }
8189
+
8190
+ //value to canvas
8191
+ function convert(v, r) {
8192
+
8193
+ Math.pow(v[0],2)
8194
+ return [ canvas.width * ( v[0] - element.xrange[0])/ (element.xrange[1]),
8195
+ canvas.height * (v[1] - element.yrange[0])/ (element.yrange[1])];
8196
+ }
8197
+
8198
+ //canvas to value
8199
+ function unconvert(v) {
8200
+ return [(v[0] * element.xrange[1] / canvas.width + element.xrange[0]),
8201
+ (v[1] * element.yrange[1] / canvas.height + element.yrange[0])];
8202
+ }
8203
+
8204
+ var selected = -1;
8205
+
8206
+ element.redraw = function( o = {} ) {
8207
+
8208
+ if( o.value ) element.value = o.value;
8209
+ if( o.xrange ) element.xrange = o.xrange;
8210
+ if( o.yrange ) element.yrange = o.yrange;
8211
+ if( o.smooth ) element.smooth = o.smooth;
8212
+ var rect = canvas.parentElement.getBoundingClientRect();
8213
+ if( canvas.parentElement.parentElement ) rect = canvas.parentElement.parentElement.getBoundingClientRect();
8214
+ if( rect && canvas.width != rect.width && rect.width && rect.width < 1000 )
8215
+ {
8216
+ canvas.width = rect.width;
8217
+ }
8218
+
8219
+ var ctx = canvas.getContext( "2d" );
8220
+ ctx.setTransform( 1, 0, 0, 1, 0, 0 );
8221
+ ctx.translate( 0, canvas.height );
8222
+ ctx.scale( 1, -1 );
8223
+
8224
+ ctx.fillStyle = element.bgcolor;
8225
+ ctx.fillRect(0,0,canvas.width,canvas.height);
8226
+
8227
+ ctx.strokeStyle = element.linecolor;
8228
+ ctx.beginPath();
8229
+
8230
+ //draw line
8231
+ var pos = convert([ element.xrange[ 0 ],element.defaulty ]);
8232
+ ctx.moveTo( pos[ 0 ], pos[ 1 ] );
8233
+ let values = [pos[ 0 ], pos[ 1 ]];
8234
+
8235
+ for(var i in element.value) {
8236
+ var value = element.value[i];
8237
+ pos = convert(value);
8238
+ values.push(pos[ 0 ]);
8239
+ values.push(pos[ 1 ]);
8240
+
8241
+ }
8242
+
8243
+ pos = convert([ element.xrange[ 1 ], element.defaulty ]);
8244
+ values.push(pos[ 0 ]);
8245
+ values.push(pos[ 1 ]);
8246
+
8247
+ // Draw points
8248
+ const center = [0,0];
8249
+ pos = convert(center)
8250
+ ctx.fillStyle = "gray";
8251
+ ctx.beginPath();
8252
+ ctx.arc( pos[ 0 ], pos[ 1 ], 3, 0, Math.PI * 2);
8253
+ ctx.fill();
8254
+
8255
+ for( var i = 0; i < element.value.length; i += 1 ) {
8256
+ var value = element.value[ i ];
8257
+ pos = convert( value );
8258
+ if( selected == i )
8259
+ ctx.fillStyle = "white";
8260
+ else
8261
+ ctx.fillStyle = element.pointscolor;
8262
+ ctx.beginPath();
8263
+ ctx.arc( pos[ 0 ], pos[ 1 ], selected == i ? 4 : 3, 0, Math.PI * 2);
8264
+ ctx.fill();
8265
+ }
8266
+
8267
+ if(element.show_samples) {
8268
+ var samples = element.resample(element.show_samples);
8269
+ ctx.fillStyle = "#888";
8270
+ for(var i = 0; i < samples.length; i += 1)
8271
+ {
8272
+ var value = [ i * ((element.xrange[ 1 ] - element.xrange[ 0 ]) / element.show_samples) + element.xrange[ 0 ], samples[ i ] ];
8273
+ pos = convert(value);
8274
+ ctx.beginPath();
8275
+ ctx.arc( pos[ 0 ], pos[ 1 ], 2, 0, Math.PI * 2);
8276
+ ctx.fill();
8277
+ }
8278
+ }
8279
+ }
8280
+
8281
+ var last_mouse = [ 0, 0 ];
8282
+
8283
+ function onmousedown( e ) {
8284
+ document.addEventListener( "mousemove", onmousemove );
8285
+ document.addEventListener( "mouseup", onmouseup );
8286
+
8287
+ var rect = canvas.getBoundingClientRect();
8288
+ var mousex = e.clientX - rect.left;
8289
+ var mousey = e.clientY - rect.top;
8290
+
8291
+ selected = computeSelected( mousex, canvas.height - mousey );
8292
+
8293
+ if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
8294
+ var v = unconvert([ mousex, canvas.height - mousey ]);
8295
+ element.value.push( v );
8296
+ sortValues();
8297
+ selected = element.value.indexOf( v );
8298
+ }
8299
+
8300
+ last_mouse = [ mousex, mousey ];
8301
+ element.redraw();
8302
+ e.preventDefault();
8303
+ e.stopPropagation();
8304
+ }
8305
+
8306
+ function onmousemove( e ) {
8307
+
8308
+ var rect = canvas.getBoundingClientRect();
8309
+ var mousex = e.clientX - rect.left;
8310
+ var mousey = e.clientY - rect.top;
8311
+
8312
+ if( mousex < 0 ) mousex = 0;
8313
+ else if( mousex > canvas.width ) mousex = canvas.width;
8314
+ if( mousey < 0 ) mousey = 0;
8315
+ else if( mousey > canvas.height ) mousey = canvas.height;
8316
+
8317
+ // Dragging to remove
8318
+ const currentMouseDiff = [ e.clientX - rect.left, e.clientY - rect.top ];
8319
+ if( selected != -1 && distance( currentMouseDiff, [ mousex, mousey ] ) > canvas.height * 0.5 )
8320
+ {
8321
+ if( element.move_out == LX.CURVE_MOVEOUT_DELETE)
8322
+ {
8323
+ element.value.splice( selected, 1 );
8324
+ }
8325
+ else
8326
+ {
8327
+ const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
8328
+ let value = element.value[ selected ];
8329
+ value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
8330
+ value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
8331
+ }
8332
+
8333
+ onmouseup( e );
8334
+ return;
8335
+ }
8336
+
8337
+ var dx = element.draggable_x ? last_mouse[ 0 ] - mousex : 0;
8338
+ var dy = element.draggable_y ? last_mouse[ 1 ] - mousey : 0;
8339
+ var delta = unconvert([ -dx, dy ]);
8340
+
8341
+ if( selected != -1 ) {
8342
+ var minx = element.xrange[ 0 ];
8343
+ var maxx = element.xrange[ 1 ];
8344
+
8345
+ if( element.no_overlap )
8346
+ {
8347
+ if( selected > 0) minx = element.value[ selected - 1 ][ 0 ];
8348
+ if( selected < ( element.value.length - 1 ) ) maxx = element.value[ selected + 1 ][ 0 ];
8349
+ }
8350
+
8351
+ var v = element.value[selected];
8352
+ v[ 0 ] += delta[ 0 ];
8353
+ v[ 1 ] += delta[ 1 ];
8354
+ if(v[ 0 ] < minx) v[ 0 ] = minx;
8355
+ else if(v[ 0 ] > maxx) v[ 0 ] = maxx;
8356
+ if(v[ 1 ] < element.yrange[ 0 ]) v[ 1 ] = element.yrange[ 0 ];
8357
+ else if(v[ 1 ] > element.yrange[ 1 ]) v[ 1 ] = element.yrange[ 1 ];
8358
+ }
8359
+
8360
+ sortValues();
8361
+ element.redraw();
8362
+ last_mouse[ 0 ] = mousex;
8363
+ last_mouse[ 1 ] = mousey;
8364
+ onchange( e );
8365
+
8366
+ e.preventDefault();
8367
+ e.stopPropagation();
8368
+ }
8369
+
8370
+ function onmouseup( e ) {
8371
+ selected = -1;
8372
+ element.redraw();
8373
+ document.removeEventListener("mousemove", onmousemove);
8374
+ document.removeEventListener("mouseup", onmouseup);
8375
+ onchange(e);
8376
+ e.preventDefault();
8377
+ e.stopPropagation();
8378
+ }
8379
+
8380
+ function onchange( e ) {
8381
+ if( options.callback )
8382
+ options.callback.call( element, element.value, e );
8383
+ }
8384
+
8385
+ function distance(a,b) { return Math.sqrt( Math.pow(b[0]-a[0],2) + Math.pow(b[1]-a[1],2) ); };
8386
+
8387
+ function computeSelected( x, y ) {
8388
+
8389
+ var minDistance = 100000;
8390
+ var maxDistance = 8; //pixels
8391
+ var selected = -1;
8392
+ for( var i = 0; i < element.value.length; i++ )
8393
+ {
8394
+ var value = element.value[ i ];
8395
+ var pos = convert( value );
8396
+ var dist = distance( [ x,y ], pos );
8397
+ if( dist < minDistance && dist < maxDistance )
8398
+ {
8399
+ minDistance = dist;
8400
+ selected = i;
8401
+ }
8402
+ }
8403
+ return selected;
8404
+ }
8405
+
8406
+ function sortValues() {
8407
+ var v = null;
8408
+ if( selected != -1 )
8409
+ {
8410
+ v = element.value[ selected ];
8411
+ }
8412
+ element.value.sort(function( a,b ) { return a[ 0 ] - b[ 0 ]; });
8413
+ if( v )
8414
+ {
8415
+ selected = element.value.indexOf( v );
8416
+ }
8417
+ }
8418
+
8419
+ element.redraw();
8420
+ return this;
8421
+ }
8422
+
8423
+ redraw( options = {} ) {
8424
+ this.element.redraw( options );
8425
+ }
8426
+ }
8427
+
8428
+ LX.Dial = Dial;
8429
+
8430
+ class AssetViewEvent {
8431
+
8432
+ static NONE = 0;
8433
+ static ASSET_SELECTED = 1;
8434
+ static ASSET_DELETED = 2;
8435
+ static ASSET_RENAMED = 3;
8436
+ static ASSET_CLONED = 4;
8437
+ static ASSET_DBLCLICKED = 5;
8438
+ static ENTER_FOLDER = 6;
8439
+ static ASSET_CHECKED = 7;
8440
+
8441
+ constructor( type, item, value ) {
8442
+ this.type = type || TreeEvent.NONE;
8443
+ this.item = item;
8444
+ this.value = value;
8445
+ this.multiple = false; // Multiple selection
8446
+ }
8447
+
8448
+ string() {
8449
+ switch(this.type) {
8450
+ case AssetViewEvent.NONE: return "assetview_event_none";
8451
+ case AssetViewEvent.ASSET_SELECTED: return "assetview_event_selected";
8452
+ case AssetViewEvent.ASSET_DELETED: return "assetview_event_deleted";
8453
+ case AssetViewEvent.ASSET_RENAMED: return "assetview_event_renamed";
8454
+ case AssetViewEvent.ASSET_CLONED: return "assetview_event_cloned";
8455
+ case AssetViewEvent.ASSET_DBLCLICKED: return "assetview_event_dblclicked";
8456
+ case AssetViewEvent.ENTER_FOLDER: return "assetview_event_enter_folder";
8457
+ case AssetViewEvent.ASSET_CHECKED: return "assetview_event_checked";
8458
+ }
8459
+ }
8460
+ };
8461
+
8462
+ LX.AssetViewEvent = AssetViewEvent;
8463
+
8464
+ /**
8465
+ * @class AssetView
7850
8466
  * @description Asset container with Tree for file system
7851
8467
  */
7852
8468
 
@@ -7886,6 +8502,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7886
8502
  this.skipPreview = options.skipPreview ?? false;
7887
8503
  this.useNativeTitle = options.useNativeTitle ?? false;
7888
8504
  this.onlyFolders = options.onlyFolders ?? true;
8505
+ this.allowMultipleSelection = options.allowMultipleSelection ?? false;
7889
8506
  this.previewActions = options.previewActions ?? [];
7890
8507
  this.contextMenu = options.contextMenu ?? [];
7891
8508
  this.onRefreshContent = options.onRefreshContent;
@@ -8284,15 +8901,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8284
8901
  itemEl.title = type + ": " + item.id;
8285
8902
  }
8286
8903
 
8287
- if( item.selected != undefined )
8904
+ if( that.allowMultipleSelection )
8288
8905
  {
8289
- let span = document.createElement('span');
8290
- span.className = "lexcheckbox";
8291
- let checkbox_input = document.createElement('input');
8292
- checkbox_input.type = "checkbox";
8293
- checkbox_input.className = "checkbox";
8294
- checkbox_input.checked = item.selected;
8295
- checkbox_input.addEventListener('change', ( e, v ) => {
8906
+ let checkbox = document.createElement( 'input' );
8907
+ checkbox.type = "checkbox";
8908
+ checkbox.className = "lexcheckbox";
8909
+ checkbox.checked = item.selected;
8910
+ checkbox.addEventListener('change', ( e, v ) => {
8296
8911
  item.selected = !item.selected;
8297
8912
  if( that.onevent )
8298
8913
  {
@@ -8302,10 +8917,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8302
8917
  }
8303
8918
  e.stopPropagation();
8304
8919
  e.stopImmediatePropagation();
8305
- })
8306
- span.appendChild(checkbox_input);
8307
- itemEl.appendChild(span);
8920
+ });
8308
8921
 
8922
+ itemEl.appendChild( checkbox );
8309
8923
  }
8310
8924
 
8311
8925
  let title = document.createElement('span');
@@ -8371,6 +8985,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8371
8985
  }
8372
8986
 
8373
8987
  this.classList.add('selected');
8988
+ that.selectedItem = item;
8374
8989
 
8375
8990
  if( !that.skipPreview )
8376
8991
  {