lexgui 0.1.42 → 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.42",
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,21 +537,22 @@ 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
555
+ * skipRoot: Skip adding LX root container
504
556
  * skipDefaultArea: Skip creation of main area
505
557
  */
506
558
 
@@ -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,7 +613,7 @@ 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.skipDefaultArea )
616
+ if( !options.skipRoot && !options.skipDefaultArea )
561
617
  {
562
618
  this.main_area = new Area( { id: options.id ?? 'mainarea' } );
563
619
  }
@@ -569,9 +625,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
569
625
 
570
626
  /**
571
627
  * @method message
572
- * @param {String} text
628
+ * @param {String} text
573
629
  * @param {String} title (Optional)
574
- * @param {*} options
630
+ * @param {*} options
575
631
  * id: Id of the message dialog
576
632
  * position: Dialog position in screen [screen centered]
577
633
  * draggable: Dialog can be dragged [false]
@@ -595,9 +651,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
595
651
 
596
652
  /**
597
653
  * @method popup
598
- * @param {String} text
654
+ * @param {String} text
599
655
  * @param {String} title (Optional)
600
- * @param {*} options
656
+ * @param {*} options
601
657
  * id: Id of the message dialog
602
658
  * time: (Number) Delay time before close automatically (ms). Defalut: [3000]
603
659
  * position: (Array) [x,y] Dialog position in screen. Default: [screen centered]
@@ -614,19 +670,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
614
670
  options.size = options.size ?? [ "auto", "auto" ];
615
671
  options.class = "lexpopup";
616
672
 
617
- const time = options.timeout || 3000;
673
+ const time = options.timeout || 3000;
618
674
  const dialog = new Dialog( title, p => {
619
675
  p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
620
676
  }, options );
621
-
677
+
622
678
  dialog.root.classList.add( 'fadein' );
623
679
  setTimeout(() => {
624
680
  dialog.root.classList.remove( 'fadein' );
625
681
  dialog.root.classList.add( 'fadeout' );
626
682
  }, time - 1000 );
627
-
683
+
628
684
  setTimeout( dialog.close, time );
629
-
685
+
630
686
  return dialog;
631
687
  }
632
688
 
@@ -634,9 +690,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
634
690
 
635
691
  /**
636
692
  * @method prompt
637
- * @param {String} text
693
+ * @param {String} text
638
694
  * @param {String} title (Optional)
639
- * @param {*} options
695
+ * @param {*} options
640
696
  * id: Id of the prompt dialog
641
697
  * position: Dialog position in screen [screen centered]
642
698
  * draggable: Dialog can be dragged [false]
@@ -685,7 +741,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
685
741
  {
686
742
  dialog.root.querySelector( 'input' ).focus();
687
743
  }
688
-
744
+
689
745
  return dialog;
690
746
  }
691
747
 
@@ -724,7 +780,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
724
780
  this.value = value;
725
781
  this.multiple = false; // Multiple selection
726
782
  }
727
-
783
+
728
784
  string() {
729
785
  switch( this.type )
730
786
  {
@@ -769,7 +825,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
769
825
  if( obj.constructor === Widget )
770
826
  {
771
827
  obj.set( value, options.skipCallback ?? true );
772
-
828
+
773
829
  if( obj.options && obj.options.callback )
774
830
  {
775
831
  obj.options.callback( value, data );
@@ -792,7 +848,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
792
848
  {
793
849
  LX.signals[ name ] = [];
794
850
  }
795
-
851
+
796
852
  if( LX.signals[ name ].indexOf( obj ) > -1 )
797
853
  {
798
854
  return;
@@ -811,12 +867,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
811
867
 
812
868
  /**
813
869
  * @constructor Area
814
- * @param {*} options
870
+ * @param {*} options
815
871
  * id: Id of the element
816
872
  * className: Add class to the element
817
873
  * width: Width of the area element [fit space]
818
874
  * height: Height of the area element [fit space]
819
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
820
880
  */
821
881
 
822
882
  constructor( options = {} ) {
@@ -831,13 +891,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
831
891
  {
832
892
  root.className += " " + options.className;
833
893
  }
834
-
894
+
835
895
  var width = options.width || "calc( 100% )";
836
896
  var height = options.height || "100%";
837
-
897
+
838
898
  // This has default options..
839
899
  this.setLimitBox( options.minWidth, options.minHeight, options.maxWidth, options.maxHeight );
840
-
900
+
841
901
  if( width.constructor == Number )
842
902
  {
843
903
  width += "px";
@@ -846,16 +906,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
846
906
  {
847
907
  height += "px";
848
908
  }
849
-
909
+
850
910
  root.style.width = width;
851
911
  root.style.height = height;
852
-
912
+
853
913
  this.offset = 0;
854
914
  this.root = root;
855
915
  this.size = [ this.root.offsetWidth, this.root.offsetHeight ];
856
916
  this.sections = [];
857
917
  this.panels = [];
858
-
918
+
859
919
  if( !options.skipAppend )
860
920
  {
861
921
  var lexroot = document.getElementById("lexroot");
@@ -897,7 +957,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
897
957
  }
898
958
 
899
959
  if( options.resize )
900
- {
960
+ {
901
961
  this.splitBar = document.createElement("div");
902
962
  let type = (overlay == "left") || (overlay == "right") ? "horizontal" : "vertical";
903
963
  this.type = overlay;
@@ -907,7 +967,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
907
967
  {
908
968
  this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
909
969
  this.splitBar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
910
- }
970
+ }
911
971
  else if( overlay == "left" )
912
972
  {
913
973
  let size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientWidth);
@@ -928,10 +988,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
928
988
 
929
989
  this.splitBar.addEventListener("mousedown", inner_mousedown);
930
990
  this.root.appendChild( this.splitBar );
931
-
991
+
932
992
  var that = this;
933
993
  var lastMousePosition = [ 0, 0 ];
934
-
994
+
935
995
  function inner_mousedown( e )
936
996
  {
937
997
  var doc = that.root.ownerDocument;
@@ -971,13 +1031,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
971
1031
  that.root.style.height = size + "px";
972
1032
  break;
973
1033
  }
974
-
1034
+
975
1035
  lastMousePosition[ 0 ] = e.x;
976
1036
  lastMousePosition[ 1 ] = e.y;
977
1037
  e.stopPropagation();
978
1038
  e.preventDefault();
979
-
980
- // Resize events
1039
+
1040
+ // Resize events
981
1041
  if( that.onresize )
982
1042
  {
983
1043
  that.onresize( that.root.getBoundingClientRect() );
@@ -1023,11 +1083,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1023
1083
 
1024
1084
  /**
1025
1085
  * @method split
1026
- * @param {*} options
1086
+ * @param {*} options
1027
1087
  * type: Split mode (horizontal, vertical) ["horizontal"]
1028
1088
  * sizes: Size of each new area (Array) ["50%", "50%"]
1029
1089
  */
1030
-
1090
+
1031
1091
  split( options = {} ) {
1032
1092
 
1033
1093
  if( this.sections.length )
@@ -1040,7 +1100,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1040
1100
 
1041
1101
  var type = options.type || "horizontal";
1042
1102
  var sizes = options.sizes || [ "50%", "50%" ];
1043
- var infer_height = false;
1044
1103
  var auto = (options.sizes === 'auto');
1045
1104
 
1046
1105
  if( !sizes[ 1 ] )
@@ -1054,7 +1113,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1054
1113
  }
1055
1114
 
1056
1115
  sizes[ 1 ] = "calc( 100% - " + size + " )";
1057
- infer_height = true;
1058
1116
  }
1059
1117
 
1060
1118
  // Create areas
@@ -1085,28 +1143,28 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1085
1143
  this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
1086
1144
  }
1087
1145
 
1088
- this.splitBar.addEventListener( 'mousedown', inner_mousedown );
1146
+ this.splitBar.addEventListener( 'mousedown', innerMouseDown );
1089
1147
 
1090
1148
  data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
1091
1149
 
1092
1150
  // Being minimizable means it's also resizeable!
1093
1151
  if( minimizable )
1094
1152
  {
1095
- this.split_extended = false;
1153
+ this.splitExtended = false;
1096
1154
 
1097
1155
  // Keep state of the animation when ends...
1098
1156
  area2.root.addEventListener('animationend', e => {
1099
- const opacity = getComputedStyle(area2.root).opacity;
1157
+ const opacity = getComputedStyle( area2.root ).opacity;
1100
1158
  area2.root.classList.remove( e.animationName + "-" + type );
1101
1159
  area2.root.style.opacity = opacity;
1102
1160
  flushCss(area2.root);
1103
1161
  });
1104
-
1162
+
1105
1163
  this.splitBar.addEventListener("contextmenu", e => {
1106
1164
  e.preventDefault();
1107
1165
  addContextMenu(null, e, c => {
1108
- c.add("Extend", { disabled: this.split_extended, callback: () => { this.extend() } });
1109
- 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() } });
1110
1168
  });
1111
1169
  });
1112
1170
  }
@@ -1118,9 +1176,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1118
1176
  width2 = sizes[ 1 ];
1119
1177
 
1120
1178
  if( width1.constructor == Number )
1179
+ {
1121
1180
  width1 += "px";
1181
+ }
1182
+
1122
1183
  if( width2.constructor == Number )
1184
+ {
1123
1185
  width2 += "px";
1186
+ }
1124
1187
 
1125
1188
  area1.root.style.width = "calc( " + width1 + " - " + data + " )";
1126
1189
  area1.root.style.height = "calc(100% - 0px)";
@@ -1152,11 +1215,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1152
1215
  var height1 = sizes[ 0 ],
1153
1216
  height2 = sizes[ 1 ];
1154
1217
 
1155
- if(height1.constructor == Number)
1218
+ if( height1.constructor == Number )
1219
+ {
1156
1220
  height1 += "px";
1157
- if(height2.constructor == Number)
1221
+ }
1222
+
1223
+ if( height2.constructor == Number )
1224
+ {
1158
1225
  height2 += "px";
1159
-
1226
+ }
1227
+
1160
1228
  area1.root.style.width = "100%";
1161
1229
  area1.root.style.height = "calc( " + height1 + " - " + data + " )";
1162
1230
  area2.root.style.height = "calc( " + height2 + " - " + data + " )";
@@ -1165,7 +1233,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1165
1233
 
1166
1234
  this.root.appendChild( area1.root );
1167
1235
 
1168
- if( resize )
1236
+ if( resize )
1169
1237
  {
1170
1238
  this.root.appendChild(this.splitBar);
1171
1239
  }
@@ -1183,35 +1251,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1183
1251
  }
1184
1252
 
1185
1253
  var that = this;
1186
- var lastMousePosition = [ 0, 0 ];
1187
1254
 
1188
- function inner_mousedown( e )
1255
+ function innerMouseDown( e )
1189
1256
  {
1190
1257
  var doc = that.root.ownerDocument;
1191
- doc.addEventListener( 'mousemove', inner_mousemove );
1192
- doc.addEventListener( 'mouseup', inner_mouseup );
1193
- lastMousePosition[0] = e.x;
1194
- lastMousePosition[1] = e.y;
1258
+ doc.addEventListener( 'mousemove', innerMouseMove );
1259
+ doc.addEventListener( 'mouseup', innerMouseUp );
1195
1260
  e.stopPropagation();
1196
1261
  e.preventDefault();
1197
1262
  document.body.classList.add( 'nocursor' );
1198
1263
  that.splitBar.classList.add( 'nocursor' );
1199
1264
  }
1200
1265
 
1201
- function inner_mousemove( e )
1266
+ function innerMouseMove( e )
1202
1267
  {
1203
- if(that.type == "horizontal")
1268
+ if( that.type == "horizontal" )
1204
1269
  {
1205
- that._moveSplit( lastMousePosition[ 0 ] - e.x );
1270
+ that._moveSplit( -e.movementX );
1206
1271
  }
1207
1272
  else
1208
1273
  {
1209
- that._moveSplit( lastMousePosition[ 1 ] - e.y );
1274
+ that._moveSplit( -e.movementY );
1210
1275
  }
1211
1276
 
1212
- lastMousePosition[ 0 ] = e.x;
1213
- lastMousePosition[ 1 ] = e.y;
1214
-
1215
1277
  const widgets = that.root.querySelectorAll( ".lexwidget" );
1216
1278
 
1217
1279
  // Send area resize to every widget in the area
@@ -1229,11 +1291,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1229
1291
  e.preventDefault();
1230
1292
  }
1231
1293
 
1232
- function inner_mouseup( e )
1294
+ function innerMouseUp( e )
1233
1295
  {
1234
1296
  var doc = that.root.ownerDocument;
1235
- doc.removeEventListener( 'mousemove', inner_mousemove );
1236
- doc.removeEventListener( 'mouseup', inner_mouseup );
1297
+ doc.removeEventListener( 'mousemove', innerMouseMove );
1298
+ doc.removeEventListener( 'mouseup', innerMouseUp );
1237
1299
  document.body.classList.remove( 'nocursor' );
1238
1300
  that.splitBar.classList.remove( 'nocursor' );
1239
1301
  }
@@ -1258,7 +1320,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1258
1320
  * Resize element
1259
1321
  */
