uil 4.0.5 → 4.1.0

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.
@@ -1653,6 +1653,9 @@ const T = {
1653
1653
  case 'logo':
1654
1654
  t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logoFill_d+"'/>";
1655
1655
  break;
1656
+ case 'donate':
1657
+ t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logo_donate+"'/>";
1658
+ break;
1656
1659
  case 'neo':
1657
1660
  t[1]="<path id='logoin' fill='"+color+"' stroke='none' d='"+T.logo_neo+"'/>";
1658
1661
  break;
@@ -1692,12 +1695,267 @@ const T = {
1692
1695
  134 166 Q 134 178.4 142.85 187.15 151.6 196 164 196 176.45 196 185.25 187.15 194 178.4 194 166 L 194 52 Z
1693
1696
  `,
1694
1697
 
1698
+ logo_donate:`
1699
+ M 171.3 80.3 Q 179.5 62.15 171.3 45.8 164.1 32.5 141.35 30.1 L 94.35 30.1 Q 89.35 30.4 88.3 35.15 L 70.5 148.05 Q 70.2 152.5 73.7 152.6 L 100.95 152.6 107 111.6 Q 108.75
1700
+ 106.55 112.6 106.45 130.45 108.05 145.3 103.9 163.35 98.75 171.3 80.3 M 179.8 71.5 Q 178.6 79.75 174.9 87.85 168.45 102.9 151.9 109.15 140.65 113.95 117.55 113 113.15
1701
+ 112.75 111 117.45 L 102.7 169.95 Q 102.45 173.8 105.5 173.85 L 128.95 173.85 Q 132.2 174.2 133.35 169.65 L 138.3 139.95 Q 139.75 135.6 143.1 135.5 146.6 135.75 150.6 135.65
1702
+ 154.55 135.5 157.35 135.1 160.15 134.7 166.75 132.35 181.35 127.4 187.9 111.2 194.25 95.75 189.5 81.95 186.75 74.85 179.8 71.5 M 103.5 209.9 Q 103.5 202.85 99.7 198.85 95.95
1703
+ 194.75 89.4 194.75 82.8 194.75 79.05 198.85 75.3 202.9 75.3 209.9 75.3 216.85 79.05 220.95 82.8 225.05 89.4 225.05 95.95 225.05 99.7 221 103.5 216.95 103.5 209.9 M 95.45 205.5
1704
+ Q 95.95 207.3 95.95 209.9 95.95 212.65 95.45 214.35 94.95 216 94 217.3 93.1 218.45 91.9 219 90.7 219.55 89.4 219.55 88.15 219.55 86.95 219.05 85.75 218.55 84.8 217.3 83.9 216.15
1705
+ 83.4 214.35 82.85 212.6 82.85 209.9 82.85 207.3 83.4 205.45 83.95 203.55 84.85 202.45 85.9 201.2 86.95 200.75 88.05 200.25 89.4 200.25 90.7 200.25 91.85 200.8 93.05 201.3 94 202.5
1706
+ 94.9 203.65 95.45 205.5 M 153.3 195.35 L 145.3 195.35 135.5 224.45 142.8 224.45 144.6 218.5 153.75 218.5 155.6 224.45 163.1 224.45 153.3 195.35 M 152.15 213.25 L 146.25 213.25
1707
+ 149.2 203.65 152.15 213.25 M 116.75 195.35 L 107.8 195.35 107.8 224.45 114.5 224.45 114.5 204.2 125.7 224.45 132.75 224.45 132.75 195.35 126.05 195.35 126.05 212.05 116.75 195.35 M
1708
+ 66.5 197.65 Q 64.15 196.15 61.45 195.75 58.8 195.35 55.75 195.35 L 46.7 195.35 46.7 224.45 55.8 224.45 Q 58.8 224.45 61.5 224.05 64.15 223.6 66.4 222.15 69.15 220.45 70.9 217.2
1709
+ 72.7 214 72.7 209.95 72.7 205.7 71 202.6 69.35 199.5 66.5 197.65 M 64.2 205 Q 65.2 207 65.2 209.9 65.2 212.75 64.25 214.75 63.3 216.75 61.5 217.85 60 218.85 58.3 218.9 56.6 219
1710
+ 54.15 219 L 54 219 54 200.8 54.15 200.8 Q 56.4 200.8 58.05 200.9 59.7 200.95 61.15 201.75 63.2 202.95 64.2 205 M 210.2 195.35 L 190.5 195.35 190.5 224.45 210.2 224.45 210.2 218.9
1711
+ 197.75 218.9 197.75 211.55 209.2 211.55 209.2 206 197.75 206 197.75 200.9 210.2 200.9 210.2 195.35 M 187.5 195.35 L 163 195.35 163 200.9 171.6 200.9 171.6 224.45 178.9 224.45 178.9
1712
+ 200.9 187.5 200.9 187.5 195.35 Z
1713
+ `,
1714
+
1695
1715
  };
1696
1716
 
1697
1717
  T.setText();
1698
1718
 
1699
1719
  const Tools = T;
1700
1720
 
1721
+ ///https://wicg.github.io/file-system-access/#api-filesystemfilehandle-getfile
1722
+
1723
+
1724
+ class Files {
1725
+
1726
+ //-----------------------------
1727
+ // FILE TYPE
1728
+ //-----------------------------
1729
+
1730
+ static autoTypes( type ) {
1731
+
1732
+ let t = [];
1733
+
1734
+ switch( type ){
1735
+ case 'svg':
1736
+ t = [ { accept: { 'image/svg+xml': '.svg'} }, ];
1737
+ break;
1738
+ case 'text':
1739
+ t = [ { description: 'Text Files', accept: { 'text/plain': ['.txt', '.text'], 'text/html': ['.html', '.htm'] } }, ];
1740
+ break;
1741
+ case 'json':
1742
+ t = [ { description: 'JSON Files', accept: { 'text/plain': ['.json'] } }, ];
1743
+ break;
1744
+ case 'image':
1745
+ t = [ { description: 'Images', accept: { 'image/*': ['.png', '.gif', '.jpeg', '.jpg'] } }, ];
1746
+ break;
1747
+
1748
+ }
1749
+
1750
+ return t
1751
+
1752
+ }
1753
+
1754
+
1755
+ //-----------------------------
1756
+ // LOAD
1757
+ //-----------------------------
1758
+
1759
+ static async load( o = {} ) {
1760
+
1761
+ if (typeof window.showOpenFilePicker !== 'function') {
1762
+ window.showOpenFilePicker = this.showOpenFilePickerPolyfill;
1763
+ }
1764
+
1765
+ try {
1766
+
1767
+ let type = o.type || '';
1768
+
1769
+ const options = {
1770
+ excludeAcceptAllOption: type ? true : false,
1771
+ multiple: false,
1772
+ //startIn:'./assets'
1773
+ };
1774
+
1775
+ options.types = this.autoTypes( type );
1776
+
1777
+ // create a new handle
1778
+ const handle = await window.showOpenFilePicker( options );
1779
+ const file = await handle[0].getFile();
1780
+ //let content = await file.text()
1781
+
1782
+ if( !file ) return null
1783
+
1784
+ let fname = file.name;
1785
+ let ftype = fname.substring( fname.lastIndexOf('.')+1, fname.length );
1786
+
1787
+ const dataUrl = [ 'png', 'jpg', 'jpeg', 'mp4', 'webm', 'ogg', 'mp3' ];
1788
+ const dataBuf = [ 'sea', 'z', 'hex', 'bvh', 'BVH', 'glb', 'gltf' ];
1789
+ const reader = new FileReader();
1790
+
1791
+ if( dataUrl.indexOf( ftype ) !== -1 ) reader.readAsDataURL( file );
1792
+ else if( dataBuf.indexOf( ftype ) !== -1 ) reader.readAsArrayBuffer( file );
1793
+ else reader.readAsText( file );
1794
+
1795
+ reader.onload = function(e) {
1796
+
1797
+ let content = e.target.result;
1798
+
1799
+ switch(type){
1800
+ case 'image':
1801
+ let img = new Image;
1802
+ img.onload = function() {
1803
+ if( o.callback ) o.callback( img, fname );
1804
+ };
1805
+ img.src = content;
1806
+ break;
1807
+ case 'json':
1808
+ if( o.callback ) o.callback( JSON.parse( content ), fname );
1809
+ break;
1810
+ default:
1811
+ if( o.callback ) o.callback( content, fname );
1812
+ break;
1813
+ }
1814
+
1815
+ };
1816
+
1817
+ } catch(e) {
1818
+
1819
+ console.log(e);
1820
+
1821
+ }
1822
+
1823
+ }
1824
+
1825
+ static showOpenFilePickerPolyfill( options ) {
1826
+ return new Promise((resolve) => {
1827
+ const input = document.createElement("input");
1828
+ input.type = "file";
1829
+ input.multiple = options.multiple;
1830
+ input.accept = options.types
1831
+ .map((type) => type.accept)
1832
+ .flatMap((inst) => Object.keys(inst).flatMap((key) => inst[key]))
1833
+ .join(",");
1834
+
1835
+ input.addEventListener("change", () => {
1836
+ resolve(
1837
+ [...input.files].map((file) => {
1838
+ return {
1839
+ getFile: async () =>
1840
+ new Promise((resolve) => {
1841
+ resolve(file);
1842
+ }),
1843
+ };
1844
+ })
1845
+ );
1846
+ });
1847
+
1848
+ input.click();
1849
+ })
1850
+ }
1851
+
1852
+
1853
+ //-----------------------------
1854
+ // SAVE
1855
+ //-----------------------------
1856
+
1857
+ static async save( o = {} ) {
1858
+
1859
+ this.usePoly = false;
1860
+
1861
+ if (typeof window.showSaveFilePicker !== 'function') {
1862
+ window.showSaveFilePicker = this.showSaveFilePickerPolyfill;
1863
+ this.usePoly = true;
1864
+ }
1865
+
1866
+ try {
1867
+
1868
+ let type = o.type || '';
1869
+
1870
+ const options = {
1871
+ suggestedName: o.name || 'hello',
1872
+ data: o.data || ''
1873
+ };
1874
+
1875
+
1876
+ options.types = this.autoTypes( type );
1877
+ options.finalType = Object.keys(options.types[0].accept )[0];
1878
+ options.suggestedName += options.types[0].accept[options.finalType][0];
1879
+
1880
+
1881
+ // create a new handle
1882
+ const handle = await window.showSaveFilePicker( options );
1883
+
1884
+ if( this.usePoly ) return
1885
+
1886
+ // create a FileSystemWritableFileStream to write to
1887
+ const file = await handle.createWritable();
1888
+
1889
+ let blob = new Blob([ options.data ], { type: options.finalType });
1890
+
1891
+ // write our file
1892
+ await file.write(blob);
1893
+
1894
+ // close the file and write the contents to disk.
1895
+ await file.close();
1896
+
1897
+ } catch(e) {
1898
+
1899
+ console.log(e);
1900
+
1901
+ }
1902
+
1903
+ }
1904
+
1905
+ static showSaveFilePickerPolyfill( options ) {
1906
+ return new Promise((resolve) => {
1907
+ const a = document.createElement("a");
1908
+ a.download = options.suggestedName || "my-file.txt";
1909
+ let blob = new Blob([ options.data ], { type:options.finalType });
1910
+ a.href = URL.createObjectURL( blob );
1911
+
1912
+ a.addEventListener("click", () => {
1913
+ resolve(
1914
+ setTimeout( () => URL.revokeObjectURL(a.href), 1000 )
1915
+ );
1916
+ });
1917
+ a.click();
1918
+ })
1919
+ }
1920
+
1921
+
1922
+ //-----------------------------
1923
+ // FOLDER not possible in poly
1924
+ //-----------------------------
1925
+
1926
+ static async getFolder() {
1927
+
1928
+ try {
1929
+
1930
+ const handle = await window.showDirectoryPicker();
1931
+ const files = [];
1932
+ for await (const entry of handle.values()) {
1933
+ const file = await entry.getFile();
1934
+ files.push(file);
1935
+ }
1936
+
1937
+ console.log(files);
1938
+ return files;
1939
+
1940
+ } catch(e) {
1941
+
1942
+ console.log(e);
1943
+
1944
+ }
1945
+
1946
+ }
1947
+
1948
+
1949
+
1950
+
1951
+
1952
+
1953
+
1954
+
1955
+
1956
+
1957
+ }
1958
+
1701
1959
  class V2 {
1702
1960
 
1703
1961
  constructor( x = 0, y = 0 ) {
@@ -1856,16 +2114,9 @@ class Proto {
1856
2114
 
1857
2115
  this.isListen = false;
1858
2116
 
1859
-
1860
-
1861
-
1862
- //this.parentGroup = null;
1863
-
1864
- //if( o.select !== undefined ) o.selectable = o.select
1865
2117
  this.isSelectable = o.selectable !== undefined ? o.selectable : false;
1866
2118
  this.unselectable = o.unselect !== undefined ? o.unselect : this.isSelectable;
1867
2119
 
1868
-
1869
2120
  this.ontop = o.ontop ? o.ontop : false; // 'beforebegin' 'afterbegin' 'beforeend' 'afterend'
1870
2121
 
1871
2122
  this.css = this.main ? this.main.css : Tools.css;
@@ -1894,12 +2145,7 @@ class Proto {
1894
2145
 
1895
2146
  // decale for canvas only
1896
2147
  this.fw = o.fw || 0;
1897
- /*this.dc = 0
1898
- if(this.isUI){
1899
- if( this.main.isCanvasOnly && this.fw) this.dc = (this.main.zone.w - this.w)*0.5
1900
- }*/
1901
2148
 
1902
-
1903
2149
  this.autoWidth = o.auto || true;// auto width or flex
1904
2150
  this.isOpen = false;// open statu
1905
2151
 
@@ -1962,13 +2208,10 @@ class Proto {
1962
2208
  this.s = [];
1963
2209
 
1964
2210
 
1965
- //this.c[0] = Tools.dom( 'div', this.css.basic + this.css.button +'align-self:stretch; position:relative; height:20px; overflow:hidden;'); //float:left;
1966
- //this.c[0] = Tools.dom( 'div', 'order: 1;' ); //
1967
2211
  this.useFlex = this.isUI ? this.main.useFlex : false;
1968
- let flexible = this.useFlex ? 'disply:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;';
2212
+ let flexible = this.useFlex ? 'display:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;';
1969
2213
 
1970
2214
  this.c[0] = Tools.dom( 'div', this.css.basic + flexible + 'position:relative; height:20px;');
1971
- //this.c[0] = Tools.dom( 'div', this.css.basic +'position:relative; height:20px; align-self: auto;');
1972
2215
 
1973
2216
 
1974
2217
  this.s[0] = this.c[0].style;
@@ -2409,26 +2652,13 @@ class Proto {
2409
2652
  }
2410
2653
 
2411
2654
  wheel( e ) { return false; }
2412
-
2413
2655
  mousedown( e ) { return false; }
2414
-
2415
2656
  mousemove( e ) { return false; }
2416
-
2417
2657
  mouseup( e ) { return false; }
2418
-
2419
2658
  keydown( e ) { return false; }
2420
-
2421
2659
  keyup( e ) { return false; }
2422
2660
 
2423
2661
 
2424
- /*dragstart ( e ) { return false; }
2425
- dragover ( e ) { return false; }
2426
- dragenter ( e ) { return false; }
2427
- dragleave ( e ) { return false; }
2428
- dragend ( e ) { return false; }
2429
- drop ( e ) { return false; }*/
2430
-
2431
-
2432
2662
  // ----------------------
2433
2663
  // object referency
2434
2664
  // ----------------------
@@ -2440,12 +2670,8 @@ class Proto {
2440
2670
 
2441
2671
  }
2442
2672
 
2443
- display( v ) {
2444
-
2445
- v = v || false;
2673
+ display( v = false ) {
2446
2674
  this.s[0].visibility = v ? 'visible' : 'hidden';
2447
- //this.s[0].display = v ? (this.useFlex? 'flex':'block') : 'none'
2448
-
2449
2675
  }
2450
2676
 
2451
2677
  // ----------------------
@@ -2679,17 +2905,16 @@ class Button extends Proto {
2679
2905
 
2680
2906
  this.on = false;
2681
2907
 
2682
- this.customSize = o.forceWidth || -1;
2908
+ // force button width
2909
+ this.bw = o.forceWidth || 0;
2910
+ if(o.bw) this.bw = o.bw;
2911
+ this.space = o.space || 3;
2683
2912
 
2684
2913
  if( typeof this.values === 'string' ) this.values = [ this.values ];
2685
2914
 
2686
2915
  this.isDown = false;
2687
2916
  this.neverlock = true;
2688
- this.isLoadButton = o.loader || false;
2689
- this.isDragButton = o.drag || false;
2690
2917
  this.res = 0;
2691
-
2692
- if( this.isDragButton ) this.isLoadButton = true;
2693
2918
 
2694
2919
  this.lng = this.values.length;
2695
2920
  this.tmp = [];
@@ -2710,22 +2935,13 @@ class Button extends Proto {
2710
2935
 
2711
2936
  }
2712
2937
 
2713
- if( !o.value || !o.values ){
2714
- if( this.c[1] !== undefined ) this.c[1].textContent = '';
2715
- this.p = o.p !== undefined ? o.p : 0;
2716
- } else {
2717
- if( !this.txt ) this.p = 0;
2718
- }
2719
-
2720
- //
2721
-
2722
- if( this.isLoadButton ) this.initLoader();
2723
- if( this.isDragButton ){
2724
- this.lng ++;
2725
- this.initDrager();
2726
- }
2727
-
2728
- //if( this.onName !== '' ) this.values[0] = this.on;
2938
+ if( !o.value && !o.values ){
2939
+ if( this.c[1] !== undefined ) {
2940
+ this.c[1].textContent = '';
2941
+ this.txt = '';
2942
+ }
2943
+ }
2944
+ if( !this.txt ) this.p = 0;
2729
2945
 
2730
2946
  this.init();
2731
2947
 
@@ -2767,7 +2983,7 @@ class Button extends Proto {
2767
2983
  if( this.value === this.values[this.res] && this.unselectable ) this.value = '';
2768
2984
  else this.value = this.values[this.res];
2769
2985
  if( this.onName !== null ) this.onOff();
2770
- if( !this.isLoadButton ) this.send();
2986
+ this.send();
2771
2987
  }
2772
2988
 
2773
2989
  return this.mousemove( e )
@@ -2827,6 +3043,8 @@ class Button extends Proto {
2827
3043
 
2828
3044
  mode ( n, id ) {
2829
3045
 
3046
+ //if(!this.s) return false
3047
+
2830
3048
  let change = false;
2831
3049
  let cc = this.colors, s = this.s;
2832
3050
  let i = id+2;
@@ -2862,104 +3080,6 @@ class Button extends Proto {
2862
3080
 
2863
3081
  }
2864
3082
 
2865
- // ----------------------
2866
-
2867
- dragover ( e ) {
2868
-
2869
- e.preventDefault();
2870
-
2871
- this.s[4].borderColor = this.colors.select;
2872
- this.s[4].color = this.colors.select;
2873
-
2874
- }
2875
-
2876
- dragend ( e ) {
2877
-
2878
- e.preventDefault();
2879
-
2880
- this.s[4].borderColor = this.color.text;
2881
- this.s[4].color = this.color.text;
2882
-
2883
- }
2884
-
2885
- drop ( e ) {
2886
-
2887
- e.preventDefault();
2888
-
2889
- this.dragend(e);
2890
- this.fileSelect( e.dataTransfer.files[0] );
2891
-
2892
- }
2893
-
2894
- initDrager () {
2895
-
2896
- this.c[4] = this.dom( 'div', this.css.txt +' text-align:center; line-height:'+(this.h-8)+'px; border:1px dashed '+this.color.text+'; top:2px; height:'+(this.h-4)+'px; border-radius:'+this.radius+'px; pointer-events:auto;' );// cursor:default;
2897
- this.c[4].textContent = 'DRAG';
2898
-
2899
- this.c[4].addEventListener( 'dragover', function(e){ this.dragover(e); }.bind(this), false );
2900
- this.c[4].addEventListener( 'dragend', function(e){ this.dragend(e); }.bind(this), false );
2901
- this.c[4].addEventListener( 'dragleave', function(e){ this.dragend(e); }.bind(this), false );
2902
- this.c[4].addEventListener( 'drop', function(e){ this.drop(e); }.bind(this), false );
2903
-
2904
- //this.c[2].events = [ ];
2905
- //this.c[4].events = [ 'dragover', 'dragend', 'dragleave', 'drop' ];
2906
-
2907
-
2908
- }
2909
-
2910
- initLoader () {
2911
-
2912
- this.c[3] = this.dom( 'input', this.css.basic +'top:0px; opacity:0; height:'+(this.h)+'px; pointer-events:auto; cursor:pointer;' );//
2913
- this.c[3].name = 'loader';
2914
- this.c[3].type = "file";
2915
-
2916
- this.c[3].addEventListener( 'change', function(e){ this.fileSelect( e.target.files[0] ); }.bind(this), false );
2917
- //this.c[3].addEventListener( 'mousedown', function(e){ }.bind(this), false );
2918
-
2919
- //this.c[2].events = [ ];
2920
- //this.c[3].events = [ 'change', 'mouseover', 'mousedown', 'mouseup', 'mouseout' ];
2921
-
2922
- //this.hide = document.createElement('input');
2923
-
2924
- }
2925
-
2926
- fileSelect ( file ) {
2927
-
2928
- let dataUrl = [ 'png', 'jpg', 'mp4', 'webm', 'ogg' ];
2929
- let dataBuf = [ 'sea', 'z', 'hex', 'bvh', 'BVH', 'glb' ];
2930
-
2931
- //if( ! e.target.files ) return;
2932
-
2933
- //let file = e.target.files[0];
2934
-
2935
- //this.c[3].type = "null";
2936
- // console.log( this.c[4] )
2937
-
2938
- if( file === undefined ) return;
2939
-
2940
- let reader = new FileReader();
2941
- let fname = file.name;
2942
- let type = fname.substring(fname.lastIndexOf('.')+1, fname.length );
2943
-
2944
- if( dataUrl.indexOf( type ) !== -1 ) reader.readAsDataURL( file );
2945
- else if( dataBuf.indexOf( type ) !== -1 ) reader.readAsArrayBuffer( file );//reader.readAsArrayBuffer( file );
2946
- else reader.readAsText( file );
2947
-
2948
- // if( type === 'png' || type === 'jpg' || type === 'mp4' || type === 'webm' || type === 'ogg' ) reader.readAsDataURL( file );
2949
- //else if( type === 'z' ) reader.readAsBinaryString( file );
2950
- //else if( type === 'sea' || type === 'bvh' || type === 'BVH' || type === 'z') reader.readAsArrayBuffer( file );
2951
- //else if( ) reader.readAsArrayBuffer( file );
2952
- //else reader.readAsText( file );
2953
-
2954
- reader.onload = function (e) {
2955
-
2956
- if( this.callback ) this.callback( e.target.result, fname, type );
2957
- //this.c[3].type = "file";
2958
- //this.send( e.target.result );
2959
- }.bind(this);
2960
-
2961
- }
2962
-
2963
3083
  label ( string, n ) {
2964
3084
 
2965
3085
  n = n || 2;
@@ -2986,13 +3106,12 @@ class Button extends Proto {
2986
3106
  let d = this.sa;
2987
3107
 
2988
3108
  let i = this.lng;
2989
- let dc = 3;
3109
+ let dc = this.space;
2990
3110
  let size = Math.floor( ( w-(dc*(i-1)) ) / i );
2991
3111
 
2992
- if( this.customSize !== -1 ){
2993
- size = this.customSize;
2994
- // d = (this.s-size)*0.5
2995
-
3112
+ if( this.bw ){
3113
+ size = this.bw < size ? this.bw : size;
3114
+ d = Math.floor((this.w-( (size * i) + (dc * (i-1)) ))*0.5);
2996
3115
  }
2997
3116
 
2998
3117
  while( i-- ){
@@ -3005,16 +3124,6 @@ class Button extends Proto {
3005
3124
 
3006
3125
  }
3007
3126
 
3008
- if( this.isDragButton ){
3009
- s[4].left = (d+size+dc) + 'px';
3010
- s[4].width = size + 'px';
3011
- }
3012
-
3013
- if( this.isLoadButton ){
3014
- s[3].left = d + 'px';
3015
- s[3].width = size + 'px';
3016
- }
3017
-
3018
3127
  }
3019
3128
 
3020
3129
  }
@@ -3044,6 +3153,7 @@ class Circular extends Proto {
3044
3153
  this.top = 0;
3045
3154
 
3046
3155
  this.c[0].style.width = this.w +'px';
3156
+ this.c[0].style.display = 'block';
3047
3157
 
3048
3158
  if(this.c[1] !== undefined) {
3049
3159
 
@@ -3282,7 +3392,7 @@ class Color extends Proto {
3282
3392
  }
3283
3393
 
3284
3394
  //this.c[0].style.textAlign = 'center';
3285
- //this.c[0].style.flex = '1 0 auto'
3395
+ this.c[0].style.display = 'block';
3286
3396
 
3287
3397
  this.c[3] = this.getColorRing();
3288
3398
  this.c[3].style.visibility = 'hidden';
@@ -4297,14 +4407,12 @@ class Group extends Proto {
4297
4407
 
4298
4408
  this.ADD = o.add;
4299
4409
 
4300
- this.uis = [];
4301
-
4302
- this.isEmpty = true;
4303
-
4304
4410
  this.autoHeight = true;
4305
- this.current = -1;
4306
- this.targetIn = null;
4307
4411
 
4412
+ this.uis = [];
4413
+ this.current = -1;
4414
+ this.proto = null;
4415
+ this.isEmpty = true;
4308
4416
  this.decal = 0;
4309
4417
 
4310
4418
  this.baseH = this.h;
@@ -4330,9 +4438,6 @@ class Group extends Proto {
4330
4438
  if( this.isLine ) this.c[5] = this.dom( 'div', this.css.basic + 'background:rgba(255, 255, 255, 0.2); width:100%; left:0; height:1px; bottom:0px');
4331
4439
 
4332
4440
  let s = this.s;
4333
-
4334
-
4335
-
4336
4441
  s[0].height = this.h + 'px';
4337
4442
  s[1].height = this.h + 'px';
4338
4443
  this.c[1].name = 'group';
@@ -4342,28 +4447,13 @@ class Group extends Proto {
4342
4447
  s[1].color = this.colors.text;
4343
4448
  s[1].fontWeight = 'bold';
4344
4449
 
4345
- if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px';
4346
- //if( o.border ) s[0].border = '1px solid ' + o.border;
4347
-
4348
-
4349
- /*if(this.decal){
4350
- s[0].boxSizing = 'border-box';
4351
- s[0].backgroundClip = 'border-box';
4352
- s[0].border = (this.decal/3)+'px solid ' + o.group.colors.background;
4353
- }*/
4354
-
4355
-
4356
-
4357
-
4450
+ if( this.radius !== 0 ) s[0].borderRadius = this.radius+'px';
4358
4451
  this.init();
4359
4452
 
4360
4453
  this.setBG( o.bg );
4361
4454
 
4362
4455
  if( o.open !== undefined ) this.open();
4363
4456
 
4364
-
4365
- //s[0].background = this.bg;
4366
-
4367
4457
  }
4368
4458
 
4369
4459
  testZone ( e ) {
@@ -4385,12 +4475,13 @@ class Group extends Proto {
4385
4475
  clearTarget () {
4386
4476
 
4387
4477
  if( this.current === -1 ) return false;
4388
-
4389
- // if(!this.targetIn ) return;
4390
- this.targetIn .uiout();
4391
- this.targetIn .reset();
4478
+ if( this.proto.s ){
4479
+ // if no s target is delete !!
4480
+ this.proto.uiout();
4481
+ this.proto.reset();
4482
+ }
4483
+ this.proto = null;
4392
4484
  this.current = -1;
4393
- this.targetIn = null;
4394
4485
  this.cursor();
4395
4486
  return true;
4396
4487
 
@@ -4411,7 +4502,7 @@ class Group extends Proto {
4411
4502
  let type = e.type;
4412
4503
 
4413
4504
  let change = false;
4414
- let targetChange = false;
4505
+ let protoChange = false;
4415
4506
 
4416
4507
  let name = this.testZone( e );
4417
4508
 
@@ -4424,9 +4515,7 @@ class Group extends Proto {
4424
4515
 
4425
4516
  if( Roots.isMobile && type === 'mousedown' ) this.getNext( e, change );
4426
4517
 
4427
- if( this.targetIn ) targetChange = this.targetIn .handleEvent( e );
4428
-
4429
- //if( type === 'mousemove' ) change = this.styles('def');
4518
+ if( this.proto ) protoChange = this.proto.handleEvent( e );
4430
4519
 
4431
4520
  if( !Roots.lock ) this.getNext( e, change );
4432
4521
 
@@ -4443,7 +4532,7 @@ class Group extends Proto {
4443
4532
  }
4444
4533
 
4445
4534
  if( this.isDown ) change = true;
4446
- if( targetChange ) change = true;
4535
+ if( protoChange ) change = true;
4447
4536
 
4448
4537
  return change;
4449
4538
 
@@ -4459,41 +4548,14 @@ class Group extends Proto {
4459
4548
  }
4460
4549
 
4461
4550
  if( next !== -1 ){
4462
- this.targetIn = this.uis[ this.current ];
4463
- this.targetIn .uiover();
4551
+ this.proto = this.uis[ this.current ];
4552
+ this.proto.uiover();
4464
4553
  }
4465
4554
 
4466
4555
  }
4467
4556
 
4468
4557
  // ----------------------
4469
4558
 
4470
- /*calcH () {
4471
-
4472
- let lng = this.uis.length, i, u, h=0, px=0, tmph=0;
4473
- for( i = 0; i < lng; i++){
4474
- u = this.uis[i];
4475
- if( !u.autoWidth ){
4476
-
4477
- if(px===0) h += u.h+1;
4478
- else {
4479
- if(tmph<u.h) h += u.h-tmph;
4480
- }
4481
- tmph = u.h;
4482
-
4483
- //tmph = tmph < u.h ? u.h : tmph;
4484
- px += u.w;
4485
- if( px+u.w > this.w ) px = 0;
4486
-
4487
- }
4488
- else h += u.h+1;
4489
- }
4490
-
4491
- return h;
4492
- }*/
4493
-
4494
-
4495
-
4496
-
4497
4559
  setBG ( bg ) {
4498
4560
 
4499
4561
  if( bg !== undefined ) this.colors.background = bg;
@@ -4526,15 +4588,10 @@ class Group extends Proto {
4526
4588
  }
4527
4589
  }
4528
4590
 
4529
- //let n = add.apply( this, a );
4530
4591
  let u = this.ADD.apply( this, a );
4531
4592
 
4532
4593
  this.uis.push( u );
4533
4594
 
4534
- //this.calc()
4535
-
4536
-
4537
-
4538
4595
  this.isEmpty = false;
4539
4596
 
4540
4597
  return u;
@@ -4555,9 +4612,7 @@ class Group extends Proto {
4555
4612
 
4556
4613
  this.clear();
4557
4614
  if( this.isUI ) this.main.calc();
4558
-
4559
4615
  super.dispose();
4560
- //Proto.prototype.clear.call( this );
4561
4616
 
4562
4617
  }
4563
4618
 
@@ -4641,12 +4696,6 @@ class Group extends Proto {
4641
4696
 
4642
4697
  this.s[0].height = this.h + 'px';
4643
4698
 
4644
- //console.log('G', this.h)
4645
-
4646
- //if( !this.isOpen ) return;
4647
-
4648
- //this.h = Roots.calcUis( this.uis, this.zone, this.zone.y + this.baseH )+this.baseH;
4649
-
4650
4699
  }
4651
4700
 
4652
4701
  parentHeight ( t ) {
@@ -4658,22 +4707,9 @@ class Group extends Proto {
4658
4707
 
4659
4708
  calc ( y ) {
4660
4709
 
4661
- if( !this.isOpen ) return;
4662
-
4663
- /*
4664
-
4665
- if( y !== undefined ){
4666
- this.h += y;
4667
- if( this.isUI ) this.main.calc( y );
4668
- } else {
4669
- this.h = this.calcH() + this.baseH;
4670
- }
4671
- this.s[0].height = this.h + 'px';*/
4672
-
4673
- // if(this.isOpen)
4710
+ if( !this.isOpen ) return
4674
4711
  if( this.isUI ) this.main.calc();
4675
4712
  else this.calcUis();
4676
-
4677
4713
  this.s[0].height = this.h + 'px';
4678
4714
 
4679
4715
  }
@@ -4686,8 +4722,6 @@ class Group extends Proto {
4686
4722
  this.uis[i].rSize();
4687
4723
  }
4688
4724
 
4689
- //this.calc()
4690
-
4691
4725
  }
4692
4726
 
4693
4727
  rSize () {
@@ -4729,6 +4763,7 @@ class Joystick extends Proto {
4729
4763
  this.tmp = new V2();
4730
4764
 
4731
4765
  this.interval = null;
4766
+ this.c[0].style.display = 'block';
4732
4767
 
4733
4768
  //this.radius = this.w * 0.5;
4734
4769
  //this.distance = this.radius*0.25;
@@ -4970,6 +5005,7 @@ class Knob extends Proto {
4970
5005
  this.top = 0;
4971
5006
 
4972
5007
  this.c[0].style.width = this.w +'px';
5008
+ this.c[0].style.display = 'block';
4973
5009
 
4974
5010
  if(this.c[1] !== undefined) {
4975
5011
 
@@ -7551,6 +7587,8 @@ class Pad2D extends Proto {
7551
7587
 
7552
7588
  //console.log(this.range)
7553
7589
 
7590
+ this.c[0].style.display = 'block';
7591
+
7554
7592
 
7555
7593
 
7556
7594
 
@@ -7807,8 +7845,8 @@ const add = function () {
7807
7845
 
7808
7846
  ref = true;
7809
7847
  if( a[2] === undefined ) [].push.call(a, {});
7810
-
7811
- type = a[2].type ? a[2].type : 'slide';//autoType.apply( this, a );
7848
+
7849
+ type = a[2].type ? a[2].type : autoType( a[0][a[1]], a[2] );
7812
7850
 
7813
7851
  o = a[2];
7814
7852
  o.name = a[1];
@@ -7817,13 +7855,15 @@ const add = function () {
7817
7855
 
7818
7856
  }
7819
7857
 
7858
+
7859
+
7820
7860
  let name = type.toLowerCase();
7821
7861
 
7822
7862
  if( name === 'group' ) o.add = add;
7823
7863
 
7824
7864
  switch( name ){
7825
7865
 
7826
- case 'bool': n = new Bool(o); break;
7866
+ case 'bool': case 'boolean': n = new Bool(o); break;
7827
7867
  case 'button': n = new Button(o); break;
7828
7868
  case 'circular': n = new Circular(o); break;
7829
7869
  case 'color': n = new Color(o); break;
@@ -7853,6 +7893,37 @@ const add = function () {
7853
7893
 
7854
7894
  }
7855
7895
 
7896
+ };
7897
+
7898
+ const autoType = function ( v, o ) {
7899
+
7900
+ let type = 'slide';
7901
+
7902
+ if( typeof v === 'boolean' ) type = 'bool';
7903
+ else if( typeof v === 'string' ){
7904
+
7905
+ if( v.substring(0,1) === '#' ) type = 'color';
7906
+ else type = 'string';
7907
+
7908
+ } else if( typeof v === 'number' ){
7909
+
7910
+ if( o.ctype ) type = 'color';
7911
+ else type = 'slide';
7912
+
7913
+ } else if( typeof v === 'array' && v instanceof Array ){
7914
+
7915
+ if( typeof v[0] === 'number' ) type = 'number';
7916
+ else if( typeof v[0] === 'string' ) type = 'list';
7917
+
7918
+ } else if( typeof v === 'object' && v instanceof Object ){
7919
+
7920
+ if( v.x !== undefined ) type = 'number';
7921
+ else type = 'list';
7922
+
7923
+ }
7924
+
7925
+ return type
7926
+
7856
7927
  };
7857
7928
 
7858
7929
  /**
@@ -7872,7 +7943,7 @@ class Gui {
7872
7943
  this.screen = null;
7873
7944
  this.plane = o.plane || null;
7874
7945
 
7875
- this.isEmpty = true;
7946
+
7876
7947
 
7877
7948
  // color
7878
7949
  if( o.config ) o.colors = o.config;
@@ -7936,9 +8007,9 @@ class Gui {
7936
8007
  this.isScroll = false;
7937
8008
 
7938
8009
  this.uis = [];
7939
-
7940
8010
  this.current = -1;
7941
- this.target = null;
8011
+ this.proto = null;
8012
+ this.isEmpty = true;
7942
8013
  this.decal = 0;
7943
8014
  this.ratio = 1;
7944
8015
  this.oy = 0;
@@ -8103,9 +8174,11 @@ class Gui {
8103
8174
  }
8104
8175
 
8105
8176
  hide ( b ) {
8177
+ this.content.style.visibility = b ? 'hidden' : 'visible';
8178
+ }
8106
8179
 
8107
- this.content.style.display = b ? 'none' : 'block';
8108
-
8180
+ display( v = false ) {
8181
+ this.content.style.visibility = v ? 'visible' : 'hidden';
8109
8182
  }
8110
8183
 
8111
8184
  onChange ( f ) {
@@ -8171,10 +8244,13 @@ class Gui {
8171
8244
  clearTarget () {
8172
8245
 
8173
8246
  if( this.current === -1 ) return false;
8174
- //if(!this.target) return;
8175
- this.target.uiout();
8176
- this.target.reset();
8177
- this.target = null;
8247
+ if( this.proto.s ){
8248
+ // if no s target is delete !!
8249
+ this.proto.uiout();
8250
+ this.proto.reset();
8251
+ }
8252
+
8253
+ this.proto = null;
8178
8254
  this.current = -1;
8179
8255
 
8180
8256
  ///console.log(this.isDown)//if(this.isDown)Roots.clearInput();
@@ -8217,7 +8293,7 @@ class Gui {
8217
8293
  let type = e.type;
8218
8294
 
8219
8295
  let change = false;
8220
- let targetChange = false;
8296
+ let protoChange = false;
8221
8297
 
8222
8298
  let name = this.testZone( e );
8223
8299
 
@@ -8236,10 +8312,10 @@ class Gui {
8236
8312
 
8237
8313
  if( Roots.isMobile && type === 'mousedown' ) this.getNext( e, change );
8238
8314
 
8239
- if( this.target ) targetChange = this.target.handleEvent( e );
8315
+ if( this.proto ) protoChange = this.proto.handleEvent( e );
8240
8316
 
8241
8317
  if( type === 'mousemove' ) change = this.mode('def');
8242
- if( type === 'wheel' && !targetChange && this.isScroll ) change = this.onWheel( e );
8318
+ if( type === 'wheel' && !protoChange && this.isScroll ) change = this.onWheel( e );
8243
8319
 
8244
8320
  if( !Roots.lock ) {
8245
8321
  this.getNext( e, change );
@@ -8274,7 +8350,7 @@ class Gui {
8274
8350
  }
8275
8351
 
8276
8352
  if( this.isDown ) change = true;
8277
- if( targetChange ) change = true;
8353
+ if( protoChange ) change = true;
8278
8354
 
8279
8355
  if( type === 'keyup' ) change = true;
8280
8356
  if( type === 'keydown' ) change = true;
@@ -8298,8 +8374,8 @@ class Gui {
8298
8374
  }
8299
8375
 
8300
8376
  if( next !== -1 ){
8301
- this.target = this.uis[ this.current ];
8302
- this.target.uiover();
8377
+ this.proto = this.uis[ this.current ];
8378
+ this.proto.uiover();
8303
8379
  }
8304
8380
 
8305
8381
  }
@@ -8359,8 +8435,8 @@ class Gui {
8359
8435
  else {
8360
8436
  a[2].isUI = true;
8361
8437
  a[2].main = this;
8362
-
8363
- ontop = a[1].ontop ? a[1].ontop : false;
8438
+ //ontop = a[1].ontop ? a[1].ontop : false;
8439
+ ontop = a[2].ontop ? a[2].ontop : false;
8364
8440
  }
8365
8441
 
8366
8442
  }
@@ -8372,17 +8448,6 @@ class Gui {
8372
8448
  if( ontop ) this.uis.unshift( u );
8373
8449
  else this.uis.push( u );
8374
8450
 
8375
- /*if( !u.autoWidth ){
8376
- let y = u.c[0].getBoundingClientRect().top;
8377
- if( this.prevY !== y ){
8378
- this.calc( u.h + 1 );
8379
- this.prevY = y;
8380
- }
8381
- }else{
8382
- this.prevY = 0;//-1;
8383
- this.calc( u.h + 1 );
8384
- }*/
8385
-
8386
8451
  this.calc();
8387
8452
 
8388
8453
  this.isEmpty = false;
@@ -8391,18 +8456,6 @@ class Gui {
8391
8456
 
8392
8457
  }
8393
8458
 
8394
- /*applyCalc () {
8395
-
8396
- //console.log(this.uis.length, this.tmpH )
8397
-
8398
- this.calc( this.tmpH );
8399
- //this.tmpH = 0;
8400
- this.tmpAdd = null;
8401
-
8402
- }*/
8403
-
8404
-
8405
-
8406
8459
  // remove one node
8407
8460
 
8408
8461
  remove ( n ) {
@@ -8437,19 +8490,12 @@ class Gui {
8437
8490
  item = this.uis.pop();
8438
8491
  this.inner.removeChild( item.c[0] );
8439
8492
  item.dispose();
8440
-
8441
- //this.uis[i].clear()
8442
8493
  }
8443
8494
 
8444
8495
  this.uis = [];
8445
8496
  this.isEmpty = true;
8446
- //this.zone = { x:0, y:0, w:this.size.w, h:0 };
8447
- //this.setWidth()
8448
- //Roots.listens = [];
8449
8497
  this.calc();
8450
8498
 
8451
-
8452
-
8453
8499
  }
8454
8500
 
8455
8501
  clear() {
@@ -8466,11 +8512,11 @@ class Gui {
8466
8512
 
8467
8513
  }
8468
8514
 
8515
+
8469
8516
  // ----------------------
8470
8517
  // ITEMS SPECIAL
8471
8518
  // ----------------------
8472
8519
 
8473
-
8474
8520
  resetItem () {
8475
8521
 
8476
8522
  if( !this.isItemMode ) return;
@@ -8485,12 +8531,11 @@ class Gui {
8485
8531
  if( !this.isItemMode ) return;
8486
8532
 
8487
8533
  name = name || '';
8488
-
8489
8534
  this.resetItem();
8490
8535
 
8491
8536
  if( !name ){
8492
8537
  this.update(0);
8493
- return;
8538
+ return
8494
8539
  }
8495
8540
 
8496
8541
  let i = this.uis.length;
@@ -8524,8 +8569,6 @@ class Gui {
8524
8569
  this.ratio = this.maxView / this.total;
8525
8570
  this.sh = this.maxView * this.ratio;
8526
8571
 
8527
- //if( this.sh < 20 ) this.sh = 20;
8528
-
8529
8572
  this.range = this.maxView - this.sh;
8530
8573
 
8531
8574
  this.oy = Tools.clamp( this.oy, 0, this.range );
@@ -8584,7 +8627,7 @@ class Gui {
8584
8627
 
8585
8628
  let diff = this.h - this.maxHeight;
8586
8629
 
8587
- if( diff > 1 ){ //this.h > this.maxHeight ){
8630
+ if( diff > 1 ){
8588
8631
 
8589
8632
  this.isScroll = true;
8590
8633
  this.zone.h = this.maxHeight + this.bh;
@@ -8597,8 +8640,6 @@ class Gui {
8597
8640
 
8598
8641
  }
8599
8642
 
8600
- //if( this.forceHeight ) this.zone.h = this.forceHeight
8601
-
8602
8643
  this.upScroll( this.isScroll );
8603
8644
 
8604
8645
  this.innerContent.style.height = this.zone.h - this.bh + 'px';
@@ -8608,11 +8649,7 @@ class Gui {
8608
8649
 
8609
8650
  if( this.forceHeight && this.lockHeight ) this.content.style.height = this.forceHeight + 'px';
8610
8651
 
8611
- //console.log( this.zone, this.bh )
8612
-
8613
- //if( this.isOpen ) this.calcUis()
8614
8652
  if( this.isCanvas ) this.draw( true );
8615
- //else if( !this.transition ) this.rezone()
8616
8653
 
8617
8654
  }
8618
8655
 
@@ -8626,20 +8663,12 @@ class Gui {
8626
8663
 
8627
8664
  this.zone.w = Math.floor( this.zone.w );
8628
8665
 
8629
- //console.log( this.zone.w )
8630
-
8631
8666
  this.content.style.width = this.zone.w + 'px';
8632
8667
 
8633
8668
  if( this.isCenter ) this.content.style.marginLeft = -(Math.floor(this.zone.w*0.5)) + 'px';
8634
8669
 
8635
8670
  this.setItemWidth( this.zone.w - this.sw );
8636
8671
 
8637
- //this.setHeight();
8638
- //this.calc()
8639
-
8640
- //if( this.isCanvasOnly ) Roots.needReZone = true;
8641
- //Roots.resize();
8642
-
8643
8672
  }
8644
8673
 
8645
8674
  setItemWidth ( w ) {
@@ -8654,6 +8683,6 @@ class Gui {
8654
8683
 
8655
8684
  }
8656
8685
 
8657
- const REVISION = '4.0.5';
8686
+ const REVISION = '4.1.0';
8658
8687
 
8659
- export { Gui, Proto, REVISION, Tools, add };
8688
+ export { Files, Gui, Proto, REVISION, Tools, add };