lexgui 0.1.41 → 0.1.43

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.41",
15
+ version: "0.1.43",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -29,16 +29,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
29
29
  LX.CURVE_MOVEOUT_DELETE = 1;
30
30
 
31
31
  function clamp( num, min, max ) { return Math.min( Math.max( num, min ), max ); }
32
- function round( number, precision ) { return +(( number ).toFixed( precision ?? 2 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' )); }
32
+ function round( number, precision ) { return precision == 0 ? Math.floor( number ) : +(( number ).toFixed( precision ?? 2 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' )); }
33
33
  function remapRange( oldValue, oldMin, oldMax, newMin, newMax ) { return ((( oldValue - oldMin ) * ( newMax - newMin )) / ( oldMax - oldMin )) + newMin; }
34
34
 
35
35
  LX.clamp = clamp;
36
36
  LX.round = round;
37
37
  LX.remapRange = remapRange;
38
-
38
+
39
39
  function getSupportedDOMName( string )
40
40
  {
41
- return string.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_').replaceAll('.', '');
41
+ return string.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_').replaceAll('.', '');
42
42
  }
43
43
 
44
44
  LX.getSupportedDOMName = getSupportedDOMName;
@@ -51,15 +51,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
51
51
  LX.has = has;
52
52
 
53
53
  function getExtension( s )
54
- {
54
+ {
55
55
  return s.includes('.') ? s.split('.').pop() : null;
56
56
  }
57
57
 
58
58
  LX.getExtension = getExtension;
59
59
 
60
60
  function deepCopy( o )
61
- {
62
- return JSON.parse(JSON.stringify(o))
61
+ {
62
+ return JSON.parse(JSON.stringify(o))
63
63
  }
64
64
 
65
65
  LX.deepCopy = deepCopy;
@@ -97,9 +97,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
97
97
  const blue = parseInt( hexStr.substring( 5, 7 ), 16 ) / 255;
98
98
  return [ red, green, blue ];
99
99
  }
100
-
100
+
101
101
  LX.hexToRgb = hexToRgb;
102
-
102
+
103
103
  function rgbToHex( rgb ) {
104
104
  let hex = "#";
105
105
  for( let c of rgb ) {
@@ -108,7 +108,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
108
108
  }
109
109
  return hex;
110
110
  }
111
-
111
+
112
112
  LX.rgbToHex = rgbToHex;
113
113
 
114
114
  function measureRealWidth( value, paddingPlusMargin = 8 ) {
@@ -169,10 +169,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
169
169
  this.x = x ?? 0;
170
170
  this.y = y ?? ( x ?? 0 );
171
171
  }
172
-
172
+
173
173
  get xy() { return [ this.x, this.y ]; }
174
174
  get yx() { return [ this.y, this.x ]; }
175
-
175
+
176
176
  set ( x, y ) { this.x = x; this.y = y; }
177
177
  add ( v, v0 = new vec2() ) { v0.set( this.x + v.x, this.y + v.y ); return v0; }
178
178
  sub ( v, v0 = new vec2() ) { v0.set( this.x - v.x, this.y - v.y ); return v0; }
@@ -279,7 +279,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
279
279
  onDragStart( currentTarget, e );
280
280
  }
281
281
  }, false );
282
-
282
+
283
283
  document.addEventListener( 'mouseup', () => {
284
284
  if( currentTarget )
285
285
  {
@@ -288,82 +288,95 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
288
288
  }
289
289
  } );
290
290
  }
291
-
291
+
292
292
  LX.makeDraggable = makeDraggable;
293
293
 
294
294
  function create_global_searchbar( root ) {
295
295
 
296
- let global_search = document.createElement("div");
297
- global_search.id = "global_search";
298
- global_search.className = "hidden";
299
- global_search.tabIndex = -1;
300
- root.appendChild( global_search );
296
+ let globalSearch = document.createElement("div");
297
+ globalSearch.id = "global-search";
298
+ globalSearch.className = "hidden";
299
+ globalSearch.tabIndex = -1;
300
+ root.appendChild( globalSearch );
301
301
 
302
302
  let allItems = [];
303
303
  let hoverElId = null;
304
304
 
305
- global_search.addEventListener('keydown', function(e) {
305
+ globalSearch.addEventListener('keydown', function( e ) {
306
306
  e.stopPropagation();
307
307
  e.stopImmediatePropagation();
308
308
  hoverElId = hoverElId ?? -1;
309
- if( e.key == 'Escape' ) {
309
+ if( e.key == 'Escape' )
310
+ {
310
311
  this.classList.add("hidden");
311
- reset_bar(true);
312
+ _resetBar( true );
312
313
  }
313
- else if( e.key == 'Enter' ) {
314
+ else if( e.key == 'Enter' )
315
+ {
314
316
  const el = allItems[ hoverElId ];
315
- if(el) {
316
- const is_checkbox = (el.item.type && el.item.type === 'checkbox');
317
+ if( el )
318
+ {
319
+ const isCheckbox = (el.item.type && el.item.type === 'checkbox');
317
320
  this.classList.toggle('hidden');
318
- if(is_checkbox) {
321
+ if( isCheckbox )
322
+ {
319
323
  el.item.checked = !el.item.checked;
320
- el.callback.call(window, el.item.checked, el.entry_name);
324
+ el.callback.call( window, el.item.checked, el.entry_name );
321
325
  }
322
326
  else
323
- el.callback.call(window, el.entry_name);
327
+ {
328
+ el.callback.call( window, el.entry_name );
329
+ }
324
330
  }
325
331
  }
326
- else if ( e.key == 'ArrowDown' && hoverElId < (allItems.length - 1) ) {
332
+ else if ( e.key == 'ArrowDown' && hoverElId < (allItems.length - 1) )
333
+ {
327
334
  hoverElId++;
328
- global_search.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
335
+ globalSearch.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
329
336
  allItems[ hoverElId ].classList.add('hovered');
330
337
 
331
338
  let dt = allItems[ hoverElId ].offsetHeight * (hoverElId + 1) - itemContainer.offsetHeight;
332
- if( dt > 0) {
339
+ if( dt > 0 )
340
+ {
333
341
  itemContainer.scrollTo({
334
342
  top: dt,
335
343
  behavior: "smooth",
336
344
  });
337
345
  }
338
346
 
339
- } else if ( e.key == 'ArrowUp' && hoverElId > 0 ) {
347
+ } else if ( e.key == 'ArrowUp' && hoverElId > 0 )
348
+ {
340
349
  hoverElId--;
341
- global_search.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
350
+ globalSearch.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
342
351
  allItems[ hoverElId ].classList.add('hovered');
343
352
  }
344
353
  });
345
354
 
346
- global_search.addEventListener('focusout', function(e) {
347
- if(e.relatedTarget == e.currentTarget) return;
355
+ globalSearch.addEventListener('focusout', function( e ) {
356
+ if( e.relatedTarget == e.currentTarget )
357
+ {
358
+ return;
359
+ }
348
360
  e.stopPropagation();
349
361
  e.stopImmediatePropagation();
350
- this.classList.add("hidden");
351
- reset_bar(true);
362
+ this.classList.add( "hidden" );
363
+ _resetBar( true );
352
364
  });
353
365
 
354
366
  root.addEventListener('keydown', e => {
355
- if( e.key == ' ' && e.ctrlKey ) {
367
+ if( e.key == ' ' && e.ctrlKey )
368
+ {
356
369
  e.stopImmediatePropagation();
357
370
  e.stopPropagation();
358
- global_search.classList.toggle('hidden');
359
- global_search.querySelector('input').focus();
360
- add_elements( undefined );
371
+ globalSearch.classList.toggle('hidden');
372
+ globalSearch.querySelector('input').focus();
373
+ _addElements( undefined );
361
374
  }
362
375
  else
363
376
  {
364
377
  for( let c of LX.components )
365
378
  {
366
- if( !LX[c] || !LX[c].prototype.onKeyPressed )
379
+ if( !LX[ c ] || !LX[ c ].prototype.onKeyPressed )
367
380
  {
368
381
  continue;
369
382
  }
@@ -377,36 +390,68 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
377
390
  }
378
391
  });
379
392
 
380
- let icon = document.createElement("a");
393
+ const header = document.createElement( "div" );
394
+ header.className = "gs-header";
395
+
396
+ const icon = document.createElement("a");
381
397
  icon.className = "fa-solid fa-magnifying-glass";
398
+ header.appendChild( icon );
382
399
 
383
- let input = document.createElement("input");
400
+ const input = document.createElement("input");
384
401
  input.placeholder = "Search...";
385
402
  input.value = "";
403
+ header.appendChild( input );
404
+
405
+ const tabArea = new Area( {
406
+ width: "100%",
407
+ skipAppend: true,
408
+ className: "gs-tabs"
409
+ } );
410
+
411
+ const gsTabs = tabArea.addTabs();
412
+ let gsFilter = null;
413
+
414
+ // These tabs will serve as buttons by now
415
+ // Filter stuff depending of the type of search
416
+ {
417
+ const _onSelectTab = ( e, tabName ) => {
418
+ gsFilter = tabName;
419
+ }
420
+
421
+ gsTabs.add( "All", document.createElement('div'), { selected: true, onSelect: _onSelectTab } );
422
+ // gsTabs.add( "Main", document.createElement('div'), { onSelect: _onSelectTab } );
423
+ }
386
424
 
387
- let itemContainer = document.createElement("div");
425
+ const itemContainer = document.createElement("div");
388
426
  itemContainer.className = "searchitembox";
389
427
 
390
- let ref_previous;
428
+ let refPrevious = null;
391
429
 
392
- const reset_bar = (reset_input) => {
430
+ const _resetBar = (reset_input) => {
393
431
  itemContainer.innerHTML = "";
394
432
  allItems.length = 0;
395
433
  hoverElId = null;
396
434
  if(reset_input) input.value = "";
397
435
  }
398
436
 
399
- const add_element = (t, c, p, i) => {
400
- if(!t.length) return;
437
+ const _addElement = ( t, c, p, i ) => {
401
438
 
402
- if(ref_previous) ref_previous.classList.remove('last');
439
+ if( !t.length )
440
+ {
441
+ return;
442
+ }
443
+
444
+ if( refPrevious ) refPrevious.classList.remove('last');
403
445
 
404
446
  let searchItem = document.createElement("div");
405
447
  searchItem.className = "searchitem last";
406
- const is_checkbox = (i && i.type && i.type === 'checkbox');
407
- if(is_checkbox) {
448
+ const isCheckbox = (i && i.type && i.type === 'checkbox');
449
+ if( isCheckbox )
450
+ {
408
451
  searchItem.innerHTML = "<a class='fa fa-check'></a><span>" + p + t + "</span>"
409
- } else {
452
+ }
453
+ else
454
+ {
410
455
  searchItem.innerHTML = p + t;
411
456
  }
412
457
  searchItem.entry_name = t;
@@ -414,29 +459,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
414
459
  searchItem.item = i;
415
460
  searchItem.addEventListener('click', function(e) {
416
461
  this.callback.call(window, this.entry_name);
417
- global_search.classList.toggle('hidden');
418
- reset_bar(true);
462
+ globalSearch.classList.toggle('hidden');
463
+ _resetBar( true );
419
464
  });
420
465
  searchItem.addEventListener('mouseenter', function(e) {
421
- global_search.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
466
+ globalSearch.querySelectorAll(".hovered").forEach(e => e.classList.remove('hovered'));
422
467
  this.classList.add('hovered');
423
- hoverElId = allItems.indexOf(this);
468
+ hoverElId = allItems.indexOf( this );
424
469
  });
425
470
  searchItem.addEventListener('mouseleave', function(e) {
426
471
  this.classList.remove('hovered');
427
472
  });
428
473
  allItems.push( searchItem );
429
- itemContainer.appendChild(searchItem);
430
- ref_previous = searchItem;
474
+ itemContainer.appendChild( searchItem );
475
+ refPrevious = searchItem;
431
476
  }
432
477
 
433
- const propagate_add = ( item, filter, path ) => {
478
+ const _propagateAdd = ( item, filter, path ) => {
434
479
 
435
480
  const key = Object.keys( item )[ 0 ];
436
481
  let name = item.name ?? path + key;
437
- if( name.toLowerCase().includes( filter ) ) {
482
+ if( name.toLowerCase().includes( filter ) )
483
+ {
438
484
  if( item.callback )
439
- add_element( item.name ?? key, item.callback, path, item );
485
+ {
486
+ _addElement( item.name ?? key, item.callback, path, item );
487
+ }
440
488
  }
441
489
 
442
490
  // is sidebar..
@@ -446,33 +494,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
446
494
  path += key + " > ";
447
495
 
448
496
  for( let c of item[ key ] )
449
- propagate_add( c, filter, path );
497
+ _propagateAdd( c, filter, path );
450
498
  };
451
499
 
452
- const add_elements = filter => {
453
-
454
- reset_bar();
500
+ const _addElements = filter => {
501
+
502
+ _resetBar();
455
503
 
456
504
  for( let m of LX.menubars )
457
- for( let i of m.items ) {
458
- propagate_add( i, filter, "" );
505
+ {
506
+ for( let i of m.items )
507
+ {
508
+ _propagateAdd( i, filter, "" );
459
509
  }
510
+ }
460
511
 
461
512
  if( LX.has('CodeEditor') )
462
513
  {
463
514
  const instances = LX.CodeEditor.getInstances();
464
515
  if(!instances.length) return;
465
-
516
+
466
517
  const languages = instances[ 0 ].languages;
467
-
518
+
468
519
  for( let l of Object.keys( languages ) ) {
469
-
520
+
470
521
  const key = "Language: " + l;
471
522
  const icon = instances[ 0 ]._getFileIcon( null, languages[ l ].ext );
472
-
523
+
473
524
  let value = icon.includes( 'fa-' ) ? "<i class='" + icon + "'></i>" :
474
525
  "<img src='" + ( "https://raw.githubusercontent.com/jxarco/lexgui.js/master/" + icon ) + "'>";
475
-
526
+
476
527
  value += key + " <span class='lang-ext'>(" + languages[ l ].ext + ")</span>";
477
528
  if( key.toLowerCase().includes( filter ) ) {
478
529
  add_element( value, () => {
@@ -486,22 +537,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
486
537
  }
487
538
 
488
539
  input.addEventListener('input', function(e) {
489
- add_elements( this.value.toLowerCase() );
540
+ _addElements( this.value.toLowerCase() );
490
541
  });
491
-
492
- global_search.appendChild(icon);
493
- global_search.appendChild(input);
494
- global_search.appendChild(itemContainer);
495
542
 
496
- return global_search;
543
+ globalSearch.appendChild( header );
544
+ globalSearch.appendChild( tabArea.root );
545
+ globalSearch.appendChild( itemContainer );
546
+
547
+ return globalSearch;
497
548
  }
498
549
 
499
550
  /**
500
551
  * @method init
501
- * @param {Object} options
552
+ * @param {Object} options
502
553
  * container: Root location for the gui (default is the document body)
503
554
  * id: Id of the main area
504
- * skip_default_area: Skip creation of main area
555
+ * skipRoot: Skip adding LX root container
556
+ * skipDefaultArea: Skip creation of main area
505
557
  */
506
558
 
507
559
  function init( options = { } )
@@ -514,7 +566,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
514
566
  var root = document.createElement( 'div' );
515
567
  root.id = "lexroot";
516
568
  root.tabIndex = -1;
517
-
569
+
518
570
  var modal = document.createElement( 'div' );
519
571
  modal.id = "modal";
520
572
 
@@ -526,15 +578,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
526
578
  // this.modal.toggle = function( force ) { this.toggleAttribute( 'hidden', force ); };
527
579
 
528
580
  this.modal.classList.add( 'hiddenOpacity' );
529
- this.modal.toggle = function( force ) { this.classList.toggle( 'hiddenOpacity', force ); };
581
+ this.modal.toggle = function( force ) { this.classList.toggle( 'hiddenOpacity', force ); };
530
582
 
531
583
  if( options.container )
532
584
  this.container = document.getElementById( options.container );
533
-
585
+
534
586
  this.global_search = create_global_searchbar( this.container );
535
587
 
536
588
  this.container.appendChild( modal );
537
- this.container.appendChild( root );
589
+
590
+ if( !options.skipRoot )
591
+ {
592
+ this.container.appendChild( root );
593
+ }
538
594
 
539
595
  // Disable drag icon
540
596
  root.addEventListener( 'dragover', function( e ) {
@@ -546,7 +602,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
546
602
  var link = document.createElement( 'link' );
547
603
  link.rel = 'stylesheet';
548
604
  link.type = 'text/css';
549
- link.href = 'https://use.fontawesome.com/releases/v6.6.0/css/all.css';
605
+ link.href = 'https://use.fontawesome.com/releases/v6.7.2/css/all.css';
550
606
  head.appendChild( link );
551
607
 
552
608
  // Global vars
@@ -557,8 +613,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
557
613
  this.ready = true;
558
614
  this.menubars = [ ];
559
615
 
560
- if( !options.skip_default_area )
616
+ if( !options.skipRoot && !options.skipDefaultArea )
617
+ {
561
618
  this.main_area = new Area( { id: options.id ?? 'mainarea' } );
619
+ }
562
620
 
563
621
  return this.main_area;
564
622
  }
@@ -567,33 +625,35 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
567
625
 
568
626
  /**
569
627
  * @method message
570
- * @param {String} text
628
+ * @param {String} text
571
629
  * @param {String} title (Optional)
572
- * @param {*} options
630
+ * @param {*} options
573
631
  * id: Id of the message dialog
574
632
  * position: Dialog position in screen [screen centered]
575
633
  * draggable: Dialog can be dragged [false]
576
634
  */
577
635
 
578
- function message(text, title, options = {})
636
+ function message( text, title, options = {} )
579
637
  {
580
- if(!text)
581
- throw("No message to show");
638
+ if( !text )
639
+ {
640
+ throw( "No message to show" );
641
+ }
582
642
 
583
643
  options.modal = true;
584
644
 
585
- return new Dialog(title, p => {
586
- p.addTextArea(null, text, null, { disabled: true, fitHeight: true });
587
- }, options);
645
+ return new Dialog( title, p => {
646
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
647
+ }, options );
588
648
  }
589
649
 
590
650
  LX.message = message;
591
651
 
592
652
  /**
593
653
  * @method popup
594
- * @param {String} text
654
+ * @param {String} text
595
655
  * @param {String} title (Optional)
596
- * @param {*} options
656
+ * @param {*} options
597
657
  * id: Id of the message dialog
598
658
  * time: (Number) Delay time before close automatically (ms). Defalut: [3000]
599
659
  * position: (Array) [x,y] Dialog position in screen. Default: [screen centered]
@@ -610,19 +670,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
610
670
  options.size = options.size ?? [ "auto", "auto" ];
611
671
  options.class = "lexpopup";
612
672
 
613
- const time = options.timeout || 3000;
673
+ const time = options.timeout || 3000;
614
674
  const dialog = new Dialog( title, p => {
615
675
  p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
616
676
  }, options );
617
-
677
+
618
678
  dialog.root.classList.add( 'fadein' );
619
679
  setTimeout(() => {
620
680
  dialog.root.classList.remove( 'fadein' );
621
681
  dialog.root.classList.add( 'fadeout' );
622
682
  }, time - 1000 );
623
-
683
+
624
684
  setTimeout( dialog.close, time );
625
-
685
+
626
686
  return dialog;
627
687
  }
628
688
 
@@ -630,9 +690,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
630
690
 
631
691
  /**
632
692
  * @method prompt
633
- * @param {String} text
693
+ * @param {String} text
634
694
  * @param {String} title (Optional)
635
- * @param {*} options
695
+ * @param {*} options
636
696
  * id: Id of the prompt dialog
637
697
  * position: Dialog position in screen [screen centered]
638
698
  * draggable: Dialog can be dragged [false]
@@ -664,7 +724,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
664
724
  text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
665
725
  dialog.close();
666
726
  prompt( text, title, callback, options );
667
- }else
727
+ }
728
+ else
668
729
  {
669
730
  if( callback ) callback.call( this, value );
670
731
  dialog.close();
@@ -680,7 +741,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
680
741
  {
681
742
  dialog.root.querySelector( 'input' ).focus();
682
743
  }
683
-
744
+
684
745
  return dialog;
685
746
  }
686
747
 
@@ -719,7 +780,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
719
780
  this.value = value;
720
781
  this.multiple = false; // Multiple selection
721
782
  }
722
-
783
+
723
784
  string() {
724
785
  switch( this.type )
725
786
  {
@@ -743,7 +804,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
743
804
  const data = LX.signals[ signalName ];
744
805
 
745
806
  if( !data )
746
- return;
807
+ {
808
+ return;
809
+ }
747
810
 
748
811
  const target = options.target;
749
812
 
@@ -762,7 +825,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
762
825
  if( obj.constructor === Widget )
763
826
  {
764
827
  obj.set( value, options.skipCallback ?? true );
765
-
828
+
766
829
  if( obj.options && obj.options.callback )
767
830
  {
768
831
  obj.options.callback( value, data );
@@ -779,13 +842,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
779
842
 
780
843
  function addSignal( name, obj, callback )
781
844
  {
782
- obj[name] = callback;
845
+ obj[ name ] = callback;
783
846
 
784
847
  if( !LX.signals[ name ] )
848
+ {
785
849
  LX.signals[ name ] = [];
786
-
850
+ }
851
+
787
852
  if( LX.signals[ name ].indexOf( obj ) > -1 )
853
+ {
788
854
  return;
855
+ }
789
856
 
790
857
  LX.signals[ name ].push( obj );
791
858
  }
@@ -800,12 +867,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
800
867
 
801
868
  /**
802
869
  * @constructor Area
803
- * @param {*} options
870
+ * @param {*} options
804
871
  * id: Id of the element
805
872
  * className: Add class to the element
806
873
  * width: Width of the area element [fit space]
807
874
  * height: Height of the area element [fit space]
808
- * no_append: Create but not append to GUI root [false]
875
+ * skipAppend: Create but not append to GUI root [false]
876
+ * minWidth: Minimum width to be applied when resizing
877
+ * minHeight: Minimum height to be applied when resizing
878
+ * maxWidth: Maximum width to be applied when resizing
879
+ * maxHeight: Maximum height to be applied when resizing
809
880
  */
810
881
 
811
882
  constructor( options = {} ) {
@@ -820,13 +891,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
820
891
  {
821
892
  root.className += " " + options.className;
822
893
  }
823
-
894
+
824
895
  var width = options.width || "calc( 100% )";
825
896
  var height = options.height || "100%";
826
-
897
+
827
898
  // This has default options..
828
899
  this.setLimitBox( options.minWidth, options.minHeight, options.maxWidth, options.maxHeight );
829
-
900
+
830
901
  if( width.constructor == Number )
831
902
  {
832
903
  width += "px";
@@ -835,17 +906,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
835
906
  {
836
907
  height += "px";
837
908
  }
838
-
909
+
839
910
  root.style.width = width;
840
911
  root.style.height = height;
841
-
912
+
842
913
  this.offset = 0;
843
914
  this.root = root;
844
915
  this.size = [ this.root.offsetWidth, this.root.offsetHeight ];
845
916
  this.sections = [];
846
917
  this.panels = [];
847
-
848
- if( !options.no_append )
918
+
919
+ if( !options.skipAppend )
849
920
  {
850
921
  var lexroot = document.getElementById("lexroot");
851
922
  lexroot.appendChild( this.root );
@@ -880,94 +951,97 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
880
951
  makeDraggable( root, options );
881
952
  }
882
953
 
883
- if( options.resizeable ) {
954
+ if( options.resizeable )
955
+ {
884
956
  root.classList.add("resizeable");
885
957
  }
886
958
 
887
959
  if( options.resize )
888
- {
889
- this.split_bar = document.createElement("div");
960
+ {
961
+ this.splitBar = document.createElement("div");
890
962
  let type = (overlay == "left") || (overlay == "right") ? "horizontal" : "vertical";
891
- this.type = overlay;;
892
- this.split_bar.className = "lexsplitbar " + type;
963
+ this.type = overlay;
964
+ this.splitBar.className = "lexsplitbar " + type;
893
965
 
894
966
  if( overlay == "right" )
895
967
  {
896
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
897
- this.split_bar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
898
- }
968
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
969
+ this.splitBar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
970
+ }
899
971
  else if( overlay == "left" )
900
972
  {
901
973
  let size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientWidth);
902
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
903
- this.split_bar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
974
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
975
+ this.splitBar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
904
976
  }
905
977
  else if( overlay == "top" )
906
978
  {
907
979
  let size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientHeight);
908
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
909
- this.split_bar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
980
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
981
+ this.splitBar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
910
982
  }
911
983
  else if( overlay == "bottom" )
912
984
  {
913
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
914
- this.split_bar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
985
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
986
+ this.splitBar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
915
987
  }
916
988
 
917
- this.split_bar.addEventListener("mousedown", inner_mousedown);
918
- this.root.appendChild( this.split_bar );
919
-
989
+ this.splitBar.addEventListener("mousedown", inner_mousedown);
990
+ this.root.appendChild( this.splitBar );
991
+
920
992
  var that = this;
921
- var last_pos = [ 0, 0 ];
922
-
993
+ var lastMousePosition = [ 0, 0 ];
994
+
923
995
  function inner_mousedown( e )
924
996
  {
925
997
  var doc = that.root.ownerDocument;
926
998
  doc.addEventListener( 'mousemove', inner_mousemove );
927
999
  doc.addEventListener( 'mouseup', inner_mouseup );
928
- last_pos[ 0 ] = e.x;
929
- last_pos[ 1 ] = e.y;
1000
+ lastMousePosition[ 0 ] = e.x;
1001
+ lastMousePosition[ 1 ] = e.y;
930
1002
  e.stopPropagation();
931
1003
  e.preventDefault();
932
1004
  document.body.classList.add( 'nocursor' );
933
- that.split_bar.classList.add( 'nocursor' );
1005
+ that.splitBar.classList.add( 'nocursor' );
934
1006
  }
935
1007
 
936
1008
  function inner_mousemove( e )
937
1009
  {
938
1010
  switch( that.type ) {
939
1011
  case "right":
940
- var dt = ( last_pos[ 0 ] - e.x );
1012
+ var dt = ( lastMousePosition[ 0 ] - e.x );
941
1013
  var size = ( that.root.offsetWidth + dt );
942
1014
  that.root.style.width = size + "px";
943
1015
  break;
944
1016
  case "left":
945
- var dt = ( last_pos[ 0 ] - e.x );
1017
+ var dt = ( lastMousePosition[ 0 ] - e.x );
946
1018
  var size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetWidth - dt));
947
1019
  that.root.style.width = size + "px";
948
- that.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
1020
+ that.splitBar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
949
1021
  break;
950
1022
  case "top":
951
- var dt = ( last_pos[ 1 ] - e.y );
1023
+ var dt = ( lastMousePosition[ 1 ] - e.y );
952
1024
  var size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetHeight - dt));
953
1025
  that.root.style.height = size + "px";
954
- that.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
1026
+ that.splitBar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
955
1027
  break;
956
1028
  case "bottom":
957
- var dt = ( last_pos[ 1 ] - e.y );
1029
+ var dt = ( lastMousePosition[ 1 ] - e.y );
958
1030
  var size = ( that.root.offsetHeight + dt );
959
1031
  that.root.style.height = size + "px";
960
1032
  break;
961
1033
  }
962
-
963
- last_pos[ 0 ] = e.x;
964
- last_pos[ 1 ] = e.y;
1034
+
1035
+ lastMousePosition[ 0 ] = e.x;
1036
+ lastMousePosition[ 1 ] = e.y;
965
1037
  e.stopPropagation();
966
1038
  e.preventDefault();
967
-
968
- // Resize events
1039
+
1040
+ // Resize events
969
1041
  if( that.onresize )
1042
+ {
970
1043
  that.onresize( that.root.getBoundingClientRect() );
1044
+ }
971
1045
  }
972
1046
 
973
1047
  function inner_mouseup( e )
@@ -976,7 +1050,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
976
1050
  doc.removeEventListener( 'mousemove', inner_mousemove );
977
1051
  doc.removeEventListener( 'mouseup', inner_mouseup );
978
1052
  document.body.classList.remove( 'nocursor' );
979
- that.split_bar.classList.remove( 'nocursor' );
1053
+ that.splitBar.classList.remove( 'nocursor' );
980
1054
  }
981
1055
  }
982
1056
  }
@@ -990,13 +1064,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
990
1064
  attach( content ) {
991
1065
 
992
1066
  // Append to last split section if area has been split
993
- if(this.sections.length) {
994
- this.sections[1].attach( content );
1067
+ if( this.sections.length )
1068
+ {
1069
+ this.sections[ 1 ].attach( content );
995
1070
  return;
996
1071
  }
997
1072
 
998
- if(!content)
999
- throw("no content to attach");
1073
+ if( !content )
1074
+ {
1075
+ throw("no content to attach");
1076
+ }
1000
1077
 
1001
1078
  content.parent = this;
1002
1079
 
@@ -1006,11 +1083,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1006
1083
 
1007
1084
  /**
1008
1085
  * @method split
1009
- * @param {*} options
1086
+ * @param {*} options
1010
1087
  * type: Split mode (horizontal, vertical) ["horizontal"]
1011
1088
  * sizes: Size of each new area (Array) ["50%", "50%"]
1012
1089
  */
1013
-
1090
+
1014
1091
  split( options = {} ) {
1015
1092
 
1016
1093
  if( this.sections.length )
@@ -1023,7 +1100,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1023
1100
 
1024
1101
  var type = options.type || "horizontal";
1025
1102
  var sizes = options.sizes || [ "50%", "50%" ];
1026
- var infer_height = false;
1027
1103
  var auto = (options.sizes === 'auto');
1028
1104
 
1029
1105
  if( !sizes[ 1 ] )
@@ -1037,18 +1113,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1037
1113
  }
1038
1114
 
1039
1115
  sizes[ 1 ] = "calc( 100% - " + size + " )";
1040
- infer_height = true;
1041
1116
  }
1042
1117
 
1043
1118
  // Create areas
1044
- var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
1045
- var area2 = new Area( { no_append: true, className: "split"} );
1119
+ var area1 = new Area( { skipAppend: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
1120
+ var area2 = new Area( { skipAppend: true, className: "split" } );
1046
1121
 
1047
1122
  area1.parentArea = this;
1048
1123
  area2.parentArea = this;
1049
1124
 
1050
1125
  let minimizable = options.minimizable ?? false;
1051
- let resize = (options.resize ?? true) || minimizable;
1126
+ let resize = ( options.resize ?? true ) || minimizable;
1052
1127
 
1053
1128
  var data = "0px";
1054
1129
  this.offset = 0;
@@ -1056,40 +1131,40 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1056
1131
  if( resize )
1057
1132
  {
1058
1133
  this.resize = resize;
1059
- this.split_bar = document.createElement( "div" );
1060
- this.split_bar.className = "lexsplitbar " + type;
1134
+ this.splitBar = document.createElement( "div" );
1135
+ this.splitBar.className = "lexsplitbar " + type;
1061
1136
 
1062
1137
  if( type == "horizontal" )
1063
1138
  {
1064
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
1139
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
1065
1140
  }
1066
1141
  else
1067
1142
  {
1068
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
1143
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
1069
1144
  }
1070
1145
 
1071
- this.split_bar.addEventListener( 'mousedown', inner_mousedown );
1146
+ this.splitBar.addEventListener( 'mousedown', innerMouseDown );
1072
1147
 
1073
1148
  data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
1074
1149
 
1075
1150
  // Being minimizable means it's also resizeable!
1076
1151
  if( minimizable )
1077
1152
  {
1078
- this.split_extended = false;
1153
+ this.splitExtended = false;
1079
1154
 
1080
1155
  // Keep state of the animation when ends...
1081
1156
  area2.root.addEventListener('animationend', e => {
1082
- const opacity = getComputedStyle(area2.root).opacity;
1157
+ const opacity = getComputedStyle( area2.root ).opacity;
1083
1158
  area2.root.classList.remove( e.animationName + "-" + type );
1084
1159
  area2.root.style.opacity = opacity;
1085
1160
  flushCss(area2.root);
1086
1161
  });
1087
-
1088
- this.split_bar.addEventListener("contextmenu", e => {
1162
+
1163
+ this.splitBar.addEventListener("contextmenu", e => {
1089
1164
  e.preventDefault();
1090
1165
  addContextMenu(null, e, c => {
1091
- c.add("Extend", { disabled: this.split_extended, callback: () => { this.extend() } });
1092
- c.add("Reduce", { disabled: !this.split_extended, callback: () => { this.reduce() } });
1166
+ c.add("Extend", { disabled: this.splitExtended, callback: () => { this.extend() } });
1167
+ c.add("Reduce", { disabled: !this.splitExtended, callback: () => { this.reduce() } });
1093
1168
  });
1094
1169
  });
1095
1170
  }
@@ -1101,9 +1176,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1101
1176
  width2 = sizes[ 1 ];
1102
1177
 
1103
1178
  if( width1.constructor == Number )
1179
+ {
1104
1180
  width1 += "px";
1181
+ }
1182
+
1105
1183
  if( width2.constructor == Number )
1184
+ {
1106
1185
  width2 += "px";
1186
+ }
1107
1187
 
1108
1188
  area1.root.style.width = "calc( " + width1 + " - " + data + " )";
1109
1189
  area1.root.style.height = "calc(100% - 0px)";
@@ -1116,7 +1196,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1116
1196
  area1.root.style.width = "100%";
1117
1197
  area2.root.style.width = "100%";
1118
1198
 
1119
- if(auto)
1199
+ if( auto )
1120
1200
  {
1121
1201
  area1.root.style.height = "auto";
1122
1202
 
@@ -1135,11 +1215,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1135
1215
  var height1 = sizes[ 0 ],
1136
1216
  height2 = sizes[ 1 ];
1137
1217
 
1138
- if(height1.constructor == Number)
1218
+ if( height1.constructor == Number )
1219
+ {
1139
1220
  height1 += "px";
1140
- if(height2.constructor == Number)
1221
+ }
1222
+
1223
+ if( height2.constructor == Number )
1224
+ {
1141
1225
  height2 += "px";
1142
-
1226
+ }
1227
+
1143
1228
  area1.root.style.width = "100%";
1144
1229
  area1.root.style.height = "calc( " + height1 + " - " + data + " )";
1145
1230
  area2.root.style.height = "calc( " + height2 + " - " + data + " )";
@@ -1148,13 +1233,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1148
1233
 
1149
1234
  this.root.appendChild( area1.root );
1150
1235
 
1151
- if( resize )
1236
+ if( resize )
1152
1237
  {
1153
- this.root.appendChild(this.split_bar);
1238
+ this.root.appendChild(this.splitBar);
1154
1239
  }
1155
1240
 
1156
1241
  this.root.appendChild( area2.root );
1157
- this.sections = [area1, area2];
1242
+ this.sections = [ area1, area2 ];
1158
1243
  this.type = type;
1159
1244
 
1160
1245
  // Update sizes
@@ -1166,35 +1251,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1166
1251
  }
1167
1252
 
1168
1253
  var that = this;
1169
- var last_pos = [ 0, 0 ];
1170
1254
 
1171
- function inner_mousedown( e )
1255
+ function innerMouseDown( e )
1172
1256
  {
1173
1257
  var doc = that.root.ownerDocument;
1174
- doc.addEventListener( 'mousemove', inner_mousemove );
1175
- doc.addEventListener( 'mouseup', inner_mouseup );
1176
- last_pos[0] = e.x;
1177
- last_pos[1] = e.y;
1258
+ doc.addEventListener( 'mousemove', innerMouseMove );
1259
+ doc.addEventListener( 'mouseup', innerMouseUp );
1178
1260
  e.stopPropagation();
1179
1261
  e.preventDefault();
1180
1262
  document.body.classList.add( 'nocursor' );
1181
- that.split_bar.classList.add( 'nocursor' );
1263
+ that.splitBar.classList.add( 'nocursor' );
1182
1264
  }
1183
1265
 
1184
- function inner_mousemove( e )
1266
+ function innerMouseMove( e )
1185
1267
  {
1186
- if(that.type == "horizontal")
1268
+ if( that.type == "horizontal" )
1187
1269
  {
1188
- that._moveSplit( last_pos[ 0 ] - e.x );
1270
+ that._moveSplit( -e.movementX );
1189
1271
  }
1190
1272
  else
1191
1273
  {
1192
- that._moveSplit( last_pos[ 1 ] - e.y );
1274
+ that._moveSplit( -e.movementY );
1193
1275
  }
1194
1276
 
1195
- last_pos[ 0 ] = e.x;
1196
- last_pos[ 1 ] = e.y;
1197
-
1198
1277
  const widgets = that.root.querySelectorAll( ".lexwidget" );
1199
1278
 
1200
1279
  // Send area resize to every widget in the area
@@ -1212,13 +1291,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1212
1291
  e.preventDefault();
1213
1292
  }
1214
1293
 
1215
- function inner_mouseup( e )
1294
+ function innerMouseUp( e )
1216
1295
  {
1217
1296
  var doc = that.root.ownerDocument;
1218
- doc.removeEventListener( 'mousemove', inner_mousemove );
1219
- doc.removeEventListener( 'mouseup', inner_mouseup );
1297
+ doc.removeEventListener( 'mousemove', innerMouseMove );
1298
+ doc.removeEventListener( 'mouseup', innerMouseUp );
1220
1299
  document.body.classList.remove( 'nocursor' );
1221
- that.split_bar.classList.remove( 'nocursor' );
1300
+ that.splitBar.classList.remove( 'nocursor' );
1222
1301
  }
1223
1302
 
1224
1303
  return this.sections;
@@ -1241,7 +1320,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1241
1320
  * Resize element
1242
1321
  */
1243
1322
  setSize( size ) {
1244
-
1323
+
1245
1324
  let [ width, height ] = size;
1246
1325
 
1247
1326
  if( width != undefined && width.constructor == Number )
@@ -1275,22 +1354,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1275
1354
  */
1276
1355
  extend() {
1277
1356
 
1278
- if( this.split_extended )
1357
+ if( this.splitExtended )
1279
1358
  {
1280
1359
  return;
1281
1360
  }
1282
1361
 
1283
1362
  let [area1, area2] = this.sections;
1284
- this.split_extended = true;
1363
+ this.splitExtended = true;
1285
1364
 
1286
1365
  if(this.type == "vertical")
1287
1366
  {
1288
1367
  this.offset = area2.root.offsetHeight;
1289
1368
  area2.root.classList.add("fadeout-vertical");
1290
- this._moveSplit(-Infinity, true);
1369
+ this._moveSplit(-Infinity, true);
1291
1370
 
1292
1371
  }
1293
- else
1372
+ else
1294
1373
  {
1295
1374
  this.offset = area2.root.offsetWidth - 8; // Force some height here...
1296
1375
  area2.root.classList.add("fadeout-horizontal");
@@ -1307,10 +1386,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1307
1386
  */
1308
1387
  reduce() {
1309
1388
 
1310
- if( !this.split_extended )
1389
+ if( !this.splitExtended )
1311
1390
  return;
1312
-
1313
- this.split_extended = false;
1391
+
1392
+ this.splitExtended = false;
1314
1393
  let [area1, area2] = this.sections;
1315
1394
 
1316
1395
  if(this.type == "vertical")
@@ -1388,7 +1467,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1388
1467
  */
1389
1468
 
1390
1469
  addMenubar( callback, options = {} ) {
1391
-
1470
+
1392
1471
  let menubar = new Menubar(options);
1393
1472
 
1394
1473
  if(callback) callback( menubar );
@@ -1433,10 +1512,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1433
1512
  */
1434
1513
 
1435
1514
  addOverlayButtons( buttons, options = {} ) {
1436
-
1515
+
1437
1516
  // Add to last split section if area has been split
1438
- if(this.sections.length) {
1439
- this.sections[1].addOverlayButtons( buttons, options );
1517
+ if( this.sections.length )
1518
+ {
1519
+ this.sections[ 1 ].addOverlayButtons( buttons, options );
1440
1520
  return;
1441
1521
  }
1442
1522
 
@@ -1446,8 +1526,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1446
1526
  this.root.style.position = "relative";
1447
1527
 
1448
1528
  options.className = "lexoverlaybuttons";
1449
- options.width = "calc( 100% - 24px )";
1450
- options.height = "auto";
1529
+
1530
+ let overlayPanel = this.addPanel( options );
1531
+ let overlayGroup = null;
1532
+
1533
+ const container = document.createElement("div");
1534
+ container.className = "lexoverlaybuttonscontainer";
1535
+ container.appendChild( overlayPanel.root );
1536
+ this.attach( container );
1451
1537
 
1452
1538
  const float = options.float;
1453
1539
 
@@ -1459,24 +1545,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1459
1545
  switch( t )
1460
1546
  {
1461
1547
  case 'h': break;
1462
- case 'v': options.className += " vertical"; break;
1548
+ case 'v': container.className += " vertical"; break;
1463
1549
  case 't': break;
1464
- case 'm': options.className += " middle"; break;
1465
- case 'b': options.className += " bottom"; break;
1550
+ case 'm': container.className += " middle"; break;
1551
+ case 'b': container.className += " bottom"; break;
1466
1552
  case 'l': break;
1467
- case 'c': options.className += " center"; break;
1468
- case 'r': options.className += " right"; break;
1553
+ case 'c': container.className += " center"; break;
1554
+ case 'r': container.className += " right"; break;
1469
1555
  }
1470
1556
  }
1471
1557
  }
1472
1558
 
1473
- let overlayPanel = this.addPanel( options );
1474
- let overlaygroup;
1475
-
1476
- const add_button = function(b, group, last) {
1559
+ const _addButton = function( b, group, last ) {
1477
1560
 
1478
- const _options = {
1479
- width: "auto",
1561
+ const _options = {
1562
+ width: "auto",
1480
1563
  selectable: b.selectable,
1481
1564
  selected: b.selected,
1482
1565
  icon: b.icon,
@@ -1486,55 +1569,54 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1486
1569
 
1487
1570
  if( group )
1488
1571
  {
1489
- if(!overlaygroup) {
1490
- overlaygroup = document.createElement('div');
1491
- overlaygroup.className = "lexoverlaygroup";
1492
- overlayPanel.queuedContainer = overlaygroup;
1572
+ if( !overlayGroup )
1573
+ {
1574
+ overlayGroup = document.createElement('div');
1575
+ overlayGroup.className = "lexoverlaygroup";
1576
+ overlayPanel.queuedContainer = overlayGroup;
1493
1577
  }
1494
1578
 
1495
- _options.parent = overlaygroup;
1579
+ _options.parent = overlayGroup;
1496
1580
  }
1497
1581
 
1498
1582
  let callback = b.callback;
1499
1583
 
1500
1584
  if( b.options )
1501
1585
  {
1502
- callback = function(value, event) {
1503
- LX.addContextMenu(null, event, function(c) {
1504
- for( let o of b.options )
1505
- c.add(o, () => {
1506
- if( b.name == o ) return;
1507
- b.name = o;
1508
- b.callback( o );
1509
- refresh_panel();
1510
- });
1511
- });
1512
- };
1586
+ overlayPanel.addDropdown( null, b.options, b.name, callback, _options );
1513
1587
  }
1514
-
1515
- overlayPanel.addButton( null, b.name, function(value, event) {
1516
- if(b.selectable) {
1517
- if( b.group ) {
1518
- let _prev = b.selected;
1519
- b.group.forEach( sub => sub.selected = false );
1520
- b.selected = !_prev;
1588
+ else
1589
+ {
1590
+ overlayPanel.addButton( null, b.name, function( value, event ) {
1591
+ if( b.selectable )
1592
+ {
1593
+ if( b.group )
1594
+ {
1595
+ let _prev = b.selected;
1596
+ b.group.forEach( sub => sub.selected = false );
1597
+ b.selected = !_prev;
1598
+ }
1599
+ else
1600
+ {
1601
+ b.selected = !b.selected;
1602
+ }
1521
1603
  }
1522
- else
1523
- b.selected = !b.selected;
1524
- }
1525
- callback( value, event );
1526
- }, _options );
1604
+
1605
+ callback( value, event );
1606
+
1607
+ }, _options );
1608
+ }
1527
1609
 
1528
1610
  // ends the group
1529
- if(overlaygroup && last)
1611
+ if( overlayGroup && last )
1530
1612
  {
1531
- overlayPanel.root.appendChild( overlaygroup );
1532
- overlaygroup = null;
1613
+ overlayPanel.root.appendChild( overlayGroup );
1614
+ overlayGroup = null;
1533
1615
  overlayPanel.clearQueue();
1534
1616
  }
1535
1617
  }
1536
1618
 
1537
- const refresh_panel = function() {
1619
+ const _refreshPanel = function() {
1538
1620
 
1539
1621
  overlayPanel.clear();
1540
1622
 
@@ -1544,15 +1626,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1544
1626
  {
1545
1627
  for( let i = 0; i < b.length; ++i )
1546
1628
  {
1547
- let sub = b[i];
1629
+ let sub = b[ i ];
1548
1630
  sub.group = b;
1549
- add_button(sub, true, i == (b.length - 1));
1631
+ _addButton(sub, true, i == ( b.length - 1 ));
1550
1632
  }
1551
- }else
1633
+ }
1634
+ else
1552
1635
  {
1553
- add_button(b);
1636
+ _addButton( b );
1554
1637
  }
1555
-
1638
+
1556
1639
  }
1557
1640
 
1558
1641
  // Add floating info
@@ -1561,16 +1644,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1561
1644
  var height = 0;
1562
1645
  overlayPanel.root.childNodes.forEach( c => { height += c.offsetHeight; } );
1563
1646
 
1564
- if( options.className.includes("middle") )
1647
+ if( container.className.includes( "middle" ) )
1565
1648
  {
1566
- overlayPanel.root.style.top = "-moz-calc( 50% - " + (height * 0.5) + "px )";
1567
- overlayPanel.root.style.top = "-webkit-calc( 50% - " + (height * 0.5) + "px )";
1568
- overlayPanel.root.style.top = "calc( 50% - " + (height * 0.5) + "px )";
1649
+ container.style.top = "-moz-calc( 50% - " + (height * 0.5) + "px )";
1650
+ container.style.top = "-webkit-calc( 50% - " + (height * 0.5) + "px )";
1651
+ container.style.top = "calc( 50% - " + (height * 0.5) + "px )";
1569
1652
  }
1570
1653
  }
1571
1654
  }
1572
1655
 
1573
- refresh_panel();
1656
+ _refreshPanel();
1574
1657
  }
1575
1658
 
1576
1659
  /**
@@ -1586,73 +1669,85 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1586
1669
  {
1587
1670
  this.parentArea._disableSplitResize();
1588
1671
  // Compensate split bar...
1589
- this.root.style.paddingTop = "4px";
1672
+ this.root.style.paddingTop = "4px";
1590
1673
  }
1591
1674
 
1592
1675
  return tabs;
1593
1676
  }
1594
1677
 
1595
- _moveSplit( dt, force_animation = false, force_width = 0 ) {
1678
+ _moveSplit( dt, forceAnimation = false, forceWidth = 0 ) {
1596
1679
 
1597
1680
  if( !this.type )
1681
+ {
1598
1682
  throw( "No split area" );
1683
+ }
1599
1684
 
1600
1685
  if( dt === undefined ) // Splitbar didn't move!
1686
+ {
1601
1687
  return;
1688
+ }
1689
+
1690
+ const a1 = this.sections[ 0 ];
1691
+ var a1Root = a1.root;
1692
+
1693
+ if( !a1Root.classList.contains( "origin" ) )
1694
+ {
1695
+ a1Root = a1Root.parentElement;
1696
+ }
1602
1697
 
1603
- var a1 = this.sections[ 0 ];
1604
- var a2 = this.sections[ 1 ];
1605
- var splitinfo = " - "+ LX.DEFAULT_SPLITBAR_SIZE + "px";
1698
+ const a2 = this.sections[ 1 ];
1699
+ const a2Root = a2.root;
1700
+ const splitData = " - "+ LX.DEFAULT_SPLITBAR_SIZE + "px";
1606
1701
 
1607
1702
  let transition = null;
1608
- if( !force_animation )
1703
+ if( !forceAnimation )
1609
1704
  {
1610
1705
  // Remove transitions for this change..
1611
- transition = a1.root.style.transition;
1612
- a1.root.style.transition = a2.root.style.transition = "none";
1613
- flushCss( a1.root );
1614
- flushCss( a2.root );
1706
+ transition = a1Root.style.transition;
1707
+ a1Root.style.transition = a2Root.style.transition = "none";
1708
+ flushCss( a1Root );
1709
+ flushCss( a2Root );
1615
1710
  }
1616
1711
 
1617
1712
  if( this.type == "horizontal" )
1618
1713
  {
1619
- var size = Math.max( a2.root.offsetWidth + dt, parseInt( a2.minWidth ) );
1620
- if( force_width ) size = force_width;
1621
- a1.root.style.width = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
1622
- a1.root.style.width = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
1623
- a1.root.style.width = "calc( 100% - " + size + "px " + splitinfo + " )";
1624
- a1.root.style.minWidth = parseInt( a1.minWidth ) + "px";
1625
- a2.root.style.width = size + "px";
1626
- if( a1.maxWidth != Infinity ) a2.root.style.minWidth = "calc( 100% - " + parseInt( a1.maxWidth ) + "px" + " )";
1714
+ var size = Math.max( a2Root.offsetWidth + dt, parseInt( a2.minWidth ) );
1715
+ if( forceWidth ) size = forceWidth;
1716
+ a1Root.style.width = "-moz-calc( 100% - " + size + "px " + splitData + " )";
1717
+ a1Root.style.width = "-webkit-calc( 100% - " + size + "px " + splitData + " )";
1718
+ a1Root.style.width = "calc( 100% - " + size + "px " + splitData + " )";
1719
+ a1Root.style.minWidth = parseInt( a1.minWidth ) + "px";
1720
+ a2Root.style.width = size + "px";
1721
+ if( a1.maxWidth != Infinity ) a2Root.style.minWidth = "calc( 100% - " + parseInt( a1.maxWidth ) + "px" + " )";
1627
1722
  }
1628
1723
  else
1629
1724
  {
1630
- var size = Math.max((a2.root.offsetHeight + dt) + a2.offset, parseInt(a2.minHeight));
1631
- if( force_width ) size = force_width;
1632
- a1.root.style.height = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
1633
- a1.root.style.height = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
1634
- a1.root.style.height = "calc( 100% - " + size + "px " + splitinfo + " )";
1635
- a1.root.style.minHeight = a1.minHeight + "px";
1636
- a2.root.style.height = ( size - a2.offset ) + "px";
1725
+ var size = Math.max((a2Root.offsetHeight + dt) + a2.offset, parseInt(a2.minHeight));
1726
+ if( forceWidth ) size = forceWidth;
1727
+ a1Root.style.height = "-moz-calc( 100% - " + size + "px " + splitData + " )";
1728
+ a1Root.style.height = "-webkit-calc( 100% - " + size + "px " + splitData + " )";
1729
+ a1Root.style.height = "calc( 100% - " + size + "px " + splitData + " )";
1730
+ a1Root.style.minHeight = a1.minHeight + "px";
1731
+ a2Root.style.height = ( size - a2.offset ) + "px";
1637
1732
  }
1638
-
1639
- if( !force_animation )
1733
+
1734
+ if( !forceAnimation )
1640
1735
  {
1641
1736
  // Reapply transitions
1642
- a1.root.style.transition = a2.root.style.transition = transition;
1737
+ a1Root.style.transition = a2Root.style.transition = transition;
1643
1738
  }
1644
1739
 
1645
1740
  this._update();
1646
1741
 
1647
- // Resize events
1742
+ // Resize events
1648
1743
  this.propagateEvent( 'onresize' );
1649
1744
  }
1650
1745
 
1651
1746
  _disableSplitResize() {
1652
1747
 
1653
1748
  this.resize = false;
1654
- this.split_bar.remove();
1655
- delete this.split_bar;
1749
+ this.splitBar.remove();
1750
+ delete this.splitBar;
1656
1751
  }
1657
1752
 
1658
1753
  _update() {
@@ -1767,11 +1862,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1767
1862
  }
1768
1863
 
1769
1864
  // debug
1770
- if(folding)
1865
+ if(folding)
1771
1866
  {
1772
1867
  this.folded = true;
1773
1868
  this.folding = folding;
1774
-
1869
+
1775
1870
  if(folding == "up") area.root.insertChildAtIndex(area.sections[1].root, 0);
1776
1871
 
1777
1872
  // Listen resize event on parent area
@@ -1798,7 +1893,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1798
1893
  this.root.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ) );
1799
1894
  this.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
1800
1895
  }
1801
-
1896
+
1802
1897
  isSelected = !Object.keys( this.tabs ).length && !this.folding ? true : isSelected;
1803
1898
 
1804
1899
  let contentEl = content.root ? content.root : content;
@@ -1826,7 +1921,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1826
1921
  tabEl.className = "lexareatab" + ( isSelected ? " selected" : "" );
1827
1922
  tabEl.innerHTML = ( options.icon ?? "" ) + name;
1828
1923
  tabEl.id = name.replace( /\s/g, '' ) + Tabs.TAB_ID++;
1829
- tabEl.title = options.title;
1924
+ tabEl.title = options.title ?? "";
1830
1925
  tabEl.selected = isSelected ?? false;
1831
1926
  tabEl.fixed = options.fixed;
1832
1927
  tabEl.instance = this;
@@ -1841,9 +1936,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1841
1936
  if( this.parentElement.childNodes.length == 1 )
1842
1937
  {
1843
1938
  this.parentElement.childNodes[ 0 ].click(); // single tab!!
1844
- }
1939
+ }
1845
1940
  } );
1846
-
1941
+
1847
1942
  tabEl.addEventListener("click", e => {
1848
1943
 
1849
1944
  e.preventDefault();
@@ -1854,11 +1949,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1854
1949
  // For folding tabs
1855
1950
  const lastValue = tabEl.selected;
1856
1951
  tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.selected = false );
1857
- tabEl.selected = !lastValue;
1952
+ tabEl.selected = !lastValue;
1858
1953
  // Manage selected
1859
1954
  tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ));
1860
1955
  tabEl.classList.toggle('selected', ( this.folding && tabEl.selected ));
1861
- // Manage visibility
1956
+ // Manage visibility
1862
1957
  tabEl.instance.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
1863
1958
  contentEl.style.display = contentEl.originalDisplay;
1864
1959
  tabEl.instance.selected = tabEl.dataset.name;
@@ -1887,7 +1982,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1887
1982
  tabEl.addEventListener("contextmenu", e => {
1888
1983
  e.preventDefault();
1889
1984
  e.stopPropagation();
1890
-
1985
+
1891
1986
  if( options.onContextMenu )
1892
1987
  {
1893
1988
  options.onContextMenu( e, tabEl.dataset.name );
@@ -1902,16 +1997,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1902
1997
  this.delete( tabEl.dataset[ "name" ] );
1903
1998
  }
1904
1999
  });
1905
-
2000
+
1906
2001
  tabEl.setAttribute( 'draggable', true );
1907
2002
  tabEl.addEventListener( 'dragstart', function( e ) {
1908
2003
  if( this.parentElement.childNodes.length == 1 ){
1909
2004
  e.preventDefault();
1910
2005
  return;
1911
- }
2006
+ }
1912
2007
  e.dataTransfer.setData( 'source', e.target.id );
1913
2008
  });
1914
-
2009
+
1915
2010
  // Attach content
1916
2011
  tabEl.childIndex = ( this.root.childElementCount - 1 );
1917
2012
  this.root.appendChild( tabEl );
@@ -1990,7 +2085,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1990
2085
  if(options.float)
1991
2086
  this.root.style.justifyContent = options.float;
1992
2087
  this.items = [];
1993
-
2088
+
1994
2089
  this.icons = {};
1995
2090
  this.shorts = {};
1996
2091
  this.buttons = [];
@@ -2029,7 +2124,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2029
2124
  } );
2030
2125
 
2031
2126
  if(found) {
2032
- insert( tokens[idx++], found );
2127
+ insert( tokens[idx++], found );
2033
2128
  }
2034
2129
  else {
2035
2130
  let item = {};
@@ -2042,7 +2137,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2042
2137
  item[ 'checked' ] = options.checked;
2043
2138
  }
2044
2139
  list.push( item );
2045
- insert( next_token, item[ token ] );
2140
+ insert( next_token, item[ token ] );
2046
2141
  }
2047
2142
  };
2048
2143
 
@@ -2057,7 +2152,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2057
2152
 
2058
2153
  // Item already created
2059
2154
  if( this.root.querySelector("#" + pKey) )
2060
- continue;
2155
+ continue;
2061
2156
 
2062
2157
  let entry = document.createElement('div');
2063
2158
  entry.className = "lexmenuentry";
@@ -2098,21 +2193,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2098
2193
  const subitem = o[k][i];
2099
2194
  const subkey = Object.keys(subitem)[0];
2100
2195
  const hasSubmenu = subitem[ subkey ].length;
2101
- const is_checkbox = subitem[ 'type' ] == 'checkbox';
2196
+ const isCheckbox = subitem[ 'type' ] == 'checkbox';
2102
2197
  let subentry = document.createElement('div');
2103
2198
  subentry.className = "lexcontextmenuentry";
2104
2199
  subentry.className += (i == o[k].length - 1 ? " last" : "");
2105
2200
  if(subkey == '')
2106
2201
  subentry.className = " lexseparator";
2107
2202
  else {
2108
-
2203
+
2109
2204
  subentry.id = subkey;
2110
2205
  let subentrycont = document.createElement('div');
2111
2206
  subentrycont.innerHTML = "";
2112
2207
  subentrycont.classList = "lexcontextmenuentrycontainer";
2113
2208
  subentry.appendChild(subentrycont);
2114
2209
  const icon = that.icons[ subkey ];
2115
- if(is_checkbox){
2210
+ if(isCheckbox){
2116
2211
  subentrycont.innerHTML += "<input type='checkbox' >";
2117
2212
  }else if(icon) {
2118
2213
  subentrycont.innerHTML += "<a class='" + icon + " fa-sm'></a>";
@@ -2132,8 +2227,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2132
2227
  const f = subitem[ 'callback' ];
2133
2228
  if(f) {
2134
2229
  f.call( this, subitem.checked, subkey, subentry );
2135
- that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2136
- }
2230
+ that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2231
+ }
2137
2232
  e.stopPropagation();
2138
2233
  e.stopImmediatePropagation();
2139
2234
  })
@@ -2163,8 +2258,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2163
2258
  const f = subitem[ 'callback' ];
2164
2259
  if(f) {
2165
2260
  f.call( this, checkbox_input ? subitem.checked : subkey, checkbox_input ? subkey : subentry );
2166
- that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2167
- }
2261
+ that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2262
+ }
2168
2263
  e.stopPropagation();
2169
2264
  e.stopImmediatePropagation();
2170
2265
  });
@@ -2210,7 +2305,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2210
2305
  if(f) {
2211
2306
  f.call( this, key, entry );
2212
2307
  return;
2213
- }
2308
+ }
2214
2309
 
2215
2310
  // Manage selected
2216
2311
  this.root.querySelectorAll(".lexmenuentry").forEach( e => e.classList.remove( 'selected' ) );
@@ -2242,7 +2337,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2242
2337
  * @param {Array} tokens: split path strings
2243
2338
  */
2244
2339
  getSubitem(item, tokens) {
2245
-
2340
+
2246
2341
  let subitem = null;
2247
2342
  let path = tokens[0];
2248
2343
  for(let i = 0; i < item.length; i++) {
@@ -2256,7 +2351,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2256
2351
  tokens.splice(0,1);
2257
2352
  return this.getSubitem(item[i][path], tokens);
2258
2353
  }
2259
-
2354
+
2260
2355
  }
2261
2356
  }
2262
2357
  }
@@ -2268,7 +2363,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2268
2363
  getItem( path ) {
2269
2364
  // process path
2270
2365
  const tokens = path.split("/");
2271
-
2366
+
2272
2367
  return this.getSubitem(this.items, tokens)
2273
2368
  }
2274
2369
 
@@ -2306,7 +2401,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2306
2401
  else {
2307
2402
  this.root.appendChild( button );
2308
2403
  }
2309
-
2404
+
2310
2405
  const _b = button.querySelector('a');
2311
2406
  _b.addEventListener("click", (e) => {
2312
2407
  if(callback && !disabled)
@@ -2347,7 +2442,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2347
2442
  else {
2348
2443
  this.root.appendChild( button );
2349
2444
  }
2350
-
2445
+
2351
2446
  const _b = button.querySelector('a');
2352
2447
  _b.addEventListener("click", (e) => {
2353
2448
  if(callback && !disabled)
@@ -2380,7 +2475,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2380
2475
  }
2381
2476
  else {
2382
2477
  this.root.appendChild( this.buttonContainer );
2383
- }
2478
+ }
2384
2479
  }
2385
2480
 
2386
2481
  for( let i = 0; i < buttons.length; ++i )
@@ -2393,7 +2488,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2393
2488
  button.title = title ?? "";
2394
2489
  button.innerHTML = "<a class='" + data.icon + " lexicon'></a>";
2395
2490
  this.buttonContainer.appendChild( button );
2396
-
2491
+
2397
2492
  const _b = button.querySelector('a');
2398
2493
  _b.addEventListener("click", (e) => {
2399
2494
  disabled = e.target.parentElement.classList.contains("disabled");
@@ -2473,6 +2568,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2473
2568
  desc.innerHTML = key;
2474
2569
  entry.appendChild( desc );
2475
2570
 
2571
+ button.addEventListener("mouseenter", () => {
2572
+ setTimeout( () => {
2573
+ desc.style.display = "unset";
2574
+ }, 100 );
2575
+ });
2576
+
2577
+ button.addEventListener("mouseleave", () => {
2578
+ setTimeout( () => {
2579
+ desc.style.display = "none";
2580
+ }, 100 );
2581
+ });
2582
+
2476
2583
  entry.addEventListener("click", () => {
2477
2584
 
2478
2585
  const f = options.callback;
@@ -2514,7 +2621,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2514
2621
  */
2515
2622
 
2516
2623
  class Widget {
2517
-
2624
+
2518
2625
  static NONE = 0;
2519
2626
  static TEXT = 1;
2520
2627
  static TEXTAREA = 2;
@@ -2570,7 +2677,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2570
2677
 
2571
2678
  if( this.onSetValue )
2572
2679
  return this.onSetValue( value, skipCallback );
2573
-
2680
+
2574
2681
  console.warn("Can't set value of " + this.typeName());
2575
2682
  }
2576
2683
 
@@ -2678,33 +2785,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2678
2785
  container = document.createElement('div');
2679
2786
  container.className = "lexcustomcontainer";
2680
2787
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
2681
-
2788
+
2682
2789
  this.queue(container);
2683
2790
 
2684
2791
  let buttonName = "<a class='fa-solid " + (options.icon ?? "fa-cube") + "' style='float:left'></a>";
2685
2792
  buttonName += custom_widget_name + (!instance ? " [empty]" : "");
2686
2793
  // Add alwayis icon to keep spacing right
2687
2794
  buttonName += "<a class='fa-solid " + (instance ? "fa-bars-staggered" : " ") + " menu' style='float:right; width:5%;'></a>";
2688
-
2795
+
2689
2796
  let buttonEl = this.addButton(null, buttonName, (value, event) => {
2690
2797
 
2691
2798
  if( instance ) {
2692
2799
  element.querySelector(".lexcustomitems").toggleAttribute('hidden');
2693
2800
  }
2694
2801
  else {
2695
- addContextMenu(null, event, c => {
2696
- c.add("New " + custom_widget_name, () => {
2802
+ addContextMenu(null, event, c => {
2803
+ c.add("New " + custom_widget_name, () => {
2697
2804
  instance = {};
2698
2805
  refresh_widget();
2699
2806
  element.querySelector(".lexcustomitems").toggleAttribute('hidden', false);
2700
2807
  });
2701
2808
  });
2702
2809
  }
2703
-
2810
+
2704
2811
  }, { buttonClass: 'custom' });
2705
-
2812
+
2706
2813
  this.clearQueue();
2707
-
2814
+
2708
2815
  if(instance)
2709
2816
  buttonEl.querySelector('a.menu').addEventListener('click', e => {
2710
2817
  e.stopImmediatePropagation();
@@ -2716,13 +2823,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2716
2823
  });
2717
2824
  });
2718
2825
  });
2719
-
2826
+
2720
2827
  // Show elements
2721
-
2828
+
2722
2829
  custom_widgets = document.createElement('div');
2723
2830
  custom_widgets.className = "lexcustomitems";
2724
2831
  custom_widgets.toggleAttribute('hidden', true);
2725
-
2832
+
2726
2833
  element.appendChild( container );
2727
2834
  element.appendChild( custom_widgets );
2728
2835
 
@@ -2730,7 +2837,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2730
2837
  {
2731
2838
 
2732
2839
  this.queue( custom_widgets );
2733
-
2840
+
2734
2841
  const on_instance_changed = ( key, value, event ) => {
2735
2842
  instance[ key ] = value;
2736
2843
  this._trigger( new IEvent( name, instance, event ), callback );
@@ -2739,7 +2846,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2739
2846
  for( let key in default_instance )
2740
2847
  {
2741
2848
  const value = instance[ key ] ?? default_instance[ key ];
2742
-
2849
+
2743
2850
  switch( value.constructor )
2744
2851
  {
2745
2852
  case String:
@@ -2780,13 +2887,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2780
2887
  }
2781
2888
 
2782
2889
  LX.ADD_CUSTOM_WIDGET = ADD_CUSTOM_WIDGET;
2783
-
2890
+
2784
2891
  /**
2785
2892
  * @class NodeTree
2786
2893
  */
2787
2894
 
2788
2895
  class NodeTree {
2789
-
2896
+
2790
2897
  constructor(domEl, data, options) {
2791
2898
  this.domEl = domEl;
2792
2899
  this.data = data;
@@ -2822,7 +2929,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2822
2929
  node.parent = parent;
2823
2930
  let isParent = node.children.length > 0;
2824
2931
  let isSelected = this.selected.indexOf( node ) > -1;
2825
-
2932
+
2826
2933
  if( this.options.onlyFolders )
2827
2934
  {
2828
2935
  let has_folders = false;
@@ -2839,10 +2946,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2839
2946
  let icon = (this.options.skip_default_icon ?? true) ? "" : "fa-solid fa-square"; // Default: no childs
2840
2947
  if( isParent ) icon = node.closed ? "fa-solid fa-caret-right" : "fa-solid fa-caret-down";
2841
2948
  item.innerHTML = "<a class='" + icon + " hierarchy'></a>";
2842
-
2949
+
2843
2950
  // Add display icon
2844
2951
  icon = node.icon;
2845
-
2952
+
2846
2953
  // Process icon
2847
2954
  if( node.icon )
2848
2955
  {
@@ -2874,7 +2981,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2874
2981
  list.querySelectorAll("li").forEach( e => { e.classList.remove('selected'); } );
2875
2982
  this.selected.length = 0;
2876
2983
  }
2877
-
2984
+
2878
2985
  // Add or remove
2879
2986
  const idx = this.selected.indexOf( node );
2880
2987
  if( idx > -1 ) {
@@ -3041,7 +3148,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3041
3148
  let name_input = document.createElement('input');
3042
3149
  name_input.toggleAttribute('hidden', !node.rename);
3043
3150
  name_input.value = node.id;
3044
- item.appendChild(name_input);
3151
+ item.appendChild(name_input);
3045
3152
 
3046
3153
  if(node.rename) {
3047
3154
  item.classList.add('selected');
@@ -3134,13 +3241,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3134
3241
  delete window.__tree_node_dragged;
3135
3242
  });
3136
3243
  }
3137
-
3244
+
3138
3245
  let handled = false;
3139
3246
 
3140
3247
  // Show/hide children
3141
3248
  if(isParent) {
3142
3249
  item.querySelector('a.hierarchy').addEventListener("click", function(e) {
3143
-
3250
+
3144
3251
  handled = true;
3145
3252
  e.stopImmediatePropagation();
3146
3253
  e.stopPropagation();
@@ -3174,8 +3281,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3174
3281
 
3175
3282
  item.appendChild(visibility);
3176
3283
  }
3177
-
3178
- if(node.actions)
3284
+
3285
+ if(node.actions)
3179
3286
  {
3180
3287
  for(var i = 0; i < node.actions.length; ++i) {
3181
3288
  let a = node.actions[i];
@@ -3214,14 +3321,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3214
3321
  this.domEl.querySelector( "ul" ).innerHTML = "";
3215
3322
  this._create_item( null, this.data, 0, selectedId );
3216
3323
  }
3217
-
3324
+
3218
3325
  /* Refreshes the tree and focuses current element */
3219
3326
  frefresh( id ) {
3220
3327
  this.refresh();
3221
3328
  var el = this.domEl.querySelector( "#" + id );
3222
3329
  if( el ) el.focus();
3223
3330
  }
3224
-
3331
+
3225
3332
  select( id ) {
3226
3333
  this.refresh( null, id );
3227
3334
  }
@@ -3234,11 +3341,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3234
3341
  class Panel {
3235
3342
 
3236
3343
  /**
3237
- * @param {*} options
3344
+ * @param {*} options
3238
3345
  * id: Id of the element
3239
3346
  * className: Add class to the element
3240
3347
  * width: Width of the panel element [fit space]
3241
3348
  * height: Height of the panel element [fit space]
3349
+ * style: CSS Style object to be applied to the panel
3242
3350
  */
3243
3351
 
3244
3352
  constructor( options = {} ) {
@@ -3385,7 +3493,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3385
3493
  this._inlineContainer.style.justifyContent = justifyContent;
3386
3494
  }
3387
3495
  }
3388
-
3496
+
3389
3497
  // Push all elements single element or Array[element, container]
3390
3498
  for( let item of this._inlineWidgets )
3391
3499
  {
@@ -3393,17 +3501,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3393
3501
 
3394
3502
  if(is_pair)
3395
3503
  {
3396
- // eg. an array, inline items appended later to
3504
+ // eg. an array, inline items appended later to
3397
3505
  if(this._inline_queued_container)
3398
3506
  this._inlineContainer.appendChild( item[0] );
3399
3507
  // eg. a dropdown, item is appended to parent, not to inline cont.
3400
3508
  else
3401
3509
  item[1].appendChild(item[0]);
3402
- }
3510
+ }
3403
3511
  else
3404
3512
  this._inlineContainer.appendChild( item );
3405
3513
  }
3406
-
3514
+
3407
3515
  if(!this._inline_queued_container)
3408
3516
  {
3409
3517
  if(this.current_branch)
@@ -3423,7 +3531,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3423
3531
  /**
3424
3532
  * @method branch
3425
3533
  * @param {String} name Name of the branch/section
3426
- * @param {*} options
3534
+ * @param {*} options
3427
3535
  * id: Id of the branch
3428
3536
  * className: Add class to the branch
3429
3537
  * closed: Set branch collapsed/opened [false]
@@ -3543,14 +3651,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3543
3651
  domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
3544
3652
  element.appendChild(domName);
3545
3653
  element.domName = domName;
3546
-
3654
+
3547
3655
  // Copy-paste info
3548
3656
  domName.addEventListener('contextmenu', function( e ) {
3549
3657
  e.preventDefault();
3550
3658
  widget.oncontextmenu( e );
3551
3659
  });
3552
3660
  }
3553
-
3661
+
3554
3662
  this.widgets[ name ] = widget;
3555
3663
  }
3556
3664
 
@@ -3579,7 +3687,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3579
3687
 
3580
3688
  if(this.current_branch)
3581
3689
  {
3582
- if(!options.skipWidget)
3690
+ if(!options.skipWidget)
3583
3691
  this.current_branch.widgets.push( widget );
3584
3692
  this.current_branch.content.appendChild( el );
3585
3693
  }
@@ -3588,7 +3696,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3588
3696
  el.classList.add("nobranch");
3589
3697
  this.root.appendChild( el );
3590
3698
  }
3591
- }
3699
+ }
3592
3700
  // Append content to queued tab container
3593
3701
  else {
3594
3702
  this.queuedContainer.appendChild( el );
@@ -3599,7 +3707,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3599
3707
 
3600
3708
  if(!this.queuedContainer) {
3601
3709
  this._inlineWidgets.push( el );
3602
- }
3710
+ }
3603
3711
  // Append content to queued tab container
3604
3712
  else {
3605
3713
  this._inlineWidgets.push( [el, this.queuedContainer] );
@@ -3638,7 +3746,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3638
3746
  let widget = this.create_widget(null, Widget.TEXT, options);
3639
3747
  let element = widget.domEl;
3640
3748
  element.className += " lexfilter noname";
3641
-
3749
+
3642
3750
  let input = document.createElement('input');
3643
3751
  input.className = 'lexinput-filter';
3644
3752
  input.setAttribute("placeholder", options.placeholder);
@@ -3650,9 +3758,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3650
3758
  element.appendChild(input);
3651
3759
  element.appendChild(searchIcon);
3652
3760
 
3653
- input.addEventListener("input", (e) => {
3761
+ input.addEventListener("input", (e) => {
3654
3762
  if(options.callback)
3655
- options.callback(input.value, e);
3763
+ options.callback(input.value, e);
3656
3764
  });
3657
3765
 
3658
3766
  return element;
@@ -3664,7 +3772,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3664
3772
 
3665
3773
  if(b.name !== branchName)
3666
3774
  continue;
3667
-
3775
+
3668
3776
  // remove all widgets
3669
3777
  for( let w of b.widgets ) {
3670
3778
  if(w.domEl.classList.contains('lexfilter'))
@@ -3726,7 +3834,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3726
3834
 
3727
3835
  if( callback )
3728
3836
  callback.call( this, event.value, event.domEvent, event.name );
3729
-
3837
+
3730
3838
  if( this.onevent )
3731
3839
  this.onevent.call( this, event );
3732
3840
  }
@@ -3865,9 +3973,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3865
3973
  this.disabled ? wValue.innerText = newValue : wValue.value = newValue;
3866
3974
  Panel._dispatch_event( wValue, "focusout", skipCallback );
3867
3975
  };
3868
-
3976
+
3869
3977
  let element = widget.domEl;
3870
-
3978
+
3871
3979
  // Add reset functionality
3872
3980
  if( widget.name && !( options.skipReset ?? false ) ) {
3873
3981
  Panel._add_reset_property( element.domName, function() {
@@ -3876,17 +3984,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3876
3984
  Panel._dispatch_event( wValue, "focusout" );
3877
3985
  } );
3878
3986
  }
3879
-
3987
+
3880
3988
  // Add widget value
3881
-
3989
+
3882
3990
  let container = document.createElement( 'div' );
3883
3991
  container.className = "lextext" + ( options.warning ? " lexwarning" : "" );
3884
3992
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " )";
3885
3993
  container.style.display = "flex";
3886
-
3994
+
3887
3995
  this.disabled = ( options.disabled || options.warning ) ?? ( options.url ? true : false );
3888
3996
  let wValue = null;
3889
-
3997
+
3890
3998
  if( !this.disabled )
3891
3999
  {
3892
4000
  wValue = document.createElement( 'input' );
@@ -3894,19 +4002,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3894
4002
  wValue.value = wValue.iValue = value || "";
3895
4003
  wValue.style.width = "100%";
3896
4004
  wValue.style.textAlign = options.float ?? "";
3897
-
4005
+
3898
4006
  if( options.placeholder )
3899
4007
  wValue.setAttribute( "placeholder", options.placeholder );
3900
-
4008
+
3901
4009
  var resolve = ( function( val, event ) {
3902
4010
  const skipCallback = event.detail;
3903
4011
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
3904
4012
  if( btn ) btn.style.display = ( val != wValue.iValue ? "block" : "none" );
3905
4013
  if( !skipCallback ) this._trigger( new IEvent( name, val, event ), callback );
3906
4014
  }).bind( this );
3907
-
4015
+
3908
4016
  const trigger = options.trigger ?? 'default';
3909
-
4017
+
3910
4018
  if( trigger == 'default' )
3911
4019
  {
3912
4020
  wValue.addEventListener( "keyup", function( e ){
@@ -3923,19 +4031,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3923
4031
  resolve( e.target.value, e );
3924
4032
  });
3925
4033
  }
3926
-
4034
+
3927
4035
  wValue.addEventListener( "mousedown", function( e ){
3928
4036
  e.stopImmediatePropagation();
3929
4037
  e.stopPropagation();
3930
4038
  });
3931
-
4039
+
3932
4040
  if( options.icon )
3933
4041
  {
3934
4042
  let icon = document.createElement( 'a' );
3935
4043
  icon.className = "inputicon " + options.icon;
3936
4044
  container.appendChild( icon );
3937
4045
  }
3938
-
4046
+
3939
4047
  } else
3940
4048
  {
3941
4049
  wValue = document.createElement( options.url ? 'a' : 'div' );
@@ -3949,18 +4057,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3949
4057
  wValue.style.width = "100%";
3950
4058
  wValue.style.textAlign = options.float ?? "";
3951
4059
  }
3952
-
4060
+
3953
4061
  Object.assign( wValue.style, options.style ?? {} );
3954
-
4062
+
3955
4063
  container.appendChild( wValue );
3956
4064
  element.appendChild( container );
3957
-
4065
+
3958
4066
  // Remove branch padding and margins
3959
4067
  if( !widget.name ) {
3960
4068
  element.className += " noname";
3961
4069
  container.style.width = "100%";
3962
4070
  }
3963
-
4071
+
3964
4072
  return widget;
3965
4073
  }
3966
4074
 
@@ -4001,7 +4109,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4001
4109
  Panel._dispatch_event( wValue, "focusout" );
4002
4110
  });
4003
4111
  }
4004
-
4112
+
4005
4113
  // Add widget value
4006
4114
 
4007
4115
  let container = document.createElement( 'div' );
@@ -4054,7 +4162,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4054
4162
 
4055
4163
  container.appendChild(wValue);
4056
4164
  element.appendChild(container);
4057
-
4165
+
4058
4166
  // Remove branch padding and margins
4059
4167
  if(!widget.name) {
4060
4168
  element.className += " noname";
@@ -4083,7 +4191,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4083
4191
  options.disabled = true;
4084
4192
  return this.addText( null, value, null, options );
4085
4193
  }
4086
-
4194
+
4087
4195
  /**
4088
4196
  * @method addButton
4089
4197
  * @param {String} name Widget name
@@ -4093,52 +4201,69 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4093
4201
  * disabled: Make the widget disabled [false]
4094
4202
  * icon: Icon class to show as button value
4095
4203
  * img: Path to image to show as button value
4204
+ * title: Text to show in native Element title
4096
4205
  */
4097
4206
 
4098
4207
  addButton( name, value, callback, options = {} ) {
4099
4208
 
4100
- let widget = this.create_widget(name, Widget.BUTTON, options);
4209
+ let widget = this.create_widget( name, Widget.BUTTON, options );
4210
+
4101
4211
  widget.onGetValue = () => {
4102
4212
  return wValue.innerText;
4103
4213
  };
4214
+
4104
4215
  widget.onSetValue = ( newValue, skipCallback ) => {
4105
- wValue.innerHTML =
4106
- (options.icon ? "<a class='" + options.icon + "'></a>" :
4216
+ wValue.innerHTML =
4217
+ (options.icon ? "<a class='" + options.icon + "'></a>" :
4107
4218
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (newValue || "") + "</span>" ));
4108
4219
  };
4109
-
4220
+
4110
4221
  let element = widget.domEl;
4111
4222
 
4112
- var wValue = document.createElement('button');
4113
- if(options.icon || options.img)
4114
- wValue.title = value;
4223
+ var wValue = document.createElement( 'button' );
4224
+ wValue.title = options.title ?? "";
4115
4225
  wValue.className = "lexbutton";
4116
- if(options.selected)
4117
- wValue.classList.add("selected");
4118
- if(options.buttonClass)
4119
- wValue.classList.add(options.buttonClass);
4120
- wValue.innerHTML =
4121
- (options.icon ? "<a class='" + options.icon + "'></a>" :
4226
+
4227
+ if( options.selected )
4228
+ {
4229
+ wValue.classList.add( "selected" );
4230
+ }
4231
+
4232
+ if( options.buttonClass )
4233
+ {
4234
+ wValue.classList.add( options.buttonClass );
4235
+ }
4236
+
4237
+ wValue.innerHTML =
4238
+ (options.icon ? "<a class='" + options.icon + "'></a>" :
4122
4239
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (value || "") + "</span>" ));
4123
4240
 
4124
4241
  wValue.style.width = "calc( 100% - " + (options.nameWidth ?? LX.DEFAULT_NAME_WIDTH) + ")";
4125
4242
 
4126
- if(options.disabled)
4127
- wValue.setAttribute("disabled", true);
4243
+ if( options.disabled )
4244
+ {
4245
+ wValue.setAttribute( "disabled", true );
4246
+ }
4128
4247
 
4129
4248
  wValue.addEventListener("click", e => {
4130
- if( options.selectable ) {
4249
+ if( options.selectable )
4250
+ {
4131
4251
  if( options.parent )
4252
+ {
4132
4253
  options.parent.querySelectorAll(".lexbutton.selected").forEach( e => { if(e == wValue) return; e.classList.remove("selected") } );
4254
+ }
4255
+
4133
4256
  wValue.classList.toggle('selected');
4134
4257
  }
4135
- this._trigger( new IEvent(name, value, e), callback );
4258
+
4259
+ this._trigger( new IEvent( name, value, e ), callback );
4136
4260
  });
4137
4261
 
4138
- element.appendChild(wValue);
4262
+ element.appendChild( wValue );
4139
4263
 
4140
4264
  // Remove branch padding and margins
4141
- if(!widget.name) {
4265
+ if( !widget.name )
4266
+ {
4142
4267
  wValue.className += " noname";
4143
4268
  wValue.style.width = "100%";
4144
4269
  }
@@ -4164,7 +4289,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4164
4289
  let container = document.createElement('div');
4165
4290
  container.className = "lexcombobuttons ";
4166
4291
  if( options.float ) container.className += options.float;
4167
- container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4292
+ container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4168
4293
 
4169
4294
  let should_select = !(options.noSelection ?? false);
4170
4295
  for( let b of values )
@@ -4177,24 +4302,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4177
4302
  if(options.buttonClass)
4178
4303
  buttonEl.classList.add(options.buttonClass);
4179
4304
 
4180
- if(options.selected == b.value)
4305
+ if(options.selected == b.value)
4181
4306
  buttonEl.classList.add("selected");
4182
-
4307
+
4183
4308
  buttonEl.innerHTML = (b.icon ? "<a class='" + b.icon +"'></a>" : "") + "<span>" + (b.icon ? "" : b.value) + "</span>";
4184
-
4309
+
4185
4310
  if(options.disabled)
4186
4311
  buttonEl.setAttribute("disabled", true);
4187
-
4312
+
4188
4313
  buttonEl.addEventListener("click", function(e) {
4189
4314
  if(should_select) {
4190
4315
  container.querySelectorAll('button').forEach( s => s.classList.remove('selected'));
4191
4316
  this.classList.add('selected');
4192
4317
  }
4193
- that._trigger( new IEvent(name, b.value, e), b.callback );
4318
+ that._trigger( new IEvent(name, b.value, e), b.callback );
4194
4319
  });
4195
-
4320
+
4196
4321
  container.appendChild(buttonEl);
4197
-
4322
+
4198
4323
  // Remove branch padding and margins
4199
4324
  if(widget.name === undefined) {
4200
4325
  buttonEl.className += " noname";
@@ -4263,11 +4388,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4263
4388
  }
4264
4389
 
4265
4390
  container.appendChild(name_el);
4266
-
4391
+
4267
4392
  if( options.callback ) {
4268
4393
  container.style.cursor = "pointer";
4269
4394
  container.addEventListener("click", (e) => {
4270
- this._trigger( new IEvent(name, null, e), options.callback );
4395
+ this._trigger( new IEvent(name, null, e), options.callback );
4271
4396
  });
4272
4397
  }
4273
4398
 
@@ -4461,33 +4586,46 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4461
4586
  wValue.name = name;
4462
4587
  wValue.iValue = value;
4463
4588
 
4464
- // Add dropdown widget button
4589
+ // Add dropdown widget button
4465
4590
  let buttonName = value;
4466
4591
  buttonName += "<a class='fa-solid fa-angle-down' style='float:right; margin-right: 3px;'></a>";
4467
4592
 
4468
4593
  this.queue(container);
4469
4594
 
4470
- let selectedOption = this.addButton( null, buttonName, (value, event) => {
4471
- if( list.unfocus_event ) {
4595
+ const _getMaxListWidth = () => {
4596
+
4597
+ let maxWidth = 0;
4598
+ for( let i of values )
4599
+ {
4600
+ const iString = String( i );
4601
+ maxWidth = Math.max( iString.length, maxWidth );
4602
+ }
4603
+ return maxWidth * 9;
4604
+ };
4605
+
4606
+ let selectedOption = this.addButton( null, buttonName, ( value, event ) => {
4607
+ if( list.unfocus_event )
4608
+ {
4472
4609
  delete list.unfocus_event;
4473
4610
  return;
4474
4611
  }
4475
4612
  const topPosition = selectedOption.getBoundingClientRect().y;
4476
4613
  list.style.top = (topPosition + selectedOption.offsetHeight) + 'px';
4477
4614
  list.style.width = (event.currentTarget.clientWidth) + 'px';
4615
+ list.style.minWidth = (_getMaxListWidth()) + 'px';
4478
4616
  list.toggleAttribute('hidden');
4479
4617
  list.focus();
4480
4618
  }, { buttonClass: 'array', skipInlineCount: true });
4481
4619
 
4482
4620
  this.clearQueue();
4483
4621
 
4484
- selectedOption.style.width = "100%";
4622
+ selectedOption.style.width = "100%";
4485
4623
 
4486
4624
  selectedOption.refresh = (v) => {
4487
4625
  if(selectedOption.querySelector("span").innerText == "")
4488
4626
  selectedOption.querySelector("span").innerText = v;
4489
4627
  else
4490
- selectedOption.querySelector("span").innerHTML = selectedOption.querySelector("span").innerHTML.replaceAll(selectedOption.querySelector("span").innerText, v);
4628
+ selectedOption.querySelector("span").innerHTML = selectedOption.querySelector("span").innerHTML.replaceAll(selectedOption.querySelector("span").innerText, v);
4491
4629
  }
4492
4630
 
4493
4631
  // Add dropdown options container
@@ -4499,12 +4637,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4499
4637
  list.addEventListener( 'focusout', function( e ) {
4500
4638
  e.stopPropagation();
4501
4639
  e.stopImmediatePropagation();
4502
- if(e.relatedTarget === selectedOption.querySelector( 'button' )) {
4640
+ if( e.relatedTarget === selectedOption.querySelector( 'button' ) )
4641
+ {
4503
4642
  this.unfocus_event = true;
4504
4643
  setTimeout( () => delete this.unfocus_event, 200 );
4505
- } else if ( e.relatedTarget && e.relatedTarget.tagName == "INPUT" ) {
4644
+ }
4645
+ else if ( e.relatedTarget && e.relatedTarget.tagName == "INPUT" )
4646
+ {
4506
4647
  return;
4507
- }else if ( e.target.id == 'lexinput-filter' ) {
4648
+ }
4649
+ else if ( e.target.className == 'lexinput-filter' )
4650
+ {
4508
4651
  return;
4509
4652
  }
4510
4653
  this.toggleAttribute( 'hidden', true );
@@ -4513,28 +4656,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4513
4656
  // Add filter options
4514
4657
  let filter = null;
4515
4658
  if(options.filter ?? false)
4659
+ {
4516
4660
  filter = this._addFilter("Search option", {container: list, callback: this._search_options.bind(list, values)});
4661
+ }
4517
4662
 
4518
4663
  // Create option list to empty it easily..
4519
- const list_options = document.createElement('span');
4520
- list.appendChild(list_options);
4521
-
4522
- if( filter ) {
4523
- list.prepend(filter);
4524
- list_options.style.height = "calc(100% - 25px)";
4525
-
4526
- filter.addEventListener('focusout', function(e) {
4664
+ const listOptions = document.createElement('span');
4665
+ list.appendChild( listOptions );
4666
+
4667
+ if( filter )
4668
+ {
4669
+ list.prepend( filter );
4670
+ listOptions.style.height = "calc(100% - 25px)";
4671
+
4672
+ filter.addEventListener('focusout', function( e ) {
4527
4673
  if (e.relatedTarget && e.relatedTarget.tagName == "UL" && e.relatedTarget.classList.contains("lexoptions"))
4674
+ {
4528
4675
  return;
4529
- list.toggleAttribute('hidden', true);
4676
+ }
4677
+ list.toggleAttribute( 'hidden', true );
4530
4678
  });
4531
4679
  }
4532
4680
 
4533
4681
  // Add dropdown options list
4534
- list.refresh = (options) => {
4682
+ list.refresh = options => {
4535
4683
 
4536
4684
  // Empty list
4537
- list_options.innerHTML = "";
4685
+ listOptions.innerHTML = "";
4538
4686
 
4539
4687
  for(let i = 0; i < options.length; i++)
4540
4688
  {
@@ -4554,7 +4702,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4554
4702
 
4555
4703
  let btn = element.querySelector(".lexwidgetname .lexicon");
4556
4704
  if(btn) btn.style.display = (value != wValue.iValue ? "block" : "none");
4557
- that._trigger( new IEvent(name, value, null), callback );
4705
+ that._trigger( new IEvent(name, value, null), callback );
4558
4706
 
4559
4707
  // Reset filter
4560
4708
  if(filter)
@@ -4593,18 +4741,20 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4593
4741
  option.setAttribute("title", iValue.value);
4594
4742
  if(value == iValue.value)
4595
4743
  li.classList.add("selected");
4596
- }
4597
- list_options.appendChild(li);
4744
+ }
4745
+
4746
+ listOptions.appendChild( li );
4598
4747
  }
4599
4748
  }
4600
4749
 
4601
- list.refresh(values);
4750
+ list.refresh( values );
4602
4751
 
4603
- container.appendChild(list);
4604
- element.appendChild(container);
4752
+ container.appendChild( list );
4753
+ element.appendChild( container );
4605
4754
 
4606
4755
  // Remove branch padding and margins
4607
- if(!widget.name) {
4756
+ if( !widget.name )
4757
+ {
4608
4758
  element.className += " noname";
4609
4759
  container.style.width = "100%";
4610
4760
  }
@@ -4748,7 +4898,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4748
4898
  for(var i = 0; i < (16 - nbits); ++i) {
4749
4899
  binary = '0' + binary;
4750
4900
  }
4751
-
4901
+
4752
4902
  for( let bit = 0; bit < 16; ++bit )
4753
4903
  {
4754
4904
  let layer = document.createElement('div');
@@ -4756,32 +4906,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4756
4906
  if( value != undefined )
4757
4907
  {
4758
4908
  const valueBit = binary[ 16 - bit - 1 ];
4759
- if(valueBit != undefined && valueBit == '1')
4760
- layer.classList.add('selected');
4909
+ if(valueBit != undefined && valueBit == '1')
4910
+ layer.classList.add('selected');
4761
4911
  }
4762
4912
  layer.innerText = bit + 1;
4763
4913
  layer.title = "Bit " + bit + ", value " + (1 << bit);
4764
4914
  container.appendChild( layer );
4765
-
4915
+
4766
4916
  layer.addEventListener("click", e => {
4767
-
4917
+
4768
4918
  e.stopPropagation();
4769
4919
  e.stopImmediatePropagation();
4770
4920
  e.target.classList.toggle('selected');
4771
4921
  value ^= ( 1 << bit );
4772
4922
  element.value = value;
4773
-
4923
+
4774
4924
  let btn = element.querySelector(".lexwidgetname .lexicon");
4775
4925
  if(btn) btn.style.display = (value != defaultValue ? "block" : "none");
4776
-
4926
+
4777
4927
  this._trigger( new IEvent(name, value, e), callback );
4778
4928
  });
4779
4929
  }
4780
-
4930
+
4781
4931
  };
4782
4932
 
4783
4933
  setLayers();
4784
-
4934
+
4785
4935
  element.appendChild(container);
4786
4936
 
4787
4937
  return widget;
@@ -4826,7 +4976,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4826
4976
  var container = document.createElement('div');
4827
4977
  container.className = "lexarray";
4828
4978
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4829
-
4979
+
4830
4980
  this.queue( container );
4831
4981
 
4832
4982
  const angle_down = `<a class='fa-solid fa-angle-down' style='float:right; margin-right: 3px;'></a>`;
@@ -4836,7 +4986,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4836
4986
  this.addButton(null, buttonName, () => {
4837
4987
  element.querySelector(".lexarrayitems").toggleAttribute('hidden');
4838
4988
  }, { buttonClass: 'array' });
4839
-
4989
+
4840
4990
  this.clearQueue();
4841
4991
 
4842
4992
  // Show elements
@@ -4844,7 +4994,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4844
4994
  let array_items = document.createElement('div');
4845
4995
  array_items.className = "lexarrayitems";
4846
4996
  array_items.toggleAttribute('hidden', true);
4847
-
4997
+
4848
4998
  element.appendChild(container);
4849
4999
  element.appendChild(array_items);
4850
5000
 
@@ -4925,7 +5075,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4925
5075
  addList( name, values, value, callback, options = {} ) {
4926
5076
 
4927
5077
  let widget = this.create_widget( name, Widget.LIST, options );
4928
-
5078
+
4929
5079
  widget.onGetValue = () => {
4930
5080
  return value;
4931
5081
  };
@@ -4937,56 +5087,56 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4937
5087
  value = newValue;
4938
5088
  if( !skipCallback ) this._trigger( new IEvent( name, newValue ), callback );
4939
5089
  };
4940
-
5090
+
4941
5091
  widget.updateValues = ( newValues ) => {
4942
-
5092
+
4943
5093
  values = newValues;
4944
5094
  listContainer.innerHTML = "";
4945
-
5095
+
4946
5096
  for( let i = 0; i < values.length; ++i )
4947
5097
  {
4948
5098
  let icon = null;
4949
5099
  let itemValue = values[ i ];
4950
-
5100
+
4951
5101
  if( itemValue.constructor === Array )
4952
5102
  {
4953
5103
  icon = itemValue[ 1 ];
4954
5104
  itemValue = itemValue[ 0 ];
4955
5105
  }
4956
-
5106
+
4957
5107
  let listElement = document.createElement( 'div' );
4958
5108
  listElement.className = "lexlistitem" + ( value == itemValue ? " selected" : "" );
4959
5109
  listElement.innerHTML = "<span>" + itemValue + "</span>" + ( icon ? "<a class='" + icon + "'></a>" : "" );
4960
-
5110
+
4961
5111
  listElement.addEventListener( 'click', e => {
4962
5112
  listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
4963
5113
  listElement.classList.toggle( 'selected' );
4964
5114
  value = itemValue;
4965
5115
  this._trigger( new IEvent( name, itemValue, e ), callback );
4966
5116
  });
4967
-
5117
+
4968
5118
  listContainer.appendChild( listElement );
4969
5119
  }
4970
5120
  };
4971
-
5121
+
4972
5122
  let element = widget.domEl;
4973
-
5123
+
4974
5124
  // Show list
4975
-
5125
+
4976
5126
  let listContainer = document.createElement( 'div' );
4977
5127
  listContainer.className = "lexlist";
4978
5128
  listContainer.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4979
-
5129
+
4980
5130
  widget.updateValues( values );
4981
-
5131
+
4982
5132
  // Remove branch padding and margins
4983
5133
  if( !widget.name ) {
4984
5134
  element.className += " noname";
4985
5135
  listContainer.style.width = "100%";
4986
5136
  }
4987
-
5137
+
4988
5138
  element.appendChild( listContainer );
4989
-
5139
+
4990
5140
  return widget;
4991
5141
  }
4992
5142
 
@@ -5038,14 +5188,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5038
5188
  const create_tags = () => {
5039
5189
 
5040
5190
  tags_container.innerHTML = "";
5041
-
5191
+
5042
5192
  for( let i = 0; i < value.length; ++i )
5043
5193
  {
5044
5194
  let tag_name = value[i];
5045
5195
  let tag = document.createElement('span');
5046
5196
  tag.className = "lextag";
5047
5197
  tag.innerHTML = tag_name;
5048
-
5198
+
5049
5199
  tag.addEventListener('click', function( e ) {
5050
5200
  this.remove();
5051
5201
  value.splice( value.indexOf( tag_name ), 1 );
@@ -5053,18 +5203,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5053
5203
  if( btn ) btn.style.display = ( value != defaultValue ? "block" : "none" );
5054
5204
  that._trigger( new IEvent( name, value, e ), callback );
5055
5205
  });
5056
-
5206
+
5057
5207
  tags_container.appendChild( tag );
5058
5208
  }
5059
-
5209
+
5060
5210
  let tag_input = document.createElement( 'input' );
5061
5211
  tag_input.value = "";
5062
5212
  tag_input.placeholder = "Tag...";
5063
5213
  tags_container.insertChildAtIndex( tag_input, 0 );
5064
-
5214
+
5065
5215
  tag_input.onkeydown = function( e ) {
5066
5216
  const val = this.value.replace(/\s/g, '');
5067
- if( e.key == ' ') {
5217
+ if( e.key == ' ') {
5068
5218
  e.preventDefault();
5069
5219
  if( !val.length || value.indexOf( val ) > -1 )
5070
5220
  return;
@@ -5075,7 +5225,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5075
5225
  that._trigger( new IEvent( name, value, e ), callback );
5076
5226
  }
5077
5227
  };
5078
-
5228
+
5079
5229
  tag_input.focus();
5080
5230
  }
5081
5231
 
@@ -5107,9 +5257,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5107
5257
  if( !name ) {
5108
5258
  throw( "Set Widget Name!" );
5109
5259
  }
5110
-
5260
+
5111
5261
  let widget = this.create_widget( name, Widget.CHECKBOX, options );
5112
-
5262
+
5113
5263
  widget.onGetValue = () => {
5114
5264
  return flag.value;
5115
5265
  };
@@ -5117,14 +5267,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5117
5267
  if( flag.value !== newValue )
5118
5268
  Panel._dispatch_event( toggle, "click", skipCallback );
5119
5269
  };
5120
-
5270
+
5121
5271
  let element = widget.domEl;
5122
-
5272
+
5123
5273
  // Add reset functionality
5124
5274
  Panel._add_reset_property( element.domName, function() {
5125
5275
  Panel._dispatch_event( toggle, "click" );
5126
5276
  });
5127
-
5277
+
5128
5278
  // Add widget value
5129
5279
 
5130
5280
  var container = document.createElement('div');
@@ -5158,29 +5308,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5158
5308
  let flag = toggle.querySelector( ".checkbox" );
5159
5309
  if( flag.disabled )
5160
5310
  return;
5161
-
5311
+
5162
5312
  const skipCallback = ( e.detail.constructor == Number ? null : e.detail );
5163
5313
 
5164
5314
  let check = toggle.querySelector( ".checkbox a" );
5165
-
5315
+
5166
5316
  flag.value = !flag.value;
5167
5317
  flag.className = "checkbox " + ( flag.value ? "on" : "" );
5168
5318
  check.style.display = flag.value ? "block" : "none";
5169
-
5319
+
5170
5320
  // Reset button (default value)
5171
5321
  if( !skipCallback )
5172
5322
  {
5173
5323
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
5174
5324
  if( btn ) btn.style.display = flag.value != flag.iValue ? "block": "none";
5175
5325
  }
5176
-
5326
+
5177
5327
  // Open suboptions
5178
5328
  let submenu = element.querySelector( ".lexcheckboxsubmenu" );
5179
5329
  if( submenu ) submenu.toggleAttribute( 'hidden', !flag.value );
5180
-
5330
+
5181
5331
  if( !skipCallback ) this._trigger( new IEvent( name, flag.value, e ), callback );
5182
5332
  });
5183
-
5333
+
5184
5334
  element.appendChild( container );
5185
5335
 
5186
5336
  if( options.suboptions )
@@ -5215,9 +5365,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5215
5365
  if( !name ) {
5216
5366
  throw( "Set Widget Name!" );
5217
5367
  }
5218
-
5368
+
5219
5369
  let widget = this.create_widget( name, Widget.COLOR, options );
5220
-
5370
+
5221
5371
  widget.onGetValue = () => {
5222
5372
  return color.value;
5223
5373
  };
@@ -5225,23 +5375,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5225
5375
  color.value = newValue;
5226
5376
  Panel._dispatch_event( color, "input", skipCallback );
5227
5377
  };
5228
-
5378
+
5229
5379
  let element = widget.domEl;
5230
5380
  let change_from_input = false;
5231
-
5381
+
5232
5382
  // Add reset functionality
5233
5383
  Panel._add_reset_property( element.domName, function() {
5234
5384
  this.style.display = "none";
5235
5385
  color.value = color.iValue;
5236
5386
  Panel._dispatch_event( color, "input" );
5237
5387
  });
5238
-
5388
+
5239
5389
  // Add widget value
5240
-
5390
+
5241
5391
  var container = document.createElement( 'span' );
5242
5392
  container.className = "lexcolor";
5243
5393
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5244
-
5394
+
5245
5395
  let color = document.createElement( 'input' );
5246
5396
  color.style.width = "32px";
5247
5397
  color.type = 'color';
@@ -5249,49 +5399,49 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5249
5399
  color.id = "color" + simple_guidGenerator();
5250
5400
  color.useRGB = options.useRGB ?? false;
5251
5401
  color.value = color.iValue = value.constructor === Array ? rgbToHex( value ) : value;
5252
-
5402
+
5253
5403
  if( options.disabled ) {
5254
5404
  color.disabled = true;
5255
5405
  }
5256
-
5406
+
5257
5407
  color.addEventListener( "input", e => {
5258
5408
  let val = e.target.value;
5259
-
5409
+
5260
5410
  const skipCallback = e.detail;
5261
-
5411
+
5262
5412
  // Change value (always hex)
5263
5413
  if( !change_from_input )
5264
5414
  text_widget.set( val );
5265
-
5415
+
5266
5416
  // Reset button (default value)
5267
5417
  if( !skipCallback )
5268
5418
  {
5269
5419
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
5270
5420
  if( btn ) btn.style.display = val != color.iValue ? "block": "none";
5271
5421
  }
5272
-
5422
+
5273
5423
  if( color.useRGB )
5274
5424
  val = hexToRgb( val );
5275
-
5425
+
5276
5426
  if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
5277
5427
  }, false );
5278
-
5428
+
5279
5429
  container.appendChild( color );
5280
-
5430
+
5281
5431
  this.queue( container );
5282
-
5432
+
5283
5433
  const text_widget = this.addText( null, color.value, v => {
5284
5434
  change_from_input = true;
5285
5435
  widget.set( v );
5286
5436
  change_from_input = false;
5287
5437
  }, { width: "calc( 100% - 32px )"});
5288
-
5438
+
5289
5439
  text_widget.domEl.style.marginLeft = "4px";
5290
-
5440
+
5291
5441
  this.clearQueue();
5292
-
5442
+
5293
5443
  element.appendChild( container );
5294
-
5444
+
5295
5445
  return widget;
5296
5446
  }
5297
5447
 
@@ -5338,7 +5488,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5338
5488
  // add widget value
5339
5489
 
5340
5490
  var container = document.createElement( 'div' );
5341
- container.className = "lexnumber";
5491
+ container.className = "lexnumber";
5342
5492
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5343
5493
 
5344
5494
  let box = document.createElement( 'div' );
@@ -5473,7 +5623,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5473
5623
 
5474
5624
  if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
5475
5625
  }, { passive: false });
5476
-
5626
+
5477
5627
  // Add drag input
5478
5628
 
5479
5629
  vecinput.addEventListener( "mousedown", inner_mousedown );
@@ -5542,7 +5692,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5542
5692
  options.onRelease.bind( vecinput )( e, vecinput );
5543
5693
  }
5544
5694
  }
5545
-
5695
+
5546
5696
  container.appendChild( box );
5547
5697
  element.appendChild( container );
5548
5698
 
@@ -5609,7 +5759,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5609
5759
  // Add widget value
5610
5760
 
5611
5761
  var container = document.createElement( 'div' );
5612
- container.className = "lexvector";
5762
+ container.className = "lexvector";
5613
5763
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5614
5764
 
5615
5765
  for( let i = 0; i < num_components; ++i ) {
@@ -5702,7 +5852,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5702
5852
 
5703
5853
  if( !skipCallback ) this._trigger( new IEvent( name, value, e ), callback );
5704
5854
  }, false );
5705
-
5855
+
5706
5856
  // Add drag input
5707
5857
 
5708
5858
  vecinput.addEventListener( "mousedown", inner_mousedown );
@@ -5806,7 +5956,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5806
5956
  }
5807
5957
 
5808
5958
  let locker = document.createElement( 'a' );
5809
- locker.className = "fa-solid fa-lock-open lexicon";
5959
+ locker.title = "Lock";
5960
+ locker.className = "fa-solid fa-lock-open lexicon lock";
5810
5961
  container.appendChild( locker );
5811
5962
  locker.addEventListener( "click", function( e ) {
5812
5963
  this.locked = !this.locked;
@@ -5820,7 +5971,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5820
5971
  this.classList.remove( "fa-lock" );
5821
5972
  }
5822
5973
  }, false );
5823
-
5974
+
5824
5975
  element.appendChild( container );
5825
5976
 
5826
5977
  return widget;
@@ -5829,7 +5980,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5829
5980
  /**
5830
5981
  * @method addVector N (2, 3, 4)
5831
5982
  * @param {String} name Widget name
5832
- * @param {Array} value Array of N components
5983
+ * @param {Array} value Array of N components
5833
5984
  * @param {Function} callback Callback function on change
5834
5985
  * @param {*} options:
5835
5986
  * disabled: Make the widget disabled [false]
@@ -5888,18 +6039,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5888
6039
 
5889
6040
  this.queue( element );
5890
6041
 
6042
+ element.aspectRatio = ( value.length == 2 ? value[ 0 ] / value[ 1 ] : null );
5891
6043
  element.dimensions = [];
5892
6044
 
5893
6045
  for( let i = 0; i < value.length; ++i )
5894
6046
  {
5895
- const size = measureRealWidth( JSON.stringify( value[ i ] ), 24 ) + 'px';
5896
6047
  element.dimensions[ i ] = this.addNumber( null, value[ i ], ( v ) => {
5897
6048
 
5898
- const value = [];
6049
+ const value = widget.onGetValue();
5899
6050
 
5900
- for( let i = 0; i < element.dimensions.length; ++i )
6051
+ if( element.locked )
5901
6052
  {
5902
- value.push( element.dimensions[ i ].onGetValue() );
6053
+ const ar = ( i == 0 ? 1.0 / element.aspectRatio : element.aspectRatio );
6054
+ const index = ( 1 + i ) % 2;
6055
+ value[ index ] = v * ar;
6056
+ element.dimensions[ index ].onSetValue( value[ index ], true );
5903
6057
  }
5904
6058
 
5905
6059
  if( callback )
@@ -5907,7 +6061,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5907
6061
  callback( value );
5908
6062
  }
5909
6063
 
5910
- }, { width: size, min: 0, disabled: options.disabled } );
6064
+ }, { min: 0, disabled: options.disabled, precision: options.precision } );
5911
6065
 
5912
6066
  if( ( i + 1 ) != value.length )
5913
6067
  {
@@ -5927,6 +6081,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5927
6081
  element.appendChild( unitSpan );
5928
6082
  }
5929
6083
 
6084
+ // Lock aspect ratio
6085
+ if( element.aspectRatio )
6086
+ {
6087
+ let locker = document.createElement( 'a' );
6088
+ locker.title = "Lock Aspect Ratio";
6089
+ locker.className = "fa-solid fa-lock-open lexicon lock";
6090
+ element.appendChild( locker );
6091
+ locker.addEventListener( "click", function( e ) {
6092
+ element.locked = !element.locked;
6093
+ if( element.locked )
6094
+ {
6095
+ this.classList.add( "fa-lock" );
6096
+ this.classList.remove( "fa-lock-open" );
6097
+
6098
+ // Recompute ratio
6099
+ const value = widget.onGetValue();
6100
+ element.aspectRatio = value[ 0 ] / value[ 1 ];
6101
+ }
6102
+ else
6103
+ {
6104
+ this.classList.add( "fa-lock-open" );
6105
+ this.classList.remove( "fa-lock" );
6106
+ }
6107
+ }, false );
6108
+ }
6109
+
5930
6110
  // Remove branch padding and margins
5931
6111
  if( !widget.name )
5932
6112
  {
@@ -5940,11 +6120,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5940
6120
  /**
5941
6121
  * @method addPad
5942
6122
  * @param {String} name Widget name
5943
- * @param {Number} value Pad value
6123
+ * @param {Array} value Pad value
5944
6124
  * @param {Function} callback Callback function on change
5945
6125
  * @param {*} options:
5946
6126
  * disabled: Make the widget disabled [false]
5947
6127
  * min, max: Min and Max values
6128
+ * padSize: Size of the pad (css)
5948
6129
  * onPress: Callback function on mouse down
5949
6130
  * onRelease: Callback function on mouse up
5950
6131
  */
@@ -6065,7 +6246,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6065
6246
  /**
6066
6247
  * @method addProgress
6067
6248
  * @param {String} name Widget name
6068
- * @param {Number} value Progress value
6249
+ * @param {Number} value Progress value
6069
6250
  * @param {*} options:
6070
6251
  * min, max: Min and Max values
6071
6252
  * low, optimum, high: Low and High boundary values, Optimum point in the range
@@ -6076,7 +6257,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6076
6257
 
6077
6258
  addProgress( name, value, options = {} ) {
6078
6259
 
6079
- if(!name) {
6260
+ if( !name )
6261
+ {
6080
6262
  throw("Set Widget Name!");
6081
6263
  }
6082
6264
 
@@ -6106,47 +6288,75 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6106
6288
  progress.min = options.min ?? 0;
6107
6289
  progress.max = options.max ?? 1;
6108
6290
  progress.value = value;
6109
-
6110
- if(options.low)
6291
+
6292
+ if( options.low )
6111
6293
  progress.low = options.low;
6112
- if(options.high)
6294
+ if( options.high )
6113
6295
  progress.high = options.high;
6114
- if(options.optimum)
6296
+ if( options.optimum )
6115
6297
  progress.optimum = options.optimum;
6116
6298
 
6117
- container.appendChild(progress);
6118
- element.appendChild(container);
6299
+ container.appendChild( progress );
6300
+ element.appendChild( container );
6119
6301
 
6120
- if(options.showValue) {
6121
- if(document.getElementById('progressvalue-' + name ))
6302
+ if( options.showValue )
6303
+ {
6304
+ if( document.getElementById('progressvalue-' + name ) )
6305
+ {
6122
6306
  document.getElementById('progressvalue-' + name ).remove();
6307
+ }
6308
+
6123
6309
  let span = document.createElement("span");
6124
6310
  span.id = "progressvalue-" + name;
6125
6311
  span.style.padding = "0px 5px";
6126
6312
  span.innerText = value;
6127
- container.appendChild(span);
6313
+ container.appendChild( span );
6128
6314
  }
6129
6315
 
6130
- if(options.editable) {
6131
- progress.classList.add("editable");
6132
- progress.addEventListener("mousemove", inner_mousemove.bind(this, value));
6133
- progress.addEventListener("mouseup", inner_mouseup.bind(this, progress));
6316
+ if( options.editable )
6317
+ {
6318
+ progress.classList.add( "editable" );
6319
+ progress.addEventListener( "mousedown", inner_mousedown );
6134
6320
 
6135
- function inner_mousemove(value, e) {
6136
-
6137
- if(e.which < 1)
6138
- return;
6139
- let v = this.getValue(name, value);
6140
- v+=e.movementX/100;
6141
- v = v.toFixed(2);
6142
- this.setValue(name, v);
6321
+ var that = this;
6143
6322
 
6144
- if(options.callback)
6145
- options.callback(v, e);
6323
+ function inner_mousedown( e )
6324
+ {
6325
+ var doc = that.root.ownerDocument;
6326
+ doc.addEventListener( 'mousemove', inner_mousemove );
6327
+ doc.addEventListener( 'mouseup', inner_mouseup );
6328
+ document.body.classList.add( 'noevents' );
6329
+ e.stopImmediatePropagation();
6330
+ e.stopPropagation();
6146
6331
  }
6147
6332
 
6148
- function inner_mouseup(el) {
6149
- el.removeEventListener("mousemove", inner_mousemove);
6333
+ function inner_mousemove( e )
6334
+ {
6335
+ let dt = -e.movementX;
6336
+
6337
+ if ( dt != 0 )
6338
+ {
6339
+ let v = that.getValue( name, value );
6340
+ v += e.movementX / 100;
6341
+ v = round( v );
6342
+ that.setValue( name, v );
6343
+
6344
+ if( options.callback )
6345
+ {
6346
+ options.callback( v, e );
6347
+ }
6348
+ }
6349
+
6350
+ e.stopPropagation();
6351
+ e.preventDefault();
6352
+ }
6353
+
6354
+ function inner_mouseup( e )
6355
+ {
6356
+ var doc = that.root.ownerDocument;
6357
+ doc.removeEventListener( 'mousemove', inner_mousemove );
6358
+ doc.removeEventListener( 'mouseup', inner_mouseup );
6359
+ document.body.classList.remove( 'noevents' );
6150
6360
  }
6151
6361
  }
6152
6362
 
@@ -6165,65 +6375,75 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6165
6375
 
6166
6376
  addFile( name, callback, options = { } ) {
6167
6377
 
6168
- if( !name ) {
6378
+ if( !name )
6379
+ {
6169
6380
  throw( "Set Widget Name!" );
6170
6381
  }
6171
-
6382
+
6172
6383
  let widget = this.create_widget( name, Widget.FILE, options );
6173
6384
  let element = widget.domEl;
6174
-
6385
+
6175
6386
  let local = options.local ?? true;
6176
6387
  let type = options.type ?? 'text';
6177
- let read = options.read ?? true;
6178
-
6388
+ let read = options.read ?? true;
6389
+
6179
6390
  // Create hidden input
6180
6391
  let input = document.createElement( 'input' );
6181
6392
  input.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " - 10%)";
6182
6393
  input.type = 'file';
6183
-
6394
+
6184
6395
  if( options.placeholder )
6396
+ {
6185
6397
  input.placeholder = options.placeholder;
6186
-
6398
+ }
6399
+
6187
6400
  input.addEventListener( 'change', function( e ) {
6188
-
6401
+
6189
6402
  const files = e.target.files;
6190
6403
  if( !files.length ) return;
6191
6404
  if( read )
6192
6405
  {
6193
6406
  if( options.onBeforeRead )
6194
6407
  options.onBeforeRead();
6195
-
6408
+
6196
6409
  const reader = new FileReader();
6197
-
6410
+
6198
6411
  if( type === 'text' ) reader.readAsText( files[ 0 ] );
6199
6412
  else if( type === 'buffer' ) reader.readAsArrayBuffer( files[ 0 ] );
6200
6413
  else if( type === 'bin' ) reader.readAsBinaryString( files[ 0 ] );
6201
6414
  else if( type === 'url' ) reader.readAsDataURL( files[ 0 ] );
6202
-
6415
+
6203
6416
  reader.onload = e => { callback.call( this, e.target.result, files[ 0 ] ) } ;
6204
6417
  }
6205
6418
  else
6206
6419
  callback( files[ 0 ] );
6207
6420
  });
6208
-
6421
+
6209
6422
  element.appendChild( input );
6210
-
6423
+
6211
6424
  this.queue( element );
6212
-
6425
+
6213
6426
  if( local )
6214
6427
  {
6428
+ let settingsDialog = null;
6429
+
6215
6430
  this.addButton(null, "<a style='margin-top: 0px;' class='fa-solid fa-gear'></a>", () => {
6216
-
6217
- new Dialog( "Load Settings", p => {
6431
+
6432
+ if( settingsDialog )
6433
+ {
6434
+ return;
6435
+ }
6436
+
6437
+ settingsDialog = new Dialog( "Load Settings", p => {
6218
6438
  p.addDropdown( "Type", [ 'text', 'buffer', 'bin', 'url' ], type, v => { type = v } );
6219
6439
  p.addButton( null, "Reload", v => { input.dispatchEvent( new Event( 'change' ) ) } );
6220
- });
6221
-
6222
- }, { className: "micro", skipInlineCount: true });
6440
+ }, { onclose: ( root ) => { root.remove(); settingsDialog = null; } } );
6441
+
6442
+ }, { className: "micro", skipInlineCount: true, title: "Settings" });
6223
6443
  }
6224
-
6444
+
6225
6445
  this.clearQueue();
6226
-
6446
+
6227
6447
  return widget;
6228
6448
  }
6229
6449
 
@@ -6281,7 +6501,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6281
6501
  node_filter_input.addEventListener('input', function(){
6282
6502
  nodeTree.refresh();
6283
6503
  });
6284
-
6504
+
6285
6505
  let searchIcon = document.createElement('a');
6286
6506
  searchIcon.className = "lexicon fa-solid fa-magnifying-glass";
6287
6507
  toolsDiv.appendChild(node_filter_input);
@@ -6315,11 +6535,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6315
6535
  element.className = "lexseparator";
6316
6536
  let widget = new Widget( null, Widget.SEPARATOR );
6317
6537
  widget.domEl = element;
6318
-
6538
+
6319
6539
  if(this.current_branch) {
6320
6540
  this.current_branch.content.appendChild( element );
6321
6541
  this.current_branch.widgets.push( widget );
6322
- } else
6542
+ } else
6323
6543
  this.root.appendChild(element);
6324
6544
  }
6325
6545
 
@@ -6331,7 +6551,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6331
6551
  * onCreate: Func to be called at tab creation
6332
6552
  * onSelect: Func to be called on select tab (optional)
6333
6553
  * }
6334
- * @param {*} options
6554
+ * @param {*} options
6335
6555
  * vertical: Use vertical or horizontal tabs (vertical by default)
6336
6556
  * showNames: Show tab name only in horizontal tabs
6337
6557
  */
@@ -6413,7 +6633,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6413
6633
  this.clearQueue();
6414
6634
  }
6415
6635
  }
6416
-
6636
+
6417
6637
  this.addSeparator();
6418
6638
  }
6419
6639
  }
@@ -6425,7 +6645,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6425
6645
  */
6426
6646
 
6427
6647
  class Branch {
6428
-
6648
+
6429
6649
  constructor( name, options = {} ) {
6430
6650
 
6431
6651
  this.name = name;
@@ -6540,23 +6760,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6540
6760
 
6541
6761
  _addBranchSeparator() {
6542
6762
 
6543
- var element = document.createElement('div');
6763
+ const element = document.createElement('div');
6544
6764
  element.className = "lexwidgetseparator";
6545
6765
  element.style.width = "100%";
6546
6766
  element.style.background = "none";
6547
6767
 
6548
- var grabber = document.createElement('div');
6768
+ const grabber = document.createElement('div');
6549
6769
  grabber.innerHTML = "&#9662;";
6550
- grabber.style.marginLeft = LX.DEFAULT_NAME_WIDTH;
6551
6770
  element.appendChild(grabber);
6552
6771
 
6553
- var line = document.createElement('div');
6772
+ doAsync( () => {
6773
+ grabber.style.marginLeft = ((parseFloat(LX.DEFAULT_NAME_WIDTH) / 100.0) * this.content.offsetWidth) + "px";
6774
+ }, 10 )
6775
+
6776
+ const line = document.createElement('div');
6554
6777
  line.style.width = "1px";
6555
6778
  line.style.marginLeft = "6px";
6556
6779
  line.style.marginTop = "2px";
6557
6780
  line.style.height = "0px"; // get in time
6558
- grabber.appendChild(line);
6559
- grabber.addEventListener("mousedown", inner_mousedown);
6781
+ grabber.appendChild( line );
6782
+ grabber.addEventListener( "mousedown", innerMouseDown );
6560
6783
 
6561
6784
  this.grabber = grabber;
6562
6785
 
@@ -6564,45 +6787,40 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6564
6787
  return that.root.offsetHeight - that.root.children[0].offsetHeight;
6565
6788
  }
6566
6789
 
6567
- var that = this;
6568
- var lastX = 0;
6569
- var lastXLine = 0;
6570
- function inner_mousedown(e)
6790
+ let that = this;
6791
+
6792
+ function innerMouseDown( e )
6571
6793
  {
6572
6794
  var doc = that.root.ownerDocument;
6573
- doc.addEventListener("mouseup",inner_mouseup);
6574
- doc.addEventListener("mousemove",inner_mousemove);
6575
- lastX = e.pageX;
6576
- lastXLine = e.pageX;
6795
+ doc.addEventListener("mouseup", innerMouseUp);
6796
+ doc.addEventListener("mousemove", innerMouseMove);
6577
6797
  e.stopPropagation();
6578
6798
  e.preventDefault();
6579
- var h = getBranchHeight();
6799
+ const h = getBranchHeight();
6580
6800
  line.style.height = (h-3) + "px";
6581
6801
  document.body.classList.add('nocursor');
6582
6802
  }
6583
-
6584
- function inner_mousemove(e)
6803
+
6804
+ function innerMouseMove(e)
6585
6805
  {
6586
- if (lastXLine != e.pageX) {
6587
- var dt = lastXLine - e.pageX;
6588
- var margin = parseFloat( grabber.style.marginLeft );
6589
- grabber.style.marginLeft = clamp(margin - dt * 0.1, 10, 90) + "%";
6590
- }
6806
+ let dt = e.movementX;
6591
6807
 
6592
- lastXLine = e.pageX;
6808
+ if ( dt != 0 )
6809
+ {
6810
+ const margin = parseFloat( grabber.style.marginLeft );
6811
+ grabber.style.marginLeft = clamp( margin + dt, 32, that.content.offsetWidth - 32 ) + "px";
6812
+ }
6593
6813
  }
6594
6814
 
6595
- function inner_mouseup(e)
6815
+ function innerMouseUp(e)
6596
6816
  {
6597
- if (lastX != e.pageX)
6598
- that._updateWidgets();
6599
- lastX = e.pageX;
6600
- lastXLine = e.pageX;
6817
+ that._updateWidgets();
6818
+
6601
6819
  line.style.height = "0px";
6602
6820
 
6603
6821
  var doc = that.root.ownerDocument;
6604
- doc.removeEventListener("mouseup",inner_mouseup);
6605
- doc.removeEventListener("mousemove",inner_mousemove);
6822
+ doc.removeEventListener("mouseup", innerMouseUp);
6823
+ doc.removeEventListener("mousemove", innerMouseMove);
6606
6824
  document.body.classList.remove('nocursor');
6607
6825
  }
6608
6826
 
@@ -6662,7 +6880,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6662
6880
  static _last_id = 0;
6663
6881
 
6664
6882
  constructor( title, callback, options = {} ) {
6665
-
6883
+
6666
6884
  if( !callback )
6667
6885
  {
6668
6886
  console.warn("Content is empty, add some widgets using 'callback' parameter!");
@@ -6699,31 +6917,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6699
6917
  titleDiv.oncontextmenu = function(e) {
6700
6918
  e.preventDefault();
6701
6919
  e.stopPropagation();
6702
-
6920
+
6703
6921
  if(!LX.main_area || LX.main_area.type !== 'horizontal')
6704
6922
  return;
6705
6923
 
6706
6924
  addContextMenu("Dock", e, p => {
6707
6925
  e.preventDefault();
6708
-
6709
- const get_next_panel = function(area) {
6710
- let p = area.panels[0];
6926
+
6927
+ const _getNextPanel = function( area ) {
6928
+ let p = area.panels[ 0 ];
6711
6929
  if( p ) return p;
6712
6930
  for(var s of area.sections){
6713
- p = get_next_panel(s);
6931
+ p = _getNextPanel( s );
6714
6932
  if( p ) return p;
6715
6933
  }
6716
6934
  }
6717
6935
 
6718
- const append_branch = function(panel) {
6936
+ const _appendBranch = function( panel ) {
6719
6937
  let branch = panel.branches.find( b => b.name === title );
6720
- if( !branch ) {
6721
- panel.branch(title);
6722
- branch = panel.branches.find( b => b.name === title );
6723
- }else
6938
+ if( !branch )
6939
+ {
6940
+ panel.branch( title );
6941
+ branch = panel.branches.find( b => b.name === title );
6942
+ }
6943
+ else
6944
+ {
6724
6945
  panel.root.appendChild( branch.root );
6946
+ }
6725
6947
 
6726
- for( let w of that.widgets ) {
6948
+ for( let w of that.widgets )
6949
+ {
6727
6950
  branch.content.appendChild( w.domEl );
6728
6951
  }
6729
6952
 
@@ -6734,16 +6957,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6734
6957
  branch.root.classList.add('last');
6735
6958
  root.remove();
6736
6959
  }
6737
-
6960
+
6738
6961
  // Right
6739
- let rpanel = get_next_panel(LX.main_area.sections[1]);
6962
+ let rpanel = _getNextPanel(LX.main_area.sections[ 1 ]);
6740
6963
  p.add('<i class="fa-regular fa-window-maximize fa-window-maximize fa-rotate-90">', {disabled: !rpanel, id: 'dock_options0', callback: () => {
6741
- append_branch(rpanel);
6964
+ _appendBranch(rpanel);
6742
6965
  }});
6743
6966
  // Left
6744
- let lpanel = get_next_panel(LX.main_area.sections[0]);
6967
+ let lpanel = _getNextPanel(LX.main_area.sections[ 0 ]);
6745
6968
  p.add('<i class="fa-regular fa-window-maximize fa-window-maximize fa-rotate-270">', {disabled: !lpanel, id: 'dock_options1', callback: () => {
6746
- append_branch(lpanel);
6969
+ _appendBranch(lpanel);
6747
6970
  }});
6748
6971
  }, { icon: "fa-regular fa-window-restore" });
6749
6972
  };
@@ -6755,41 +6978,61 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6755
6978
  {
6756
6979
  this.close = () => {
6757
6980
 
6981
+ if( options.onBeforeClose )
6982
+ {
6983
+ options.onBeforeClose( this );
6984
+ }
6985
+
6758
6986
  if( !options.onclose )
6759
6987
  {
6760
6988
  that.panel.clear();
6761
6989
  root.remove();
6762
- } else
6990
+ }
6991
+ else
6763
6992
  {
6764
6993
  options.onclose( this.root );
6765
6994
  }
6766
6995
 
6767
- if(modal)
6768
- LX.modal.toggle(true);
6996
+ if( modal )
6997
+ {
6998
+ LX.modal.toggle( true );
6999
+ }
6769
7000
  };
6770
7001
 
6771
- var closeButton = document.createElement('a');
7002
+ var closeButton = document.createElement( 'a' );
6772
7003
  closeButton.className = "lexdialogcloser fa-solid fa-xmark";
6773
7004
  closeButton.title = "Close";
6774
- closeButton.addEventListener('click', this.close);
7005
+ closeButton.addEventListener( "click", this.close );
6775
7006
 
6776
- if(title) titleDiv.appendChild(closeButton);
6777
- else {
6778
- closeButton.classList.add("notitle");
6779
- root.appendChild(closeButton);
7007
+ if( title )
7008
+ {
7009
+ titleDiv.appendChild( closeButton );
7010
+ }
7011
+ else
7012
+ {
7013
+ closeButton.classList.add( "notitle" );
7014
+ root.appendChild( closeButton );
6780
7015
  }
6781
7016
  }
6782
7017
 
6783
7018
  const panel = new Panel();
6784
- panel.root.classList.add('lexdialogcontent');
6785
- if(!title) panel.root.classList.add('notitle');
6786
- if(callback)
6787
- callback.call(this, panel);
6788
- root.appendChild(panel.root);
7019
+ panel.root.classList.add( "lexdialogcontent" );
7020
+
7021
+ if( !title )
7022
+ {
7023
+ panel.root.classList.add( "notitle" );
7024
+ }
7025
+
7026
+ if( callback )
7027
+ {
7028
+ callback.call( this, panel );
7029
+ }
7030
+
7031
+ root.appendChild( panel.root );
6789
7032
 
6790
7033
  // Make branches have a distintive to manage some cases
6791
7034
  panel.root.querySelectorAll(".lexbranch").forEach( b => b.classList.add("dialog") );
6792
-
7035
+
6793
7036
  this.panel = panel;
6794
7037
  this.root = root;
6795
7038
  this.title = titleDiv;
@@ -6800,26 +7043,34 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6800
7043
  }
6801
7044
 
6802
7045
  // Process position and size
6803
- if(size.length && typeof(size[0]) != "string")
6804
- size[0] += "px";
6805
- if(size.length && typeof(size[1]) != "string")
6806
- size[1] += "px";
7046
+ if( size.length && typeof(size[ 0 ]) != "string" )
7047
+ {
7048
+ size[ 0 ] += "px";
7049
+ }
7050
+
7051
+ if( size.length && typeof(size[ 1 ]) != "string" )
7052
+ {
7053
+ size[ 1 ] += "px";
7054
+ }
6807
7055
 
6808
- root.style.width = size[0] ? (size[0]) : "25%";
6809
- root.style.height = size[1] ? (size[1]) : "auto";
7056
+ root.style.width = size[ 0 ] ? (size[ 0 ]) : "25%";
7057
+ root.style.height = size[ 1 ] ? (size[ 1 ]) : "auto";
7058
+
7059
+ if( options.size )
7060
+ {
7061
+ this.size = size;
7062
+ }
6810
7063
 
6811
- if(options.size) this.size = size;
6812
-
6813
7064
  let rect = root.getBoundingClientRect();
6814
- root.style.left = position[0] ? (position[0]) : "calc( 50% - " + (rect.width * 0.5) + "px )";
6815
- root.style.top = position[1] ? (position[1]) : "calc( 50% - " + (rect.height * 0.5) + "px )";
7065
+ root.style.left = position[ 0 ] ? (position[ 0 ]) : "calc( 50% - " + ( rect.width * 0.5 ) + "px )";
7066
+ root.style.top = position[ 1 ] ? (position[ 1 ]) : "calc( 50% - " + ( rect.height * 0.5 ) + "px )";
6816
7067
 
6817
7068
  panel.root.style.width = "calc( 100% - 30px )";
6818
- panel.root.style.height = title ? "calc( 100% - " + (titleDiv.offsetHeight + 30) + "px )" : "calc( 100% - 51px )";
7069
+ panel.root.style.height = title ? "calc( 100% - " + ( titleDiv.offsetHeight + 30 ) + "px )" : "calc( 100% - 51px )";
6819
7070
  }
6820
7071
 
6821
7072
  destroy() {
6822
-
7073
+
6823
7074
  this.root.remove();
6824
7075
  }
6825
7076
 
@@ -6830,7 +7081,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6830
7081
  }
6831
7082
 
6832
7083
  setPosition(x, y) {
6833
-
7084
+
6834
7085
  this.root.style.left = x + "px";
6835
7086
  this.root.style.top = y + "px";
6836
7087
  }
@@ -6859,9 +7110,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6859
7110
 
6860
7111
  options.draggable = options.draggable ?? false;
6861
7112
  options.closable = options.closable ?? false;
6862
-
7113
+
6863
7114
  super( title, callback, options );
6864
-
7115
+
6865
7116
  let that = this;
6866
7117
  // Update margins on branch title closes/opens
6867
7118
  LX.addSignal("@on_branch_closed", this.panel, closed => {
@@ -6869,7 +7120,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6869
7120
  this.root.style.top = "calc(100% - " + (this.root.offsetHeight + 6) + "px)";
6870
7121
  });
6871
7122
 
6872
- // Custom
7123
+ // Custom
6873
7124
  this.root.classList.add( "pocket" );
6874
7125
  if( !options.position ) {
6875
7126
  this.root.style.left = "calc(100% - " + (this.root.offsetWidth + 6) + "px)";
@@ -6883,7 +7134,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6883
7134
  this.title.tabIndex = -1;
6884
7135
  this.title.addEventListener("click", e => {
6885
7136
 
6886
- // Sized dialogs have to keep their size
7137
+ // Sized dialogs have to keep their size
6887
7138
  if( this.size )
6888
7139
  {
6889
7140
  if( !this.minimized ) this.root.style.height = "auto";
@@ -6894,7 +7145,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6894
7145
  this.minimized = !this.minimized;
6895
7146
 
6896
7147
  if( this.dock_pos == PocketDialog.BOTTOM )
6897
- that.root.style.top = this.root.classList.contains("minimized") ?
7148
+ that.root.style.top = this.root.classList.contains("minimized") ?
6898
7149
  "calc(100% - " + (that.title.offsetHeight + 6) + "px)" : "calc(100% - " + (that.root.offsetHeight + 6) + "px)";
6899
7150
  });
6900
7151
 
@@ -6909,10 +7160,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6909
7160
  const t = float[i];
6910
7161
  switch( t )
6911
7162
  {
6912
- case 'b':
7163
+ case 'b':
6913
7164
  this.root.style.top = "calc(100% - " + (this.root.offsetHeight + 6) + "px)";
6914
7165
  break;
6915
- case 'l':
7166
+ case 'l':
6916
7167
  this.root.style.left = options.position ? options.position[ 1 ] : "0px";
6917
7168
  break;
6918
7169
  }
@@ -6946,7 +7197,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6946
7197
  class ContextMenu {
6947
7198
 
6948
7199
  constructor( event, title, options = {} ) {
6949
-
7200
+
6950
7201
  // remove all context menus
6951
7202
  document.body.querySelectorAll(".lexcontextmenubox").forEach(e => e.remove());
6952
7203
 
@@ -6958,7 +7209,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6958
7209
  this.root.addEventListener("mouseleave", function() {
6959
7210
  this.remove();
6960
7211
  });
6961
-
7212
+
6962
7213
  this.items = [];
6963
7214
  this.colors = {};
6964
7215
 
@@ -6975,9 +7226,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6975
7226
  _adjust_position( div, margin, useAbsolute = false ) {
6976
7227
 
6977
7228
  let rect = div.getBoundingClientRect();
6978
-
7229
+
6979
7230
  if( !useAbsolute )
6980
- {
7231
+ {
6981
7232
  let width = rect.width;
6982
7233
  if( rect.left < 0 )
6983
7234
  {
@@ -7004,7 +7255,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7004
7255
  {
7005
7256
  div.style.left = div.offsetLeft + (dt - margin) + "px";
7006
7257
  }
7007
-
7258
+
7008
7259
  dt = window.innerHeight - (rect.top + rect.height);
7009
7260
  if( dt < 0 )
7010
7261
  {
@@ -7064,14 +7315,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7064
7315
  entry.addEventListener("click", e => {
7065
7316
  e.stopPropagation();
7066
7317
  e.stopImmediatePropagation();
7067
-
7318
+
7068
7319
  if(disabled) return;
7069
-
7320
+
7070
7321
  const f = o[ 'callback' ];
7071
7322
  if(f) {
7072
7323
  f.call( this, k, entry );
7073
7324
  this.root.remove();
7074
- }
7325
+ }
7075
7326
 
7076
7327
  if( !hasSubmenu )
7077
7328
  return;
@@ -7135,7 +7386,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7135
7386
  } );
7136
7387
 
7137
7388
  if(found) {
7138
- insert( tokens[idx++], found );
7389
+ insert( tokens[idx++], found );
7139
7390
  }
7140
7391
  else {
7141
7392
  let item = {};
@@ -7146,10 +7397,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7146
7397
  item[ 'id' ] = options.id;
7147
7398
  item[ 'callback' ] = options.callback;
7148
7399
  item[ 'disabled' ] = options.disabled ?? false;
7149
- }
7400
+ }
7150
7401
 
7151
7402
  list.push( item );
7152
- insert( next_token, item[ token ] );
7403
+ insert( next_token, item[ token ] );
7153
7404
  }
7154
7405
  };
7155
7406
 
@@ -7234,14 +7485,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7234
7485
  class Curve {
7235
7486
 
7236
7487
  constructor( panel, value, options = {} ) {
7237
-
7488
+
7238
7489
  let element = document.createElement( "div" );
7239
7490
  element.className = "curve " + ( options.className ? options.className : "" );
7240
7491
  element.style.minHeight = "50px";
7241
7492
  element.style.width = options.width || "100%";
7242
7493
  element.style.minWidth = "50px";
7243
7494
  element.style.minHeight = "20px";
7244
-
7495
+
7245
7496
  element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
7246
7497
  element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
7247
7498
  element.linecolor = options.lineColor || "#555";
@@ -7256,24 +7507,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7256
7507
  element.draggable_y = options.draggableY ?? true;
7257
7508
  element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
7258
7509
  element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
7259
-
7510
+
7260
7511
  this.element = element;
7261
-
7512
+
7262
7513
  let canvas = document.createElement( "canvas" );
7263
7514
  canvas.width = options.width || 200;
7264
7515
  canvas.height = options.height || 50;
7265
7516
  element.appendChild( canvas );
7266
7517
  this.canvas = canvas;
7267
-
7518
+
7268
7519
  element.addEventListener( "mousedown", onmousedown );
7269
-
7520
+
7270
7521
  element.getValueAt = function( x ) {
7271
-
7522
+
7272
7523
  if( x < element.xrange[ 0 ] || x > element.xrange[ 1 ] )
7273
7524
  {
7274
7525
  return element.defaulty;
7275
7526
  }
7276
-
7527
+
7277
7528
  var last = [ element.xrange[ 0 ], element.defaulty ];
7278
7529
  var f = 0;
7279
7530
  for( var i = 0; i < element.value.length; i += 1 )
@@ -7285,17 +7536,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7285
7536
  f = ( x - last[ 0 ] ) / (v[ 0 ] - last[ 0 ]);
7286
7537
  return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
7287
7538
  }
7288
-
7539
+
7289
7540
  last = v;
7290
7541
  }
7291
-
7542
+
7292
7543
  v = [ element.xrange[ 1 ], element.defaulty ];
7293
7544
  f = (x - last[ 0 ]) / (v[ 0 ] - last[ 0 ]);
7294
7545
  return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
7295
7546
  }
7296
-
7547
+
7297
7548
  element.resample = function( samples ) {
7298
-
7549
+
7299
7550
  var r = [];
7300
7551
  var dx = (element.xrange[1] - element.xrange[ 0 ]) / samples;
7301
7552
  for(var i = element.xrange[0]; i <= element.xrange[1]; i += dx)
@@ -7304,9 +7555,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7304
7555
  }
7305
7556
  return r;
7306
7557
  }
7307
-
7558
+
7308
7559
  element.addValue = function(v) {
7309
-
7560
+
7310
7561
  for(var i = 0; i < element.value; i++) {
7311
7562
  var value = element.value[i];
7312
7563
  if(value[0] < v[0]) continue;
@@ -7314,27 +7565,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7314
7565
  redraw();
7315
7566
  return;
7316
7567
  }
7317
-
7568
+
7318
7569
  element.value.push(v);
7319
7570
  redraw();
7320
7571
  }
7321
-
7572
+
7322
7573
  //value to canvas
7323
7574
  function convert(v) {
7324
7575
  return [ canvas.width * ( v[0] - element.xrange[0])/ (element.xrange[1]),
7325
7576
  canvas.height * (v[1] - element.yrange[0])/ (element.yrange[1])];
7326
7577
  }
7327
-
7578
+
7328
7579
  //canvas to value
7329
7580
  function unconvert(v) {
7330
7581
  return [(v[0] * element.xrange[1] / canvas.width + element.xrange[0]),
7331
7582
  (v[1] * element.yrange[1] / canvas.height + element.yrange[0])];
7332
7583
  }
7333
-
7584
+
7334
7585
  var selected = -1;
7335
-
7586
+
7336
7587
  element.redraw = function( o = {} ) {
7337
-
7588
+
7338
7589
  if( o.value ) element.value = o.value;
7339
7590
  if( o.xrange ) element.xrange = o.xrange;
7340
7591
  if( o.yrange ) element.yrange = o.yrange;
@@ -7345,23 +7596,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7345
7596
  {
7346
7597
  canvas.width = rect.width;
7347
7598
  }
7348
-
7599
+
7349
7600
  var ctx = canvas.getContext( "2d" );
7350
7601
  ctx.setTransform( 1, 0, 0, 1, 0, 0 );
7351
7602
  ctx.translate( 0, canvas.height );
7352
7603
  ctx.scale( 1, -1 );
7353
-
7604
+
7354
7605
  ctx.fillStyle = element.bgcolor;
7355
7606
  ctx.fillRect(0,0,canvas.width,canvas.height);
7356
-
7607
+
7357
7608
  ctx.strokeStyle = element.linecolor;
7358
7609
  ctx.beginPath();
7359
-
7610
+
7360
7611
  //draw line
7361
7612
  var pos = convert([ element.xrange[ 0 ],element.defaulty ]);
7362
7613
  ctx.moveTo( pos[ 0 ], pos[ 1 ] );
7363
7614
  let values = [pos[ 0 ], pos[ 1 ]];
7364
-
7615
+
7365
7616
  for(var i in element.value) {
7366
7617
  var value = element.value[i];
7367
7618
  pos = convert(value);
@@ -7370,7 +7621,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7370
7621
  if(!element.smooth)
7371
7622
  ctx.lineTo( pos[ 0 ], pos[ 1 ] );
7372
7623
  }
7373
-
7624
+
7374
7625
  pos = convert([ element.xrange[ 1 ], element.defaulty ]);
7375
7626
  values.push(pos[ 0 ]);
7376
7627
  values.push(pos[ 1 ]);
@@ -7383,7 +7634,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7383
7634
  {
7384
7635
  LX.UTILS.drawSpline( ctx, values, element.smooth );
7385
7636
  }
7386
-
7637
+
7387
7638
  // Draw points
7388
7639
  for( var i = 0; i < element.value.length; i += 1 ) {
7389
7640
  var value = element.value[ i ];
@@ -7396,7 +7647,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7396
7647
  ctx.arc( pos[ 0 ], pos[ 1 ], selected == i ? 4 : 3, 0, Math.PI * 2);
7397
7648
  ctx.fill();
7398
7649
  }
7399
-
7650
+
7400
7651
  if(element.show_samples) {
7401
7652
  var samples = element.resample(element.show_samples);
7402
7653
  ctx.fillStyle = "#888";
@@ -7410,43 +7661,43 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7410
7661
  }
7411
7662
  }
7412
7663
  }
7413
-
7664
+
7414
7665
  var last_mouse = [ 0, 0 ];
7415
-
7666
+
7416
7667
  function onmousedown( e ) {
7417
7668
  document.addEventListener( "mousemove", onmousemove );
7418
7669
  document.addEventListener( "mouseup", onmouseup );
7419
-
7670
+
7420
7671
  var rect = canvas.getBoundingClientRect();
7421
7672
  var mousex = e.clientX - rect.left;
7422
7673
  var mousey = e.clientY - rect.top;
7423
-
7674
+
7424
7675
  selected = computeSelected( mousex, canvas.height - mousey );
7425
-
7676
+
7426
7677
  if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
7427
7678
  var v = unconvert([ mousex, canvas.height - mousey ]);
7428
7679
  element.value.push( v );
7429
7680
  sortValues();
7430
7681
  selected = element.value.indexOf( v );
7431
7682
  }
7432
-
7683
+
7433
7684
  last_mouse = [ mousex, mousey ];
7434
7685
  element.redraw();
7435
7686
  e.preventDefault();
7436
7687
  e.stopPropagation();
7437
7688
  }
7438
-
7689
+
7439
7690
  function onmousemove( e ) {
7440
-
7691
+
7441
7692
  var rect = canvas.getBoundingClientRect();
7442
7693
  var mousex = e.clientX - rect.left;
7443
7694
  var mousey = e.clientY - rect.top;
7444
-
7695
+
7445
7696
  if( mousex < 0 ) mousex = 0;
7446
7697
  else if( mousex > canvas.width ) mousex = canvas.width;
7447
7698
  if( mousey < 0 ) mousey = 0;
7448
7699
  else if( mousey > canvas.height ) mousey = canvas.height;
7449
-
7700
+
7450
7701
  // Dragging to remove
7451
7702
  const currentMouseDiff = [ e.clientX - rect.left, e.clientY - rect.top ];
7452
7703
  if( selected != -1 && distance( currentMouseDiff, [ mousex, mousey ] ) > canvas.height * 0.5 )
@@ -7462,25 +7713,25 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7462
7713
  value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
7463
7714
  value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
7464
7715
  }
7465
-
7716
+
7466
7717
  onmouseup( e );
7467
7718
  return;
7468
7719
  }
7469
-
7720
+
7470
7721
  var dx = element.draggable_x ? last_mouse[ 0 ] - mousex : 0;
7471
7722
  var dy = element.draggable_y ? last_mouse[ 1 ] - mousey : 0;
7472
7723
  var delta = unconvert([ -dx, dy ]);
7473
-
7724
+
7474
7725
  if( selected != -1 ) {
7475
7726
  var minx = element.xrange[ 0 ];
7476
7727
  var maxx = element.xrange[ 1 ];
7477
-
7728
+
7478
7729
  if( element.no_overlap )
7479
7730
  {
7480
7731
  if( selected > 0) minx = element.value[ selected - 1 ][ 0 ];
7481
7732
  if( selected < ( element.value.length - 1 ) ) maxx = element.value[ selected + 1 ][ 0 ];
7482
7733
  }
7483
-
7734
+
7484
7735
  var v = element.value[selected];
7485
7736
  v[ 0 ] += delta[ 0 ];
7486
7737
  v[ 1 ] += delta[ 1 ];
@@ -7489,17 +7740,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7489
7740
  if(v[ 1 ] < element.yrange[ 0 ]) v[ 1 ] = element.yrange[ 0 ];
7490
7741
  else if(v[ 1 ] > element.yrange[ 1 ]) v[ 1 ] = element.yrange[ 1 ];
7491
7742
  }
7492
-
7743
+
7493
7744
  sortValues();
7494
7745
  element.redraw();
7495
7746
  last_mouse[ 0 ] = mousex;
7496
7747
  last_mouse[ 1 ] = mousey;
7497
7748
  onchange( e );
7498
-
7749
+
7499
7750
  e.preventDefault();
7500
7751
  e.stopPropagation();
7501
7752
  }
7502
-
7753
+
7503
7754
  function onmouseup( e ) {
7504
7755
  selected = -1;
7505
7756
  element.redraw();
@@ -7509,16 +7760,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7509
7760
  e.preventDefault();
7510
7761
  e.stopPropagation();
7511
7762
  }
7512
-
7763
+
7513
7764
  function onchange( e ) {
7514
7765
  if( options.callback )
7515
7766
  options.callback.call( element, element.value, e );
7516
7767
  }
7517
-
7768
+
7518
7769
  function distance(a,b) { return Math.sqrt( Math.pow(b[0]-a[0],2) + Math.pow(b[1]-a[1],2) ); };
7519
-
7770
+
7520
7771
  function computeSelected( x, y ) {
7521
-
7772
+
7522
7773
  var minDistance = 100000;
7523
7774
  var maxDistance = 8; //pixels
7524
7775
  var selected = -1;
@@ -7535,7 +7786,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7535
7786
  }
7536
7787
  return selected;
7537
7788
  }
7538
-
7789
+
7539
7790
  function sortValues() {
7540
7791
  var v = null;
7541
7792
  if( selected != -1 )
@@ -7548,11 +7799,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7548
7799
  selected = element.value.indexOf( v );
7549
7800
  }
7550
7801
  }
7551
-
7802
+
7552
7803
  element.redraw();
7553
7804
  return this;
7554
7805
  }
7555
-
7806
+
7556
7807
  redraw( options = {} ) {
7557
7808
  this.element.redraw( options );
7558
7809
  }
@@ -7570,14 +7821,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7570
7821
  static ASSET_DBLCLICKED = 5;
7571
7822
  static ENTER_FOLDER = 6;
7572
7823
  static ASSET_CHECKED = 7;
7573
-
7824
+
7574
7825
  constructor( type, item, value ) {
7575
7826
  this.type = type || TreeEvent.NONE;
7576
7827
  this.item = item;
7577
7828
  this.value = value;
7578
7829
  this.multiple = false; // Multiple selection
7579
7830
  }
7580
-
7831
+
7581
7832
  string() {
7582
7833
  switch(this.type) {
7583
7834
  case AssetViewEvent.NONE: return "assetview_event_none";
@@ -7633,9 +7884,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7633
7884
 
7634
7885
  this.skipBrowser = options.skipBrowser ?? false;
7635
7886
  this.skipPreview = options.skipPreview ?? false;
7887
+ this.useNativeTitle = options.useNativeTitle ?? false;
7636
7888
  this.onlyFolders = options.onlyFolders ?? true;
7637
7889
  this.previewActions = options.previewActions ?? [];
7638
7890
  this.contextMenu = options.contextMenu ?? [];
7891
+ this.onRefreshContent = options.onRefreshContent;
7639
7892
 
7640
7893
  if( !this.skipBrowser )
7641
7894
  {
@@ -7650,7 +7903,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7650
7903
  {
7651
7904
  [ contentArea, right ] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
7652
7905
  }
7653
-
7906
+
7654
7907
  this.allowedTypes = options.allowedTypes || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
7655
7908
 
7656
7909
  this.prevData = [];
@@ -7668,7 +7921,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7668
7921
  }
7669
7922
 
7670
7923
  this._createContentPanel( contentArea );
7671
-
7924
+
7672
7925
  // Create resource preview panel
7673
7926
  if( !this.skipPreview )
7674
7927
  {
@@ -7684,7 +7937,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7684
7937
 
7685
7938
  this.prevData.length = 0;
7686
7939
  this.nextData.length = 0;
7687
-
7940
+
7688
7941
  this.data = data;
7689
7942
 
7690
7943
  this._processData( this.data, null );
@@ -7705,14 +7958,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7705
7958
  * @method clear
7706
7959
  */
7707
7960
  clear() {
7961
+
7708
7962
  if( this.previewPanel )
7709
7963
  {
7710
7964
  this.previewPanel.clear();
7711
7965
  }
7966
+
7712
7967
  if( this.leftPanel )
7713
7968
  {
7714
7969
  this.leftPanel.clear();
7715
7970
  }
7971
+
7716
7972
  if( this.rightPanel )
7717
7973
  {
7718
7974
  this.rightPanel.clear()
@@ -7744,7 +8000,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7744
8000
  */
7745
8001
 
7746
8002
  _updatePath( data ) {
7747
-
8003
+
7748
8004
  this.path.length = 0;
7749
8005
 
7750
8006
  const push_parents_id = i => {
@@ -7783,8 +8039,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7783
8039
  children: this.data
7784
8040
  }
7785
8041
 
7786
- this.tree = this.leftPanel.addTree("Content Browser", treeData, {
7787
- // icons: tree_icons,
8042
+ this.tree = this.leftPanel.addTree( "Content Browser", treeData, {
8043
+ // icons: tree_icons,
7788
8044
  filter: false,
7789
8045
  onlyFolders: this.onlyFolders,
7790
8046
  onevent: event => {
@@ -7794,7 +8050,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7794
8050
 
7795
8051
  switch( event.type )
7796
8052
  {
7797
- case LX.TreeEvent.NODE_SELECTED:
8053
+ case LX.TreeEvent.NODE_SELECTED:
7798
8054
  if( !event.multiple )
7799
8055
  {
7800
8056
  this._enterFolder( node );
@@ -7809,13 +8065,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7809
8065
  LX.emit("@on_folder_change", this.path.join('/'));
7810
8066
  }
7811
8067
  break;
7812
- case LX.TreeEvent.NODE_DRAGGED:
8068
+ case LX.TreeEvent.NODE_DRAGGED:
7813
8069
  node.folder = value;
7814
8070
  this._refreshContent();
7815
8071
  break;
7816
8072
  }
7817
8073
  },
7818
- });
8074
+ });
7819
8075
  }
7820
8076
 
7821
8077
  /**
@@ -7844,7 +8100,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7844
8100
  this.rightPanel = area.addPanel({ className: 'lexassetcontentpanel' });
7845
8101
  }
7846
8102
 
7847
- const on_sort = (value, event) => {
8103
+ const on_sort = ( value, event ) => {
7848
8104
  const cmenu = addContextMenu( "Sort by", event, c => {
7849
8105
  c.add("Name", () => this._sortData('id') );
7850
8106
  c.add("Type", () => this._sortData('type') );
@@ -7854,10 +8110,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7854
8110
  } );
7855
8111
  const parent = this.parent.root.parentElement;
7856
8112
  if( parent.classList.contains('lexdialog') )
8113
+ {
7857
8114
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
8115
+ }
7858
8116
  }
7859
8117
 
7860
- const on_change_view = (value, event) => {
8118
+ const on_change_view = ( value, event ) => {
7861
8119
  const cmenu = addContextMenu( "Layout", event, c => {
7862
8120
  c.add("Content", () => this._setContentLayout( AssetView.LAYOUT_CONTENT ) );
7863
8121
  c.add("");
@@ -7868,7 +8126,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7868
8126
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
7869
8127
  }
7870
8128
 
7871
- const on_change_page = (value, event) => {
8129
+ const on_change_page = ( value, event ) => {
7872
8130
  if( !this.allowNextPage )
7873
8131
  {
7874
8132
  return;
@@ -7885,13 +8143,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7885
8143
  }
7886
8144
 
7887
8145
  this.rightPanel.sameLine();
7888
- this.rightPanel.addDropdown("Filter", this.allowedTypes, this.allowedTypes[0], (v) => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" });
7889
- this.rightPanel.addText(null, this.searchValue ?? "", (v) => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." });
7890
- this.rightPanel.addButton(null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" });
7891
- this.rightPanel.addButton(null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" });
8146
+ this.rightPanel.addDropdown( "Filter", this.allowedTypes, this.allowedTypes[ 0 ], v => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" } );
8147
+ this.rightPanel.addText( null, this.searchValue ?? "", v => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." } );
8148
+ this.rightPanel.addButton( null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" } );
8149
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" } );
7892
8150
  // Content Pages
7893
- this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-left'></a>", on_change_page.bind(this, -1), { className: "micro", title: "Previous Page" });
7894
- this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" });
8151
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-angles-left'></a>", on_change_page.bind(this, -1), { className: "micro", title: "Previous Page" }) ;
8152
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" } );
7895
8153
  this.rightPanel.endLine();
7896
8154
 
7897
8155
  if( !this.skipBrowser )
@@ -7901,7 +8159,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7901
8159
  {
7902
8160
  value: "Left",
7903
8161
  icon: "fa-solid fa-left-long",
7904
- callback: (domEl) => {
8162
+ callback: domEl => {
7905
8163
  if(!this.prevData.length) return;
7906
8164
  this.nextData.push( this.currentData );
7907
8165
  this.currentData = this.prevData.pop();
@@ -7912,7 +8170,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7912
8170
  {
7913
8171
  value: "Right",
7914
8172
  icon: "fa-solid fa-right-long",
7915
- callback: (domEl) => {
8173
+ callback: domEl => {
7916
8174
  if(!this.nextData.length) return;
7917
8175
  this.prevData.push( this.currentData );
7918
8176
  this.currentData = this.nextData.pop();
@@ -7923,7 +8181,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7923
8181
  {
7924
8182
  value: "Refresh",
7925
8183
  icon: "fa-solid fa-arrows-rotate",
7926
- callback: (domEl) => { this._refreshContent(); }
8184
+ callback: domEl => { this._refreshContent(); }
7927
8185
  }
7928
8186
  ], { width: "auto", noSelection: true } );
7929
8187
  this.rightPanel.addText(null, this.path.join('/'), null, { disabled: true, signal: "@on_folder_change", style: { fontWeight: "bolder", fontSize: "16px", color: "#aaa" } });
@@ -7935,17 +8193,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7935
8193
  this.content.className = "lexassetscontent";
7936
8194
  this.rightPanel.root.appendChild(this.content);
7937
8195
 
7938
- this.content.addEventListener('dragenter', function(e) {
8196
+ this.content.addEventListener('dragenter', function( e ) {
7939
8197
  e.preventDefault();
7940
8198
  this.classList.add('dragging');
7941
8199
  });
7942
- this.content.addEventListener('dragleave', function(e) {
8200
+ this.content.addEventListener('dragleave', function( e ) {
7943
8201
  e.preventDefault();
7944
8202
  this.classList.remove('dragging');
7945
8203
  });
7946
- this.content.addEventListener('drop', (e) => {
8204
+ this.content.addEventListener('drop', ( e ) => {
7947
8205
  e.preventDefault();
7948
- this._processDrop(e);
8206
+ this._processDrop( e );
7949
8207
  });
7950
8208
  this.content.addEventListener('click', function() {
7951
8209
  this.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
@@ -7956,29 +8214,80 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7956
8214
 
7957
8215
  _refreshContent( searchValue, filter ) {
7958
8216
 
7959
- const isContentLayout = (this.layout == AssetView.LAYOUT_CONTENT); // default
7960
-
7961
- this.filter = filter ?? (this.filter ?? "None");
8217
+ const isContentLayout = ( this.layout == AssetView.LAYOUT_CONTENT ); // default
8218
+
8219
+ this.filter = filter ?? ( this.filter ?? "None" );
7962
8220
  this.searchValue = searchValue ?? (this.searchValue ?? "");
7963
8221
  this.content.innerHTML = "";
7964
8222
  this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
7965
8223
  let that = this;
7966
-
8224
+
7967
8225
  const add_item = function(item) {
7968
-
8226
+
7969
8227
  const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
7970
8228
  const extension = getExtension( item.id );
7971
8229
  const isFolder = type === "Folder";
7972
-
8230
+
7973
8231
  let itemEl = document.createElement('li');
7974
8232
  itemEl.className = "lexassetitem " + item.type.toLowerCase();
7975
- itemEl.title = type + ": " + item.id;
7976
8233
  itemEl.tabIndex = -1;
7977
8234
  that.content.appendChild( itemEl );
7978
-
7979
- if(item.selected != undefined) {
8235
+
8236
+ if( !that.useNativeTitle )
8237
+ {
8238
+ let desc = document.createElement( 'span' );
8239
+ desc.className = 'lexitemdesc';
8240
+ desc.innerHTML = "File: " + item.id + "<br>Type: " + type;
8241
+ that.content.appendChild( desc );
8242
+
8243
+ itemEl.addEventListener("mousemove", e => {
8244
+
8245
+ if( !isContentLayout )
8246
+ {
8247
+ return;
8248
+ }
8249
+
8250
+ const rect = itemEl.getBoundingClientRect();
8251
+ const targetRect = e.target.getBoundingClientRect();
8252
+ const parentRect = desc.parentElement.getBoundingClientRect();
8253
+
8254
+ let localOffsetX = targetRect.x - parentRect.x - ( targetRect.x - rect.x );
8255
+ let localOffsetY = targetRect.y - parentRect.y - ( targetRect.y - rect.y );
8256
+
8257
+ if( e.target.classList.contains( "lexassettitle" ) )
8258
+ {
8259
+ localOffsetY += ( targetRect.y - rect.y );
8260
+ }
8261
+
8262
+ desc.style.left = (localOffsetX + e.offsetX + 12) + "px";
8263
+ desc.style.top = (localOffsetY + e.offsetY) + "px";
8264
+ });
8265
+
8266
+ itemEl.addEventListener("mouseenter", () => {
8267
+ if( isContentLayout )
8268
+ {
8269
+ desc.style.display = "unset";
8270
+ }
8271
+ });
8272
+
8273
+ itemEl.addEventListener("mouseleave", () => {
8274
+ if( isContentLayout )
8275
+ {
8276
+ setTimeout( () => {
8277
+ desc.style.display = "none";
8278
+ }, 100 );
8279
+ }
8280
+ });
8281
+ }
8282
+ else
8283
+ {
8284
+ itemEl.title = type + ": " + item.id;
8285
+ }
8286
+
8287
+ if( item.selected != undefined )
8288
+ {
7980
8289
  let span = document.createElement('span');
7981
- span.className = "lexcheckbox";
8290
+ span.className = "lexcheckbox";
7982
8291
  let checkbox_input = document.createElement('input');
7983
8292
  checkbox_input.type = "checkbox";
7984
8293
  checkbox_input.className = "checkbox";
@@ -7996,18 +8305,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7996
8305
  })
7997
8306
  span.appendChild(checkbox_input);
7998
8307
  itemEl.appendChild(span);
7999
-
8308
+
8000
8309
  }
8310
+
8001
8311
  let title = document.createElement('span');
8002
8312
  title.className = "lexassettitle";
8003
8313
  title.innerText = item.id;
8004
8314
  itemEl.appendChild( title );
8005
-
8315
+
8006
8316
  if( !that.skipPreview ) {
8007
-
8317
+
8008
8318
  let preview = null;
8009
8319
  const hasImage = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
8010
-
8320
+
8011
8321
  if( hasImage || isFolder || !isContentLayout)
8012
8322
  {
8013
8323
  preview = document.createElement('img');
@@ -8020,17 +8330,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8020
8330
  preview = document.createElement('svg');
8021
8331
  preview.className = "asset-file-preview";
8022
8332
  itemEl.appendChild(preview);
8023
-
8333
+
8024
8334
  let textEl = document.createElement('text');
8025
8335
  preview.appendChild(textEl);
8026
8336
  // If no extension, e.g. Clip, use the type...
8027
8337
  textEl.innerText = (!extension || extension == item.id) ? item.type.toUpperCase() : ("." + extension.toUpperCase());
8028
-
8338
+
8029
8339
  var newLength = textEl.innerText.length;
8030
8340
  var charsPerLine = 2.5;
8031
8341
  var newEmSize = charsPerLine / newLength;
8032
8342
  var textBaseSize = 64;
8033
-
8343
+
8034
8344
  if(newEmSize < 1) {
8035
8345
  var newFontSize = newEmSize * textBaseSize;
8036
8346
  textEl.style.fontSize = newFontSize + "px";
@@ -8038,7 +8348,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8038
8348
  }
8039
8349
  }
8040
8350
  }
8041
-
8351
+
8042
8352
  if( !isFolder )
8043
8353
  {
8044
8354
  let info = document.createElement('span');
@@ -8046,13 +8356,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8046
8356
  info.innerText = type;
8047
8357
  itemEl.appendChild(info);
8048
8358
  }
8049
-
8359
+
8050
8360
  itemEl.addEventListener('click', function(e) {
8051
8361
  e.stopImmediatePropagation();
8052
8362
  e.stopPropagation();
8053
-
8363
+
8054
8364
  const isDoubleClick = ( e.detail == LX.MOUSE_DOUBLE_CLICK );
8055
-
8365
+
8056
8366
  if( !isDoubleClick )
8057
8367
  {
8058
8368
  if( !e.shiftKey )
@@ -8066,13 +8376,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8066
8376
  {
8067
8377
  that._previewAsset( item );
8068
8378
  }
8069
- }
8379
+ }
8070
8380
  else if( isFolder )
8071
8381
  {
8072
8382
  that._enterFolder( item );
8073
8383
  return;
8074
8384
  }
8075
-
8385
+
8076
8386
  if( that.onevent )
8077
8387
  {
8078
8388
  const event = new AssetViewEvent(isDoubleClick ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
@@ -8080,42 +8390,48 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8080
8390
  that.onevent( event );
8081
8391
  }
8082
8392
  });
8083
-
8393
+
8084
8394
  if( that.contextMenu )
8085
8395
  {
8086
8396
  itemEl.addEventListener('contextmenu', function(e) {
8087
8397
  e.preventDefault();
8088
-
8398
+
8089
8399
  const multiple = that.content.querySelectorAll('.selected').length;
8090
-
8091
- LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8400
+
8401
+ LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8092
8402
  isFolder ? item.id : item.type, e, m => {
8093
- if(multiple <= 1)
8403
+ if( multiple <= 1 )
8404
+ {
8094
8405
  m.add("Rename");
8406
+ }
8095
8407
  if( !isFolder )
8096
- m.add("Clone", that._clone_item.bind(that, item));
8097
- if(multiple <= 1)
8408
+ {
8409
+ m.add("Clone", that._cloneItem.bind( that, item ));
8410
+ }
8411
+ if( multiple <= 1 )
8412
+ {
8098
8413
  m.add("Properties");
8414
+ }
8099
8415
  m.add("");
8100
- m.add("Delete", that._delete_item.bind(that, item));
8416
+ m.add("Delete", that._deleteItem.bind( that, item ));
8101
8417
  });
8102
8418
  });
8103
8419
  }
8104
-
8420
+
8105
8421
  itemEl.addEventListener("dragstart", function(e) {
8106
8422
  e.preventDefault();
8107
8423
  }, false );
8108
-
8424
+
8109
8425
  return itemEl;
8110
8426
  }
8111
-
8427
+
8112
8428
  const fr = new FileReader();
8113
-
8429
+
8114
8430
  const filteredData = this.currentData.filter( _i => {
8115
8431
  return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
8116
8432
  _i.id.toLowerCase().includes(this.searchValue.toLowerCase())
8117
8433
  } );
8118
-
8434
+
8119
8435
  if( filter || searchValue )
8120
8436
  {
8121
8437
  this.contentPage = 1;
@@ -8124,17 +8440,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8124
8440
  // Show all data if using filters
8125
8441
  const startIndex = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
8126
8442
  const endIndex = Math.min( startIndex + AssetView.MAX_PAGE_ELEMENTS, filteredData.length );
8127
-
8443
+
8128
8444
  for( let i = startIndex; i < endIndex; ++i )
8129
8445
  {
8130
8446
  let item = filteredData[ i ];
8131
-
8447
+
8132
8448
  if( item.path )
8133
8449
  {
8134
8450
  LX.request({ url: item.path, dataType: 'blob', success: (f) => {
8135
8451
  item.bytesize = f.size;
8136
8452
  fr.readAsDataURL( f );
8137
- fr.onload = e => {
8453
+ fr.onload = e => {
8138
8454
  item.src = e.currentTarget.result; // This is a base64 string...
8139
8455
  item._path = item.path;
8140
8456
  delete item.path;
@@ -8146,8 +8462,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8146
8462
  item.domEl = add_item( item );
8147
8463
  }
8148
8464
  }
8465
+
8149
8466
  this.allowNextPage = filteredData.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
8150
8467
  LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((filteredData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1));
8468
+
8469
+ if( this.onRefreshContent )
8470
+ {
8471
+ this.onRefreshContent( searchValue, filter );
8472
+ }
8151
8473
  }
8152
8474
 
8153
8475
  /**
@@ -8179,16 +8501,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8179
8501
  this.previewPanel.addText("Type", file.type, null, options);
8180
8502
  if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
8181
8503
  if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
8182
-
8504
+
8183
8505
  this.previewPanel.addSeparator();
8184
-
8506
+
8185
8507
  const previewActions = [...this.previewActions];
8186
8508
 
8187
8509
  if( !previewActions.length )
8188
8510
  {
8189
8511
  // By default
8190
8512
  previewActions.push({
8191
- name: 'Download',
8513
+ name: 'Download',
8192
8514
  callback: () => LX.downloadURL(file.src, file.id)
8193
8515
  });
8194
8516
  }
@@ -8216,8 +8538,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8216
8538
  if(result) continue;
8217
8539
 
8218
8540
  fr.readAsDataURL( file );
8219
- fr.onload = e => {
8220
-
8541
+ fr.onload = e => {
8542
+
8221
8543
  let ext = file.name.substr(file.name.lastIndexOf('.') + 1).toLowerCase();
8222
8544
 
8223
8545
  let item = {
@@ -8232,12 +8554,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8232
8554
  case 'png':
8233
8555
  case 'jpg':
8234
8556
  item.type = "image"; break;
8235
- case 'js':
8236
- case 'css':
8557
+ case 'js':
8558
+ case 'css':
8237
8559
  item.type = "script"; break;
8238
- case 'json':
8560
+ case 'json':
8239
8561
  item.type = "json"; break;
8240
- case 'obj':
8562
+ case 'obj':
8241
8563
  item.type = "mesh"; break;
8242
8564
  default:
8243
8565
  item.type = ext;
@@ -8246,7 +8568,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8246
8568
  }
8247
8569
 
8248
8570
  this.currentData.push( item );
8249
-
8571
+
8250
8572
  if(i == (num_files - 1)) {
8251
8573
  this._refreshContent();
8252
8574
  if( !this.skipBrowser )
@@ -8311,26 +8633,31 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8311
8633
 
8312
8634
  _cloneItem( item ) {
8313
8635
 
8314
- const idx = this.currentData.indexOf(item);
8315
- if(idx > -1) {
8316
- delete item.domEl;
8317
- delete item.folder;
8318
- const new_item = deepCopy( item );
8319
- this.currentData.splice(idx, 0, new_item);
8320
- this._refreshContent(this.searchValue, this.filter);
8636
+ const idx = this.currentData.indexOf( item );
8637
+ if( idx < 0 )
8638
+ {
8639
+ return;
8640
+ }
8321
8641
 
8322
- if(this.onevent) {
8323
- const event = new AssetViewEvent(AssetViewEvent.ASSET_CLONED, item );
8324
- this.onevent( event );
8325
- }
8642
+ delete item.domEl;
8643
+ delete item.folder;
8644
+ const new_item = deepCopy( item );
8645
+ this.currentData.splice( idx, 0, new_item );
8326
8646
 
8327
- this._processData(this.data);
8647
+ this._refreshContent( this.searchValue, this.filter );
8648
+
8649
+ if( this.onevent )
8650
+ {
8651
+ const event = new AssetViewEvent( AssetViewEvent.ASSET_CLONED, item );
8652
+ this.onevent( event );
8328
8653
  }
8654
+
8655
+ this._processData( this.data );
8329
8656
  }
8330
8657
  }
8331
8658
 
8332
8659
  LX.AssetView = AssetView;
8333
-
8660
+
8334
8661
  /*
8335
8662
  * Requests
8336
8663
  */
@@ -8338,12 +8665,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8338
8665
  Object.assign(LX, {
8339
8666
 
8340
8667
  /**
8341
- * Request file from url (it could be a binary, text, etc.). If you want a simplied version use
8668
+ * Request file from url (it could be a binary, text, etc.). If you want a simplied version use
8342
8669
  * @method request
8343
8670
  * @param {Object} request object with all the parameters like data (for sending forms), dataType, success, error
8344
8671
  * @param {Function} on_complete
8345
8672
  **/
8346
- request(request) {
8673
+ request( request ) {
8347
8674
 
8348
8675
  var dataType = request.dataType || "text";
8349
8676
  if(dataType == "json") //parse it locally
@@ -8458,7 +8785,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8458
8785
  requestBinary(url, on_complete, on_error ) {
8459
8786
  return this.request({ url: url, dataType:"binary", success: on_complete, error: on_error });
8460
8787
  },
8461
-
8788
+
8462
8789
  /**
8463
8790
  * Request script and inserts it in the DOM
8464
8791
  * @method requireScript
@@ -8487,7 +8814,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8487
8814
  script.src = url[i] + ( version ? "?version=" + version : "" );
8488
8815
  script.original_src = url[i];
8489
8816
  script.async = false;
8490
- script.onload = function(e) {
8817
+ script.onload = function(e) {
8491
8818
  total--;
8492
8819
  loaded_scripts.push(this);
8493
8820
  if(total)
@@ -8499,7 +8826,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8499
8826
  on_complete( loaded_scripts );
8500
8827
  };
8501
8828
  if(on_error)
8502
- script.onerror = function(err) {
8829
+ script.onerror = function(err) {
8503
8830
  on_error(err, this.original_src, this.num );
8504
8831
  }
8505
8832
  document.getElementsByTagName('head')[0].appendChild(script);
@@ -8523,7 +8850,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8523
8850
  {
8524
8851
  LX.request({ url: url, dataType: 'blob', success: (f) => {
8525
8852
  fr.readAsDataURL( f );
8526
- fr.onload = e => {
8853
+ fr.onload = e => {
8527
8854
  _download(e.currentTarget.result);
8528
8855
  };
8529
8856
  } });
@@ -8609,31 +8936,31 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8609
8936
  element.offsetHeight;
8610
8937
  },
8611
8938
  getControlPoints( x0, y0, x1, y1, x2, y2 ,t ) {
8612
-
8939
+
8613
8940
  // x0,y0,x1,y1 are the coordinates of the end (knot) pts of this segment
8614
8941
  // x2,y2 is the next knot -- not connected here but needed to calculate p2
8615
8942
  // p1 is the control point calculated here, from x1 back toward x0.
8616
- // p2 is the next control point, calculated here and returned to become the
8943
+ // p2 is the next control point, calculated here and returned to become the
8617
8944
  // next segment's p1.
8618
8945
  // t is the 'tension' which controls how far the control points spread.
8619
-
8946
+
8620
8947
  // Scaling factors: distances from this knot to the previous and following knots.
8621
8948
  var d01=Math.sqrt(Math.pow(x1-x0,2)+Math.pow(y1-y0,2));
8622
8949
  var d12=Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
8623
-
8950
+
8624
8951
  var fa=t*d01/(d01+d12);
8625
8952
  var fb=t-fa;
8626
-
8953
+
8627
8954
  var p1x=x1+fa*(x0-x2);
8628
8955
  var p1y=y1+fa*(y0-y2);
8629
-
8956
+
8630
8957
  var p2x=x1-fb*(x0-x2);
8631
- var p2y=y1-fb*(y0-y2);
8632
-
8958
+ var p2y=y1-fb*(y0-y2);
8959
+
8633
8960
  return [p1x,p1y,p2x,p2y]
8634
8961
  },
8635
8962
  drawSpline( ctx, pts, t ) {
8636
-
8963
+
8637
8964
  ctx.save();
8638
8965
  var cp=[]; // array of control points, as x0,y0,x1,y1,...
8639
8966
  var n=pts.length;
@@ -8641,7 +8968,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8641
8968
  // Draw an open curve, not connected at the ends
8642
8969
  for(var i=0;i<n-4;i+=2) {
8643
8970
  cp=cp.concat(LX.UTILS.getControlPoints(pts[i],pts[i+1],pts[i+2],pts[i+3],pts[i+4],pts[i+5],t));
8644
- }
8971
+ }
8645
8972
 
8646
8973
  for(var i=2;i<pts.length-5;i+=2) {
8647
8974
  ctx.beginPath();
@@ -8649,7 +8976,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8649
8976
  ctx.bezierCurveTo(cp[2*i-2],cp[2*i-1],cp[2*i],cp[2*i+1],pts[i+2],pts[i+3]);
8650
8977
  ctx.stroke();
8651
8978
  ctx.closePath();
8652
-
8979
+
8653
8980
  }
8654
8981
  // For open curves the first and last arcs are simple quadratics.
8655
8982
  ctx.beginPath();
@@ -8657,13 +8984,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8657
8984
  ctx.quadraticCurveTo(cp[0],cp[1],pts[2],pts[3]);
8658
8985
  ctx.stroke();
8659
8986
  ctx.closePath();
8660
-
8987
+
8661
8988
  ctx.beginPath();
8662
8989
  ctx.moveTo(pts[n-2],pts[n-1]);
8663
8990
  ctx.quadraticCurveTo(cp[2*n-10],cp[2*n-9],pts[n-4],pts[n-3]);
8664
8991
  ctx.stroke();
8665
8992
  ctx.closePath();
8666
-
8993
+
8667
8994
  ctx.restore();
8668
8995
  }
8669
8996
  };