1260
1322
  setSize( size ) {
1261
-
1323
+
1262
1324
  let [ width, height ] = size;
1263
1325
 
1264
1326
  if( width != undefined && width.constructor == Number )
@@ -1292,22 +1354,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1292
1354
  */
1293
1355
  extend() {
1294
1356
 
1295
- if( this.split_extended )
1357
+ if( this.splitExtended )
1296
1358
  {
1297
1359
  return;
1298
1360
  }
1299
1361
 
1300
1362
  let [area1, area2] = this.sections;
1301
- this.split_extended = true;
1363
+ this.splitExtended = true;
1302
1364
 
1303
1365
  if(this.type == "vertical")
1304
1366
  {
1305
1367
  this.offset = area2.root.offsetHeight;
1306
1368
  area2.root.classList.add("fadeout-vertical");
1307
- this._moveSplit(-Infinity, true);
1369
+ this._moveSplit(-Infinity, true);
1308
1370
 
1309
1371
  }
1310
- else
1372
+ else
1311
1373
  {
1312
1374
  this.offset = area2.root.offsetWidth - 8; // Force some height here...
1313
1375
  area2.root.classList.add("fadeout-horizontal");
@@ -1324,10 +1386,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1324
1386
  */
1325
1387
  reduce() {
1326
1388
 
1327
- if( !this.split_extended )
1389
+ if( !this.splitExtended )
1328
1390
  return;
1329
-
1330
- this.split_extended = false;
1391
+
1392
+ this.splitExtended = false;
1331
1393
  let [area1, area2] = this.sections;
1332
1394
 
1333
1395
  if(this.type == "vertical")
@@ -1405,7 +1467,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1405
1467
  */
1406
1468
 
1407
1469
  addMenubar( callback, options = {} ) {
1408
-
1470
+
1409
1471
  let menubar = new Menubar(options);
1410
1472
 
1411
1473
  if(callback) callback( menubar );
@@ -1450,10 +1512,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1450
1512
  */
1451
1513
 
1452
1514
  addOverlayButtons( buttons, options = {} ) {
1453
-
1515
+
1454
1516
  // Add to last split section if area has been split
1455
- if(this.sections.length) {
1456
- this.sections[1].addOverlayButtons( buttons, options );
1517
+ if( this.sections.length )
1518
+ {
1519
+ this.sections[ 1 ].addOverlayButtons( buttons, options );
1457
1520
  return;
1458
1521
  }
1459
1522
 
@@ -1463,8 +1526,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1463
1526
  this.root.style.position = "relative";
1464
1527
 
1465
1528
  options.className = "lexoverlaybuttons";
1466
- options.width = "calc( 100% - 24px )";
1467
- 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 );
1468
1537
 
1469
1538
  const float = options.float;
1470
1539
 
@@ -1476,24 +1545,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1476
1545
  switch( t )
1477
1546
  {
1478
1547
  case 'h': break;
1479
- case 'v': options.className += " vertical"; break;
1548
+ case 'v': container.className += " vertical"; break;
1480
1549
  case 't': break;
1481
- case 'm': options.className += " middle"; break;
1482
- case 'b': options.className += " bottom"; break;
1550
+ case 'm': container.className += " middle"; break;
1551
+ case 'b': container.className += " bottom"; break;
1483
1552
  case 'l': break;
1484
- case 'c': options.className += " center"; break;
1485
- case 'r': options.className += " right"; break;
1553
+ case 'c': container.className += " center"; break;
1554
+ case 'r': container.className += " right"; break;
1486
1555
  }
1487
1556
  }
1488
1557
  }
1489
1558
 
1490
- let overlayPanel = this.addPanel( options );
1491
- let overlaygroup;
1492
-
1493
- const add_button = function(b, group, last) {
1559
+ const _addButton = function( b, group, last ) {
1494
1560
 
1495
- const _options = {
1496
- width: "auto",
1561
+ const _options = {
1562
+ width: "auto",
1497
1563
  selectable: b.selectable,
1498
1564
  selected: b.selected,
1499
1565
  icon: b.icon,
@@ -1503,55 +1569,54 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1503
1569
 
1504
1570
  if( group )
1505
1571
  {
1506
- if(!overlaygroup) {
1507
- overlaygroup = document.createElement('div');
1508
- overlaygroup.className = "lexoverlaygroup";
1509
- overlayPanel.queuedContainer = overlaygroup;
1572
+ if( !overlayGroup )
1573
+ {
1574
+ overlayGroup = document.createElement('div');
1575
+ overlayGroup.className = "lexoverlaygroup";
1576
+ overlayPanel.queuedContainer = overlayGroup;
1510
1577
  }
1511
1578
 
1512
- _options.parent = overlaygroup;
1579
+ _options.parent = overlayGroup;
1513
1580
  }
1514
1581
 
1515
1582
  let callback = b.callback;
1516
1583
 
1517
1584
  if( b.options )
1518
1585
  {
1519
- callback = function(value, event) {
1520
- LX.addContextMenu(null, event, function(c) {
1521
- for( let o of b.options )
1522
- c.add(o, () => {
1523
- if( b.name == o ) return;
1524
- b.name = o;
1525
- b.callback( o );
1526
- refresh_panel();
1527
- });
1528
- });
1529
- };
1586
+ overlayPanel.addDropdown( null, b.options, b.name, callback, _options );
1530
1587
  }
1531
-
1532
- overlayPanel.addButton( null, b.name, function(value, event) {
1533
- if(b.selectable) {
1534
- if( b.group ) {
1535
- let _prev = b.selected;
1536
- b.group.forEach( sub => sub.selected = false );
1537
- 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
+ }
1538
1603
  }
1539
- else
1540
- b.selected = !b.selected;
1541
- }
1542
- callback( value, event );
1543
- }, _options );
1604
+
1605
+ callback( value, event );
1606
+
1607
+ }, _options );
1608
+ }
1544
1609
 
1545
1610
  // ends the group
1546
- if(overlaygroup && last)
1611
+ if( overlayGroup && last )
1547
1612
  {
1548
- overlayPanel.root.appendChild( overlaygroup );
1549
- overlaygroup = null;
1613
+ overlayPanel.root.appendChild( overlayGroup );
1614
+ overlayGroup = null;
1550
1615
  overlayPanel.clearQueue();
1551
1616
  }
1552
1617
  }
1553
1618
 
1554
- const refresh_panel = function() {
1619
+ const _refreshPanel = function() {
1555
1620
 
1556
1621
  overlayPanel.clear();
1557
1622
 
@@ -1561,15 +1626,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1561
1626
  {
1562
1627
  for( let i = 0; i < b.length; ++i )
1563
1628
  {
1564
- let sub = b[i];
1629
+ let sub = b[ i ];
1565
1630
  sub.group = b;
1566
- add_button(sub, true, i == (b.length - 1));
1631
+ _addButton(sub, true, i == ( b.length - 1 ));
1567
1632
  }
1568
- }else
1633
+ }
1634
+ else
1569
1635
  {
1570
- add_button(b);
1636
+ _addButton( b );
1571
1637
  }
1572
-
1638
+
1573
1639
  }
1574
1640
 
1575
1641
  // Add floating info
@@ -1578,16 +1644,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1578
1644
  var height = 0;
1579
1645
  overlayPanel.root.childNodes.forEach( c => { height += c.offsetHeight; } );
1580
1646
 
1581
- if( options.className.includes("middle") )
1647
+ if( container.className.includes( "middle" ) )
1582
1648
  {
1583
- overlayPanel.root.style.top = "-moz-calc( 50% - " + (height * 0.5) + "px )";
1584
- overlayPanel.root.style.top = "-webkit-calc( 50% - " + (height * 0.5) + "px )";
1585
- 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 )";
1586
1652
  }
1587
1653
  }
1588
1654
  }
1589
1655
 
1590
- refresh_panel();
1656
+ _refreshPanel();
1591
1657
  }
1592
1658
 
1593
1659
  /**
@@ -1603,65 +1669,77 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1603
1669
  {
1604
1670
  this.parentArea._disableSplitResize();
1605
1671
  // Compensate split bar...
1606
- this.root.style.paddingTop = "4px";
1672
+ this.root.style.paddingTop = "4px";
1607
1673
  }
1608
1674
 
1609
1675
  return tabs;
1610
1676
  }
1611
1677
 
1612
- _moveSplit( dt, force_animation = false, force_width = 0 ) {
1678
+ _moveSplit( dt, forceAnimation = false, forceWidth = 0 ) {
1613
1679
 
1614
1680
  if( !this.type )
1681
+ {
1615
1682
  throw( "No split area" );
1683
+ }
1616
1684
 
1617
1685
  if( dt === undefined ) // Splitbar didn't move!
1686
+ {
1618
1687
  return;
1688
+ }
1689
+
1690
+ const a1 = this.sections[ 0 ];
1691
+ var a1Root = a1.root;
1619
1692
 
1620
- var a1 = this.sections[ 0 ];
1621
- var a2 = this.sections[ 1 ];
1622
- var splitinfo = " - "+ LX.DEFAULT_SPLITBAR_SIZE + "px";
1693
+ if( !a1Root.classList.contains( "origin" ) )
1694
+ {
1695
+ a1Root = a1Root.parentElement;
1696
+ }
1697
+
1698
+ const a2 = this.sections[ 1 ];
1699
+ const a2Root = a2.root;
1700
+ const splitData = " - "+ LX.DEFAULT_SPLITBAR_SIZE + "px";
1623
1701
 
1624
1702
  let transition = null;
1625
- if( !force_animation )
1703
+ if( !forceAnimation )
1626
1704
  {
1627
1705
  // Remove transitions for this change..
1628
- transition = a1.root.style.transition;
1629
- a1.root.style.transition = a2.root.style.transition = "none";
1630
- flushCss( a1.root );
1631
- flushCss( a2.root );
1706
+ transition = a1Root.style.transition;
1707
+ a1Root.style.transition = a2Root.style.transition = "none";
1708
+ flushCss( a1Root );
1709
+ flushCss( a2Root );
1632
1710
  }
1633
1711
 
1634
1712
  if( this.type == "horizontal" )
1635
1713
  {
1636
- var size = Math.max( a2.root.offsetWidth + dt, parseInt( a2.minWidth ) );
1637
- if( force_width ) size = force_width;
1638
- a1.root.style.width = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
1639
- a1.root.style.width = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
1640
- a1.root.style.width = "calc( 100% - " + size + "px " + splitinfo + " )";
1641
- a1.root.style.minWidth = parseInt( a1.minWidth ) + "px";
1642
- a2.root.style.width = size + "px";
1643
- 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" + " )";
1644
1722
  }
1645
1723
  else
1646
1724
  {
1647
- var size = Math.max((a2.root.offsetHeight + dt) + a2.offset, parseInt(a2.minHeight));
1648
- if( force_width ) size = force_width;
1649
- a1.root.style.height = "-moz-calc( 100% - " + size + "px " + splitinfo + " )";
1650
- a1.root.style.height = "-webkit-calc( 100% - " + size + "px " + splitinfo + " )";
1651
- a1.root.style.height = "calc( 100% - " + size + "px " + splitinfo + " )";
1652
- a1.root.style.minHeight = a1.minHeight + "px";
1653
- 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";
1654
1732
  }
1655
-
1656
- if( !force_animation )
1733
+
1734
+ if( !forceAnimation )
1657
1735
  {
1658
1736
  // Reapply transitions
1659
- a1.root.style.transition = a2.root.style.transition = transition;
1737
+ a1Root.style.transition = a2Root.style.transition = transition;
1660
1738
  }
1661
1739
 
1662
1740
  this._update();
1663
1741
 
1664
- // Resize events
1742
+ // Resize events
1665
1743
  this.propagateEvent( 'onresize' );
1666
1744
  }
1667
1745
 
@@ -1784,11 +1862,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1784
1862
  }
1785
1863
 
1786
1864
  // debug
1787
- if(folding)
1865
+ if(folding)
1788
1866
  {
1789
1867
  this.folded = true;
1790
1868
  this.folding = folding;
1791
-
1869
+
1792
1870
  if(folding == "up") area.root.insertChildAtIndex(area.sections[1].root, 0);
1793
1871
 
1794
1872
  // Listen resize event on parent area
@@ -1815,7 +1893,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1815
1893
  this.root.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ) );
1816
1894
  this.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
1817
1895
  }
1818
-
1896
+
1819
1897
  isSelected = !Object.keys( this.tabs ).length && !this.folding ? true : isSelected;
1820
1898
 
1821
1899
  let contentEl = content.root ? content.root : content;
@@ -1843,7 +1921,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1843
1921
  tabEl.className = "lexareatab" + ( isSelected ? " selected" : "" );
1844
1922
  tabEl.innerHTML = ( options.icon ?? "" ) + name;
1845
1923
  tabEl.id = name.replace( /\s/g, '' ) + Tabs.TAB_ID++;
1846
- tabEl.title = options.title;
1924
+ tabEl.title = options.title ?? "";
1847
1925
  tabEl.selected = isSelected ?? false;
1848
1926
  tabEl.fixed = options.fixed;
1849
1927
  tabEl.instance = this;
@@ -1858,9 +1936,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1858
1936
  if( this.parentElement.childNodes.length == 1 )
1859
1937
  {
1860
1938
  this.parentElement.childNodes[ 0 ].click(); // single tab!!
1861
- }
1939
+ }
1862
1940
  } );
1863
-
1941
+
1864
1942
  tabEl.addEventListener("click", e => {
1865
1943
 
1866
1944
  e.preventDefault();
@@ -1871,11 +1949,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1871
1949
  // For folding tabs
1872
1950
  const lastValue = tabEl.selected;
1873
1951
  tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.selected = false );
1874
- tabEl.selected = !lastValue;
1952
+ tabEl.selected = !lastValue;
1875
1953
  // Manage selected
1876
1954
  tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ));
1877
1955
  tabEl.classList.toggle('selected', ( this.folding && tabEl.selected ));
1878
- // Manage visibility
1956
+ // Manage visibility
1879
1957
  tabEl.instance.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
1880
1958
  contentEl.style.display = contentEl.originalDisplay;
1881
1959
  tabEl.instance.selected = tabEl.dataset.name;
@@ -1904,7 +1982,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1904
1982
  tabEl.addEventListener("contextmenu", e => {
1905
1983
  e.preventDefault();
1906
1984
  e.stopPropagation();
1907
-
1985
+
1908
1986
  if( options.onContextMenu )
1909
1987
  {
1910
1988
  options.onContextMenu( e, tabEl.dataset.name );
@@ -1919,16 +1997,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1919
1997
  this.delete( tabEl.dataset[ "name" ] );
1920
1998
  }
1921
1999
  });
1922
-
2000
+
1923
2001
  tabEl.setAttribute( 'draggable', true );
1924
2002
  tabEl.addEventListener( 'dragstart', function( e ) {
1925
2003
  if( this.parentElement.childNodes.length == 1 ){
1926
2004
  e.preventDefault();
1927
2005
  return;
1928
- }
2006
+ }
1929
2007
  e.dataTransfer.setData( 'source', e.target.id );
1930
2008
  });
1931
-
2009
+
1932
2010
  // Attach content
1933
2011
  tabEl.childIndex = ( this.root.childElementCount - 1 );
1934
2012
  this.root.appendChild( tabEl );
@@ -2007,7 +2085,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2007
2085
  if(options.float)
2008
2086
  this.root.style.justifyContent = options.float;
2009
2087
  this.items = [];
2010
-
2088
+
2011
2089
  this.icons = {};
2012
2090
  this.shorts = {};
2013
2091
  this.buttons = [];
@@ -2046,7 +2124,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2046
2124
  } );
2047
2125
 
2048
2126
  if(found) {
2049
- insert( tokens[idx++], found );
2127
+ insert( tokens[idx++], found );
2050
2128
  }
2051
2129
  else {
2052
2130
  let item = {};
@@ -2059,7 +2137,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2059
2137
  item[ 'checked' ] = options.checked;
2060
2138
  }
2061
2139
  list.push( item );
2062
- insert( next_token, item[ token ] );
2140
+ insert( next_token, item[ token ] );
2063
2141
  }
2064
2142
  };
2065
2143
 
@@ -2074,7 +2152,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2074
2152
 
2075
2153
  // Item already created
2076
2154
  if( this.root.querySelector("#" + pKey) )
2077
- continue;
2155
+ continue;
2078
2156
 
2079
2157
  let entry = document.createElement('div');
2080
2158
  entry.className = "lexmenuentry";
@@ -2115,21 +2193,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2115
2193
  const subitem = o[k][i];
2116
2194
  const subkey = Object.keys(subitem)[0];
2117
2195
  const hasSubmenu = subitem[ subkey ].length;
2118
- const is_checkbox = subitem[ 'type' ] == 'checkbox';
2196
+ const isCheckbox = subitem[ 'type' ] == 'checkbox';
2119
2197
  let subentry = document.createElement('div');
2120
2198
  subentry.className = "lexcontextmenuentry";
2121
2199
  subentry.className += (i == o[k].length - 1 ? " last" : "");
2122
2200
  if(subkey == '')
2123
2201
  subentry.className = " lexseparator";
2124
2202
  else {
2125
-
2203
+
2126
2204
  subentry.id = subkey;
2127
2205
  let subentrycont = document.createElement('div');
2128
2206
  subentrycont.innerHTML = "";
2129
2207
  subentrycont.classList = "lexcontextmenuentrycontainer";
2130
2208
  subentry.appendChild(subentrycont);
2131
2209
  const icon = that.icons[ subkey ];
2132
- if(is_checkbox){
2210
+ if(isCheckbox){
2133
2211
  subentrycont.innerHTML += "<input type='checkbox' >";
2134
2212
  }else if(icon) {
2135
2213
  subentrycont.innerHTML += "<a class='" + icon + " fa-sm'></a>";
@@ -2149,8 +2227,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2149
2227
  const f = subitem[ 'callback' ];
2150
2228
  if(f) {
2151
2229
  f.call( this, subitem.checked, subkey, subentry );
2152
- that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2153
- }
2230
+ that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2231
+ }
2154
2232
  e.stopPropagation();
2155
2233
  e.stopImmediatePropagation();
2156
2234
  })
@@ -2180,8 +2258,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2180
2258
  const f = subitem[ 'callback' ];
2181
2259
  if(f) {
2182
2260
  f.call( this, checkbox_input ? subitem.checked : subkey, checkbox_input ? subkey : subentry );
2183
- that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2184
- }
2261
+ that.root.querySelectorAll(".lexcontextmenu").forEach(e => e.remove());
2262
+ }
2185
2263
  e.stopPropagation();
2186
2264
  e.stopImmediatePropagation();
2187
2265
  });
@@ -2227,7 +2305,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2227
2305
  if(f) {
2228
2306
  f.call( this, key, entry );
2229
2307
  return;
2230
- }
2308
+ }
2231
2309
 
2232
2310
  // Manage selected
2233
2311
  this.root.querySelectorAll(".lexmenuentry").forEach( e => e.classList.remove( 'selected' ) );
@@ -2259,7 +2337,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2259
2337
  * @param {Array} tokens: split path strings
2260
2338
  */
