lexgui 0.1.34 → 0.1.35

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.css CHANGED
@@ -6,6 +6,7 @@
6
6
  --global-font: "Figtree", sans-serif;
7
7
  --global-title-font: "Poppins", sans-serif;
8
8
  --global-font-size: 12px;
9
+ --global-font-size-big: 14px;
9
10
  --global-color-primary: #212121;
10
11
  --global-color-secondary: #2c2c2c;
11
12
  --global-color-terciary: #444;
@@ -828,7 +829,7 @@ body.noevents * {
828
829
  }
829
830
 
830
831
  .lexbutton.array a {
831
- margin-top: 3px;
832
+ margin-top: 2px;
832
833
  }
833
834
 
834
835
  .lexbutton:hover {
@@ -873,7 +874,8 @@ body.noevents * {
873
874
  }
874
875
 
875
876
  .lexcombobuttons .lexbutton.combo {
876
- margin-left: 0px;
877
+ margin-left: 1px;
878
+ margin-right: 1px;
877
879
  border-radius: 0px;
878
880
  display: flex;
879
881
  padding-top: 0.35em;
@@ -882,13 +884,15 @@ body.noevents * {
882
884
  }
883
885
 
884
886
  .lexcombobuttons .lexbutton.combo:first-child {
885
- border-top-left-radius: 5px;
886
- border-bottom-left-radius: 5px;
887
+ border-top-left-radius: 4px;
888
+ border-bottom-left-radius: 4px;
889
+ margin-left: 0px;
887
890
  }
888
891
 
889
892
  .lexcombobuttons .lexbutton.combo:last-child {
890
- border-top-right-radius: 5px;
891
- border-bottom-right-radius: 5px;
893
+ border-top-right-radius: 4px;
894
+ border-bottom-right-radius: 4px;
895
+ margin-right: 0px;
892
896
  }
893
897
 
894
898
  .lexcombobuttons .lexbutton.combo.selected {
@@ -1111,9 +1115,11 @@ input[type=checkbox]:checked:after {
1111
1115
 
1112
1116
  .lexcolor {
1113
1117
  display: flex;
1118
+ /*
1114
1119
  flex-wrap: wrap;
1115
1120
  padding-left: 6px;
1116
1121
  padding-right: 6px;
1122
+ */
1117
1123
  align-items: center;
1118
1124
  }
1119
1125
 
@@ -1146,6 +1152,10 @@ input[type=checkbox]:checked:after {
1146
1152
  cursor: pointer;
1147
1153
  }
1148
1154
 
1155
+ .lexcolor .lexwidget {
1156
+ padding: 0px;
1157
+ }
1158
+
1149
1159
  /* Vector Widgets */
1150
1160
 
1151
1161
  .lexvector {
@@ -2078,9 +2088,9 @@ meter::-webkit-meter-even-less-good-value {
2078
2088
  }
2079
2089
 
2080
2090
  .lexoverlaybuttons .lexbutton {
2081
- padding: 14px 10px;
2082
- font-size: var(--global-font-size);
2083
- border-radius: 6px;
2091
+ padding: 18px 12px;
2092
+ font-size: var(--global-font-size-big);
2093
+ border-radius: 10px;
2084
2094
  justify-content: center;
2085
2095
  background-color: #313132a5;
2086
2096
  -webkit-backdrop-filter: blur(6px);
@@ -2088,9 +2098,13 @@ meter::-webkit-meter-even-less-good-value {
2088
2098
  color: #d1d1d3bd;
2089
2099
  }
2090
2100
 
2101
+ .lexoverlaybuttons .lexbutton span {
2102
+ font-size: var(--global-font-size-big);
2103
+ }
2104
+
2091
2105
  .lexoverlaybuttons .lexbutton a {
2092
2106
  line-height: 19px;
2093
- font-size: var(--global-font-size);
2107
+ font-size: var(--global-font-size-big);
2094
2108
  }
2095
2109
 
2096
2110
  .lexoverlaybuttons .lexbutton img {
@@ -2201,11 +2215,11 @@ meter::-webkit-meter-even-less-good-value {
2201
2215
  }
2202
2216
 
2203
2217
  .lexareatabs.row .lexareatab {
2204
- background-color: var(--global-color-secondary);
2218
+ background-color: var(--global-color-terciary);
2205
2219
  padding-left: 16px;
2206
2220
  padding-right: 16px;
2207
2221
  margin-right: 4px;
2208
- border-radius: 6px;
2222
+ border-radius: 4px;
2209
2223
  }
2210
2224
 
2211
2225
  .lexareatabs.fit {
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.34",
15
+ version: "0.1.35",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -472,7 +472,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
472
472
  var link = document.createElement( 'link' );
473
473
  link.rel = 'stylesheet';
474
474
  link.type = 'text/css';
475
- link.href = 'https://use.fontawesome.com/releases/v6.5.1/css/all.css';
475
+ link.href = 'https://use.fontawesome.com/releases/v6.6.0/css/all.css';
476
476
  head.appendChild( link );
477
477
 
478
478
  // Global vars
@@ -526,26 +526,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
526
526
  * size: (Array) [width, height]
527
527
  */
528
528
 
529
- function popup(text, title, options = {})
529
+ function popup( text, title, options = {} )
530
530
  {
531
- if(!text)
531
+ if( !text )
532
+ {
532
533
  throw("No message to show");
534
+ }
533
535
 
534
- options.size = options.size ?? ["auto", "auto"];
536
+ options.size = options.size ?? [ "auto", "auto" ];
535
537
  options.class = "lexpopup";
536
- const time = options.timeout || 3000;
537
538
 
538
- const dialog = new Dialog(title, p => {
539
- p.addTextArea(null, text, null, { disabled: true, fitHeight: true });
540
- }, options);
541
-
542
- dialog.root.classList.add("fadein");
539
+ const time = options.timeout || 3000;
540
+ const dialog = new Dialog( title, p => {
541
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
542
+ }, options );
543
+
544
+ dialog.root.classList.add( 'fadein' );
543
545
  setTimeout(() => {
544
- dialog.root.classList.remove("fadein");
545
- dialog.root.classList.add("fadeout");
546
- }, time - 1000);
546
+ dialog.root.classList.remove( 'fadein' );
547
+ dialog.root.classList.add( 'fadeout' );
548
+ }, time - 1000 );
549
+
550
+ setTimeout( dialog.close, time );
547
551
 
548
- setTimeout(dialog.close, time);
549
552
  return dialog;
550
553
  }
551
554
 
@@ -564,36 +567,45 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
564
567
  * required: Input has to be filled [true]. Default: false
565
568
  */
566
569
 
567
- function prompt(text, title, callback, options = {})
570
+ function prompt( text, title, callback, options = {} )
568
571
  {
569
572
  options.modal = true;
570
573
 
571
574
  let value = "";
572
575
 
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 === '') {
576
+ const dialog = new Dialog( title, p => {
580
577
 
581
- text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
582
- dialog.close() ;
583
- prompt(text, title, callback, options);
584
- }else {
578
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
579
+
580
+ if( options.input ?? true )
581
+ {
582
+ p.addText( null, options.input || value, v => value = v, { placeholder: "..." } );
583
+ }
585
584
 
586
- callback.call(this, value);
587
- dialog.close() ;
585
+ p.sameLine( 2 );
586
+
587
+ p.addButton( null, options.accept || "OK", () => {
588
+ if( options.required && value === '' )
589
+ {
590
+ text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
591
+ dialog.close();
592
+ prompt( text, title, callback, options );
593
+ }else
594
+ {
595
+ if( callback ) callback.call( this, value );
596
+ dialog.close();
588
597
  }
589
-
590
598
  }, { buttonClass: "accept" });
599
+
591
600
  p.addButton(null, "Cancel", () => {if(options.on_cancel) options.on_cancel(); dialog.close();} );
592
- }, options);
601
+
602
+ }, options );
593
603
 
594
604
  // Focus text prompt
595
- if(options.input !== false)
596
- dialog.root.querySelector('input').focus();
605
+ if( options.input ?? true )
606
+ {
607
+ dialog.root.querySelector( 'input' ).focus();
608
+ }
597
609
 
598
610
  return dialog;
599
611
  }
@@ -884,35 +896,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
884
896
 
885
897
  split( options = {} ) {
886
898
 
887
- if(this.sections.length)
899
+ if( this.sections.length )
888
900
  {
889
901
  // 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;
902
+ this.offset = this.root.childNodes[ 0 ].offsetHeight; // store offset to take into account when resizing
903
+ this._root = this.sections[ 0 ].root;
904
+ this.root = this.sections[ 1 ].root;
893
905
  }
894
906
 
895
907
  var type = options.type || "horizontal";
896
- var sizes = options.sizes || ["50%", "50%"];
908
+ var sizes = options.sizes || [ "50%", "50%" ];
897
909
  var infer_height = false;
898
- var auto = options.sizes === 'auto';
910
+ var auto = (options.sizes === 'auto');
899
911
 
900
- if( !sizes[1] )
912
+ if( !sizes[ 1 ] )
901
913
  {
902
- let size = sizes[0];
914
+ let size = sizes[ 0 ];
903
915
  let margin = options.top ? options.top : 0;
904
- if(size.constructor == Number) {
916
+ if( size.constructor == Number )
917
+ {
905
918
  size += margin;
906
919
  size += "px";
907
920
  }
908
-
909
- sizes[1] = "calc( 100% - " + size + " )";
921
+
922
+ sizes[ 1 ] = "calc( 100% - " + size + " )";
910
923
  infer_height = true;
911
924
  }
912
925
 
913
926
  // 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"});
927
+ var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
928
+ var area2 = new Area( { no_append: true, className: "split"} );
916
929
 
917
930
  area1.parentArea = this;
918
931
  area2.parentArea = this;
@@ -923,23 +936,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
923
936
  var data = "0px";
924
937
  this.offset = 0;
925
938
 
926
- if(resize)
939
+ if( resize )
927
940
  {
928
941
  this.resize = resize;
929
- this.split_bar = document.createElement("div");
942
+ this.split_bar = document.createElement( "div" );
930
943
  this.split_bar.className = "lexsplitbar " + type;
931
944
 
932
- if(type == "horizontal") {
945
+ if( type == "horizontal" )
946
+ {
933
947
  this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
934
948
  }
935
- else {
949
+ else
950
+ {
936
951
  this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
937
952
  }
938
- this.split_bar.addEventListener("mousedown", inner_mousedown);
939
- data = LX.DEFAULT_SPLITBAR_SIZE/2 + "px"; // updates
953
+
954
+ this.split_bar.addEventListener( 'mousedown', inner_mousedown );
955
+
956
+ data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
940
957
 
941
958
  // Being minimizable means it's also resizeable!
942
- if(minimizable)
959
+ if( minimizable )
943
960
  {
944
961
  this.split_extended = false;
945
962
 
@@ -961,14 +978,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
961
978
  }
962
979
  }
963
980
 
964
- if(type == "horizontal")
981
+ if( type == "horizontal" )
965
982
  {
966
- var width1 = sizes[0],
967
- width2 = sizes[1];
983
+ var width1 = sizes[ 0 ],
984
+ width2 = sizes[ 1 ];
968
985
 
969
- if(width1.constructor == Number)
986
+ if( width1.constructor == Number )
970
987
  width1 += "px";
971
- if(width2.constructor == Number)
988
+ if( width2.constructor == Number )
972
989
  width2 += "px";
973
990
 
974
991
  area1.root.style.width = "calc( " + width1 + " - " + data + " )";
@@ -987,20 +1004,20 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
987
1004
  area1.root.style.height = "auto";
988
1005
 
989
1006
  // Listen resize event on first area
990
- const resizeObserver = new ResizeObserver((entries) => {
1007
+ const resizeObserver = new ResizeObserver( entries => {
991
1008
  for (const entry of entries) {
992
1009
  const bb = entry.contentRect;
993
1010
  area2.root.style.height = "calc(100% - " + ( bb.height + 4) + "px )";
994
1011
  }
995
1012
  });
996
1013
 
997
- resizeObserver.observe(area1.root);
1014
+ resizeObserver.observe( area1.root );
998
1015
  }
999
1016
  else
1000
1017
  {
1001
- var height1 = sizes[0],
1002
- height2 = sizes[1];
1003
-
1018
+ var height1 = sizes[ 0 ],
1019
+ height2 = sizes[ 1 ];
1020
+
1004
1021
  if(height1.constructor == Number)
1005
1022
  height1 += "px";
1006
1023
  if(height2.constructor == Number)
@@ -1014,7 +1031,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1014
1031
 
1015
1032
  this.root.appendChild( area1.root );
1016
1033
 
1017
- if(resize)
1034
+ if( resize )
1018
1035
  {
1019
1036
  this.root.appendChild(this.split_bar);
1020
1037
  }
@@ -1026,55 +1043,67 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1026
1043
  // Update sizes
1027
1044
  this._update();
1028
1045
 
1029
- if(!resize)
1046
+ if( !resize )
1030
1047
  {
1031
1048
  return this.sections;
1032
1049
  }
1033
1050
 
1034
- // from litegui.js @jagenjo
1035
-
1036
1051
  var that = this;
1037
- var last_pos = [0,0];
1038
- function inner_mousedown(e)
1052
+ var last_pos = [ 0, 0 ];
1053
+
1054
+ function inner_mousedown( e )
1039
1055
  {
1040
1056
  var doc = that.root.ownerDocument;
1041
- doc.addEventListener("mousemove",inner_mousemove);
1042
- doc.addEventListener("mouseup",inner_mouseup);
1057
+ doc.addEventListener( 'mousemove', inner_mousemove );
1058
+ doc.addEventListener( 'mouseup', inner_mouseup );
1043
1059
  last_pos[0] = e.x;
1044
1060
  last_pos[1] = e.y;
1045
1061
  e.stopPropagation();
1046
1062
  e.preventDefault();
1047
- document.body.classList.add("nocursor");
1048
- that.split_bar.classList.add("nocursor");
1063
+ document.body.classList.add( 'nocursor' );
1064
+ that.split_bar.classList.add( 'nocursor' );
1049
1065
  }
1050
1066
 
1051
- function inner_mousemove(e)
1067
+ function inner_mousemove( e )
1052
1068
  {
1053
- if(that.type == "horizontal") {
1054
- that._moveSplit(last_pos[0] - e.x);
1069
+ if(that.type == "horizontal")
1070
+ {
1071
+ that._moveSplit( last_pos[ 0 ] - e.x );
1055
1072
  }
1056
- else {
1057
- that._moveSplit(last_pos[1] - e.y);
1073
+ else
1074
+ {
1075
+ that._moveSplit( last_pos[ 1 ] - e.y );
1058
1076
  }
1059
-
1060
- last_pos[0] = e.x;
1061
- last_pos[1] = e.y;
1077
+
1078
+ last_pos[ 0 ] = e.x;
1079
+ last_pos[ 1 ] = e.y;
1080
+
1081
+ const widgets = that.root.querySelectorAll( ".lexwidget" );
1082
+
1083
+ // Send area resize to every widget in the area
1084
+ for( let widget of widgets )
1085
+ {
1086
+ const jsInstance = widget.jsIinstance;
1087
+
1088
+ if( jsInstance.onresize )
1089
+ {
1090
+ jsInstance.onresize();
1091
+ }
1092
+ }
1093
+
1062
1094
  e.stopPropagation();
1063
1095
  e.preventDefault();
1064
1096
  }
1065
1097
 
1066
- function inner_mouseup(e)
1098
+ function inner_mouseup( e )
1067
1099
  {
1068
1100
  var doc = that.root.ownerDocument;
1069
- doc.removeEventListener("mousemove",inner_mousemove);
1070
- doc.removeEventListener("mouseup",inner_mouseup);
1071
- document.body.classList.remove("nocursor");
1072
- that.split_bar.classList.remove("nocursor");
1101
+ doc.removeEventListener( 'mousemove', inner_mousemove );
1102
+ doc.removeEventListener( 'mouseup', inner_mouseup );
1103
+ document.body.classList.remove( 'nocursor' );
1104
+ that.split_bar.classList.remove( 'nocursor' );
1073
1105
  }
1074
1106
 
1075
- // Is this necessary?..
1076
- // setTimeout( () => this._moveSplit(0), 100);
1077
-
1078
1107
  return this.sections;
1079
1108
  }
1080
1109
 
@@ -3220,7 +3249,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3220
3249
 
3221
3250
  if( type != Widget.TITLE )
3222
3251
  {
3223
- element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE || ( type == Widget.BUTTON && !name ) ? 10 : 20) + "px)";
3252
+ element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE ? 10 : 20) + "px)";
3224
3253
  if( options.width ) {
3225
3254
  element.style.width = element.style.minWidth = options.width;
3226
3255
  }
@@ -4294,10 +4323,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4294
4323
  element.appendChild( container );
4295
4324
 
4296
4325
  // Resize
4297
- curveInstance.canvas.width = container.offsetWidth;
4298
- curveInstance.redraw();
4299
4326
  widget.onresize = curveInstance.redraw.bind( curveInstance );
4300
4327
  widget.curveInstance = curveInstance;
4328
+
4329
+ doAsync(() => {
4330
+ curveInstance.canvas.width = container.offsetWidth;
4331
+ curveInstance.redraw();
4332
+ });
4333
+
4301
4334
  return widget;
4302
4335
  }
4303
4336
 
@@ -4850,7 +4883,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4850
4883
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4851
4884
 
4852
4885
  let color = document.createElement( 'input' );
4853
- color.style.width = "calc(30% - 6px)";
4886
+ color.style.width = "32px";
4854
4887
  color.type = 'color';
4855
4888
  color.className = "colorinput";
4856
4889
  color.id = "color" + simple_guidGenerator();
@@ -4891,7 +4924,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4891
4924
  change_from_input = true;
4892
4925
  widget.set( v );
4893
4926
  change_from_input = false;
4894
- }, { width: "calc(70% - 4px)" });
4927
+ }, { width: "calc( 100% - 32px )"});
4895
4928
 
4896
4929
  text_widget.domEl.style.marginLeft = "4px";
4897
4930
 
@@ -6611,11 +6644,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6611
6644
 
6612
6645
  selected = computeSelected( mousex, canvas.height - mousey );
6613
6646
 
6614
- if(selected == -1 && element.allow_add_values) {
6615
- var v = unconvert([ mousex, canvas.height-mousey ]);
6616
- element.value.push(v);
6647
+ if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
6648
+ var v = unconvert([ mousex, canvas.height - mousey ]);
6649
+ element.value.push( v );
6617
6650
  sortValues();
6618
- selected = element.value.indexOf(v);
6651
+ selected = element.value.indexOf( v );
6619
6652
  }
6620
6653
 
6621
6654
  last_mouse = [ mousex, mousey ];
@@ -6647,7 +6680,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6647
6680
  {
6648
6681
  const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
6649
6682
  let value = element.value[ selected ];
6650
- value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 1 ] : element.xrange[ 0 ] );
6683
+ value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
6651
6684
  value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
6652
6685
  }
6653
6686
 
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  var LX = {
11
- version: "0.1.34",
11
+ version: "0.1.35",
12
12
  ready: false,
13
13
  components: [], // specific pre-build components
14
14
  signals: {} // events and triggers
@@ -469,7 +469,7 @@ function init( options = { } )
469
469
  var link = document.createElement( 'link' );
470
470
  link.rel = 'stylesheet';
471
471
  link.type = 'text/css';
472
- link.href = 'https://use.fontawesome.com/releases/v6.5.1/css/all.css';
472
+ link.href = 'https://use.fontawesome.com/releases/v6.6.0/css/all.css';
473
473
  head.appendChild( link );
474
474
 
475
475
  // Global vars
@@ -523,26 +523,29 @@ LX.message = message;
523
523
  * size: (Array) [width, height]
524
524
  */
525
525
 
526
- function popup(text, title, options = {})
526
+ function popup( text, title, options = {} )
527
527
  {
528
- if(!text)
528
+ if( !text )
529
+ {
529
530
  throw("No message to show");
531
+ }
530
532
 
531
- options.size = options.size ?? ["auto", "auto"];
533
+ options.size = options.size ?? [ "auto", "auto" ];
532
534
  options.class = "lexpopup";
533
- const time = options.timeout || 3000;
534
535
 
535
- const dialog = new Dialog(title, p => {
536
- p.addTextArea(null, text, null, { disabled: true, fitHeight: true });
537
- }, options);
536
+ const time = options.timeout || 3000;
537
+ const dialog = new Dialog( title, p => {
538
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
539
+ }, options );
538
540
 
539
- dialog.root.classList.add("fadein");
541
+ dialog.root.classList.add( 'fadein' );
540
542
  setTimeout(() => {
541
- dialog.root.classList.remove("fadein");
542
- dialog.root.classList.add("fadeout");
543
- }, time - 1000);
543
+ dialog.root.classList.remove( 'fadein' );
544
+ dialog.root.classList.add( 'fadeout' );
545
+ }, time - 1000 );
544
546
 
545
- setTimeout(dialog.close, time);
547
+ setTimeout( dialog.close, time );
548
+
546
549
  return dialog;
547
550
  }
548
551
 
@@ -561,36 +564,45 @@ LX.popup = popup;
561
564
  * required: Input has to be filled [true]. Default: false
562
565
  */
563
566
 
564
- function prompt(text, title, callback, options = {})
567
+ function prompt( text, title, callback, options = {} )
565
568
  {
566
569
  options.modal = true;
567
570
 
568
571
  let value = "";
569
572
 
570
- const dialog = new Dialog(title, p => {
571
- p.addTextArea(null, text, null, { disabled: true });
572
- if(options.input !== false)
573
- p.addText(null, options.input || value, (v) => value = v, {placeholder: "..."} );
574
- p.sameLine(2);
575
- p.addButton(null, options.accept || "OK", () => {
576
- if(options.required && value === '') {
573
+ const dialog = new Dialog( title, p => {
577
574
 
578
- text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
579
- dialog.close() ;
580
- prompt(text, title, callback, options);
581
- }else {
575
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
576
+
577
+ if( options.input ?? true )
578
+ {
579
+ p.addText( null, options.input || value, v => value = v, { placeholder: "..." } );
580
+ }
582
581
 
583
- callback.call(this, value);
584
- dialog.close() ;
582
+ p.sameLine( 2 );
583
+
584
+ p.addButton( null, options.accept || "OK", () => {
585
+ if( options.required && value === '' )
586
+ {
587
+ text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
588
+ dialog.close();
589
+ prompt( text, title, callback, options );
590
+ }else
591
+ {
592
+ if( callback ) callback.call( this, value );
593
+ dialog.close();
585
594
  }
586
-
587
595
  }, { buttonClass: "accept" });
596
+
588
597
  p.addButton(null, "Cancel", () => {if(options.on_cancel) options.on_cancel(); dialog.close();} );
589
- }, options);
598
+
599
+ }, options );
590
600
 
591
601
  // Focus text prompt
592
- if(options.input !== false)
593
- dialog.root.querySelector('input').focus();
602
+ if( options.input ?? true )
603
+ {
604
+ dialog.root.querySelector( 'input' ).focus();
605
+ }
594
606
 
595
607
  return dialog;
596
608
  }
@@ -896,35 +908,36 @@ class Area {
896
908
 
897
909
  split( options = {} ) {
898
910
 
899
- if(this.sections.length)
911
+ if( this.sections.length )
900
912
  {
901
913
  // In case Area has been split before, get 2nd section as root
902
- this.offset = this.root.childNodes[0].offsetHeight; // store offset to take into account when resizing
903
- this._root = this.sections[0].root;
904
- this.root = this.sections[1].root;
914
+ this.offset = this.root.childNodes[ 0 ].offsetHeight; // store offset to take into account when resizing
915
+ this._root = this.sections[ 0 ].root;
916
+ this.root = this.sections[ 1 ].root;
905
917
  }
906
918
 
907
919
  var type = options.type || "horizontal";
908
- var sizes = options.sizes || ["50%", "50%"];
920
+ var sizes = options.sizes || [ "50%", "50%" ];
909
921
  var infer_height = false;
910
- var auto = options.sizes === 'auto';
922
+ var auto = (options.sizes === 'auto');
911
923
 
912
- if( !sizes[1] )
924
+ if( !sizes[ 1 ] )
913
925
  {
914
- let size = sizes[0];
926
+ let size = sizes[ 0 ];
915
927
  let margin = options.top ? options.top : 0;
916
- if(size.constructor == Number) {
928
+ if( size.constructor == Number )
929
+ {
917
930
  size += margin;
918
931
  size += "px";
919
932
  }
920
933
 
921
- sizes[1] = "calc( 100% - " + size + " )";
934
+ sizes[ 1 ] = "calc( 100% - " + size + " )";
922
935
  infer_height = true;
923
936
  }
924
937
 
925
938
  // Create areas
926
- var area1 = new Area({ no_append: true, className: "split" + (options.menubar || options.sidebar ? "" : " origin") });
927
- var area2 = new Area({ no_append: true, className: "split"});
939
+ var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
940
+ var area2 = new Area( { no_append: true, className: "split"} );
928
941
 
929
942
  area1.parentArea = this;
930
943
  area2.parentArea = this;
@@ -935,23 +948,27 @@ class Area {
935
948
  var data = "0px";
936
949
  this.offset = 0;
937
950
 
938
- if(resize)
951
+ if( resize )
939
952
  {
940
953
  this.resize = resize;
941
- this.split_bar = document.createElement("div");
954
+ this.split_bar = document.createElement( "div" );
942
955
  this.split_bar.className = "lexsplitbar " + type;
943
956
 
944
- if(type == "horizontal") {
957
+ if( type == "horizontal" )
958
+ {
945
959
  this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
946
960
  }
947
- else {
961
+ else
962
+ {
948
963
  this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
949
964
  }
950
- this.split_bar.addEventListener("mousedown", inner_mousedown);
951
- data = LX.DEFAULT_SPLITBAR_SIZE/2 + "px"; // updates
965
+
966
+ this.split_bar.addEventListener( 'mousedown', inner_mousedown );
967
+
968
+ data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
952
969
 
953
970
  // Being minimizable means it's also resizeable!
954
- if(minimizable)
971
+ if( minimizable )
955
972
  {
956
973
  this.split_extended = false;
957
974
 
@@ -973,14 +990,14 @@ class Area {
973
990
  }
974
991
  }
975
992
 
976
- if(type == "horizontal")
993
+ if( type == "horizontal" )
977
994
  {
978
- var width1 = sizes[0],
979
- width2 = sizes[1];
995
+ var width1 = sizes[ 0 ],
996
+ width2 = sizes[ 1 ];
980
997
 
981
- if(width1.constructor == Number)
998
+ if( width1.constructor == Number )
982
999
  width1 += "px";
983
- if(width2.constructor == Number)
1000
+ if( width2.constructor == Number )
984
1001
  width2 += "px";
985
1002
 
986
1003
  area1.root.style.width = "calc( " + width1 + " - " + data + " )";
@@ -999,19 +1016,19 @@ class Area {
999
1016
  area1.root.style.height = "auto";
1000
1017
 
1001
1018
  // Listen resize event on first area
1002
- const resizeObserver = new ResizeObserver((entries) => {
1019
+ const resizeObserver = new ResizeObserver( entries => {
1003
1020
  for (const entry of entries) {
1004
1021
  const bb = entry.contentRect;
1005
1022
  area2.root.style.height = "calc(100% - " + ( bb.height + 4) + "px )";
1006
1023
  }
1007
1024
  });
1008
1025
 
1009
- resizeObserver.observe(area1.root);
1026
+ resizeObserver.observe( area1.root );
1010
1027
  }
1011
1028
  else
1012
1029
  {
1013
- var height1 = sizes[0],
1014
- height2 = sizes[1];
1030
+ var height1 = sizes[ 0 ],
1031
+ height2 = sizes[ 1 ];
1015
1032
 
1016
1033
  if(height1.constructor == Number)
1017
1034
  height1 += "px";
@@ -1026,7 +1043,7 @@ class Area {
1026
1043
 
1027
1044
  this.root.appendChild( area1.root );
1028
1045
 
1029
- if(resize)
1046
+ if( resize )
1030
1047
  {
1031
1048
  this.root.appendChild(this.split_bar);
1032
1049
  }
@@ -1038,55 +1055,67 @@ class Area {
1038
1055
  // Update sizes
1039
1056
  this._update();
1040
1057
 
1041
- if(!resize)
1058
+ if( !resize )
1042
1059
  {
1043
1060
  return this.sections;
1044
1061
  }
1045
1062
 
1046
- // from litegui.js @jagenjo
1047
-
1048
1063
  var that = this;
1049
- var last_pos = [0,0];
1050
- function inner_mousedown(e)
1064
+ var last_pos = [ 0, 0 ];
1065
+
1066
+ function inner_mousedown( e )
1051
1067
  {
1052
1068
  var doc = that.root.ownerDocument;
1053
- doc.addEventListener("mousemove",inner_mousemove);
1054
- doc.addEventListener("mouseup",inner_mouseup);
1069
+ doc.addEventListener( 'mousemove', inner_mousemove );
1070
+ doc.addEventListener( 'mouseup', inner_mouseup );
1055
1071
  last_pos[0] = e.x;
1056
1072
  last_pos[1] = e.y;
1057
1073
  e.stopPropagation();
1058
1074
  e.preventDefault();
1059
- document.body.classList.add("nocursor");
1060
- that.split_bar.classList.add("nocursor");
1075
+ document.body.classList.add( 'nocursor' );
1076
+ that.split_bar.classList.add( 'nocursor' );
1061
1077
  }
1062
1078
 
1063
- function inner_mousemove(e)
1079
+ function inner_mousemove( e )
1064
1080
  {
1065
- if(that.type == "horizontal") {
1066
- that._moveSplit(last_pos[0] - e.x);
1081
+ if(that.type == "horizontal")
1082
+ {
1083
+ that._moveSplit( last_pos[ 0 ] - e.x );
1067
1084
  }
1068
- else {
1069
- that._moveSplit(last_pos[1] - e.y);
1085
+ else
1086
+ {
1087
+ that._moveSplit( last_pos[ 1 ] - e.y );
1070
1088
  }
1071
1089
 
1072
- last_pos[0] = e.x;
1073
- last_pos[1] = e.y;
1090
+ last_pos[ 0 ] = e.x;
1091
+ last_pos[ 1 ] = e.y;
1092
+
1093
+ const widgets = that.root.querySelectorAll( ".lexwidget" );
1094
+
1095
+ // Send area resize to every widget in the area
1096
+ for( let widget of widgets )
1097
+ {
1098
+ const jsInstance = widget.jsIinstance;
1099
+
1100
+ if( jsInstance.onresize )
1101
+ {
1102
+ jsInstance.onresize();
1103
+ }
1104
+ }
1105
+
1074
1106
  e.stopPropagation();
1075
1107
  e.preventDefault();
1076
1108
  }
1077
1109
 
1078
- function inner_mouseup(e)
1110
+ function inner_mouseup( e )
1079
1111
  {
1080
1112
  var doc = that.root.ownerDocument;
1081
- doc.removeEventListener("mousemove",inner_mousemove);
1082
- doc.removeEventListener("mouseup",inner_mouseup);
1083
- document.body.classList.remove("nocursor");
1084
- that.split_bar.classList.remove("nocursor");
1113
+ doc.removeEventListener( 'mousemove', inner_mousemove );
1114
+ doc.removeEventListener( 'mouseup', inner_mouseup );
1115
+ document.body.classList.remove( 'nocursor' );
1116
+ that.split_bar.classList.remove( 'nocursor' );
1085
1117
  }
1086
1118
 
1087
- // Is this necessary?..
1088
- // setTimeout( () => this._moveSplit(0), 100);
1089
-
1090
1119
  return this.sections;
1091
1120
  }
1092
1121
 
@@ -3303,7 +3332,7 @@ class Panel {
3303
3332
 
3304
3333
  if( type != Widget.TITLE )
3305
3334
  {
3306
- element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE || ( type == Widget.BUTTON && !name ) ? 10 : 20) + "px)";
3335
+ element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE ? 10 : 20) + "px)";
3307
3336
  if( options.width ) {
3308
3337
  element.style.width = element.style.minWidth = options.width;
3309
3338
  }
@@ -3355,6 +3384,7 @@ class Panel {
3355
3384
  }
3356
3385
 
3357
3386
  widget.domEl = element;
3387
+ element.jsIinstance = widget;
3358
3388
 
3359
3389
  const insert_widget = el => {
3360
3390
  if(options.container)
@@ -4380,10 +4410,14 @@ class Panel {
4380
4410
  element.appendChild( container );
4381
4411
 
4382
4412
  // Resize
4383
- curveInstance.canvas.width = container.offsetWidth;
4384
- curveInstance.redraw();
4385
4413
  widget.onresize = curveInstance.redraw.bind( curveInstance );
4386
4414
  widget.curveInstance = curveInstance;
4415
+
4416
+ doAsync(() => {
4417
+ curveInstance.canvas.width = container.offsetWidth;
4418
+ curveInstance.redraw();
4419
+ });
4420
+
4387
4421
  return widget;
4388
4422
  }
4389
4423
 
@@ -4936,7 +4970,7 @@ class Panel {
4936
4970
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4937
4971
 
4938
4972
  let color = document.createElement( 'input' );
4939
- color.style.width = "calc(30% - 6px)";
4973
+ color.style.width = "32px";
4940
4974
  color.type = 'color';
4941
4975
  color.className = "colorinput";
4942
4976
  color.id = "color" + simple_guidGenerator();
@@ -4977,7 +5011,7 @@ class Panel {
4977
5011
  change_from_input = true;
4978
5012
  widget.set( v );
4979
5013
  change_from_input = false;
4980
- }, { width: "calc(70% - 4px)" });
5014
+ }, { width: "calc( 100% - 32px )"});
4981
5015
 
4982
5016
  text_widget.domEl.style.marginLeft = "4px";
4983
5017
 
@@ -6702,11 +6736,11 @@ class Curve {
6702
6736
 
6703
6737
  selected = computeSelected( mousex, canvas.height - mousey );
6704
6738
 
6705
- if(selected == -1 && element.allow_add_values) {
6706
- var v = unconvert([ mousex, canvas.height-mousey ]);
6707
- element.value.push(v);
6739
+ if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
6740
+ var v = unconvert([ mousex, canvas.height - mousey ]);
6741
+ element.value.push( v );
6708
6742
  sortValues();
6709
- selected = element.value.indexOf(v);
6743
+ selected = element.value.indexOf( v );
6710
6744
  }
6711
6745
 
6712
6746
  last_mouse = [ mousex, mousey ];
@@ -6738,7 +6772,7 @@ class Curve {
6738
6772
  {
6739
6773
  const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
6740
6774
  let value = element.value[ selected ];
6741
- value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 1 ] : element.xrange[ 0 ] );
6775
+ value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
6742
6776
  value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
6743
6777
  }
6744
6778
 
@@ -6833,6 +6867,7 @@ class Curve {
6833
6867
  }
6834
6868
 
6835
6869
  redraw( options = {} ) {
6870
+ console.log("REDRAW!!");
6836
6871
  this.element.redraw( options );
6837
6872
  }
6838
6873
  }
package/changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # lexgui.js changelog
2
2
 
3
+ ## 0.1.36 (dev)
4
+
5
+ ## 0.1.35
6
+
7
+ Fix `moveOutAction` clamping X value.
8
+ Add values in curve only with MOUSE_LEFT_CLICK.
9
+ Curve redraw and color widget styling fixes.
10
+ Minor general styling improvements.
11
+
3
12
  ## 0.1.34
4
13
 
5
14
  Fix setValue on Checkbox.
package/demo.js CHANGED
@@ -32,7 +32,7 @@ area.addMenubar( m => {
32
32
  m.add( "Project/Export/DAE", { icon: "fa-solid fa-cube", short: "D", callback: () => { console.log("Exporting DAE...") }} );
33
33
  m.add( "Project/Export/GLTF", { short: "G" } );
34
34
  m.add( "Editor/Autosave", { type: 'checkbox', icon: "fa fa-floppy-disk", callback: (v, name) => { console.log(name + ": " + v ) } });
35
- m.add( "Editor/Test", () => LX.prompt("Editor", "Test?"));
35
+ m.add( "Editor/Test", () => LX.prompt("Write in the text area below the bml instructions to move the avatar from the web application. A sample of BML instructions can be tested through the helper tabs in the right panel.", "Test?"));
36
36
  m.add( "Editor/Settings", { icon: "fa-solid fa-gears", callback: () => {
37
37
  const dialog = new LX.Dialog( "Settings", p => {
38
38
  p.addText("A Text", "Testing first widget");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lexgui",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "JS library to create web graphical user interfaces",
5
5
  "type": "module",
6
6
  "main": "./build/lexgui.js",