lexgui 0.1.34 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/build/lexgui.css +37 -20
- package/build/lexgui.js +405 -269
- package/build/lexgui.module.js +384 -261
- package/changelog.md +20 -0
- package/demo.js +12 -7
- package/package.json +1 -1
package/build/lexgui.js
CHANGED
|
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
var LX = global.LX = {
|
|
15
|
-
version: "0.1.
|
|
15
|
+
version: "0.1.36",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -45,43 +45,43 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
45
45
|
|
|
46
46
|
LX.has = has;
|
|
47
47
|
|
|
48
|
-
function getExtension(s)
|
|
48
|
+
function getExtension( s )
|
|
49
49
|
{
|
|
50
50
|
return s.includes('.') ? s.split('.').pop() : null;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
LX.getExtension = getExtension;
|
|
54
|
-
|
|
55
|
-
function deepCopy(o)
|
|
54
|
+
|
|
55
|
+
function deepCopy( o )
|
|
56
56
|
{
|
|
57
57
|
return JSON.parse(JSON.stringify(o))
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
LX.deepCopy = deepCopy;
|
|
61
61
|
|
|
62
|
-
function setThemeColor(
|
|
62
|
+
function setThemeColor( colorName, color )
|
|
63
63
|
{
|
|
64
|
-
var r = document.querySelector(':root');
|
|
65
|
-
r.style.setProperty(
|
|
64
|
+
var r = document.querySelector( ':root' );
|
|
65
|
+
r.style.setProperty( '--' + colorName, color );
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
LX.setThemeColor = setThemeColor;
|
|
69
|
-
|
|
70
|
-
function getThemeColor(
|
|
69
|
+
|
|
70
|
+
function getThemeColor( colorName )
|
|
71
71
|
{
|
|
72
|
-
var r = getComputedStyle(document.querySelector(':root'));
|
|
73
|
-
return r.getPropertyValue(
|
|
72
|
+
var r = getComputedStyle( document.querySelector( ':root' ) );
|
|
73
|
+
return r.getPropertyValue( '--' + colorName );
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
LX.getThemeColor = getThemeColor;
|
|
77
77
|
|
|
78
|
-
function getBase64Image(img) {
|
|
79
|
-
var canvas = document.createElement(
|
|
78
|
+
function getBase64Image( img ) {
|
|
79
|
+
var canvas = document.createElement( 'canvas' );
|
|
80
80
|
canvas.width = img.width;
|
|
81
81
|
canvas.height = img.height;
|
|
82
|
-
var ctx = canvas.getContext(
|
|
83
|
-
ctx.drawImage(img, 0, 0);
|
|
84
|
-
return canvas.toDataURL(
|
|
82
|
+
var ctx = canvas.getContext( '2d' );
|
|
83
|
+
ctx.drawImage( img, 0, 0 );
|
|
84
|
+
return canvas.toDataURL( 'image/png' );
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
LX.getBase64Image = getBase64Image;
|
|
@@ -133,22 +133,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
133
133
|
|
|
134
134
|
function doAsync( fn, ms ) {
|
|
135
135
|
if( ASYNC_ENABLED )
|
|
136
|
+
{
|
|
136
137
|
setTimeout( fn, ms ?? 0 );
|
|
138
|
+
}
|
|
137
139
|
else
|
|
140
|
+
{
|
|
138
141
|
fn();
|
|
142
|
+
}
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
// Math classes
|
|
142
146
|
|
|
143
147
|
class vec2 {
|
|
144
148
|
|
|
145
|
-
constructor(x, y) {
|
|
149
|
+
constructor( x, y ) {
|
|
146
150
|
this.x = x ?? 0;
|
|
147
|
-
this.y = y ?? (x ?? 0);
|
|
151
|
+
this.y = y ?? ( x ?? 0 );
|
|
148
152
|
}
|
|
149
153
|
|
|
150
|
-
get xy() { return [ this.x, this.y]; }
|
|
151
|
-
get yx() { return [ this.y, this.x]; }
|
|
154
|
+
get xy() { return [ this.x, this.y ]; }
|
|
155
|
+
get yx() { return [ this.y, this.x ]; }
|
|
152
156
|
|
|
153
157
|
set ( x, y ) { this.x = x; this.y = y; }
|
|
154
158
|
add ( v, v0 = new vec2() ) { v0.set( this.x + v.x, this.y + v.y ); return v0; }
|
|
@@ -156,6 +160,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
156
160
|
mul ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x * v.x, this.y * v.y ); return v0; }
|
|
157
161
|
div ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x / v.x, this.y / v.y ); return v0; }
|
|
158
162
|
abs ( v0 = new vec2() ) { v0.set( Math.abs( this.x ), Math.abs( this.y ) ); return v0; }
|
|
163
|
+
dot ( v ) { return this.x * v.x + this.y * v.y; }
|
|
164
|
+
len2 () { return this.dot( this ) }
|
|
165
|
+
len () { return Math.sqrt( this.len2() ); }
|
|
166
|
+
nrm ( v0 = new vec2() ) { v0.set( this.x, this.y ); return v0.mul( 1.0 / this.len(), v0 ); }
|
|
167
|
+
dst ( v ) { return v.sub( this ).len(); }
|
|
159
168
|
};
|
|
160
169
|
|
|
161
170
|
LX.vec2 = vec2;
|
|
@@ -472,7 +481,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
472
481
|
var link = document.createElement( 'link' );
|
|
473
482
|
link.rel = 'stylesheet';
|
|
474
483
|
link.type = 'text/css';
|
|
475
|
-
link.href = 'https://use.fontawesome.com/releases/v6.
|
|
484
|
+
link.href = 'https://use.fontawesome.com/releases/v6.6.0/css/all.css';
|
|
476
485
|
head.appendChild( link );
|
|
477
486
|
|
|
478
487
|
// Global vars
|
|
@@ -526,26 +535,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
526
535
|
* size: (Array) [width, height]
|
|
527
536
|
*/
|
|
528
537
|
|
|
529
|
-
function popup(text, title, options = {})
|
|
538
|
+
function popup( text, title, options = {} )
|
|
530
539
|
{
|
|
531
|
-
if(!text)
|
|
540
|
+
if( !text )
|
|
541
|
+
{
|
|
532
542
|
throw("No message to show");
|
|
543
|
+
}
|
|
533
544
|
|
|
534
|
-
options.size = options.size ?? ["auto", "auto"];
|
|
545
|
+
options.size = options.size ?? [ "auto", "auto" ];
|
|
535
546
|
options.class = "lexpopup";
|
|
536
|
-
const time = options.timeout || 3000;
|
|
537
547
|
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
548
|
+
const time = options.timeout || 3000;
|
|
549
|
+
const dialog = new Dialog( title, p => {
|
|
550
|
+
p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
|
|
551
|
+
}, options );
|
|
552
|
+
|
|
553
|
+
dialog.root.classList.add( 'fadein' );
|
|
543
554
|
setTimeout(() => {
|
|
544
|
-
dialog.root.classList.remove(
|
|
545
|
-
dialog.root.classList.add(
|
|
546
|
-
}, time - 1000);
|
|
555
|
+
dialog.root.classList.remove( 'fadein' );
|
|
556
|
+
dialog.root.classList.add( 'fadeout' );
|
|
557
|
+
}, time - 1000 );
|
|
558
|
+
|
|
559
|
+
setTimeout( dialog.close, time );
|
|
547
560
|
|
|
548
|
-
setTimeout(dialog.close, time);
|
|
549
561
|
return dialog;
|
|
550
562
|
}
|
|
551
563
|
|
|
@@ -564,36 +576,45 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
564
576
|
* required: Input has to be filled [true]. Default: false
|
|
565
577
|
*/
|
|
566
578
|
|
|
567
|
-
function prompt(text, title, callback, options = {})
|
|
579
|
+
function prompt( text, title, callback, options = {} )
|
|
568
580
|
{
|
|
569
581
|
options.modal = true;
|
|
570
582
|
|
|
571
583
|
let value = "";
|
|
572
584
|
|
|
573
|
-
const dialog = new Dialog(title, p => {
|
|
574
|
-
p.addTextArea(null, text, null, { disabled: true });
|
|
575
|
-
if(options.input !== false)
|
|
576
|
-
p.addText(null, options.input || value, (v) => value = v, {placeholder: "..."} );
|
|
577
|
-
p.sameLine(2);
|
|
578
|
-
p.addButton(null, options.accept || "OK", () => {
|
|
579
|
-
if(options.required && value === '') {
|
|
585
|
+
const dialog = new Dialog( title, p => {
|
|
580
586
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
587
|
+
p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
|
|
588
|
+
|
|
589
|
+
if( options.input ?? true )
|
|
590
|
+
{
|
|
591
|
+
p.addText( null, options.input || value, v => value = v, { placeholder: "..." } );
|
|
592
|
+
}
|
|
585
593
|
|
|
586
|
-
|
|
587
|
-
|
|
594
|
+
p.sameLine( 2 );
|
|
595
|
+
|
|
596
|
+
p.addButton( null, options.accept || "OK", () => {
|
|
597
|
+
if( options.required && value === '' )
|
|
598
|
+
{
|
|
599
|
+
text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
|
|
600
|
+
dialog.close();
|
|
601
|
+
prompt( text, title, callback, options );
|
|
602
|
+
}else
|
|
603
|
+
{
|
|
604
|
+
if( callback ) callback.call( this, value );
|
|
605
|
+
dialog.close();
|
|
588
606
|
}
|
|
589
|
-
|
|
590
607
|
}, { buttonClass: "accept" });
|
|
608
|
+
|
|
591
609
|
p.addButton(null, "Cancel", () => {if(options.on_cancel) options.on_cancel(); dialog.close();} );
|
|
592
|
-
|
|
610
|
+
|
|
611
|
+
}, options );
|
|
593
612
|
|
|
594
613
|
// Focus text prompt
|
|
595
|
-
if(options.input
|
|
596
|
-
|
|
614
|
+
if( options.input ?? true )
|
|
615
|
+
{
|
|
616
|
+
dialog.root.querySelector( 'input' ).focus();
|
|
617
|
+
}
|
|
597
618
|
|
|
598
619
|
return dialog;
|
|
599
620
|
}
|
|
@@ -649,16 +670,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
649
670
|
|
|
650
671
|
LX.TreeEvent = TreeEvent;
|
|
651
672
|
|
|
652
|
-
function emit(
|
|
673
|
+
function emit( signalName, value, options = {} )
|
|
653
674
|
{
|
|
654
|
-
const data = LX.signals[
|
|
675
|
+
const data = LX.signals[ signalName ];
|
|
655
676
|
|
|
656
677
|
if( !data )
|
|
657
678
|
return;
|
|
658
679
|
|
|
680
|
+
const target = options.target;
|
|
681
|
+
|
|
659
682
|
if( target )
|
|
660
683
|
{
|
|
661
|
-
if(target[
|
|
684
|
+
if( target[ signalName ])
|
|
685
|
+
{
|
|
686
|
+
target[ signalName ].call( target, value );
|
|
687
|
+
}
|
|
688
|
+
|
|
662
689
|
return;
|
|
663
690
|
}
|
|
664
691
|
|
|
@@ -666,13 +693,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
666
693
|
{
|
|
667
694
|
if( obj.constructor === Widget )
|
|
668
695
|
{
|
|
669
|
-
obj.set( value );
|
|
696
|
+
obj.set( value, options.skipCallback ?? true );
|
|
670
697
|
|
|
671
|
-
if(obj.options && obj.options.callback)
|
|
672
|
-
|
|
673
|
-
|
|
698
|
+
if( obj.options && obj.options.callback )
|
|
699
|
+
{
|
|
700
|
+
obj.options.callback( value, data );
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
else
|
|
674
704
|
{
|
|
675
|
-
obj[
|
|
705
|
+
obj[ signalName ].call( obj, value );
|
|
676
706
|
}
|
|
677
707
|
}
|
|
678
708
|
}
|
|
@@ -711,13 +741,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
711
741
|
*/
|
|
712
742
|
|
|
713
743
|
constructor( options = {} ) {
|
|
714
|
-
|
|
715
|
-
var root = document.createElement('div');
|
|
744
|
+
|
|
745
|
+
var root = document.createElement( 'div' );
|
|
716
746
|
root.className = "lexarea";
|
|
717
|
-
if(options.id)
|
|
747
|
+
if( options.id )
|
|
748
|
+
{
|
|
718
749
|
root.id = options.id;
|
|
719
|
-
|
|
750
|
+
}
|
|
751
|
+
if( options.className )
|
|
752
|
+
{
|
|
720
753
|
root.className += " " + options.className;
|
|
754
|
+
}
|
|
721
755
|
|
|
722
756
|
var width = options.width || "calc( 100% )";
|
|
723
757
|
var height = options.height || "100%";
|
|
@@ -725,10 +759,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
725
759
|
// This has default options..
|
|
726
760
|
this.setLimitBox( options.minWidth, options.minHeight, options.maxWidth, options.maxHeight );
|
|
727
761
|
|
|
728
|
-
if(width.constructor == Number)
|
|
762
|
+
if( width.constructor == Number )
|
|
763
|
+
{
|
|
729
764
|
width += "px";
|
|
730
|
-
|
|
765
|
+
}
|
|
766
|
+
if( height.constructor == Number )
|
|
767
|
+
{
|
|
731
768
|
height += "px";
|
|
769
|
+
}
|
|
732
770
|
|
|
733
771
|
root.style.width = width;
|
|
734
772
|
root.style.height = height;
|
|
@@ -739,115 +777,136 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
739
777
|
this.sections = [];
|
|
740
778
|
this.panels = [];
|
|
741
779
|
|
|
742
|
-
if(!options.no_append)
|
|
780
|
+
if( !options.no_append )
|
|
781
|
+
{
|
|
743
782
|
var lexroot = document.getElementById("lexroot");
|
|
744
783
|
lexroot.appendChild( this.root );
|
|
745
784
|
}
|
|
746
785
|
|
|
747
786
|
let overlay = options.overlay;
|
|
748
787
|
|
|
749
|
-
if(overlay)
|
|
788
|
+
if( overlay )
|
|
750
789
|
{
|
|
751
790
|
this.root.classList.add("overlay-" + overlay);
|
|
752
|
-
|
|
753
|
-
if( options.
|
|
791
|
+
|
|
792
|
+
if( options.left )
|
|
793
|
+
{
|
|
794
|
+
this.root.style.left = options.left;
|
|
795
|
+
}
|
|
796
|
+
else if( options.right )
|
|
797
|
+
{
|
|
798
|
+
this.root.style.right = options.right;
|
|
799
|
+
}
|
|
800
|
+
else if( options.top )
|
|
801
|
+
{
|
|
802
|
+
this.root.style.top = options.top;
|
|
803
|
+
}
|
|
804
|
+
else if( options.bottom )
|
|
805
|
+
{
|
|
806
|
+
this.root.style.bottom = options.bottom;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const draggable = options.draggable ?? true;
|
|
810
|
+
if( draggable )
|
|
754
811
|
makeDraggable( root );
|
|
755
812
|
|
|
756
813
|
if( options.resizeable ) {
|
|
757
814
|
root.classList.add("resizeable");
|
|
758
815
|
}
|
|
759
816
|
|
|
760
|
-
if(options.resize)
|
|
817
|
+
if( options.resize )
|
|
761
818
|
{
|
|
762
819
|
this.split_bar = document.createElement("div");
|
|
763
|
-
let type = overlay == "left" || overlay == "right" ? "horizontal" : "vertical";
|
|
820
|
+
let type = (overlay == "left") || (overlay == "right") ? "horizontal" : "vertical";
|
|
764
821
|
this.type = overlay;;
|
|
765
822
|
this.split_bar.className = "lexsplitbar " + type;
|
|
766
|
-
|
|
823
|
+
|
|
824
|
+
if( overlay == "right" )
|
|
825
|
+
{
|
|
767
826
|
this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
768
|
-
this.split_bar.style.left = -LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
827
|
+
this.split_bar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
769
828
|
}
|
|
770
|
-
else if(overlay == "left")
|
|
829
|
+
else if( overlay == "left" )
|
|
830
|
+
{
|
|
771
831
|
let size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientWidth);
|
|
772
832
|
this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
773
|
-
this.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
833
|
+
this.split_bar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
774
834
|
}
|
|
775
|
-
else if
|
|
835
|
+
else if( overlay == "top" )
|
|
836
|
+
{
|
|
776
837
|
let size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientHeight);
|
|
777
838
|
this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
778
|
-
this.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
839
|
+
this.split_bar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
779
840
|
}
|
|
780
|
-
else if(overlay == "bottom")
|
|
841
|
+
else if( overlay == "bottom" )
|
|
842
|
+
{
|
|
781
843
|
this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
782
|
-
this.split_bar.style.top = -LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
844
|
+
this.split_bar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
783
845
|
}
|
|
784
846
|
|
|
785
847
|
this.split_bar.addEventListener("mousedown", inner_mousedown);
|
|
786
|
-
this.root.appendChild(this.split_bar);
|
|
848
|
+
this.root.appendChild( this.split_bar );
|
|
787
849
|
|
|
788
850
|
var that = this;
|
|
789
|
-
var last_pos = [0,0];
|
|
851
|
+
var last_pos = [ 0, 0 ];
|
|
790
852
|
|
|
791
|
-
function inner_mousedown(e)
|
|
853
|
+
function inner_mousedown( e )
|
|
792
854
|
{
|
|
793
855
|
var doc = that.root.ownerDocument;
|
|
794
|
-
doc.addEventListener(
|
|
795
|
-
doc.addEventListener(
|
|
796
|
-
last_pos[0] = e.x;
|
|
797
|
-
last_pos[1] = e.y;
|
|
856
|
+
doc.addEventListener( 'mousemove', inner_mousemove );
|
|
857
|
+
doc.addEventListener( 'mouseup', inner_mouseup );
|
|
858
|
+
last_pos[ 0 ] = e.x;
|
|
859
|
+
last_pos[ 1 ] = e.y;
|
|
798
860
|
e.stopPropagation();
|
|
799
861
|
e.preventDefault();
|
|
800
|
-
document.body.classList.add(
|
|
801
|
-
that.split_bar.classList.add(
|
|
862
|
+
document.body.classList.add( 'nocursor' );
|
|
863
|
+
that.split_bar.classList.add( 'nocursor' );
|
|
802
864
|
}
|
|
803
865
|
|
|
804
|
-
function inner_mousemove(e)
|
|
866
|
+
function inner_mousemove( e )
|
|
805
867
|
{
|
|
806
|
-
switch(that.type) {
|
|
868
|
+
switch( that.type ) {
|
|
807
869
|
case "right":
|
|
808
|
-
var dt = (last_pos[0] - e.x);
|
|
809
|
-
var size = (that.root.offsetWidth + dt);
|
|
870
|
+
var dt = ( last_pos[ 0 ] - e.x );
|
|
871
|
+
var size = ( that.root.offsetWidth + dt );
|
|
810
872
|
that.root.style.width = size + "px";
|
|
811
873
|
break;
|
|
812
|
-
|
|
813
874
|
case "left":
|
|
814
|
-
var dt = (last_pos[0] - e.x);
|
|
875
|
+
var dt = ( last_pos[ 0 ] - e.x );
|
|
815
876
|
var size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetWidth - dt));
|
|
816
877
|
that.root.style.width = size + "px";
|
|
817
878
|
that.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
818
879
|
break;
|
|
819
|
-
|
|
820
880
|
case "top":
|
|
821
|
-
var dt = (last_pos[1] - e.y);
|
|
881
|
+
var dt = ( last_pos[ 1 ] - e.y );
|
|
822
882
|
var size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetHeight - dt));
|
|
823
883
|
that.root.style.height = size + "px";
|
|
824
884
|
that.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
825
885
|
break;
|
|
826
|
-
|
|
827
886
|
case "bottom":
|
|
828
|
-
var dt = (last_pos[1] - e.y);
|
|
829
|
-
var size = (that.root.offsetHeight + dt);
|
|
887
|
+
var dt = ( last_pos[ 1 ] - e.y );
|
|
888
|
+
var size = ( that.root.offsetHeight + dt );
|
|
830
889
|
that.root.style.height = size + "px";
|
|
831
890
|
break;
|
|
832
891
|
}
|
|
833
892
|
|
|
834
|
-
last_pos[0] = e.x;
|
|
835
|
-
last_pos[1] = e.y;
|
|
893
|
+
last_pos[ 0 ] = e.x;
|
|
894
|
+
last_pos[ 1 ] = e.y;
|
|
836
895
|
e.stopPropagation();
|
|
837
896
|
e.preventDefault();
|
|
838
897
|
|
|
839
898
|
// Resize events
|
|
840
|
-
if(that.onresize)
|
|
899
|
+
if( that.onresize )
|
|
841
900
|
that.onresize( that.root.getBoundingClientRect() );
|
|
842
901
|
}
|
|
843
902
|
|
|
844
|
-
function inner_mouseup(e)
|
|
903
|
+
function inner_mouseup( e )
|
|
845
904
|
{
|
|
846
905
|
var doc = that.root.ownerDocument;
|
|
847
|
-
doc.removeEventListener(
|
|
848
|
-
doc.removeEventListener(
|
|
849
|
-
document.body.classList.remove(
|
|
850
|
-
that.split_bar.classList.remove(
|
|
906
|
+
doc.removeEventListener( 'mousemove', inner_mousemove );
|
|
907
|
+
doc.removeEventListener( 'mouseup', inner_mouseup );
|
|
908
|
+
document.body.classList.remove( 'nocursor' );
|
|
909
|
+
that.split_bar.classList.remove( 'nocursor' );
|
|
851
910
|
}
|
|
852
911
|
}
|
|
853
912
|
}
|
|
@@ -884,35 +943,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
884
943
|
|
|
885
944
|
split( options = {} ) {
|
|
886
945
|
|
|
887
|
-
if(this.sections.length)
|
|
946
|
+
if( this.sections.length )
|
|
888
947
|
{
|
|
889
948
|
// In case Area has been split before, get 2nd section as root
|
|
890
|
-
this.offset = this.root.childNodes[0].offsetHeight; // store offset to take into account when resizing
|
|
891
|
-
this._root = this.sections[0].root;
|
|
892
|
-
this.root = this.sections[1].root;
|
|
949
|
+
this.offset = this.root.childNodes[ 0 ].offsetHeight; // store offset to take into account when resizing
|
|
950
|
+
this._root = this.sections[ 0 ].root;
|
|
951
|
+
this.root = this.sections[ 1 ].root;
|
|
893
952
|
}
|
|
894
953
|
|
|
895
954
|
var type = options.type || "horizontal";
|
|
896
|
-
var sizes = options.sizes || ["50%", "50%"];
|
|
955
|
+
var sizes = options.sizes || [ "50%", "50%" ];
|
|
897
956
|
var infer_height = false;
|
|
898
|
-
var auto = options.sizes === 'auto';
|
|
957
|
+
var auto = (options.sizes === 'auto');
|
|
899
958
|
|
|
900
|
-
if( !sizes[1] )
|
|
959
|
+
if( !sizes[ 1 ] )
|
|
901
960
|
{
|
|
902
|
-
let size = sizes[0];
|
|
961
|
+
let size = sizes[ 0 ];
|
|
903
962
|
let margin = options.top ? options.top : 0;
|
|
904
|
-
if(size.constructor == Number)
|
|
963
|
+
if( size.constructor == Number )
|
|
964
|
+
{
|
|
905
965
|
size += margin;
|
|
906
966
|
size += "px";
|
|
907
967
|
}
|
|
908
|
-
|
|
909
|
-
sizes[1] = "calc( 100% - " + size + " )";
|
|
968
|
+
|
|
969
|
+
sizes[ 1 ] = "calc( 100% - " + size + " )";
|
|
910
970
|
infer_height = true;
|
|
911
971
|
}
|
|
912
972
|
|
|
913
973
|
// Create areas
|
|
914
|
-
var area1 = new Area({ no_append: true, className: "split" + (options.menubar || options.sidebar ? "" : " origin") });
|
|
915
|
-
var area2 = new Area({ no_append: true, className: "split"});
|
|
974
|
+
var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
|
|
975
|
+
var area2 = new Area( { no_append: true, className: "split"} );
|
|
916
976
|
|
|
917
977
|
area1.parentArea = this;
|
|
918
978
|
area2.parentArea = this;
|
|
@@ -923,23 +983,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
923
983
|
var data = "0px";
|
|
924
984
|
this.offset = 0;
|
|
925
985
|
|
|
926
|
-
if(resize)
|
|
986
|
+
if( resize )
|
|
927
987
|
{
|
|
928
988
|
this.resize = resize;
|
|
929
|
-
this.split_bar = document.createElement("div");
|
|
989
|
+
this.split_bar = document.createElement( "div" );
|
|
930
990
|
this.split_bar.className = "lexsplitbar " + type;
|
|
931
991
|
|
|
932
|
-
if(type == "horizontal")
|
|
992
|
+
if( type == "horizontal" )
|
|
993
|
+
{
|
|
933
994
|
this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
934
995
|
}
|
|
935
|
-
else
|
|
996
|
+
else
|
|
997
|
+
{
|
|
936
998
|
this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
937
999
|
}
|
|
938
|
-
|
|
939
|
-
|
|
1000
|
+
|
|
1001
|
+
this.split_bar.addEventListener( 'mousedown', inner_mousedown );
|
|
1002
|
+
|
|
1003
|
+
data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
|
|
940
1004
|
|
|
941
1005
|
// Being minimizable means it's also resizeable!
|
|
942
|
-
if(minimizable)
|
|
1006
|
+
if( minimizable )
|
|
943
1007
|
{
|
|
944
1008
|
this.split_extended = false;
|
|
945
1009
|
|
|
@@ -961,14 +1025,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
961
1025
|
}
|
|
962
1026
|
}
|
|
963
1027
|
|
|
964
|
-
if(type == "horizontal")
|
|
1028
|
+
if( type == "horizontal" )
|
|
965
1029
|
{
|
|
966
|
-
var width1 = sizes[0],
|
|
967
|
-
width2 = sizes[1];
|
|
1030
|
+
var width1 = sizes[ 0 ],
|
|
1031
|
+
width2 = sizes[ 1 ];
|
|
968
1032
|
|
|
969
|
-
if(width1.constructor == Number)
|
|
1033
|
+
if( width1.constructor == Number )
|
|
970
1034
|
width1 += "px";
|
|
971
|
-
if(width2.constructor == Number)
|
|
1035
|
+
if( width2.constructor == Number )
|
|
972
1036
|
width2 += "px";
|
|
973
1037
|
|
|
974
1038
|
area1.root.style.width = "calc( " + width1 + " - " + data + " )";
|
|
@@ -987,20 +1051,20 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
987
1051
|
area1.root.style.height = "auto";
|
|
988
1052
|
|
|
989
1053
|
// Listen resize event on first area
|
|
990
|
-
const resizeObserver = new ResizeObserver(
|
|
1054
|
+
const resizeObserver = new ResizeObserver( entries => {
|
|
991
1055
|
for (const entry of entries) {
|
|
992
1056
|
const bb = entry.contentRect;
|
|
993
1057
|
area2.root.style.height = "calc(100% - " + ( bb.height + 4) + "px )";
|
|
994
1058
|
}
|
|
995
1059
|
});
|
|
996
1060
|
|
|
997
|
-
resizeObserver.observe(area1.root);
|
|
1061
|
+
resizeObserver.observe( area1.root );
|
|
998
1062
|
}
|
|
999
1063
|
else
|
|
1000
1064
|
{
|
|
1001
|
-
var height1 = sizes[0],
|
|
1002
|
-
height2 = sizes[1];
|
|
1003
|
-
|
|
1065
|
+
var height1 = sizes[ 0 ],
|
|
1066
|
+
height2 = sizes[ 1 ];
|
|
1067
|
+
|
|
1004
1068
|
if(height1.constructor == Number)
|
|
1005
1069
|
height1 += "px";
|
|
1006
1070
|
if(height2.constructor == Number)
|
|
@@ -1014,7 +1078,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1014
1078
|
|
|
1015
1079
|
this.root.appendChild( area1.root );
|
|
1016
1080
|
|
|
1017
|
-
if(resize)
|
|
1081
|
+
if( resize )
|
|
1018
1082
|
{
|
|
1019
1083
|
this.root.appendChild(this.split_bar);
|
|
1020
1084
|
}
|
|
@@ -1026,55 +1090,67 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1026
1090
|
// Update sizes
|
|
1027
1091
|
this._update();
|
|
1028
1092
|
|
|
1029
|
-
if(!resize)
|
|
1093
|
+
if( !resize )
|
|
1030
1094
|
{
|
|
1031
1095
|
return this.sections;
|
|
1032
1096
|
}
|
|
1033
1097
|
|
|
1034
|
-
// from litegui.js @jagenjo
|
|
1035
|
-
|
|
1036
1098
|
var that = this;
|
|
1037
|
-
var last_pos = [0,0];
|
|
1038
|
-
|
|
1099
|
+
var last_pos = [ 0, 0 ];
|
|
1100
|
+
|
|
1101
|
+
function inner_mousedown( e )
|
|
1039
1102
|
{
|
|
1040
1103
|
var doc = that.root.ownerDocument;
|
|
1041
|
-
doc.addEventListener(
|
|
1042
|
-
doc.addEventListener(
|
|
1104
|
+
doc.addEventListener( 'mousemove', inner_mousemove );
|
|
1105
|
+
doc.addEventListener( 'mouseup', inner_mouseup );
|
|
1043
1106
|
last_pos[0] = e.x;
|
|
1044
1107
|
last_pos[1] = e.y;
|
|
1045
1108
|
e.stopPropagation();
|
|
1046
1109
|
e.preventDefault();
|
|
1047
|
-
document.body.classList.add(
|
|
1048
|
-
that.split_bar.classList.add(
|
|
1110
|
+
document.body.classList.add( 'nocursor' );
|
|
1111
|
+
that.split_bar.classList.add( 'nocursor' );
|
|
1049
1112
|
}
|
|
1050
1113
|
|
|
1051
|
-
function inner_mousemove(e)
|
|
1114
|
+
function inner_mousemove( e )
|
|
1052
1115
|
{
|
|
1053
|
-
if(that.type == "horizontal")
|
|
1054
|
-
|
|
1116
|
+
if(that.type == "horizontal")
|
|
1117
|
+
{
|
|
1118
|
+
that._moveSplit( last_pos[ 0 ] - e.x );
|
|
1055
1119
|
}
|
|
1056
|
-
else
|
|
1057
|
-
|
|
1120
|
+
else
|
|
1121
|
+
{
|
|
1122
|
+
that._moveSplit( last_pos[ 1 ] - e.y );
|
|
1058
1123
|
}
|
|
1059
|
-
|
|
1060
|
-
last_pos[0] = e.x;
|
|
1061
|
-
last_pos[1] = e.y;
|
|
1124
|
+
|
|
1125
|
+
last_pos[ 0 ] = e.x;
|
|
1126
|
+
last_pos[ 1 ] = e.y;
|
|
1127
|
+
|
|
1128
|
+
const widgets = that.root.querySelectorAll( ".lexwidget" );
|
|
1129
|
+
|
|
1130
|
+
// Send area resize to every widget in the area
|
|
1131
|
+
for( let widget of widgets )
|
|
1132
|
+
{
|
|
1133
|
+
const jsInstance = widget.jsIinstance;
|
|
1134
|
+
|
|
1135
|
+
if( jsInstance.onresize )
|
|
1136
|
+
{
|
|
1137
|
+
jsInstance.onresize();
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1062
1141
|
e.stopPropagation();
|
|
1063
1142
|
e.preventDefault();
|
|
1064
1143
|
}
|
|
1065
1144
|
|
|
1066
|
-
function inner_mouseup(e)
|
|
1145
|
+
function inner_mouseup( e )
|
|
1067
1146
|
{
|
|
1068
1147
|
var doc = that.root.ownerDocument;
|
|
1069
|
-
doc.removeEventListener(
|
|
1070
|
-
doc.removeEventListener(
|
|
1071
|
-
document.body.classList.remove(
|
|
1072
|
-
that.split_bar.classList.remove(
|
|
1148
|
+
doc.removeEventListener( 'mousemove', inner_mousemove );
|
|
1149
|
+
doc.removeEventListener( 'mouseup', inner_mouseup );
|
|
1150
|
+
document.body.classList.remove( 'nocursor' );
|
|
1151
|
+
that.split_bar.classList.remove( 'nocursor' );
|
|
1073
1152
|
}
|
|
1074
1153
|
|
|
1075
|
-
// Is this necessary?..
|
|
1076
|
-
// setTimeout( () => this._moveSplit(0), 100);
|
|
1077
|
-
|
|
1078
1154
|
return this.sections;
|
|
1079
1155
|
}
|
|
1080
1156
|
|
|
@@ -1113,7 +1189,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1113
1189
|
this.propagateEvent("onresize");
|
|
1114
1190
|
}
|
|
1115
1191
|
|
|
1116
|
-
|
|
1192
|
+
/**
|
|
1117
1193
|
* @method extend
|
|
1118
1194
|
* Hide 2nd area split
|
|
1119
1195
|
*/
|
|
@@ -1563,7 +1639,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1563
1639
|
this.classList.remove("dockingtab");
|
|
1564
1640
|
|
|
1565
1641
|
// Change tabs instance
|
|
1566
|
-
LX.emit( "@on_tab_docked"
|
|
1642
|
+
LX.emit( "@on_tab_docked" );
|
|
1567
1643
|
el.instance = that;
|
|
1568
1644
|
|
|
1569
1645
|
// Show on drop
|
|
@@ -1635,22 +1711,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1635
1711
|
|
|
1636
1712
|
let isSelected = options.selected ?? false;
|
|
1637
1713
|
|
|
1638
|
-
if( isSelected )
|
|
1639
|
-
|
|
1640
|
-
this.
|
|
1714
|
+
if( isSelected )
|
|
1715
|
+
{
|
|
1716
|
+
this.root.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ) );
|
|
1717
|
+
this.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
|
|
1641
1718
|
}
|
|
1642
1719
|
|
|
1643
1720
|
isSelected = !Object.keys( this.tabs ).length && !this.folding ? true : isSelected;
|
|
1644
1721
|
|
|
1645
1722
|
let contentEl = content.root ? content.root : content;
|
|
1646
|
-
contentEl.style.display
|
|
1647
|
-
contentEl.
|
|
1723
|
+
contentEl.originalDisplay = contentEl.style.display;
|
|
1724
|
+
contentEl.style.display = isSelected ? contentEl.originalDisplay : "none";
|
|
1725
|
+
contentEl.classList.add( 'lextabcontent' );
|
|
1648
1726
|
|
|
1649
1727
|
// Process icon
|
|
1650
1728
|
if( options.icon )
|
|
1651
1729
|
{
|
|
1652
1730
|
if( options.icon.includes( 'fa-' ) ) // It's fontawesome icon...
|
|
1731
|
+
{
|
|
1653
1732
|
options.icon = "<i class='" + options.icon + "'></i>";
|
|
1733
|
+
}
|
|
1654
1734
|
else // an image..
|
|
1655
1735
|
{
|
|
1656
1736
|
const rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
@@ -1659,26 +1739,31 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1659
1739
|
}
|
|
1660
1740
|
|
|
1661
1741
|
// Create tab
|
|
1662
|
-
let tabEl = document.createElement('span');
|
|
1663
|
-
tabEl.dataset["name"] = name;
|
|
1664
|
-
tabEl.className = "lexareatab" + (isSelected ? " selected" : "");
|
|
1665
|
-
tabEl.innerHTML = (options.icon ?? "") + name;
|
|
1666
|
-
tabEl.id = name.replace(/\s/g, '') + Tabs.TAB_ID++;
|
|
1742
|
+
let tabEl = document.createElement( 'span' );
|
|
1743
|
+
tabEl.dataset[ "name" ] = name;
|
|
1744
|
+
tabEl.className = "lexareatab" + ( isSelected ? " selected" : "" );
|
|
1745
|
+
tabEl.innerHTML = ( options.icon ?? "" ) + name;
|
|
1746
|
+
tabEl.id = name.replace( /\s/g, '' ) + Tabs.TAB_ID++;
|
|
1667
1747
|
tabEl.title = options.title;
|
|
1668
1748
|
tabEl.selected = isSelected ?? false;
|
|
1669
1749
|
tabEl.fixed = options.fixed;
|
|
1670
|
-
if(tabEl.selected)
|
|
1671
|
-
this.selected = name;
|
|
1672
1750
|
tabEl.instance = this;
|
|
1673
1751
|
contentEl.id = tabEl.id + "_content";
|
|
1674
1752
|
|
|
1753
|
+
if( tabEl.selected )
|
|
1754
|
+
{
|
|
1755
|
+
this.selected = name;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1675
1758
|
LX.addSignal( "@on_tab_docked", tabEl, function() {
|
|
1676
|
-
if( this.parentElement.childNodes.length == 1 )
|
|
1677
|
-
|
|
1759
|
+
if( this.parentElement.childNodes.length == 1 )
|
|
1760
|
+
{
|
|
1761
|
+
this.parentElement.childNodes[ 0 ].click(); // single tab!!
|
|
1678
1762
|
}
|
|
1679
1763
|
} );
|
|
1680
1764
|
|
|
1681
1765
|
tabEl.addEventListener("click", e => {
|
|
1766
|
+
|
|
1682
1767
|
e.preventDefault();
|
|
1683
1768
|
e.stopPropagation();
|
|
1684
1769
|
|
|
@@ -1686,25 +1771,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1686
1771
|
{
|
|
1687
1772
|
// For folding tabs
|
|
1688
1773
|
const lastValue = tabEl.selected;
|
|
1689
|
-
tabEl.parentElement.querySelectorAll('span').forEach( s => s.selected = false );
|
|
1774
|
+
tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.selected = false );
|
|
1690
1775
|
tabEl.selected = !lastValue;
|
|
1691
1776
|
// Manage selected
|
|
1692
|
-
tabEl.parentElement.querySelectorAll('span').forEach( s => s.classList.remove('selected'));
|
|
1693
|
-
tabEl.classList.toggle('selected', (this.folding && tabEl.selected));
|
|
1777
|
+
tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ));
|
|
1778
|
+
tabEl.classList.toggle('selected', ( this.folding && tabEl.selected ));
|
|
1694
1779
|
// Manage visibility
|
|
1695
|
-
tabEl.instance.area.root.querySelectorAll('.lextabcontent').forEach( c => c.style.display = 'none');
|
|
1696
|
-
contentEl.style.display =
|
|
1780
|
+
tabEl.instance.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
|
|
1781
|
+
contentEl.style.display = contentEl.originalDisplay;
|
|
1697
1782
|
tabEl.instance.selected = tabEl.dataset.name;
|
|
1698
1783
|
}
|
|
1699
1784
|
|
|
1700
1785
|
if( this.folding )
|
|
1701
1786
|
{
|
|
1702
1787
|
this.folded = tabEl.selected;
|
|
1703
|
-
this.area.root.classList.toggle('folded', !this.folded);
|
|
1788
|
+
this.area.root.classList.toggle( 'folded', !this.folded );
|
|
1704
1789
|
}
|
|
1705
1790
|
|
|
1706
|
-
if(options.onSelect)
|
|
1791
|
+
if( options.onSelect )
|
|
1792
|
+
{
|
|
1707
1793
|
options.onSelect(e, tabEl.dataset.name);
|
|
1794
|
+
}
|
|
1708
1795
|
|
|
1709
1796
|
if( this.thumb )
|
|
1710
1797
|
{
|
|
@@ -1719,25 +1806,28 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1719
1806
|
e.preventDefault();
|
|
1720
1807
|
e.stopPropagation();
|
|
1721
1808
|
|
|
1722
|
-
if(options.onContextMenu)
|
|
1809
|
+
if( options.onContextMenu )
|
|
1810
|
+
{
|
|
1723
1811
|
options.onContextMenu( e, tabEl.dataset.name );
|
|
1812
|
+
}
|
|
1724
1813
|
});
|
|
1725
1814
|
|
|
1726
1815
|
tabEl.addEventListener("mouseup", e => {
|
|
1727
1816
|
e.preventDefault();
|
|
1728
1817
|
e.stopPropagation();
|
|
1729
|
-
if( e.button == 1 )
|
|
1730
|
-
|
|
1818
|
+
if( e.button == 1 )
|
|
1819
|
+
{
|
|
1820
|
+
this.delete( tabEl.dataset[ "name" ] );
|
|
1731
1821
|
}
|
|
1732
1822
|
});
|
|
1733
1823
|
|
|
1734
|
-
tabEl.setAttribute('draggable', true);
|
|
1735
|
-
tabEl.addEventListener(
|
|
1824
|
+
tabEl.setAttribute( 'draggable', true );
|
|
1825
|
+
tabEl.addEventListener( 'dragstart', function( e ) {
|
|
1736
1826
|
if( this.parentElement.childNodes.length == 1 ){
|
|
1737
1827
|
e.preventDefault();
|
|
1738
1828
|
return;
|
|
1739
1829
|
}
|
|
1740
|
-
e.dataTransfer.setData(
|
|
1830
|
+
e.dataTransfer.setData( 'source', e.target.id );
|
|
1741
1831
|
});
|
|
1742
1832
|
|
|
1743
1833
|
// Attach content
|
|
@@ -2445,8 +2535,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2445
2535
|
}
|
|
2446
2536
|
|
|
2447
2537
|
refresh() {
|
|
2448
|
-
|
|
2449
|
-
// if( this.options.callback ) this.options.callback();
|
|
2538
|
+
|
|
2450
2539
|
}
|
|
2451
2540
|
}
|
|
2452
2541
|
|
|
@@ -3220,7 +3309,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3220
3309
|
|
|
3221
3310
|
if( type != Widget.TITLE )
|
|
3222
3311
|
{
|
|
3223
|
-
element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE
|
|
3312
|
+
element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE ? 10 : 20) + "px)";
|
|
3224
3313
|
if( options.width ) {
|
|
3225
3314
|
element.style.width = element.style.minWidth = options.width;
|
|
3226
3315
|
}
|
|
@@ -3675,6 +3764,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3675
3764
|
* placeholder: Add input placeholder
|
|
3676
3765
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3677
3766
|
* inputWidth: Width of the text input
|
|
3767
|
+
* float: Justify input text content
|
|
3768
|
+
* justifyName: Justify name content
|
|
3678
3769
|
* fitHeight: Height adapts to text
|
|
3679
3770
|
*/
|
|
3680
3771
|
|
|
@@ -3712,6 +3803,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3712
3803
|
let wValue = document.createElement( 'textarea' );
|
|
3713
3804
|
wValue.value = wValue.iValue = value || "";
|
|
3714
3805
|
wValue.style.width = "100%";
|
|
3806
|
+
wValue.style.textAlign = options.float ?? "";
|
|
3715
3807
|
Object.assign( wValue.style, options.style ?? {} );
|
|
3716
3808
|
|
|
3717
3809
|
if( options.disabled ?? false ) wValue.setAttribute("disabled", true);
|
|
@@ -3788,8 +3880,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3788
3880
|
* @param {String} value Button name
|
|
3789
3881
|
* @param {Function} callback Callback function on click
|
|
3790
3882
|
* @param {*} options:
|
|
3791
|
-
* icon
|
|
3792
3883
|
* disabled: Make the widget disabled [false]
|
|
3884
|
+
* icon: Icon class to show as button value
|
|
3885
|
+
* img: Path to image to show as button value
|
|
3793
3886
|
*/
|
|
3794
3887
|
|
|
3795
3888
|
addButton( name, value, callback, options = {} ) {
|
|
@@ -4294,10 +4387,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4294
4387
|
element.appendChild( container );
|
|
4295
4388
|
|
|
4296
4389
|
// Resize
|
|
4297
|
-
curveInstance.canvas.width = container.offsetWidth;
|
|
4298
|
-
curveInstance.redraw();
|
|
4299
4390
|
widget.onresize = curveInstance.redraw.bind( curveInstance );
|
|
4300
4391
|
widget.curveInstance = curveInstance;
|
|
4392
|
+
|
|
4393
|
+
doAsync(() => {
|
|
4394
|
+
curveInstance.canvas.width = container.offsetWidth;
|
|
4395
|
+
curveInstance.redraw();
|
|
4396
|
+
});
|
|
4397
|
+
|
|
4301
4398
|
return widget;
|
|
4302
4399
|
}
|
|
4303
4400
|
|
|
@@ -4401,6 +4498,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4401
4498
|
* @param {Array} values By default values in the array
|
|
4402
4499
|
* @param {Function} callback Callback function on change
|
|
4403
4500
|
* @param {*} options:
|
|
4501
|
+
* innerValues (Array): Use dropdown mode and use values as options
|
|
4404
4502
|
*/
|
|
4405
4503
|
|
|
4406
4504
|
addArray( name, values = [], callback, options = {} ) {
|
|
@@ -4850,7 +4948,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4850
4948
|
container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
4851
4949
|
|
|
4852
4950
|
let color = document.createElement( 'input' );
|
|
4853
|
-
color.style.width = "
|
|
4951
|
+
color.style.width = "32px";
|
|
4854
4952
|
color.type = 'color';
|
|
4855
4953
|
color.className = "colorinput";
|
|
4856
4954
|
color.id = "color" + simple_guidGenerator();
|
|
@@ -4891,7 +4989,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4891
4989
|
change_from_input = true;
|
|
4892
4990
|
widget.set( v );
|
|
4893
4991
|
change_from_input = false;
|
|
4894
|
-
}, { width: "calc(
|
|
4992
|
+
}, { width: "calc( 100% - 32px )"});
|
|
4895
4993
|
|
|
4896
4994
|
text_widget.domEl.style.marginLeft = "4px";
|
|
4897
4995
|
|
|
@@ -5322,9 +5420,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5322
5420
|
* @param {*} options:
|
|
5323
5421
|
* min, max: Min and Max values
|
|
5324
5422
|
* low, optimum, high: Low and High boundary values, Optimum point in the range
|
|
5325
|
-
* showValue:
|
|
5326
|
-
* editable:
|
|
5327
|
-
* callback:
|
|
5423
|
+
* showValue: Show current value
|
|
5424
|
+
* editable: Allow edit value
|
|
5425
|
+
* callback: Function called on change value
|
|
5328
5426
|
*/
|
|
5329
5427
|
|
|
5330
5428
|
addProgress( name, value, options = {} ) {
|
|
@@ -5578,64 +5676,93 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5578
5676
|
|
|
5579
5677
|
/**
|
|
5580
5678
|
* @method addTabs
|
|
5581
|
-
* @param {Array} tabs Contains objects with {
|
|
5679
|
+
* @param {Array} tabs Contains objects with {
|
|
5680
|
+
* name: Name of the tab (if icon, use as title)
|
|
5681
|
+
* icon: Icon to be used as the tab icon (optional)
|
|
5682
|
+
* onCreate: Func to be called at tab creation
|
|
5683
|
+
* onSelect: Func to be called on select tab (optional)
|
|
5684
|
+
* }
|
|
5582
5685
|
* @param {*} options
|
|
5583
5686
|
* vertical: Use vertical or horizontal tabs (vertical by default)
|
|
5584
5687
|
* showNames: Show tab name only in horizontal tabs
|
|
5585
5688
|
*/
|
|
5586
5689
|
|
|
5587
5690
|
addTabs( tabs, options = {} ) {
|
|
5691
|
+
|
|
5588
5692
|
let root = this.current_branch ? this.current_branch.content : this.root;
|
|
5589
|
-
|
|
5693
|
+
|
|
5694
|
+
if( !this.current_branch )
|
|
5695
|
+
{
|
|
5590
5696
|
console.warn("No current branch!");
|
|
5697
|
+
}
|
|
5591
5698
|
|
|
5592
|
-
if(tabs.constructor != Array)
|
|
5593
|
-
|
|
5699
|
+
if( tabs.constructor != Array )
|
|
5700
|
+
{
|
|
5701
|
+
throw( "Param @tabs must be an Array!" );
|
|
5702
|
+
}
|
|
5594
5703
|
|
|
5595
5704
|
const vertical = options.vertical ?? true;
|
|
5596
|
-
const showNames = !vertical && (options.showNames ?? false);
|
|
5705
|
+
const showNames = !vertical && ( options.showNames ?? false );
|
|
5597
5706
|
|
|
5598
|
-
let container = document.createElement('div');
|
|
5707
|
+
let container = document.createElement( 'div' );
|
|
5599
5708
|
container.className = "lextabscontainer";
|
|
5600
|
-
if( !vertical )
|
|
5709
|
+
if( !vertical )
|
|
5710
|
+
{
|
|
5711
|
+
container.className += " horizontal";
|
|
5712
|
+
}
|
|
5601
5713
|
|
|
5602
|
-
let tabContainer = document.createElement(
|
|
5603
|
-
tabContainer.className =
|
|
5714
|
+
let tabContainer = document.createElement( 'div' );
|
|
5715
|
+
tabContainer.className = 'tabs';
|
|
5604
5716
|
container.appendChild( tabContainer );
|
|
5605
5717
|
root.appendChild( container );
|
|
5606
5718
|
|
|
5607
|
-
for(
|
|
5719
|
+
for( let i = 0; i < tabs.length; ++i )
|
|
5608
5720
|
{
|
|
5609
|
-
const tab = tabs[i];
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
tabEl
|
|
5613
|
-
tabEl.
|
|
5721
|
+
const tab = tabs[ i ];
|
|
5722
|
+
console.assert( tab.name );
|
|
5723
|
+
const isSelected = ( i == 0 );
|
|
5724
|
+
let tabEl = document.createElement( 'div' );
|
|
5725
|
+
tabEl.className = "lextab " + (i == tabs.length - 1 ? "last" : "") + ( isSelected ? "selected" : "" );
|
|
5726
|
+
tabEl.innerHTML = ( showNames ? tab.name : "" ) + "<a class='" + ( tab.icon || "fa fa-hashtag" ) + " " + (showNames ? "withname" : "") + "'></a>";
|
|
5614
5727
|
tabEl.title = tab.name;
|
|
5615
5728
|
|
|
5616
|
-
let infoContainer = document.createElement(
|
|
5617
|
-
infoContainer.id = tab.name.replace(/\s/g, '');
|
|
5729
|
+
let infoContainer = document.createElement( 'div' );
|
|
5730
|
+
infoContainer.id = tab.name.replace( /\s/g, '' );
|
|
5618
5731
|
infoContainer.className = "widgets";
|
|
5619
|
-
|
|
5732
|
+
|
|
5733
|
+
if(!isSelected)
|
|
5734
|
+
{
|
|
5735
|
+
infoContainer.toggleAttribute('hidden', true);
|
|
5736
|
+
}
|
|
5737
|
+
|
|
5620
5738
|
container.appendChild( infoContainer );
|
|
5621
5739
|
|
|
5622
|
-
tabEl.addEventListener(
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
el.
|
|
5740
|
+
tabEl.addEventListener( 'click', e => {
|
|
5741
|
+
|
|
5742
|
+
// Change selected tab
|
|
5743
|
+
tabContainer.querySelectorAll( '.lextab' ).forEach( e => { e.classList.remove( 'selected' ); } );
|
|
5744
|
+
e.target.classList.add( 'selected' );
|
|
5745
|
+
// Hide all tabs content
|
|
5746
|
+
container.querySelectorAll(".widgets").forEach( e => { e.toggleAttribute( 'hidden', true ); } );
|
|
5747
|
+
// Show tab content
|
|
5748
|
+
const el = container.querySelector( '#' + infoContainer.id );
|
|
5749
|
+
el.toggleAttribute( 'hidden' );
|
|
5750
|
+
|
|
5751
|
+
if( tab.onSelect )
|
|
5752
|
+
{
|
|
5753
|
+
tab.onSelect( this, infoContainer );
|
|
5754
|
+
}
|
|
5631
5755
|
});
|
|
5632
5756
|
|
|
5633
|
-
tabContainer.appendChild(tabEl);
|
|
5757
|
+
tabContainer.appendChild( tabEl );
|
|
5634
5758
|
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5759
|
+
if( tab.onCreate )
|
|
5760
|
+
{
|
|
5761
|
+
// push to tab space
|
|
5762
|
+
this.queue( infoContainer );
|
|
5763
|
+
tab.onCreate( this, infoContainer );
|
|
5764
|
+
this.clearQueue();
|
|
5765
|
+
}
|
|
5639
5766
|
}
|
|
5640
5767
|
|
|
5641
5768
|
this.addSeparator();
|
|
@@ -5651,14 +5778,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5651
5778
|
class Branch {
|
|
5652
5779
|
|
|
5653
5780
|
constructor( name, options = {} ) {
|
|
5781
|
+
|
|
5654
5782
|
this.name = name;
|
|
5655
5783
|
|
|
5656
|
-
var root = document.createElement('div');
|
|
5784
|
+
var root = document.createElement( 'div' );
|
|
5657
5785
|
root.className = "lexbranch";
|
|
5658
|
-
if(options.id)
|
|
5786
|
+
if( options.id )
|
|
5787
|
+
{
|
|
5659
5788
|
root.id = options.id;
|
|
5660
|
-
|
|
5789
|
+
}
|
|
5790
|
+
if( options.className )
|
|
5791
|
+
{
|
|
5661
5792
|
root.className += " " + options.className;
|
|
5793
|
+
}
|
|
5662
5794
|
|
|
5663
5795
|
root.style.width = "calc(100% - 7px)";
|
|
5664
5796
|
root.style.margin = "0 auto";
|
|
@@ -5669,65 +5801,69 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5669
5801
|
this.widgets = [];
|
|
5670
5802
|
|
|
5671
5803
|
// create element
|
|
5672
|
-
var title = document.createElement('div');
|
|
5804
|
+
var title = document.createElement( 'div' );
|
|
5673
5805
|
title.className = "lexbranchtitle";
|
|
5674
|
-
|
|
5806
|
+
|
|
5675
5807
|
title.innerHTML = "<a class='fa-solid fa-angle-up switch-branch-button'></a>";
|
|
5676
|
-
if(options.icon)
|
|
5808
|
+
if( options.icon )
|
|
5809
|
+
{
|
|
5677
5810
|
title.innerHTML += "<a class='branchicon " + options.icon + "' style='margin-right: 8px; margin-bottom: -2px;'>";
|
|
5678
5811
|
}
|
|
5679
5812
|
title.innerHTML += name || "Branch";
|
|
5680
5813
|
|
|
5681
|
-
root.appendChild(title);
|
|
5814
|
+
root.appendChild( title );
|
|
5682
5815
|
|
|
5683
|
-
var
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
root.appendChild(
|
|
5687
|
-
this.content =
|
|
5816
|
+
var branchContent = document.createElement( 'div' );
|
|
5817
|
+
branchContent.id = name.replace(/\s/g, '');
|
|
5818
|
+
branchContent.className = "lexbranchcontent";
|
|
5819
|
+
root.appendChild(branchContent);
|
|
5820
|
+
this.content = branchContent;
|
|
5688
5821
|
|
|
5689
5822
|
this._addBranchSeparator();
|
|
5690
5823
|
|
|
5691
|
-
if( options.closed )
|
|
5824
|
+
if( options.closed )
|
|
5825
|
+
{
|
|
5692
5826
|
title.className += " closed";
|
|
5693
5827
|
root.className += " closed";
|
|
5694
5828
|
this.grabber.setAttribute('hidden', true);
|
|
5695
5829
|
doAsync( () => {
|
|
5696
|
-
this.content.setAttribute('hidden', true);
|
|
5697
|
-
}, 15);
|
|
5830
|
+
this.content.setAttribute( 'hidden', true );
|
|
5831
|
+
}, 15 );
|
|
5698
5832
|
}
|
|
5699
5833
|
|
|
5700
|
-
this.onclick = function(e){
|
|
5834
|
+
this.onclick = function( e ) {
|
|
5701
5835
|
e.stopPropagation();
|
|
5702
|
-
this.classList.toggle('closed');
|
|
5703
|
-
this.parentElement.classList.toggle('closed');
|
|
5836
|
+
this.classList.toggle( 'closed' );
|
|
5837
|
+
this.parentElement.classList.toggle( 'closed' );
|
|
5704
5838
|
|
|
5705
|
-
that.content.toggleAttribute('hidden');
|
|
5706
|
-
that.grabber.toggleAttribute('hidden');
|
|
5839
|
+
that.content.toggleAttribute( 'hidden' );
|
|
5840
|
+
that.grabber.toggleAttribute( 'hidden' );
|
|
5707
5841
|
|
|
5708
|
-
LX.emit("@on_branch_closed", this.classList.contains("closed"), that.panel);
|
|
5842
|
+
LX.emit( "@on_branch_closed", this.classList.contains("closed"), { target: that.panel } );
|
|
5709
5843
|
};
|
|
5710
5844
|
|
|
5711
|
-
this.oncontextmenu = function(e) {
|
|
5845
|
+
this.oncontextmenu = function( e ) {
|
|
5712
5846
|
|
|
5713
5847
|
e.preventDefault();
|
|
5714
5848
|
e.stopPropagation();
|
|
5715
5849
|
|
|
5716
5850
|
if( this.parentElement.classList.contains("dialog") )
|
|
5717
|
-
|
|
5718
|
-
|
|
5851
|
+
{
|
|
5852
|
+
return;
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5719
5855
|
addContextMenu("Dock", e, p => {
|
|
5720
5856
|
e.preventDefault();
|
|
5721
5857
|
// p.add('<i class="fa-regular fa-window-maximize">', {id: 'dock_options0'});
|
|
5722
5858
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-180">', {id: 'dock_options1'});
|
|
5723
5859
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-90">', {id: 'dock_options2'});
|
|
5724
5860
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-270">', {id: 'dock_options3'});
|
|
5725
|
-
p.add('Floating', that._on_make_floating.bind(that));
|
|
5861
|
+
p.add( 'Floating', that._on_make_floating.bind( that ) );
|
|
5726
5862
|
}, { icon: "fa-regular fa-window-restore" });
|
|
5727
5863
|
};
|
|
5728
5864
|
|
|
5729
|
-
title.addEventListener(
|
|
5730
|
-
title.addEventListener(
|
|
5865
|
+
title.addEventListener( 'click', this.onclick );
|
|
5866
|
+
title.addEventListener( 'contextmenu', this.oncontextmenu );
|
|
5731
5867
|
}
|
|
5732
5868
|
|
|
5733
5869
|
_on_make_floating() {
|
|
@@ -6611,11 +6747,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6611
6747
|
|
|
6612
6748
|
selected = computeSelected( mousex, canvas.height - mousey );
|
|
6613
6749
|
|
|
6614
|
-
if(selected == -1 && element.allow_add_values) {
|
|
6615
|
-
var v = unconvert([ mousex, canvas.height-mousey ]);
|
|
6616
|
-
element.value.push(v);
|
|
6750
|
+
if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
|
|
6751
|
+
var v = unconvert([ mousex, canvas.height - mousey ]);
|
|
6752
|
+
element.value.push( v );
|
|
6617
6753
|
sortValues();
|
|
6618
|
-
selected = element.value.indexOf(v);
|
|
6754
|
+
selected = element.value.indexOf( v );
|
|
6619
6755
|
}
|
|
6620
6756
|
|
|
6621
6757
|
last_mouse = [ mousex, mousey ];
|
|
@@ -6647,7 +6783,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
6647
6783
|
{
|
|
6648
6784
|
const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
|
|
6649
6785
|
let value = element.value[ selected ];
|
|
6650
|
-
value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[
|
|
6786
|
+
value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
|
|
6651
6787
|
value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
|
|
6652
6788
|
}
|
|
6653
6789
|
|