2261
2339
  getSubitem(item, tokens) {
2262
-
2340
+
2263
2341
  let subitem = null;
2264
2342
  let path = tokens[0];
2265
2343
  for(let i = 0; i < item.length; i++) {
@@ -2273,7 +2351,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2273
2351
  tokens.splice(0,1);
2274
2352
  return this.getSubitem(item[i][path], tokens);
2275
2353
  }
2276
-
2354
+
2277
2355
  }
2278
2356
  }
2279
2357
  }
@@ -2285,7 +2363,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2285
2363
  getItem( path ) {
2286
2364
  // process path
2287
2365
  const tokens = path.split("/");
2288
-
2366
+
2289
2367
  return this.getSubitem(this.items, tokens)
2290
2368
  }
2291
2369
 
@@ -2323,7 +2401,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2323
2401
  else {
2324
2402
  this.root.appendChild( button );
2325
2403
  }
2326
-
2404
+
2327
2405
  const _b = button.querySelector('a');
2328
2406
  _b.addEventListener("click", (e) => {
2329
2407
  if(callback && !disabled)
@@ -2364,7 +2442,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2364
2442
  else {
2365
2443
  this.root.appendChild( button );
2366
2444
  }
2367
-
2445
+
2368
2446
  const _b = button.querySelector('a');
2369
2447
  _b.addEventListener("click", (e) => {
2370
2448
  if(callback && !disabled)
@@ -2397,7 +2475,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2397
2475
  }
2398
2476
  else {
2399
2477
  this.root.appendChild( this.buttonContainer );
2400
- }
2478
+ }
2401
2479
  }
2402
2480
 
2403
2481
  for( let i = 0; i < buttons.length; ++i )
@@ -2410,7 +2488,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2410
2488
  button.title = title ?? "";
2411
2489
  button.innerHTML = "<a class='" + data.icon + " lexicon'></a>";
2412
2490
  this.buttonContainer.appendChild( button );
2413
-
2491
+
2414
2492
  const _b = button.querySelector('a');
2415
2493
  _b.addEventListener("click", (e) => {
2416
2494
  disabled = e.target.parentElement.classList.contains("disabled");
@@ -2543,7 +2621,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2543
2621
  */
2544
2622
 
2545
2623
  class Widget {
2546
-
2624
+
2547
2625
  static NONE = 0;
2548
2626
  static TEXT = 1;
2549
2627
  static TEXTAREA = 2;
@@ -2599,7 +2677,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2599
2677
 
2600
2678
  if( this.onSetValue )
2601
2679
  return this.onSetValue( value, skipCallback );
2602
-
2680
+
2603
2681
  console.warn("Can't set value of " + this.typeName());
2604
2682
  }
2605
2683
 
@@ -2707,33 +2785,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2707
2785
  container = document.createElement('div');
2708
2786
  container.className = "lexcustomcontainer";
2709
2787
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
2710
-
2788
+
2711
2789
  this.queue(container);
2712
2790
 
2713
2791
  let buttonName = "<a class='fa-solid " + (options.icon ?? "fa-cube") + "' style='float:left'></a>";
2714
2792
  buttonName += custom_widget_name + (!instance ? " [empty]" : "");
2715
2793
  // Add alwayis icon to keep spacing right
2716
2794
  buttonName += "<a class='fa-solid " + (instance ? "fa-bars-staggered" : " ") + " menu' style='float:right; width:5%;'></a>";
2717
-
2795
+
2718
2796
  let buttonEl = this.addButton(null, buttonName, (value, event) => {
2719
2797
 
2720
2798
  if( instance ) {
2721
2799
  element.querySelector(".lexcustomitems").toggleAttribute('hidden');
2722
2800
  }
2723
2801
  else {
2724
- addContextMenu(null, event, c => {
2725
- c.add("New " + custom_widget_name, () => {
2802
+ addContextMenu(null, event, c => {
2803
+ c.add("New " + custom_widget_name, () => {
2726
2804
  instance = {};
2727
2805
  refresh_widget();
2728
2806
  element.querySelector(".lexcustomitems").toggleAttribute('hidden', false);
2729
2807
  });
2730
2808
  });
2731
2809
  }
2732
-
2810
+
2733
2811
  }, { buttonClass: 'custom' });
2734
-
2812
+
2735
2813
  this.clearQueue();
2736
-
2814
+
2737
2815
  if(instance)
2738
2816
  buttonEl.querySelector('a.menu').addEventListener('click', e => {
2739
2817
  e.stopImmediatePropagation();
@@ -2745,13 +2823,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2745
2823
  });
2746
2824
  });
2747
2825
  });
2748
-
2826
+
2749
2827
  // Show elements
2750
-
2828
+
2751
2829
  custom_widgets = document.createElement('div');
2752
2830
  custom_widgets.className = "lexcustomitems";
2753
2831
  custom_widgets.toggleAttribute('hidden', true);
2754
-
2832
+
2755
2833
  element.appendChild( container );
2756
2834
  element.appendChild( custom_widgets );
2757
2835
 
@@ -2759,7 +2837,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2759
2837
  {
2760
2838
 
2761
2839
  this.queue( custom_widgets );
2762
-
2840
+
2763
2841
  const on_instance_changed = ( key, value, event ) => {
2764
2842
  instance[ key ] = value;
2765
2843
  this._trigger( new IEvent( name, instance, event ), callback );
@@ -2768,7 +2846,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2768
2846
  for( let key in default_instance )
2769
2847
  {
2770
2848
  const value = instance[ key ] ?? default_instance[ key ];
2771
-
2849
+
2772
2850
  switch( value.constructor )
2773
2851
  {
2774
2852
  case String:
@@ -2809,13 +2887,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2809
2887
  }
2810
2888
 
2811
2889
  LX.ADD_CUSTOM_WIDGET = ADD_CUSTOM_WIDGET;
2812
-
2890
+
2813
2891
  /**
2814
2892
  * @class NodeTree
2815
2893
  */
2816
2894
 
2817
2895
  class NodeTree {
2818
-
2896
+
2819
2897
  constructor(domEl, data, options) {
2820
2898
  this.domEl = domEl;
2821
2899
  this.data = data;
@@ -2851,7 +2929,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2851
2929
  node.parent = parent;
2852
2930
  let isParent = node.children.length > 0;
2853
2931
  let isSelected = this.selected.indexOf( node ) > -1;
2854
-
2932
+
2855
2933
  if( this.options.onlyFolders )
2856
2934
  {
2857
2935
  let has_folders = false;
@@ -2868,10 +2946,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2868
2946
  let icon = (this.options.skip_default_icon ?? true) ? "" : "fa-solid fa-square"; // Default: no childs
2869
2947
  if( isParent ) icon = node.closed ? "fa-solid fa-caret-right" : "fa-solid fa-caret-down";
2870
2948
  item.innerHTML = "<a class='" + icon + " hierarchy'></a>";
2871
-
2949
+
2872
2950
  // Add display icon
2873
2951
  icon = node.icon;
2874
-
2952
+
2875
2953
  // Process icon
2876
2954
  if( node.icon )
2877
2955
  {
@@ -2903,7 +2981,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2903
2981
  list.querySelectorAll("li").forEach( e => { e.classList.remove('selected'); } );
2904
2982
  this.selected.length = 0;
2905
2983
  }
2906
-
2984
+
2907
2985
  // Add or remove
2908
2986
  const idx = this.selected.indexOf( node );
2909
2987
  if( idx > -1 ) {
@@ -3070,7 +3148,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3070
3148
  let name_input = document.createElement('input');
3071
3149
  name_input.toggleAttribute('hidden', !node.rename);
3072
3150
  name_input.value = node.id;
3073
- item.appendChild(name_input);
3151
+ item.appendChild(name_input);
3074
3152
 
3075
3153
  if(node.rename) {
3076
3154
  item.classList.add('selected');
@@ -3163,13 +3241,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3163
3241
  delete window.__tree_node_dragged;
3164
3242
  });
3165
3243
  }
3166
-
3244
+
3167
3245
  let handled = false;
3168
3246
 
3169
3247
  // Show/hide children
3170
3248
  if(isParent) {
3171
3249
  item.querySelector('a.hierarchy').addEventListener("click", function(e) {
3172
-
3250
+
3173
3251
  handled = true;
3174
3252
  e.stopImmediatePropagation();
3175
3253
  e.stopPropagation();
@@ -3203,8 +3281,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3203
3281
 
3204
3282
  item.appendChild(visibility);
3205
3283
  }
3206
-
3207
- if(node.actions)
3284
+
3285
+ if(node.actions)
3208
3286
  {
3209
3287
  for(var i = 0; i < node.actions.length; ++i) {
3210
3288
  let a = node.actions[i];
@@ -3243,14 +3321,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3243
3321
  this.domEl.querySelector( "ul" ).innerHTML = "";
3244
3322
  this._create_item( null, this.data, 0, selectedId );
3245
3323
  }
3246
-
3324
+
3247
3325
  /* Refreshes the tree and focuses current element */
3248
3326
  frefresh( id ) {
3249
3327
  this.refresh();
3250
3328
  var el = this.domEl.querySelector( "#" + id );
3251
3329
  if( el ) el.focus();
3252
3330
  }
3253
-
3331
+
3254
3332
  select( id ) {
3255
3333
  this.refresh( null, id );
3256
3334
  }
@@ -3263,11 +3341,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3263
3341
  class Panel {
3264
3342
 
3265
3343
  /**
3266
- * @param {*} options
3344
+ * @param {*} options
3267
3345
  * id: Id of the element
3268
3346
  * className: Add class to the element
3269
3347
  * width: Width of the panel element [fit space]
3270
3348
  * height: Height of the panel element [fit space]
3349
+ * style: CSS Style object to be applied to the panel
3271
3350
  */
3272
3351
 
3273
3352
  constructor( options = {} ) {
@@ -3414,7 +3493,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3414
3493
  this._inlineContainer.style.justifyContent = justifyContent;
3415
3494
  }
3416
3495
  }
3417
-
3496
+
3418
3497
  // Push all elements single element or Array[element, container]
3419
3498
  for( let item of this._inlineWidgets )
3420
3499
  {
@@ -3422,17 +3501,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3422
3501
 
3423
3502
  if(is_pair)
3424
3503
  {
3425
- // eg. an array, inline items appended later to
3504
+ // eg. an array, inline items appended later to
3426
3505
  if(this._inline_queued_container)
3427
3506
  this._inlineContainer.appendChild( item[0] );
3428
3507
  // eg. a dropdown, item is appended to parent, not to inline cont.
3429
3508
  else
3430
3509
  item[1].appendChild(item[0]);
3431
- }
3510
+ }
3432
3511
  else
3433
3512
  this._inlineContainer.appendChild( item );
3434
3513
  }
3435
-
3514
+
3436
3515
  if(!this._inline_queued_container)
3437
3516
  {
3438
3517
  if(this.current_branch)
@@ -3452,7 +3531,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3452
3531
  /**
3453
3532
  * @method branch
3454
3533
  * @param {String} name Name of the branch/section
3455
- * @param {*} options
3534
+ * @param {*} options
3456
3535
  * id: Id of the branch
3457
3536
  * className: Add class to the branch
3458
3537
  * closed: Set branch collapsed/opened [false]
@@ -3572,14 +3651,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3572
3651
  domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
3573
3652
  element.appendChild(domName);
3574
3653
  element.domName = domName;
3575
-
3654
+
3576
3655
  // Copy-paste info
3577
3656
  domName.addEventListener('contextmenu', function( e ) {
3578
3657
  e.preventDefault();
3579
3658
  widget.oncontextmenu( e );
3580
3659
  });
3581
3660
  }
3582
-
3661
+
3583
3662
  this.widgets[ name ] = widget;
3584
3663
  }
3585
3664
 
@@ -3608,7 +3687,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3608
3687
 
3609
3688
  if(this.current_branch)
3610
3689
  {
3611
- if(!options.skipWidget)
3690
+ if(!options.skipWidget)
3612
3691
  this.current_branch.widgets.push( widget );
3613
3692
  this.current_branch.content.appendChild( el );
3614
3693
  }
@@ -3617,7 +3696,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3617
3696
  el.classList.add("nobranch");
3618
3697
  this.root.appendChild( el );
3619
3698
  }
3620
- }
3699
+ }
3621
3700
  // Append content to queued tab container
3622
3701
  else {
3623
3702
  this.queuedContainer.appendChild( el );
@@ -3628,7 +3707,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3628
3707
 
3629
3708
  if(!this.queuedContainer) {
3630
3709
  this._inlineWidgets.push( el );
3631
- }
3710
+ }
3632
3711
  // Append content to queued tab container
3633
3712
  else {
3634
3713
  this._inlineWidgets.push( [el, this.queuedContainer] );
@@ -3667,7 +3746,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3667
3746
  let widget = this.create_widget(null, Widget.TEXT, options);
3668
3747
  let element = widget.domEl;
3669
3748
  element.className += " lexfilter noname";
3670
-
3749
+
3671
3750
  let input = document.createElement('input');
3672
3751
  input.className = 'lexinput-filter';
3673
3752
  input.setAttribute("placeholder", options.placeholder);
@@ -3679,9 +3758,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3679
3758
  element.appendChild(input);
3680
3759
  element.appendChild(searchIcon);
3681
3760
 
3682
- input.addEventListener("input", (e) => {
3761
+ input.addEventListener("input", (e) => {
3683
3762
  if(options.callback)
3684
- options.callback(input.value, e);
3763
+ options.callback(input.value, e);
3685
3764
  });
3686
3765
 
3687
3766
  return element;
@@ -3693,7 +3772,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3693
3772
 
3694
3773
  if(b.name !== branchName)
3695
3774
  continue;
3696
-
3775
+
3697
3776
  // remove all widgets
3698
3777
  for( let w of b.widgets ) {
3699
3778
  if(w.domEl.classList.contains('lexfilter'))
@@ -3755,7 +3834,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3755
3834
 
3756
3835
  if( callback )
3757
3836
  callback.call( this, event.value, event.domEvent, event.name );
3758
-
3837
+
3759
3838
  if( this.onevent )
3760
3839
  this.onevent.call( this, event );
3761
3840
  }
@@ -3894,9 +3973,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3894
3973
  this.disabled ? wValue.innerText = newValue : wValue.value = newValue;
3895
3974
  Panel._dispatch_event( wValue, "focusout", skipCallback );
3896
3975
  };
3897
-
3976
+
3898
3977
  let element = widget.domEl;
3899
-
3978
+
3900
3979
  // Add reset functionality
3901
3980
  if( widget.name && !( options.skipReset ?? false ) ) {
3902
3981
  Panel._add_reset_property( element.domName, function() {
@@ -3905,17 +3984,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3905
3984
  Panel._dispatch_event( wValue, "focusout" );
3906
3985
  } );
3907
3986
  }
3908
-
3987
+
3909
3988
  // Add widget value
3910
-
3989
+
3911
3990
  let container = document.createElement( 'div' );
3912
3991
  container.className = "lextext" + ( options.warning ? " lexwarning" : "" );
3913
3992
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " )";
3914
3993
  container.style.display = "flex";
3915
-
3994
+
3916
3995
  this.disabled = ( options.disabled || options.warning ) ?? ( options.url ? true : false );
3917
3996
  let wValue = null;
3918
-
3997
+
3919
3998
  if( !this.disabled )
3920
3999
  {
3921
4000
  wValue = document.createElement( 'input' );
@@ -3923,19 +4002,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3923
4002
  wValue.value = wValue.iValue = value || "";
3924
4003
  wValue.style.width = "100%";
3925
4004
  wValue.style.textAlign = options.float ?? "";
3926
-
4005
+
3927
4006
  if( options.placeholder )
3928
4007
  wValue.setAttribute( "placeholder", options.placeholder );
3929
-
4008
+
3930
4009
  var resolve = ( function( val, event ) {
3931
4010
  const skipCallback = event.detail;
3932
4011
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
3933
4012
  if( btn ) btn.style.display = ( val != wValue.iValue ? "block" : "none" );
3934
4013
  if( !skipCallback ) this._trigger( new IEvent( name, val, event ), callback );
3935
4014
  }).bind( this );
3936
-
4015
+
3937
4016
  const trigger = options.trigger ?? 'default';
3938
-
4017
+
3939
4018
  if( trigger == 'default' )
3940
4019
  {
3941
4020
  wValue.addEventListener( "keyup", function( e ){
@@ -3952,19 +4031,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3952
4031
  resolve( e.target.value, e );
3953
4032
  });
3954
4033
  }
3955
-
4034
+
3956
4035
  wValue.addEventListener( "mousedown", function( e ){
3957
4036
  e.stopImmediatePropagation();
3958
4037
  e.stopPropagation();
3959
4038
  });
3960
-
4039
+
3961
4040
  if( options.icon )
3962
4041
  {
3963
4042
  let icon = document.createElement( 'a' );
3964
4043
  icon.className = "inputicon " + options.icon;
3965
4044
  container.appendChild( icon );
3966
4045
  }
3967
-
4046
+
3968
4047
  } else
3969
4048
  {
3970
4049
  wValue = document.createElement( options.url ? 'a' : 'div' );
@@ -3978,18 +4057,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3978
4057
  wValue.style.width = "100%";
3979
4058
  wValue.style.textAlign = options.float ?? "";
3980
4059
  }
3981
-
4060
+
3982
4061
  Object.assign( wValue.style, options.style ?? {} );
3983
-
4062
+
3984
4063
  container.appendChild( wValue );
3985
4064
  element.appendChild( container );
3986
-
4065
+
3987
4066
  // Remove branch padding and margins
3988
4067
  if( !widget.name ) {
3989
4068
  element.className += " noname";
3990
4069
  container.style.width = "100%";
3991
4070
  }
3992
-
4071
+
3993
4072
  return widget;
3994
4073
  }
3995
4074
 
@@ -4030,7 +4109,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4030
4109
  Panel._dispatch_event( wValue, "focusout" );
4031
4110
  });
4032
4111
  }
4033
-
4112
+
4034
4113
  // Add widget value
4035
4114
 
4036
4115
  let container = document.createElement( 'div' );
@@ -4083,7 +4162,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4083
4162
 
4084
4163
  container.appendChild(wValue);
4085
4164
  element.appendChild(container);
4086
-
4165
+
4087
4166
  // Remove branch padding and margins
4088
4167
  if(!widget.name) {
4089
4168
  element.className += " noname";
@@ -4112,7 +4191,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4112
4191
  options.disabled = true;
4113
4192
  return this.addText( null, value, null, options );
4114
4193
  }
4115
-
4194
+
4116
4195
  /**
4117
4196
  * @method addButton
4118
4197
  * @param {String} name Widget name
@@ -4134,8 +4213,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4134
4213
  };
4135
4214
 
4136
4215
  widget.onSetValue = ( newValue, skipCallback ) => {
4137
- wValue.innerHTML =
4138
- (options.icon ? "<a class='" + options.icon + "'></a>" :
4216
+ wValue.innerHTML =
4217
+ (options.icon ? "<a class='" + options.icon + "'></a>" :
4139
4218
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (newValue || "") + "</span>" ));
4140
4219
  };
4141
4220
 
@@ -4155,8 +4234,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4155
4234
  wValue.classList.add( options.buttonClass );
4156
4235
  }
4157
4236
 
4158
- wValue.innerHTML =
4159
- (options.icon ? "<a class='" + options.icon + "'></a>" :
4237
+ wValue.innerHTML =
4238
+ (options.icon ? "<a class='" + options.icon + "'></a>" :
4160
4239
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (value || "") + "</span>" ));
4161
4240
 
4162
4241
  wValue.style.width = "calc( 100% - " + (options.nameWidth ?? LX.DEFAULT_NAME_WIDTH) + ")";
@@ -4210,7 +4289,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4210
4289
  let container = document.createElement('div');
4211
4290
  container.className = "lexcombobuttons ";
4212
4291
  if( options.float ) container.className += options.float;
4213
- container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4292
+ container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4214
4293
 
4215
4294
  let should_select = !(options.noSelection ?? false);
4216
4295
  for( let b of values )
@@ -4223,24 +4302,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4223
4302
  if(options.buttonClass)
4224
4303
  buttonEl.classList.add(options.buttonClass);
4225
4304
 
4226
- if(options.selected == b.value)
4305
+ if(options.selected == b.value)
4227
4306
  buttonEl.classList.add("selected");
4228
-
4307
+
4229
4308
  buttonEl.innerHTML = (b.icon ? "<a class='" + b.icon +"'></a>" : "") + "<span>" + (b.icon ? "" : b.value) + "</span>";
4230
-
4309
+
4231
4310
  if(options.disabled)
4232
4311
  buttonEl.setAttribute("disabled", true);
4233
-
4312
+
4234
4313
  buttonEl.addEventListener("click", function(e) {
4235
4314
  if(should_select) {
4236
4315
  container.querySelectorAll('button').forEach( s => s.classList.remove('selected'));
4237
4316
  this.classList.add('selected');
4238
4317
  }
4239
- that._trigger( new IEvent(name, b.value, e), b.callback );
4318
+ that._trigger( new IEvent(name, b.value, e), b.callback );
4240
4319
  });
4241
-
4320
+
4242
4321
  container.appendChild(buttonEl);
4243
-
4322
+
4244
4323
  // Remove branch padding and margins
4245
4324
  if(widget.name === undefined) {
4246
4325
  buttonEl.className += " noname";
@@ -4309,11 +4388,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4309
4388
  }
4310
4389
 
4311
4390
  container.appendChild(name_el);
4312
-
4391
+
4313
4392
  if( options.callback ) {
4314
4393
  container.style.cursor = "pointer";
4315
4394
  container.addEventListener("click", (e) => {
4316
- this._trigger( new IEvent(name, null, e), options.callback );
4395
+ this._trigger( new IEvent(name, null, e), options.callback );
4317
4396
  });
4318
4397
  }
4319
4398
 
@@ -4507,33 +4586,46 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4507
4586
  wValue.name = name;
4508
4587
  wValue.iValue = value;
4509
4588
 
4510
- // Add dropdown widget button
4589
+ // Add dropdown widget button
4511
4590
  let buttonName = value;
4512
4591
  buttonName += "<a class='fa-solid fa-angle-down' style='float:right; margin-right: 3px;'></a>";
4513
4592
 
4514
4593
  this.queue(container);
4515
4594
 
4516
- let selectedOption = this.addButton( null, buttonName, (value, event) => {
4517
- 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
+ {
4518
4609
  delete list.unfocus_event;
4519
4610
  return;
4520
4611
  }
4521
4612
  const topPosition = selectedOption.getBoundingClientRect().y;
4522
4613
  list.style.top = (topPosition + selectedOption.offsetHeight) + 'px';
4523
4614
  list.style.width = (event.currentTarget.clientWidth) + 'px';
4615
+ list.style.minWidth = (_getMaxListWidth()) + 'px';
4524
4616
  list.toggleAttribute('hidden');
4525
4617
  list.focus();
4526
4618
  }, { buttonClass: 'array', skipInlineCount: true });
4527
4619
 
4528
4620
  this.clearQueue();
4529
4621
 
4530
- selectedOption.style.width = "100%";
4622
+ selectedOption.style.width = "100%";
4531
4623
 
4532
4624
  selectedOption.refresh = (v) => {
4533
4625
  if(selectedOption.querySelector("span").innerText == "")
4534
4626
  selectedOption.querySelector("span").innerText = v;
4535
4627
  else
4536
- 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);
4537
4629
  }
4538
4630
 
4539
4631
  // Add dropdown options container
@@ -4545,12 +4637,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4545
4637
  list.addEventListener( 'focusout', function( e ) {
4546
4638
  e.stopPropagation();
4547
4639
  e.stopImmediatePropagation();
4548
- if(e.relatedTarget === selectedOption.querySelector( 'button' )) {
4640
+ if( e.relatedTarget === selectedOption.querySelector( 'button' ) )
4641
+ {
4549
4642
  this.unfocus_event = true;
4550
4643
  setTimeout( () => delete this.unfocus_event, 200 );
4551
- } else if ( e.relatedTarget && e.relatedTarget.tagName == "INPUT" ) {
4644
+ }
4645
+ else if ( e.relatedTarget && e.relatedTarget.tagName == "INPUT" )
4646
+ {
4552
4647
  return;
4553
- }else if ( e.target.id == 'lexinput-filter' ) {
4648
+ }
4649
+ else if ( e.target.className == 'lexinput-filter' )
4650
+ {
4554
4651
  return;
4555
4652
  }
4556
4653
  this.toggleAttribute( 'hidden', true );
@@ -4559,28 +4656,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4559
4656
  // Add filter options
4560
4657
  let filter = null;
4561
4658
  if(options.filter ?? false)
4659
+ {
4562
4660
  filter = this._addFilter("Search option", {container: list, callback: this._search_options.bind(list, values)});
4661
+ }
4563
4662
 
4564
4663
  // Create option list to empty it easily..
4565
- const list_options = document.createElement('span');
4566
- list.appendChild(list_options);
4567
-
4568
- if( filter ) {
4569
- list.prepend(filter);
4570
- list_options.style.height = "calc(100% - 25px)";
4571
-
4572
- 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 ) {
4573
4673
  if (e.relatedTarget && e.relatedTarget.tagName == "UL" && e.relatedTarget.classList.contains("lexoptions"))
4674
+ {
4574
4675
  return;
4575
- list.toggleAttribute('hidden', true);
4676
+ }
4677
+ list.toggleAttribute( 'hidden', true );
4576
4678
  });
4577
4679
  }
4578
4680
 
4579
4681
  // Add dropdown options list
4580
- list.refresh = (options) => {
4682
+ list.refresh = options => {
4581
4683
 
4582
4684
  // Empty list
4583
- list_options.innerHTML = "";
4685
+ listOptions.innerHTML = "";
4584
4686
 
4585
4687
  for(let i = 0; i < options.length; i++)
4586
4688
  {
@@ -4600,7 +4702,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4600
4702
 
4601
4703
  let btn = element.querySelector(".lexwidgetname .lexicon");
4602
4704
  if(btn) btn.style.display = (value != wValue.iValue ? "block" : "none");
4603
- that._trigger( new IEvent(name, value, null), callback );
4705
+ that._trigger( new IEvent(name, value, null), callback );
4604
4706
 
4605
4707
  // Reset filter
4606
4708
  if(filter)
@@ -4639,19 +4741,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4639
4741
  option.setAttribute("title", iValue.value);
4640
4742
  if(value == iValue.value)
4641
4743
  li.classList.add("selected");
4642
- }
4643
- list_options.appendChild(li);
4744
+ }
4745
+
4746
+ listOptions.appendChild( li );
4644
4747
  }
4645
4748
  }
4646
4749
 
4647
- list.refresh(values);
4750
+ list.refresh( values );
4648
4751
 
4649
- container.appendChild(list);
4650
- element.appendChild(container);
4752
+ container.appendChild( list );
4753
+ element.appendChild( container );
4651
4754
 
4652
4755
  // Remove branch padding and margins
4653
- if(!widget.name) {
4654
- element.className += " noname";
4756
+ if( !widget.name )
4757
+ {
4758
+ element.className += " noname";
4655
4759
  container.style.width = "100%";
4656
4760
  }
4657
4761
 
@@ -4794,7 +4898,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4794
4898
  for(var i = 0; i < (16 - nbits); ++i) {
4795
4899
  binary = '0' + binary;
4796
4900
  }
4797
-
4901
+
4798
4902
  for( let bit = 0; bit < 16; ++bit )
4799
4903
  {
4800
4904
  let layer = document.createElement('div');
@@ -4802,32 +4906,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4802
4906
  if( value != undefined )
4803
4907
  {
4804
4908
  const valueBit = binary[ 16 - bit - 1 ];
4805
- if(valueBit != undefined && valueBit == '1')
4806
- layer.classList.add('selected');
4909
+ if(valueBit != undefined && valueBit == '1')
4910
+ layer.classList.add('selected');
4807
4911
  }
4808
4912
  layer.innerText = bit + 1;
4809
4913
  layer.title = "Bit " + bit + ", value " + (1 << bit);
4810
4914
  container.appendChild( layer );
4811
-
4915
+
4812
4916
  layer.addEventListener("click", e => {
4813
-
4917
+
4814
4918
  e.stopPropagation();
4815
4919
  e.stopImmediatePropagation();
4816
4920
  e.target.classList.toggle('selected');
4817
4921
  value ^= ( 1 << bit );
4818
4922
  element.value = value;
4819
-
4923
+
4820
4924
  let btn = element.querySelector(".lexwidgetname .lexicon");
4821
4925
  if(btn) btn.style.display = (value != defaultValue ? "block" : "none");
4822
-
4926
+
4823
4927
  this._trigger( new IEvent(name, value, e), callback );
4824
4928
  });
4825
4929
  }
4826
-
4930
+
4827
4931
  };
4828
4932
 
4829
4933
  setLayers();
4830
-
4934
+
4831
4935
  element.appendChild(container);
4832
4936
 
4833
4937
  return widget;
@@ -4872,7 +4976,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4872
4976
  var container = document.createElement('div');
4873
4977
  container.className = "lexarray";
4874
4978
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4875
-
4979
+
4876
4980
  this.queue( container );
4877
4981
 
4878
4982
  const angle_down = `<a class='fa-solid fa-angle-down' style='float:right; margin-right: 3px;'></a>`;
@@ -4882,7 +4986,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4882
4986
  this.addButton(null, buttonName, () => {
4883
4987
  element.querySelector(".lexarrayitems").toggleAttribute('hidden');
4884
4988
  }, { buttonClass: 'array' });
4885
-
4989
+
4886
4990
  this.clearQueue();
4887
4991
 
4888
4992
  // Show elements
@@ -4890,7 +4994,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4890
4994
  let array_items = document.createElement('div');
4891
4995
  array_items.className = "lexarrayitems";
4892
4996
  array_items.toggleAttribute('hidden', true);
4893
-
4997
+
4894
4998
  element.appendChild(container);
4895
4999
  element.appendChild(array_items);
4896
5000
 
@@ -4971,7 +5075,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4971
5075
  addList( name, values, value, callback, options = {} ) {
4972
5076
 
4973
5077
  let widget = this.create_widget( name, Widget.LIST, options );
4974
-
5078
+
4975
5079
  widget.onGetValue = () => {
4976
5080
  return value;
4977
5081
  };
@@ -4983,56 +5087,56 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4983
5087
  value = newValue;
4984
5088
  if( !skipCallback ) this._trigger( new IEvent( name, newValue ), callback );
4985
5089
  };
4986
-
5090
+
4987
5091
  widget.updateValues = ( newValues ) => {
4988
-
5092
+
4989
5093
  values = newValues;
4990
5094
  listContainer.innerHTML = "";
4991
-
5095
+
4992
5096
  for( let i = 0; i < values.length; ++i )
4993
5097
  {
4994
5098
  let icon = null;
4995
5099
  let itemValue = values[ i ];
4996
-
5100
+
4997
5101
  if( itemValue.constructor === Array )
4998
5102
  {
4999
5103
  icon = itemValue[ 1 ];
5000
5104
  itemValue = itemValue[ 0 ];
5001
5105
  }
5002
-
5106
+
5003
5107
  let listElement = document.createElement( 'div' );
5004
5108
  listElement.className = "lexlistitem" + ( value == itemValue ? " selected" : "" );
5005
5109
  listElement.innerHTML = "<span>" + itemValue + "</span>" + ( icon ? "<a class='" + icon + "'></a>" : "" );
5006
-
5110
+
5007
5111
  listElement.addEventListener( 'click', e => {
5008
5112
  listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
5009
5113
  listElement.classList.toggle( 'selected' );
5010
5114
  value = itemValue;
5011
5115
  this._trigger( new IEvent( name, itemValue, e ), callback );
5012
5116
  });
5013
-
5117
+
5014
5118
  listContainer.appendChild( listElement );
5015
5119
  }
5016
5120
  };
5017
-
5121
+
5018
5122
  let element = widget.domEl;
5019
-
5123
+
5020
5124
  // Show list
5021
-
5125
+
5022
5126
  let listContainer = document.createElement( 'div' );
5023
5127
  listContainer.className = "lexlist";
5024
5128
  listContainer.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5025
-
5129
+
5026
5130
  widget.updateValues( values );
5027
-
5131
+
5028
5132
  // Remove branch padding and margins
5029
5133
  if( !widget.name ) {
5030
5134
  element.className += " noname";
5031
5135
  listContainer.style.width = "100%";
5032
5136
  }
5033
-
5137
+
5034
5138
  element.appendChild( listContainer );
5035
-
5139
+
5036
5140
  return widget;
5037
5141
  }
5038
5142
 
@@ -5084,14 +5188,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5084
5188
  const create_tags = () => {
5085
5189
 
5086
5190
  tags_container.innerHTML = "";
5087
-
5191
+
5088
5192
  for( let i = 0; i < value.length; ++i )
5089
5193
  {
5090
5194
  let tag_name = value[i];
5091
5195
  let tag = document.createElement('span');
5092
5196
  tag.className = "lextag";
5093
5197
  tag.innerHTML = tag_name;
5094
-
5198
+
5095
5199
  tag.addEventListener('click', function( e ) {
5096
5200
  this.remove();
5097
5201
  value.splice( value.indexOf( tag_name ), 1 );
@@ -5099,18 +5203,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5099
5203
  if( btn ) btn.style.display = ( value != defaultValue ? "block" : "none" );
5100
5204
  that._trigger( new IEvent( name, value, e ), callback );
5101
5205
  });
5102
-
5206
+
5103
5207
  tags_container.appendChild( tag );
5104
5208
  }
5105
-
5209
+
5106
5210
  let tag_input = document.createElement( 'input' );
5107
5211
  tag_input.value = "";
5108
5212
  tag_input.placeholder = "Tag...";
5109
5213
  tags_container.insertChildAtIndex( tag_input, 0 );
5110
-
5214
+
5111
5215
  tag_input.onkeydown = function( e ) {
5112
5216
  const val = this.value.replace(/\s/g, '');
5113
- if( e.key == ' ') {
5217
+ if( e.key == ' ') {
5114
5218
  e.preventDefault();
5115
5219
  if( !val.length || value.indexOf( val ) > -1 )
5116
5220
  return;
@@ -5121,7 +5225,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5121
5225
  that._trigger( new IEvent( name, value, e ), callback );
5122
5226
  }
5123
5227
  };
5124
-
5228
+
5125
5229
  tag_input.focus();
5126
5230
  }
5127
5231
 
@@ -5153,9 +5257,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5153
5257
  if( !name ) {
5154
5258
  throw( "Set Widget Name!" );
5155
5259
  }
5156
-
5260
+
5157
5261
  let widget = this.create_widget( name, Widget.CHECKBOX, options );
5158
-
5262
+
5159
5263
  widget.onGetValue = () => {
5160
5264
  return flag.value;
5161
5265
  };
@@ -5163,14 +5267,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5163
5267
  if( flag.value !== newValue )
5164
5268
  Panel._dispatch_event( toggle, "click", skipCallback );
5165
5269
  };
5166
-
5270
+
5167
5271
  let element = widget.domEl;
5168
-
5272
+
5169
5273
  // Add reset functionality
5170
5274
  Panel._add_reset_property( element.domName, function() {
5171
5275
  Panel._dispatch_event( toggle, "click" );
5172
5276
  });
5173
-
5277
+
5174
5278
  // Add widget value
5175
5279
 
5176
5280
  var container = document.createElement('div');
@@ -5204,29 +5308,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5204
5308
  let flag = toggle.querySelector( ".checkbox" );
5205
5309
  if( flag.disabled )
5206
5310
  return;
5207
-
5311
+
5208
5312
  const skipCallback = ( e.detail.constructor == Number ? null : e.detail );
5209
5313
 
5210
5314
  let check = toggle.querySelector( ".checkbox a" );
5211
-
5315
+
5212
5316
  flag.value = !flag.value;
5213
5317
  flag.className = "checkbox " + ( flag.value ? "on" : "" );
5214
5318
  check.style.display = flag.value ? "block" : "none";
5215
-
5319
+
5216
5320
  // Reset button (default value)
5217
5321
  if( !skipCallback )
5218
5322
  {
5219
5323
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
5220
5324
  if( btn ) btn.style.display = flag.value != flag.iValue ? "block": "none";
5221
5325
  }
5222
-
5326
+
5223
5327
  // Open suboptions
5224
5328
  let submenu = element.querySelector( ".lexcheckboxsubmenu" );
5225
5329
  if( submenu ) submenu.toggleAttribute( 'hidden', !flag.value );
5226
-
5330
+
5227
5331
  if( !skipCallback ) this._trigger( new IEvent( name, flag.value, e ), callback );
5228
5332
  });
5229
-
5333
+
5230
5334
  element.appendChild( container );
5231
5335
 
5232
5336
  if( options.suboptions )
@@ -5261,9 +5365,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5261
5365
  if( !name ) {
5262
5366
  throw( "Set Widget Name!" );
5263
5367
  }
5264
-
5368
+
5265
5369
  let widget = this.create_widget( name, Widget.COLOR, options );
5266
-
5370
+
5267
5371
  widget.onGetValue = () => {
5268
5372
  return color.value;
5269
5373
  };
@@ -5271,23 +5375,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5271
5375
  color.value = newValue;
5272
5376
  Panel._dispatch_event( color, "input", skipCallback );
5273
5377
  };
5274
-
5378
+
5275
5379
  let element = widget.domEl;
5276
5380
  let change_from_input = false;
5277
-
5381
+
5278
5382
  // Add reset functionality
5279
5383
  Panel._add_reset_property( element.domName, function() {
5280
5384
  this.style.display = "none";
5281
5385
  color.value = color.iValue;
5282
5386
  Panel._dispatch_event( color, "input" );
5283
5387
  });
5284
-
5388
+
5285
5389
  // Add widget value
5286
-
5390
+
5287
5391
  var container = document.createElement( 'span' );
5288
5392
  container.className = "lexcolor";
5289
5393
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5290
-
5394
+
5291
5395
  let color = document.createElement( 'input' );
5292
5396
  color.style.width = "32px";
5293
5397
  color.type = 'color';
@@ -5295,49 +5399,49 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5295
5399
  color.id = "color" + simple_guidGenerator();
5296
5400
  color.useRGB = options.useRGB ?? false;
5297
5401
  color.value = color.iValue = value.constructor === Array ? rgbToHex( value ) : value;
5298
-
5402
+
5299
5403
  if( options.disabled ) {
5300
5404
  color.disabled = true;
5301
5405
  }
5302
-
5406
+
5303
5407
  color.addEventListener( "input", e => {
5304
5408
  let val = e.target.value;
5305
-
5409
+
5306
5410
  const skipCallback = e.detail;
5307
-
5411
+
5308
5412
  // Change value (always hex)
5309
5413
  if( !change_from_input )
5310
5414
  text_widget.set( val );
5311
-
5415
+
5312
5416
  // Reset button (default value)
5313
5417
  if( !skipCallback )
5314
5418
  {
5315
5419
  let btn = element.querySelector( ".lexwidgetname .lexicon" );
5316
5420
  if( btn ) btn.style.display = val != color.iValue ? "block": "none";
5317
5421
  }
5318
-
5422
+
5319
5423
  if( color.useRGB )
5320
5424
  val = hexToRgb( val );
5321
-
5425
+
5322
5426
  if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
5323
5427
  }, false );
5324
-
5428
+
5325
5429
  container.appendChild( color );
5326
-
5430
+
5327
5431
  this.queue( container );
5328
-
5432
+
5329
5433
  const text_widget = this.addText( null, color.value, v => {
5330
5434
  change_from_input = true;
5331
5435
  widget.set( v );
5332
5436
  change_from_input = false;
5333
5437
  }, { width: "calc( 100% - 32px )"});
5334
-
5438
+
5335
5439
  text_widget.domEl.style.marginLeft = "4px";
5336
-
5440
+
5337
5441
  this.clearQueue();
5338
-
5442
+
5339
5443
  element.appendChild( container );
5340
-
5444
+
5341
5445
  return widget;
5342
5446
  }
5343
5447
 
@@ -5384,7 +5488,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5384
5488
  // add widget value
5385
5489
 
5386
5490
  var container = document.createElement( 'div' );
5387
- container.className = "lexnumber";
5491
+ container.className = "lexnumber";
5388
5492
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5389
5493
 
5390
5494
  let box = document.createElement( 'div' );
@@ -5519,7 +5623,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5519
5623
 
5520
5624
  if( !skipCallback ) this._trigger( new IEvent( name, val, e ), callback );
5521
5625
  }, { passive: false });
5522
-
5626
+
5523
5627
  // Add drag input
5524
5628
 
5525
5629
  vecinput.addEventListener( "mousedown", inner_mousedown );
@@ -5588,7 +5692,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5588
5692
  options.onRelease.bind( vecinput )( e, vecinput );
5589
5693
  }
5590
5694
  }
5591
-
5695
+
5592
5696
  container.appendChild( box );
5593
5697
  element.appendChild( container );
5594
5698
 
@@ -5655,7 +5759,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5655
5759
  // Add widget value
5656
5760
 
5657
5761
  var container = document.createElement( 'div' );
5658
- container.className = "lexvector";
5762
+ container.className = "lexvector";
5659
5763
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
5660
5764
 
5661
5765
  for( let i = 0; i < num_components; ++i ) {
@@ -5748,7 +5852,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5748
5852
 
5749
5853
  if( !skipCallback ) this._trigger( new IEvent( name, value, e ), callback );
5750
5854
  }, false );
5751
-
5855
+
5752
5856
  // Add drag input
5753
5857
 
5754
5858
  vecinput.addEventListener( "mousedown", inner_mousedown );
@@ -5852,7 +5956,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5852
5956
  }
5853
5957
 
5854
5958
  let locker = document.createElement( 'a' );
5855
- locker.className = "fa-solid fa-lock-open lexicon";
5959
+ locker.title = "Lock";
5960
+ locker.className = "fa-solid fa-lock-open lexicon lock";
5856
5961
  container.appendChild( locker );
5857
5962
  locker.addEventListener( "click", function( e ) {
5858
5963
  this.locked = !this.locked;
@@ -5866,7 +5971,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5866
5971
  this.classList.remove( "fa-lock" );
5867
5972
  }
5868
5973
  }, false );
5869
-
5974
+
5870
5975
  element.appendChild( container );
5871
5976
 
5872
5977
  return widget;
@@ -5875,7 +5980,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5875
5980
  /**
5876
5981
  * @method addVector N (2, 3, 4)
5877
5982
  * @param {String} name Widget name
5878
- * @param {Array} value Array of N components
5983
+ * @param {Array} value Array of N components
5879
5984
  * @param {Function} callback Callback function on change
5880
5985
  * @param {*} options:
5881
5986
  * disabled: Make the widget disabled [false]
@@ -5934,18 +6039,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5934
6039
 
5935
6040
  this.queue( element );
5936
6041
 
6042
+ element.aspectRatio = ( value.length == 2 ? value[ 0 ] / value[ 1 ] : null );
5937
6043
  element.dimensions = [];
5938
6044
 
5939
6045
  for( let i = 0; i < value.length; ++i )
5940
6046
  {
5941
- const size = measureRealWidth( JSON.stringify( value[ i ] ), 24 ) + 'px';
5942
6047
  element.dimensions[ i ] = this.addNumber( null, value[ i ], ( v ) => {
5943
6048
 
5944
- const value = [];
6049
+ const value = widget.onGetValue();
5945
6050
 
5946
- for( let i = 0; i < element.dimensions.length; ++i )
6051
+ if( element.locked )
5947
6052
  {
5948
- 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 );
5949
6057
  }
5950
6058
 
5951
6059
  if( callback )
@@ -5953,7 +6061,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5953
6061
  callback( value );
5954
6062
  }
5955
6063
 
5956
- }, { width: size, min: 0, disabled: options.disabled } );
6064
+ }, { min: 0, disabled: options.disabled, precision: options.precision } );
5957
6065
 
5958
6066
  if( ( i + 1 ) != value.length )
5959
6067
  {
@@ -5973,6 +6081,32 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5973
6081
  element.appendChild( unitSpan );
5974
6082
  }
5975
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
+
5976
6110
  // Remove branch padding and margins
5977
6111
  if( !widget.name )
5978
6112
  {
@@ -5986,11 +6120,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5986
6120
  /**
5987
6121
  * @method addPad
5988
6122
  * @param {String} name Widget name
5989
- * @param {Number} value Pad value
6123
+ * @param {Array} value Pad value
5990
6124
  * @param {Function} callback Callback function on change
5991
6125
  * @param {*} options:
5992
6126
  * disabled: Make the widget disabled [false]
5993
6127
  * min, max: Min and Max values
6128
+ * padSize: Size of the pad (css)
5994
6129
  * onPress: Callback function on mouse down
5995
6130
  * onRelease: Callback function on mouse up
5996
6131
  */
@@ -6111,7 +6246,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6111
6246
  /**
6112
6247
  * @method addProgress
6113
6248
  * @param {String} name Widget name
6114
- * @param {Number} value Progress value
6249
+ * @param {Number} value Progress value
6115
6250
  * @param {*} options:
6116
6251
  * min, max: Min and Max values
6117
6252
  * low, optimum, high: Low and High boundary values, Optimum point in the range
@@ -6153,7 +6288,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6153
6288
  progress.min = options.min ?? 0;
6154
6289
  progress.max = options.max ?? 1;
6155
6290
  progress.value = value;
6156
-
6291
+
6157
6292
  if( options.low )
6158
6293
  progress.low = options.low;
6159
6294
  if( options.high )
@@ -6240,65 +6375,75 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6240
6375
 
6241
6376
  addFile( name, callback, options = { } ) {
6242
6377
 
6243
- if( !name ) {
6378
+ if( !name )
6379
+ {
6244
6380
  throw( "Set Widget Name!" );
6245
6381
  }
6246
-
6382
+
6247
6383
  let widget = this.create_widget( name, Widget.FILE, options );
6248
6384
  let element = widget.domEl;
6249
-
6385
+
6250
6386
  let local = options.local ?? true;
6251
6387
  let type = options.type ?? 'text';
6252
- let read = options.read ?? true;
6253
-
6388
+ let read = options.read ?? true;
6389
+
6254
6390
  // Create hidden input
6255
6391
  let input = document.createElement( 'input' );
6256
6392
  input.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + " - 10%)";
6257
6393
  input.type = 'file';
6258
-
6394
+
6259
6395
  if( options.placeholder )
6396
+ {
6260
6397
  input.placeholder = options.placeholder;
6261
-
6398
+ }
6399
+
6262
6400
  input.addEventListener( 'change', function( e ) {
6263
-
6401
+
6264
6402
  const files = e.target.files;
6265
6403
  if( !files.length ) return;
6266
6404
  if( read )
6267
6405
  {
6268
6406
  if( options.onBeforeRead )
6269
6407
  options.onBeforeRead();
6270
-
6408
+
6271
6409
  const reader = new FileReader();
6272
-
6410
+
6273
6411
  if( type === 'text' ) reader.readAsText( files[ 0 ] );
6274
6412
  else if( type === 'buffer' ) reader.readAsArrayBuffer( files[ 0 ] );
6275
6413
  else if( type === 'bin' ) reader.readAsBinaryString( files[ 0 ] );
6276
6414
  else if( type === 'url' ) reader.readAsDataURL( files[ 0 ] );
6277
-
6415
+
6278
6416
  reader.onload = e => { callback.call( this, e.target.result, files[ 0 ] ) } ;
6279
6417
  }
6280
6418
  else
6281
6419
  callback( files[ 0 ] );
6282
6420
  });
6283
-
6421
+
6284
6422
  element.appendChild( input );
6285
-
6423
+
6286
6424
  this.queue( element );
6287
-
6425
+
6288
6426
  if( local )
6289
6427
  {
6428
+ let settingsDialog = null;
6429
+
6290
6430
  this.addButton(null, "<a style='margin-top: 0px;' class='fa-solid fa-gear'></a>", () => {
6291
-
6292
- new Dialog( "Load Settings", p => {
6431
+
6432
+ if( settingsDialog )
6433
+ {
6434
+ return;
6435
+ }
6436
+
6437
+ settingsDialog = new Dialog( "Load Settings", p => {
6293
6438
  p.addDropdown( "Type", [ 'text', 'buffer', 'bin', 'url' ], type, v => { type = v } );
6294
6439
  p.addButton( null, "Reload", v => { input.dispatchEvent( new Event( 'change' ) ) } );
6295
- });
6296
-
6297
- }, { className: "micro", skipInlineCount: true });
6440
+ }, { onclose: ( root ) => { root.remove(); settingsDialog = null; } } );
6441
+
6442
+ }, { className: "micro", skipInlineCount: true, title: "Settings" });
6298
6443
  }
6299
-
6444
+
6300
6445
  this.clearQueue();
6301
-
6446
+
6302
6447
  return widget;
6303
6448
  }
6304
6449
 
@@ -6356,7 +6501,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6356
6501
  node_filter_input.addEventListener('input', function(){
6357
6502
  nodeTree.refresh();
6358
6503
  });
6359
-
6504
+
6360
6505
  let searchIcon = document.createElement('a');
6361
6506
  searchIcon.className = "lexicon fa-solid fa-magnifying-glass";
6362
6507
  toolsDiv.appendChild(node_filter_input);
@@ -6390,11 +6535,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6390
6535
  element.className = "lexseparator";
6391
6536
  let widget = new Widget( null, Widget.SEPARATOR );
6392
6537
  widget.domEl = element;
6393
-
6538
+
6394
6539
  if(this.current_branch) {
6395
6540
  this.current_branch.content.appendChild( element );
6396
6541
  this.current_branch.widgets.push( widget );
6397
- } else
6542
+ } else
6398
6543
  this.root.appendChild(element);
6399
6544
  }
6400
6545
 
@@ -6406,7 +6551,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6406
6551
  * onCreate: Func to be called at tab creation
6407
6552
  * onSelect: Func to be called on select tab (optional)
6408
6553
  * }
6409
- * @param {*} options
6554
+ * @param {*} options
6410
6555
  * vertical: Use vertical or horizontal tabs (vertical by default)
6411
6556
  * showNames: Show tab name only in horizontal tabs
6412
6557
  */
@@ -6488,7 +6633,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6488
6633
  this.clearQueue();
6489
6634
  }
6490
6635
  }
6491
-
6636
+
6492
6637
  this.addSeparator();
6493
6638
  }
6494
6639
  }
@@ -6500,7 +6645,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6500
6645
  */
6501
6646
 
6502
6647
  class Branch {
6503
-
6648
+
6504
6649
  constructor( name, options = {} ) {
6505
6650
 
6506
6651
  this.name = name;
@@ -6615,23 +6760,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6615
6760
 
6616
6761
  _addBranchSeparator() {
6617
6762
 
6618
- var element = document.createElement('div');
6763
+ const element = document.createElement('div');
6619
6764
  element.className = "lexwidgetseparator";
6620
6765
  element.style.width = "100%";
6621
6766
  element.style.background = "none";
6622
6767
 
6623
- var grabber = document.createElement('div');
6768
+ const grabber = document.createElement('div');
6624
6769
  grabber.innerHTML = "&#9662;";
6625
- grabber.style.marginLeft = LX.DEFAULT_NAME_WIDTH;
6626
6770
  element.appendChild(grabber);
6627
6771
 
6628
- 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');
6629
6777
  line.style.width = "1px";
6630
6778
  line.style.marginLeft = "6px";
6631
6779
  line.style.marginTop = "2px";
6632
6780
  line.style.height = "0px"; // get in time
6633
- grabber.appendChild(line);
6634
- grabber.addEventListener("mousedown", inner_mousedown);
6781
+ grabber.appendChild( line );
6782
+ grabber.addEventListener( "mousedown", innerMouseDown );
6635
6783
 
6636
6784
  this.grabber = grabber;
6637
6785
 
@@ -6639,45 +6787,40 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6639
6787
  return that.root.offsetHeight - that.root.children[0].offsetHeight;
6640
6788
  }
6641
6789
 
6642
- var that = this;
6643
- var lastX = 0;
6644
- var lastXLine = 0;
6645
- function inner_mousedown(e)
6790
+ let that = this;
6791
+
6792
+ function innerMouseDown( e )
6646
6793
  {
6647
6794
  var doc = that.root.ownerDocument;
6648
- doc.addEventListener("mouseup",inner_mouseup);
6649
- doc.addEventListener("mousemove",inner_mousemove);
6650
- lastX = e.pageX;
6651
- lastXLine = e.pageX;
6795
+ doc.addEventListener("mouseup", innerMouseUp);
6796
+ doc.addEventListener("mousemove", innerMouseMove);
6652
6797
  e.stopPropagation();
6653
6798
  e.preventDefault();
6654
- var h = getBranchHeight();
6799
+ const h = getBranchHeight();
6655
6800
  line.style.height = (h-3) + "px";
6656
6801
  document.body.classList.add('nocursor');
6657
6802
  }
6658
-
6659
- function inner_mousemove(e)
6803
+
6804
+ function innerMouseMove(e)
6660
6805
  {
6661
- if (lastXLine != e.pageX) {
6662
- var dt = lastXLine - e.pageX;
6663
- var margin = parseFloat( grabber.style.marginLeft );
6664
- grabber.style.marginLeft = clamp(margin - dt * 0.1, 10, 90) + "%";
6665
- }
6806
+ let dt = e.movementX;
6666
6807
 
6667
- 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
+ }
6668
6813
  }
6669
6814
 
6670
- function inner_mouseup(e)
6815
+ function innerMouseUp(e)
6671
6816
  {
6672
- if (lastX != e.pageX)
6673
- that._updateWidgets();
6674
- lastX = e.pageX;
6675
- lastXLine = e.pageX;
6817
+ that._updateWidgets();
6818
+
6676
6819
  line.style.height = "0px";
6677
6820
 
6678
6821
  var doc = that.root.ownerDocument;
6679
- doc.removeEventListener("mouseup",inner_mouseup);
6680
- doc.removeEventListener("mousemove",inner_mousemove);
6822
+ doc.removeEventListener("mouseup", innerMouseUp);
6823
+ doc.removeEventListener("mousemove", innerMouseMove);
6681
6824
  document.body.classList.remove('nocursor');
6682
6825
  }
6683
6826
 
@@ -6737,7 +6880,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6737
6880
  static _last_id = 0;
6738
6881
 
6739
6882
  constructor( title, callback, options = {} ) {
6740
-
6883
+
6741
6884
  if( !callback )
6742
6885
  {
6743
6886
  console.warn("Content is empty, add some widgets using 'callback' parameter!");
@@ -6774,31 +6917,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6774
6917
  titleDiv.oncontextmenu = function(e) {
6775
6918
  e.preventDefault();
6776
6919
  e.stopPropagation();
6777
-
6920
+
6778
6921
  if(!LX.main_area || LX.main_area.type !== 'horizontal')
6779
6922
  return;
6780
6923
 
6781
6924
  addContextMenu("Dock", e, p => {
6782
6925
  e.preventDefault();
6783
-
6784
- const get_next_panel = function(area) {
6785
- let p = area.panels[0];
6926
+
6927
+ const _getNextPanel = function( area ) {
6928
+ let p = area.panels[ 0 ];
6786
6929
  if( p ) return p;
6787
6930
  for(var s of area.sections){
6788
- p = get_next_panel(s);
6931
+ p = _getNextPanel( s );
6789
6932
  if( p ) return p;
6790
6933
  }
6791
6934
  }
6792
6935
 
6793
- const append_branch = function(panel) {
6936
+ const _appendBranch = function( panel ) {
6794
6937
  let branch = panel.branches.find( b => b.name === title );
6795
- if( !branch ) {
6796
- panel.branch(title);
6797
- branch = panel.branches.find( b => b.name === title );
6798
- }else
6938
+ if( !branch )
6939
+ {
6940
+ panel.branch( title );
6941
+ branch = panel.branches.find( b => b.name === title );
6942
+ }
6943
+ else
6944
+ {
6799
6945
  panel.root.appendChild( branch.root );
6946
+ }
6800
6947
 
6801
- for( let w of that.widgets ) {
6948
+ for( let w of that.widgets )
6949
+ {
6802
6950
  branch.content.appendChild( w.domEl );
6803
6951
  }
6804
6952
 
@@ -6809,16 +6957,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6809
6957
  branch.root.classList.add('last');
6810
6958
  root.remove();
6811
6959
  }
6812
-
6960
+
6813
6961
  // Right
6814
- let rpanel = get_next_panel(LX.main_area.sections[1]);
6962
+ let rpanel = _getNextPanel(LX.main_area.sections[ 1 ]);
6815
6963
  p.add('<i class="fa-regular fa-window-maximize fa-window-maximize fa-rotate-90">', {disabled: !rpanel, id: 'dock_options0', callback: () => {
6816
- append_branch(rpanel);
6964
+ _appendBranch(rpanel);
6817
6965
  }});
6818
6966
  // Left
6819
- let lpanel = get_next_panel(LX.main_area.sections[0]);
6967
+ let lpanel = _getNextPanel(LX.main_area.sections[ 0 ]);
6820
6968
  p.add('<i class="fa-regular fa-window-maximize fa-window-maximize fa-rotate-270">', {disabled: !lpanel, id: 'dock_options1', callback: () => {
6821
- append_branch(lpanel);
6969
+ _appendBranch(lpanel);
6822
6970
  }});
6823
6971
  }, { icon: "fa-regular fa-window-restore" });
6824
6972
  };
@@ -6830,41 +6978,61 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6830
6978
  {
6831
6979
  this.close = () => {
6832
6980
 
6981
+ if( options.onBeforeClose )
6982
+ {
6983
+ options.onBeforeClose( this );
6984
+ }
6985
+
6833
6986
  if( !options.onclose )
6834
6987
  {
6835
6988
  that.panel.clear();
6836
6989
  root.remove();
6837
- } else
6990
+ }
6991
+ else
6838
6992
  {
6839
6993
  options.onclose( this.root );
6840
6994
  }
6841
6995
 
6842
- if(modal)
6843
- LX.modal.toggle(true);
6996
+ if( modal )
6997
+ {
6998
+ LX.modal.toggle( true );
6999
+ }
6844
7000
  };
6845
7001
 
6846
- var closeButton = document.createElement('a');
7002
+ var closeButton = document.createElement( 'a' );
6847
7003
  closeButton.className = "lexdialogcloser fa-solid fa-xmark";
6848
7004
  closeButton.title = "Close";
6849
- closeButton.addEventListener('click', this.close);
7005
+ closeButton.addEventListener( "click", this.close );
6850
7006
 
6851
- if(title) titleDiv.appendChild(closeButton);
6852
- else {
6853
- closeButton.classList.add("notitle");
6854
- root.appendChild(closeButton);
7007
+ if( title )
7008
+ {
7009
+ titleDiv.appendChild( closeButton );
7010
+ }
7011
+ else
7012
+ {
7013
+ closeButton.classList.add( "notitle" );
7014
+ root.appendChild( closeButton );
6855
7015
  }
6856
7016
  }
6857
7017
 
6858
7018
  const panel = new Panel();
6859
- panel.root.classList.add('lexdialogcontent');
6860
- if(!title) panel.root.classList.add('notitle');
6861
- if(callback)
6862
- callback.call(this, panel);
6863
- 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 );
6864
7032
 
6865
7033
  // Make branches have a distintive to manage some cases
6866
7034
  panel.root.querySelectorAll(".lexbranch").forEach( b => b.classList.add("dialog") );
6867
-
7035
+
6868
7036
  this.panel = panel;
6869
7037
  this.root = root;
6870
7038
  this.title = titleDiv;
@@ -6875,26 +7043,34 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6875
7043
  }
6876
7044
 
6877
7045
  // Process position and size
6878
- if(size.length && typeof(size[0]) != "string")
6879
- size[0] += "px";
6880
- if(size.length && typeof(size[1]) != "string")
6881
- 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
+ }
7055
+
7056
+ root.style.width = size[ 0 ] ? (size[ 0 ]) : "25%";
7057
+ root.style.height = size[ 1 ] ? (size[ 1 ]) : "auto";
6882
7058
 
6883
- root.style.width = size[0] ? (size[0]) : "25%";
6884
- root.style.height = size[1] ? (size[1]) : "auto";
7059
+ if( options.size )
7060
+ {
7061
+ this.size = size;
7062
+ }
6885
7063
 
6886
- if(options.size) this.size = size;
6887
-
6888
7064
  let rect = root.getBoundingClientRect();
6889
- root.style.left = position[0] ? (position[0]) : "calc( 50% - " + (rect.width * 0.5) + "px )";
6890
- 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 )";
6891
7067
 
6892
7068
  panel.root.style.width = "calc( 100% - 30px )";
6893
- 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 )";
6894
7070
  }
6895
7071
 
6896
7072
  destroy() {
6897
-
7073
+
6898
7074
  this.root.remove();
6899
7075
  }
6900
7076
 
@@ -6905,7 +7081,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6905
7081
  }
6906
7082
 
6907
7083
  setPosition(x, y) {
6908
-
7084
+
6909
7085
  this.root.style.left = x + "px";
6910
7086
  this.root.style.top = y + "px";
6911
7087
  }
@@ -6934,9 +7110,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6934
7110
 
6935
7111
  options.draggable = options.draggable ?? false;
6936
7112
  options.closable = options.closable ?? false;
6937
-
7113
+
6938
7114
  super( title, callback, options );
6939
-
7115
+
6940
7116
  let that = this;
6941
7117
  // Update margins on branch title closes/opens
6942
7118
  LX.addSignal("@on_branch_closed", this.panel, closed => {
@@ -6944,7 +7120,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6944
7120
  this.root.style.top = "calc(100% - " + (this.root.offsetHeight + 6) + "px)";
6945
7121
  });
6946
7122
 
6947
- // Custom
7123
+ // Custom
6948
7124
  this.root.classList.add( "pocket" );
6949
7125
  if( !options.position ) {
6950
7126
  this.root.style.left = "calc(100% - " + (this.root.offsetWidth + 6) + "px)";
@@ -6958,7 +7134,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6958
7134
  this.title.tabIndex = -1;
6959
7135
  this.title.addEventListener("click", e => {
6960
7136
 
6961
- // Sized dialogs have to keep their size
7137
+ // Sized dialogs have to keep their size
6962
7138
  if( this.size )
6963
7139
  {
6964
7140
  if( !this.minimized ) this.root.style.height = "auto";
@@ -6969,7 +7145,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6969
7145
  this.minimized = !this.minimized;
6970
7146
 
6971
7147
  if( this.dock_pos == PocketDialog.BOTTOM )
6972
- that.root.style.top = this.root.classList.contains("minimized") ?
7148
+ that.root.style.top = this.root.classList.contains("minimized") ?
6973
7149
  "calc(100% - " + (that.title.offsetHeight + 6) + "px)" : "calc(100% - " + (that.root.offsetHeight + 6) + "px)";
6974
7150
  });
6975
7151
 
@@ -6984,10 +7160,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6984
7160
  const t = float[i];
6985
7161
  switch( t )
6986
7162
  {
6987
- case 'b':
7163
+ case 'b':
6988
7164
  this.root.style.top = "calc(100% - " + (this.root.offsetHeight + 6) + "px)";
6989
7165
  break;
6990
- case 'l':
7166
+ case 'l':
6991
7167
  this.root.style.left = options.position ? options.position[ 1 ] : "0px";
6992
7168
  break;
6993
7169
  }
@@ -7021,7 +7197,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7021
7197
  class ContextMenu {
7022
7198
 
7023
7199
  constructor( event, title, options = {} ) {
7024
-
7200
+
7025
7201
  // remove all context menus
7026
7202
  document.body.querySelectorAll(".lexcontextmenubox").forEach(e => e.remove());
7027
7203
 
@@ -7033,7 +7209,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7033
7209
  this.root.addEventListener("mouseleave", function() {
7034
7210
  this.remove();
7035
7211
  });
7036
-
7212
+
7037
7213
  this.items = [];
7038
7214
  this.colors = {};
7039
7215
 
@@ -7050,9 +7226,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7050
7226
  _adjust_position( div, margin, useAbsolute = false ) {
7051
7227
 
7052
7228
  let rect = div.getBoundingClientRect();
7053
-
7229
+
7054
7230
  if( !useAbsolute )
7055
- {
7231
+ {
7056
7232
  let width = rect.width;
7057
7233
  if( rect.left < 0 )
7058
7234
  {
@@ -7079,7 +7255,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7079
7255
  {
7080
7256
  div.style.left = div.offsetLeft + (dt - margin) + "px";
7081
7257
  }
7082
-
7258
+
7083
7259
  dt = window.innerHeight - (rect.top + rect.height);
7084
7260
  if( dt < 0 )
7085
7261
  {
@@ -7139,14 +7315,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7139
7315
  entry.addEventListener("click", e => {
7140
7316
  e.stopPropagation();
7141
7317
  e.stopImmediatePropagation();
7142
-
7318
+
7143
7319
  if(disabled) return;
7144
-
7320
+
7145
7321
  const f = o[ 'callback' ];
7146
7322
  if(f) {
7147
7323
  f.call( this, k, entry );
7148
7324
  this.root.remove();
7149
- }
7325
+ }
7150
7326
 
7151
7327
  if( !hasSubmenu )
7152
7328
  return;
@@ -7210,7 +7386,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7210
7386
  } );
7211
7387
 
7212
7388
  if(found) {
7213
- insert( tokens[idx++], found );
7389
+ insert( tokens[idx++], found );
7214
7390
  }
7215
7391
  else {
7216
7392
  let item = {};
@@ -7221,10 +7397,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7221
7397
  item[ 'id' ] = options.id;
7222
7398
  item[ 'callback' ] = options.callback;
7223
7399
  item[ 'disabled' ] = options.disabled ?? false;
7224
- }
7400
+ }
7225
7401
 
7226
7402
  list.push( item );
7227
- insert( next_token, item[ token ] );
7403
+ insert( next_token, item[ token ] );
7228
7404
  }
7229
7405
  };
7230
7406
 
@@ -7309,14 +7485,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7309
7485
  class Curve {
7310
7486
 
7311
7487
  constructor( panel, value, options = {} ) {
7312
-
7488
+
7313
7489
  let element = document.createElement( "div" );
7314
7490
  element.className = "curve " + ( options.className ? options.className : "" );
7315
7491
  element.style.minHeight = "50px";
7316
7492
  element.style.width = options.width || "100%";
7317
7493
  element.style.minWidth = "50px";
7318
7494
  element.style.minHeight = "20px";
7319
-
7495
+
7320
7496
  element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
7321
7497
  element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
7322
7498
  element.linecolor = options.lineColor || "#555";
@@ -7331,24 +7507,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7331
7507
  element.draggable_y = options.draggableY ?? true;
7332
7508
  element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
7333
7509
  element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
7334
-
7510
+
7335
7511
  this.element = element;
7336
-
7512
+
7337
7513
  let canvas = document.createElement( "canvas" );
7338
7514
  canvas.width = options.width || 200;
7339
7515
  canvas.height = options.height || 50;
7340
7516
  element.appendChild( canvas );
7341
7517
  this.canvas = canvas;
7342
-
7518
+
7343
7519
  element.addEventListener( "mousedown", onmousedown );
7344
-
7520
+
7345
7521
  element.getValueAt = function( x ) {
7346
-
7522
+
7347
7523
  if( x < element.xrange[ 0 ] || x > element.xrange[ 1 ] )
7348
7524
  {
7349
7525
  return element.defaulty;
7350
7526
  }
7351
-
7527
+
7352
7528
  var last = [ element.xrange[ 0 ], element.defaulty ];
7353
7529
  var f = 0;
7354
7530
  for( var i = 0; i < element.value.length; i += 1 )
@@ -7360,17 +7536,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7360
7536
  f = ( x - last[ 0 ] ) / (v[ 0 ] - last[ 0 ]);
7361
7537
  return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
7362
7538
  }
7363
-
7539
+
7364
7540
  last = v;
7365
7541
  }
7366
-
7542
+
7367
7543
  v = [ element.xrange[ 1 ], element.defaulty ];
7368
7544
  f = (x - last[ 0 ]) / (v[ 0 ] - last[ 0 ]);
7369
7545
  return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
7370
7546
  }
7371
-
7547
+
7372
7548
  element.resample = function( samples ) {
7373
-
7549
+
7374
7550
  var r = [];
7375
7551
  var dx = (element.xrange[1] - element.xrange[ 0 ]) / samples;
7376
7552
  for(var i = element.xrange[0]; i <= element.xrange[1]; i += dx)
@@ -7379,9 +7555,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7379
7555
  }
7380
7556
  return r;
7381
7557
  }
7382
-
7558
+
7383
7559
  element.addValue = function(v) {
7384
-
7560
+
7385
7561
  for(var i = 0; i < element.value; i++) {
7386
7562
  var value = element.value[i];
7387
7563
  if(value[0] < v[0]) continue;
@@ -7389,27 +7565,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7389
7565
  redraw();
7390
7566
  return;
7391
7567
  }
7392
-
7568
+
7393
7569
  element.value.push(v);
7394
7570
  redraw();
7395
7571
  }
7396
-
7572
+
7397
7573
  //value to canvas
7398
7574
  function convert(v) {
7399
7575
  return [ canvas.width * ( v[0] - element.xrange[0])/ (element.xrange[1]),
7400
7576
  canvas.height * (v[1] - element.yrange[0])/ (element.yrange[1])];
7401
7577
  }
7402
-
7578
+
7403
7579
  //canvas to value
7404
7580
  function unconvert(v) {
7405
7581
  return [(v[0] * element.xrange[1] / canvas.width + element.xrange[0]),
7406
7582
  (v[1] * element.yrange[1] / canvas.height + element.yrange[0])];
7407
7583
  }
7408
-
7584
+
7409
7585
  var selected = -1;
7410
-
7586
+
7411
7587
  element.redraw = function( o = {} ) {
7412
-
7588
+
7413
7589
  if( o.value ) element.value = o.value;
7414
7590
  if( o.xrange ) element.xrange = o.xrange;
7415
7591
  if( o.yrange ) element.yrange = o.yrange;
@@ -7420,23 +7596,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7420
7596
  {
7421
7597
  canvas.width = rect.width;
7422
7598
  }
7423
-
7599
+
7424
7600
  var ctx = canvas.getContext( "2d" );
7425
7601
  ctx.setTransform( 1, 0, 0, 1, 0, 0 );
7426
7602
  ctx.translate( 0, canvas.height );
7427
7603
  ctx.scale( 1, -1 );
7428
-
7604
+
7429
7605
  ctx.fillStyle = element.bgcolor;
7430
7606
  ctx.fillRect(0,0,canvas.width,canvas.height);
7431
-
7607
+
7432
7608
  ctx.strokeStyle = element.linecolor;
7433
7609
  ctx.beginPath();
7434
-
7610
+
7435
7611
  //draw line
7436
7612
  var pos = convert([ element.xrange[ 0 ],element.defaulty ]);
7437
7613
  ctx.moveTo( pos[ 0 ], pos[ 1 ] );
7438
7614
  let values = [pos[ 0 ], pos[ 1 ]];
7439
-
7615
+
7440
7616
  for(var i in element.value) {
7441
7617
  var value = element.value[i];
7442
7618
  pos = convert(value);
@@ -7445,7 +7621,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7445
7621
  if(!element.smooth)
7446
7622
  ctx.lineTo( pos[ 0 ], pos[ 1 ] );
7447
7623
  }
7448
-
7624
+
7449
7625
  pos = convert([ element.xrange[ 1 ], element.defaulty ]);
7450
7626
  values.push(pos[ 0 ]);
7451
7627
  values.push(pos[ 1 ]);
@@ -7458,7 +7634,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7458
7634
  {
7459
7635
  LX.UTILS.drawSpline( ctx, values, element.smooth );
7460
7636
  }
7461
-
7637
+
7462
7638
  // Draw points
7463
7639
  for( var i = 0; i < element.value.length; i += 1 ) {
7464
7640
  var value = element.value[ i ];
@@ -7471,7 +7647,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7471
7647
  ctx.arc( pos[ 0 ], pos[ 1 ], selected == i ? 4 : 3, 0, Math.PI * 2);
7472
7648
  ctx.fill();
7473
7649
  }
7474
-
7650
+
7475
7651
  if(element.show_samples) {
7476
7652
  var samples = element.resample(element.show_samples);
7477
7653
  ctx.fillStyle = "#888";
@@ -7485,43 +7661,43 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7485
7661
  }
7486
7662
  }
7487
7663
  }
7488
-
7664
+
7489
7665
  var last_mouse = [ 0, 0 ];
7490
-
7666
+
7491
7667
  function onmousedown( e ) {
7492
7668
  document.addEventListener( "mousemove", onmousemove );
7493
7669
  document.addEventListener( "mouseup", onmouseup );
7494
-
7670
+
7495
7671
  var rect = canvas.getBoundingClientRect();
7496
7672
  var mousex = e.clientX - rect.left;
7497
7673
  var mousey = e.clientY - rect.top;
7498
-
7674
+
7499
7675
  selected = computeSelected( mousex, canvas.height - mousey );
7500
-
7676
+
7501
7677
  if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
7502
7678
  var v = unconvert([ mousex, canvas.height - mousey ]);
7503
7679
  element.value.push( v );
7504
7680
  sortValues();
7505
7681
  selected = element.value.indexOf( v );
7506
7682
  }
7507
-
7683
+
7508
7684
  last_mouse = [ mousex, mousey ];
7509
7685
  element.redraw();
7510
7686
  e.preventDefault();
7511
7687
  e.stopPropagation();
7512
7688
  }
7513
-
7689
+
7514
7690
  function onmousemove( e ) {
7515
-
7691
+
7516
7692
  var rect = canvas.getBoundingClientRect();
7517
7693
  var mousex = e.clientX - rect.left;
7518
7694
  var mousey = e.clientY - rect.top;
7519
-
7695
+
7520
7696
  if( mousex < 0 ) mousex = 0;
7521
7697
  else if( mousex > canvas.width ) mousex = canvas.width;
7522
7698
  if( mousey < 0 ) mousey = 0;
7523
7699
  else if( mousey > canvas.height ) mousey = canvas.height;
7524
-
7700
+
7525
7701
  // Dragging to remove
7526
7702
  const currentMouseDiff = [ e.clientX - rect.left, e.clientY - rect.top ];
7527
7703
  if( selected != -1 && distance( currentMouseDiff, [ mousex, mousey ] ) > canvas.height * 0.5 )
@@ -7537,25 +7713,25 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7537
7713
  value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
7538
7714
  value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
7539
7715
  }
7540
-
7716
+
7541
7717
  onmouseup( e );
7542
7718
  return;
7543
7719
  }
7544
-
7720
+
7545
7721
  var dx = element.draggable_x ? last_mouse[ 0 ] - mousex : 0;
7546
7722
  var dy = element.draggable_y ? last_mouse[ 1 ] - mousey : 0;
7547
7723
  var delta = unconvert([ -dx, dy ]);
7548
-
7724
+
7549
7725
  if( selected != -1 ) {
7550
7726
  var minx = element.xrange[ 0 ];
7551
7727
  var maxx = element.xrange[ 1 ];
7552
-
7728
+
7553
7729
  if( element.no_overlap )
7554
7730
  {
7555
7731
  if( selected > 0) minx = element.value[ selected - 1 ][ 0 ];
7556
7732
  if( selected < ( element.value.length - 1 ) ) maxx = element.value[ selected + 1 ][ 0 ];
7557
7733
  }
7558
-
7734
+
7559
7735
  var v = element.value[selected];
7560
7736
  v[ 0 ] += delta[ 0 ];
7561
7737
  v[ 1 ] += delta[ 1 ];
@@ -7564,17 +7740,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7564
7740
  if(v[ 1 ] < element.yrange[ 0 ]) v[ 1 ] = element.yrange[ 0 ];
7565
7741
  else if(v[ 1 ] > element.yrange[ 1 ]) v[ 1 ] = element.yrange[ 1 ];
7566
7742
  }
7567
-
7743
+
7568
7744
  sortValues();
7569
7745
  element.redraw();
7570
7746
  last_mouse[ 0 ] = mousex;
7571
7747
  last_mouse[ 1 ] = mousey;
7572
7748
  onchange( e );
7573
-
7749
+
7574
7750
  e.preventDefault();
7575
7751
  e.stopPropagation();
7576
7752
  }
7577
-
7753
+
7578
7754
  function onmouseup( e ) {
7579
7755
  selected = -1;
7580
7756
  element.redraw();
@@ -7584,16 +7760,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7584
7760
  e.preventDefault();
7585
7761
  e.stopPropagation();
7586
7762
  }
7587
-
7763
+
7588
7764
  function onchange( e ) {
7589
7765
  if( options.callback )
7590
7766
  options.callback.call( element, element.value, e );
7591
7767
  }
7592
-
7768
+
7593
7769
  function distance(a,b) { return Math.sqrt( Math.pow(b[0]-a[0],2) + Math.pow(b[1]-a[1],2) ); };
7594
-
7770
+
7595
7771
  function computeSelected( x, y ) {
7596
-
7772
+
7597
7773
  var minDistance = 100000;
7598
7774
  var maxDistance = 8; //pixels
7599
7775
  var selected = -1;
@@ -7610,7 +7786,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7610
7786
  }
7611
7787
  return selected;
7612
7788
  }
7613
-
7789
+
7614
7790
  function sortValues() {
7615
7791
  var v = null;
7616
7792
  if( selected != -1 )
@@ -7623,11 +7799,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7623
7799
  selected = element.value.indexOf( v );
7624
7800
  }
7625
7801
  }
7626
-
7802
+
7627
7803
  element.redraw();
7628
7804
  return this;
7629
7805
  }
7630
-
7806
+
7631
7807
  redraw( options = {} ) {
7632
7808
  this.element.redraw( options );
7633
7809
  }
@@ -7645,14 +7821,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7645
7821
  static ASSET_DBLCLICKED = 5;
7646
7822
  static ENTER_FOLDER = 6;
7647
7823
  static ASSET_CHECKED = 7;
7648
-
7824
+
7649
7825
  constructor( type, item, value ) {
7650
7826
  this.type = type || TreeEvent.NONE;
7651
7827
  this.item = item;
7652
7828
  this.value = value;
7653
7829
  this.multiple = false; // Multiple selection
7654
7830
  }
7655
-
7831
+
7656
7832
  string() {
7657
7833
  switch(this.type) {
7658
7834
  case AssetViewEvent.NONE: return "assetview_event_none";
@@ -7727,7 +7903,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7727
7903
  {
7728
7904
  [ contentArea, right ] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
7729
7905
  }
7730
-
7906
+
7731
7907
  this.allowedTypes = options.allowedTypes || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
7732
7908
 
7733
7909
  this.prevData = [];
@@ -7745,7 +7921,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7745
7921
  }
7746
7922
 
7747
7923
  this._createContentPanel( contentArea );
7748
-
7924
+
7749
7925
  // Create resource preview panel
7750
7926
  if( !this.skipPreview )
7751
7927
  {
@@ -7761,7 +7937,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7761
7937
 
7762
7938
  this.prevData.length = 0;
7763
7939
  this.nextData.length = 0;
7764
-
7940
+
7765
7941
  this.data = data;
7766
7942
 
7767
7943
  this._processData( this.data, null );
@@ -7824,7 +8000,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7824
8000
  */
7825
8001
 
7826
8002
  _updatePath( data ) {
7827
-
8003
+
7828
8004
  this.path.length = 0;
7829
8005
 
7830
8006
  const push_parents_id = i => {
@@ -7864,7 +8040,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7864
8040
  }
7865
8041
 
7866
8042
  this.tree = this.leftPanel.addTree( "Content Browser", treeData, {
7867
- // icons: tree_icons,
8043
+ // icons: tree_icons,
7868
8044
  filter: false,
7869
8045
  onlyFolders: this.onlyFolders,
7870
8046
  onevent: event => {
@@ -7874,7 +8050,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7874
8050
 
7875
8051
  switch( event.type )
7876
8052
  {
7877
- case LX.TreeEvent.NODE_SELECTED:
8053
+ case LX.TreeEvent.NODE_SELECTED:
7878
8054
  if( !event.multiple )
7879
8055
  {
7880
8056
  this._enterFolder( node );
@@ -7889,13 +8065,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7889
8065
  LX.emit("@on_folder_change", this.path.join('/'));
7890
8066
  }
7891
8067
  break;
7892
- case LX.TreeEvent.NODE_DRAGGED:
8068
+ case LX.TreeEvent.NODE_DRAGGED:
7893
8069
  node.folder = value;
7894
8070
  this._refreshContent();
7895
8071
  break;
7896
8072
  }
7897
8073
  },
7898
- });
8074
+ });
7899
8075
  }
7900
8076
 
7901
8077
  /**
@@ -8039,24 +8215,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8039
8215
  _refreshContent( searchValue, filter ) {
8040
8216
 
8041
8217
  const isContentLayout = ( this.layout == AssetView.LAYOUT_CONTENT ); // default
8042
-
8218
+
8043
8219
  this.filter = filter ?? ( this.filter ?? "None" );
8044
8220
  this.searchValue = searchValue ?? (this.searchValue ?? "");
8045
8221
  this.content.innerHTML = "";
8046
8222
  this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
8047
8223
  let that = this;
8048
-
8224
+
8049
8225
  const add_item = function(item) {
8050
-
8226
+
8051
8227
  const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
8052
8228
  const extension = getExtension( item.id );
8053
8229
  const isFolder = type === "Folder";
8054
-
8230
+
8055
8231
  let itemEl = document.createElement('li');
8056
8232
  itemEl.className = "lexassetitem " + item.type.toLowerCase();
8057
8233
  itemEl.tabIndex = -1;
8058
8234
  that.content.appendChild( itemEl );
8059
-
8235
+
8060
8236
  if( !that.useNativeTitle )
8061
8237
  {
8062
8238
  let desc = document.createElement( 'span' );
@@ -8111,7 +8287,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8111
8287
  if( item.selected != undefined )
8112
8288
  {
8113
8289
  let span = document.createElement('span');
8114
- span.className = "lexcheckbox";
8290
+ span.className = "lexcheckbox";
8115
8291
  let checkbox_input = document.createElement('input');
8116
8292
  checkbox_input.type = "checkbox";
8117
8293
  checkbox_input.className = "checkbox";
@@ -8129,19 +8305,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8129
8305
  })
8130
8306
  span.appendChild(checkbox_input);
8131
8307
  itemEl.appendChild(span);
8132
-
8308
+
8133
8309
  }
8134
8310
 
8135
8311
  let title = document.createElement('span');
8136
8312
  title.className = "lexassettitle";
8137
8313
  title.innerText = item.id;
8138
8314
  itemEl.appendChild( title );
8139
-
8315
+
8140
8316
  if( !that.skipPreview ) {
8141
-
8317
+
8142
8318
  let preview = null;
8143
8319
  const hasImage = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
8144
-
8320
+
8145
8321
  if( hasImage || isFolder || !isContentLayout)
8146
8322
  {
8147
8323
  preview = document.createElement('img');
@@ -8154,17 +8330,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8154
8330
  preview = document.createElement('svg');
8155
8331
  preview.className = "asset-file-preview";
8156
8332
  itemEl.appendChild(preview);
8157
-
8333
+
8158
8334
  let textEl = document.createElement('text');
8159
8335
  preview.appendChild(textEl);
8160
8336
  // If no extension, e.g. Clip, use the type...
8161
8337
  textEl.innerText = (!extension || extension == item.id) ? item.type.toUpperCase() : ("." + extension.toUpperCase());
8162
-
8338
+
8163
8339
  var newLength = textEl.innerText.length;
8164
8340
  var charsPerLine = 2.5;
8165
8341
  var newEmSize = charsPerLine / newLength;
8166
8342
  var textBaseSize = 64;
8167
-
8343
+
8168
8344
  if(newEmSize < 1) {
8169
8345
  var newFontSize = newEmSize * textBaseSize;
8170
8346
  textEl.style.fontSize = newFontSize + "px";
@@ -8172,7 +8348,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8172
8348
  }
8173
8349
  }
8174
8350
  }
8175
-
8351
+
8176
8352
  if( !isFolder )
8177
8353
  {
8178
8354
  let info = document.createElement('span');
@@ -8180,13 +8356,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8180
8356
  info.innerText = type;
8181
8357
  itemEl.appendChild(info);
8182
8358
  }
8183
-
8359
+
8184
8360
  itemEl.addEventListener('click', function(e) {
8185
8361
  e.stopImmediatePropagation();
8186
8362
  e.stopPropagation();
8187
-
8363
+
8188
8364
  const isDoubleClick = ( e.detail == LX.MOUSE_DOUBLE_CLICK );
8189
-
8365
+
8190
8366
  if( !isDoubleClick )
8191
8367
  {
8192
8368
  if( !e.shiftKey )
@@ -8200,13 +8376,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8200
8376
  {
8201
8377
  that._previewAsset( item );
8202
8378
  }
8203
- }
8379
+ }
8204
8380
  else if( isFolder )
8205
8381
  {
8206
8382
  that._enterFolder( item );
8207
8383
  return;
8208
8384
  }
8209
-
8385
+
8210
8386
  if( that.onevent )
8211
8387
  {
8212
8388
  const event = new AssetViewEvent(isDoubleClick ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
@@ -8214,15 +8390,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8214
8390
  that.onevent( event );
8215
8391
  }
8216
8392
  });
8217
-
8393
+
8218
8394
  if( that.contextMenu )
8219
8395
  {
8220
8396
  itemEl.addEventListener('contextmenu', function(e) {
8221
8397
  e.preventDefault();
8222
-
8398
+
8223
8399
  const multiple = that.content.querySelectorAll('.selected').length;
8224
-
8225
- LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8400
+
8401
+ LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8226
8402
  isFolder ? item.id : item.type, e, m => {
8227
8403
  if( multiple <= 1 )
8228
8404
  {
@@ -8241,21 +8417,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8241
8417
  });
8242
8418
  });
8243
8419
  }
8244
-
8420
+
8245
8421
  itemEl.addEventListener("dragstart", function(e) {
8246
8422
  e.preventDefault();
8247
8423
  }, false );
8248
-
8424
+
8249
8425
  return itemEl;
8250
8426
  }
8251
-
8427
+
8252
8428
  const fr = new FileReader();
8253
-
8429
+
8254
8430
  const filteredData = this.currentData.filter( _i => {
8255
8431
  return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
8256
8432
  _i.id.toLowerCase().includes(this.searchValue.toLowerCase())
8257
8433
  } );
8258
-
8434
+
8259
8435
  if( filter || searchValue )
8260
8436
  {
8261
8437
  this.contentPage = 1;
@@ -8264,17 +8440,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8264
8440
  // Show all data if using filters
8265
8441
  const startIndex = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
8266
8442
  const endIndex = Math.min( startIndex + AssetView.MAX_PAGE_ELEMENTS, filteredData.length );
8267
-
8443
+
8268
8444
  for( let i = startIndex; i < endIndex; ++i )
8269
8445
  {
8270
8446
  let item = filteredData[ i ];
8271
-
8447
+
8272
8448
  if( item.path )
8273
8449
  {
8274
8450
  LX.request({ url: item.path, dataType: 'blob', success: (f) => {
8275
8451
  item.bytesize = f.size;
8276
8452
  fr.readAsDataURL( f );
8277
- fr.onload = e => {
8453
+ fr.onload = e => {
8278
8454
  item.src = e.currentTarget.result; // This is a base64 string...
8279
8455
  item._path = item.path;
8280
8456
  delete item.path;
@@ -8325,16 +8501,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8325
8501
  this.previewPanel.addText("Type", file.type, null, options);
8326
8502
  if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
8327
8503
  if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
8328
-
8504
+
8329
8505
  this.previewPanel.addSeparator();
8330
-
8506
+
8331
8507
  const previewActions = [...this.previewActions];
8332
8508
 
8333
8509
  if( !previewActions.length )
8334
8510
  {
8335
8511
  // By default
8336
8512
  previewActions.push({
8337
- name: 'Download',
8513
+ name: 'Download',
8338
8514
  callback: () => LX.downloadURL(file.src, file.id)
8339
8515
  });
8340
8516
  }
@@ -8362,8 +8538,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8362
8538
  if(result) continue;
8363
8539
 
8364
8540
  fr.readAsDataURL( file );
8365
- fr.onload = e => {
8366
-
8541
+ fr.onload = e => {
8542
+
8367
8543
  let ext = file.name.substr(file.name.lastIndexOf('.') + 1).toLowerCase();
8368
8544
 
8369
8545
  let item = {
@@ -8378,12 +8554,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8378
8554
  case 'png':
8379
8555
  case 'jpg':
8380
8556
  item.type = "image"; break;
8381
- case 'js':
8382
- case 'css':
8557
+ case 'js':
8558
+ case 'css':
8383
8559
  item.type = "script"; break;
8384
- case 'json':
8560
+ case 'json':
8385
8561
  item.type = "json"; break;
8386
- case 'obj':
8562
+ case 'obj':
8387
8563
  item.type = "mesh"; break;
8388
8564
  default:
8389
8565
  item.type = ext;
@@ -8392,7 +8568,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8392
8568
  }
8393
8569
 
8394
8570
  this.currentData.push( item );
8395
-
8571
+
8396
8572
  if(i == (num_files - 1)) {
8397
8573
  this._refreshContent();
8398
8574
  if( !this.skipBrowser )
@@ -8481,7 +8657,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8481
8657
  }
8482
8658
 
8483
8659
  LX.AssetView = AssetView;
8484
-
8660
+
8485
8661
  /*
8486
8662
  * Requests
8487
8663
  */
@@ -8489,7 +8665,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8489
8665
  Object.assign(LX, {
8490
8666
 
8491
8667
  /**
8492
- * 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
8493
8669
  * @method request
8494
8670
  * @param {Object} request object with all the parameters like data (for sending forms), dataType, success, error
8495
8671
  * @param {Function} on_complete
@@ -8609,7 +8785,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8609
8785
  requestBinary(url, on_complete, on_error ) {
8610
8786
  return this.request({ url: url, dataType:"binary", success: on_complete, error: on_error });
8611
8787
  },
8612
-
8788
+
8613
8789
  /**
8614
8790
  * Request script and inserts it in the DOM
8615
8791
  * @method requireScript
@@ -8638,7 +8814,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8638
8814
  script.src = url[i] + ( version ? "?version=" + version : "" );
8639
8815
  script.original_src = url[i];
8640
8816
  script.async = false;
8641
- script.onload = function(e) {
8817
+ script.onload = function(e) {
8642
8818
  total--;
8643
8819
  loaded_scripts.push(this);
8644
8820
  if(total)
@@ -8650,7 +8826,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8650
8826
  on_complete( loaded_scripts );
8651
8827
  };
8652
8828
  if(on_error)
8653
- script.onerror = function(err) {
8829
+ script.onerror = function(err) {
8654
8830
  on_error(err, this.original_src, this.num );
8655
8831
  }
8656
8832
  document.getElementsByTagName('head')[0].appendChild(script);
@@ -8674,7 +8850,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8674
8850
  {
8675
8851
  LX.request({ url: url, dataType: 'blob', success: (f) => {
8676
8852
  fr.readAsDataURL( f );
8677
- fr.onload = e => {
8853
+ fr.onload = e => {
8678
8854
  _download(e.currentTarget.result);
8679
8855
  };
8680
8856
  } });
@@ -8760,31 +8936,31 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8760
8936
  element.offsetHeight;
8761
8937
  },
8762
8938
  getControlPoints( x0, y0, x1, y1, x2, y2 ,t ) {
8763
-
8939
+
8764
8940
  // x0,y0,x1,y1 are the coordinates of the end (knot) pts of this segment
8765
8941
  // x2,y2 is the next knot -- not connected here but needed to calculate p2
8766
8942
  // p1 is the control point calculated here, from x1 back toward x0.
8767
- // 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
8768
8944
  // next segment's p1.
8769
8945
  // t is the 'tension' which controls how far the control points spread.
8770
-
8946
+
8771
8947
  // Scaling factors: distances from this knot to the previous and following knots.
8772
8948
  var d01=Math.sqrt(Math.pow(x1-x0,2)+Math.pow(y1-y0,2));
8773
8949
  var d12=Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
8774
-
8950
+
8775
8951
  var fa=t*d01/(d01+d12);
8776
8952
  var fb=t-fa;
8777
-
8953
+
8778
8954
  var p1x=x1+fa*(x0-x2);
8779
8955
  var p1y=y1+fa*(y0-y2);
8780
-
8956
+
8781
8957
  var p2x=x1-fb*(x0-x2);
8782
- var p2y=y1-fb*(y0-y2);
8783
-
8958
+ var p2y=y1-fb*(y0-y2);
8959
+
8784
8960
  return [p1x,p1y,p2x,p2y]
8785
8961
  },
8786
8962
  drawSpline( ctx, pts, t ) {
8787
-
8963
+
8788
8964
  ctx.save();
8789
8965
  var cp=[]; // array of control points, as x0,y0,x1,y1,...
8790
8966
  var n=pts.length;
@@ -8792,7 +8968,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8792
8968
  // Draw an open curve, not connected at the ends
8793
8969
  for(var i=0;i<n-4;i+=2) {
8794
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));
8795
- }
8971
+ }
8796
8972
 
8797
8973
  for(var i=2;i<pts.length-5;i+=2) {
8798
8974
  ctx.beginPath();
@@ -8800,7 +8976,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8800
8976
  ctx.bezierCurveTo(cp[2*i-2],cp[2*i-1],cp[2*i],cp[2*i+1],pts[i+2],pts[i+3]);
8801
8977
  ctx.stroke();
8802
8978
  ctx.closePath();
8803
-
8979
+
8804
8980
  }
8805
8981
  // For open curves the first and last arcs are simple quadratics.
8806
8982
  ctx.beginPath();
@@ -8808,13 +8984,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8808
8984
  ctx.quadraticCurveTo(cp[0],cp[1],pts[2],pts[3]);
8809
8985
  ctx.stroke();
8810
8986
  ctx.closePath();
8811
-
8987
+
8812
8988
  ctx.beginPath();
8813
8989
  ctx.moveTo(pts[n-2],pts[n-1]);
8814
8990
  ctx.quadraticCurveTo(cp[2*n-10],cp[2*n-9],pts[n-4],pts[n-3]);
8815
8991
  ctx.stroke();
8816
8992
  ctx.closePath();
8817
-
8993
+
8818
8994
  ctx.restore();
8819
8995
  }
8820
8996
  };