lexgui 0.1.0 → 0.1.2

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.
@@ -701,6 +701,9 @@ class Timeline {
701
701
  if(!this.session)
702
702
  return;
703
703
 
704
+ if( this.secondsToPixels * v < 100)
705
+ return;
706
+
704
707
  var centerx = this.canvas.width * 0.5;
705
708
  var x = this.xToTime( centerx );
706
709
  this.secondsToPixels *= v;
@@ -1060,7 +1063,7 @@ class Timeline {
1060
1063
  if( x2 < 0 || x > this.canvas.width )
1061
1064
  continue;
1062
1065
 
1063
- //background rect
1066
+ // Background rect
1064
1067
  ctx.globalAlpha = trackAlpha;
1065
1068
  ctx.fillStyle = clip.clipColor || "#5e9fdd"//#333";
1066
1069
  //ctx.fillRect(x,y,w,trackHeight);
@@ -1078,50 +1081,41 @@ class Timeline {
1078
1081
  if(fadeoutX)
1079
1082
  ctx.roundRect( x + w - fadeoutX, y + offset, fadeoutX, trackHeight, {tl: 0, bl: 0, tr:5, br:5}, true);
1080
1083
 
1081
- // //draw clip content
1082
- // if( clip.drawClip )
1083
- // {
1084
- // ctx.save();
1085
- // ctx.translate(x,y);
1086
- // ctx.strokeStyle = "#AAA";
1087
- // ctx.fillStyle = "#AAA";
1088
- // clip.drawClip( ctx, x2-x, trackHeight, this.selectedClip == clip || track.selected[j], this );
1089
- // ctx.restore();
1090
- // }
1091
- //draw clip outline
1084
+ // Draw clip outline
1092
1085
  if(clip.hidden)
1093
1086
  ctx.globalAlpha = trackAlpha * 0.5;
1094
1087
 
1095
- var safex = Math.max(-2, x );
1096
- var safex2 = Math.min( this.canvas.width + 2, x2 );
1097
- // ctx.lineWidth = 0.5;
1098
- // ctx.strokeStyle = clip.constructor.color || "black";
1099
- // ctx.strokeRect( safex, y, safex2-safex, trackHeight );
1100
1088
  ctx.globalAlpha = trackAlpha;
1101
1089
  if(this.selectedClip == clip || track.selected[j])
1102
1090
  selectedClipArea = [x, y + offset, x2-x, trackHeight];
1103
1091
 
1104
- ctx.font = "12px Rubik";
1105
- //render clip selection area
1092
+ ctx.fillStyle = "black"; //Timeline.FONT_COLOR; // clip.color || Timeline.FONT_COLOR;
1093
+ ctx.font = "12px" + Timeline.FONT;
1094
+
1095
+ // Render clip selection area
1106
1096
  if(selectedClipArea)
1107
1097
  {
1108
1098
  ctx.strokeStyle = track.clips[j].clipColor;
1109
- ctx.globalAlpha = 0.5;
1099
+ ctx.fillStyle = "white"; //(Timeline.FONT_COLOR || track.clips[j].clipColor);
1100
+ ctx.globalAlpha = 0.6;
1110
1101
  ctx.lineWidth = 2.5;
1111
1102
  ctx.roundRect(selectedClipArea[0]-1,selectedClipArea[1]-1,selectedClipArea[2]+2,selectedClipArea[3]+2, 5, false, true);
1112
1103
  ctx.strokeStyle = "#888";
1113
1104
  ctx.lineWidth = 0.5;
1114
1105
  ctx.globalAlpha = this.opacity;
1115
- ctx.font = "bold 13px Rubik";
1106
+ ctx.font = "bold 13px " + Timeline.FONT;
1116
1107
  }
1117
1108
 
1118
1109
  let text = clip.id.replaceAll("_", " ").replaceAll("-", " ");
1119
- let textInfo = ctx.measureText( text );
1120
- ctx.fillStyle = clip.color || Timeline.FONT_COLOR;
1121
1110
 
1122
- if( textInfo.width < (w - 24) )
1123
- ctx.fillText( text, x + (w - textInfo.width)*0.5, y + offset + 12 );
1124
- ctx.font = "12px Rubik";
1111
+ if( this.secondsToPixels < 200)
1112
+ ctx.font = this.secondsToPixels*0.06 +"px" + Timeline.FONT;
1113
+
1114
+ let textInfo = ctx.measureText( text );
1115
+ if(this.secondsToPixels > 100)
1116
+ ctx.fillText( text, x + (w - textInfo.width)*0.5, y + offset + trackHeight/2 + textInfo.fontBoundingBoxDescent );
1117
+
1118
+ ctx.font = "12px" + Timeline.FONT;
1125
1119
  }
1126
1120
  }
1127
1121
 
@@ -1232,7 +1226,7 @@ class Timeline {
1232
1226
  *
1233
1227
  *
1234
1228
  */
1235
- resize( size = [this.root.parent.root.clientWidth, this.root.parent.root.clientHeight]) {
1229
+ resize( size = [this.root.parent.root.clientWidth, this.root.parent.root.clientHeight] ) {
1236
1230
 
1237
1231
  this.root.root.style.width = size[0] + "px";
1238
1232
  this.root.root.style.height = size[1] + "px";
@@ -1242,6 +1236,8 @@ class Timeline {
1242
1236
 
1243
1237
  let w = size[0] - this.leftPanel.root.clientWidth - 8;
1244
1238
  this.resizeCanvas([w , size[1]]);
1239
+
1240
+ this.session.start_time = 0;
1245
1241
  }
1246
1242
 
1247
1243
  resizeCanvas( size ) {
@@ -1255,8 +1251,8 @@ class Timeline {
1255
1251
  var w = Math.max(300, this.canvas.width);
1256
1252
  this.secondsToPixels = ( w - this.session.left_margin ) / this.duration;
1257
1253
  this.pixelsToSeconds = 1 / this.secondsToPixels;
1254
+
1258
1255
  this.draw(this.currentTime);
1259
-
1260
1256
  }
1261
1257
 
1262
1258
  /**
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.0.1",
15
+ version: "0.1.2",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -120,6 +120,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
120
120
  fn();
121
121
  }
122
122
 
123
+ // Math classes
124
+
125
+ class vec2 {
126
+
127
+ constructor(x, y) {
128
+ this.x = x ?? 0;
129
+ this.y = y ?? 0;
130
+ }
131
+
132
+ get xy() { return [ this.x, this.y]; }
133
+ get yx() { return [ this.y, this.x]; }
134
+
135
+ set( x, y ) { this.x = x; this.y = y; }
136
+ add( v ) { this.set( this.x + v.x, this.y + v.y ) }
137
+ sub( v ) { this.set( this.x - v.x, this.y - v.y ) }
138
+ mul( v ) { this.set( this.x * v.x, this.y * v.y ) }
139
+ div( v ) { this.set( this.x / v.x, this.y / v.y ) }
140
+ };
141
+
142
+ LX.vec2 = vec2;
143
+
144
+ // Other utils
145
+
123
146
  function set_as_draggable(domEl) {
124
147
 
125
148
  let offsetX;
@@ -3000,7 +3023,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3000
3023
  };
3001
3024
 
3002
3025
  // Process inline widgets
3003
- if(this._inline_widgets_left > 0)
3026
+ if(this._inline_widgets_left > 0 && !options.skipInlineCount)
3004
3027
  {
3005
3028
  if(!this._inlineWidgets) {
3006
3029
  this._inlineWidgets = [];
@@ -3753,7 +3776,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3753
3776
  element.querySelector(".lexoptions").style.width = (event.currentTarget.clientWidth) + 2 + 'px';
3754
3777
  element.querySelector(".lexoptions").toggleAttribute('hidden');
3755
3778
  list.focus();
3756
- }, { buttonClass: 'array' });
3779
+ }, { buttonClass: 'array', skipInlineCount: true });
3757
3780
 
3758
3781
  this.clearQueue();
3759
3782
 
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  var LX = {
11
- version: "0.0.1",
11
+ version: "0.1.2",
12
12
  ready: false,
13
13
  components: [], // specific pre-build components
14
14
  signals: {} // events and triggers
@@ -116,6 +116,29 @@ function doAsync( fn, ms ) {
116
116
  fn();
117
117
  }
118
118
 
119
+ // Math classes
120
+
121
+ class vec2 {
122
+
123
+ constructor(x, y) {
124
+ this.x = x ?? 0;
125
+ this.y = y ?? 0;
126
+ }
127
+
128
+ get xy() { return [ this.x, this.y]; }
129
+ get yx() { return [ this.y, this.x]; }
130
+
131
+ set( x, y ) { this.x = x; this.y = y; }
132
+ add( v ) { this.set( this.x + v.x, this.y + v.y ) }
133
+ sub( v ) { this.set( this.x - v.x, this.y - v.y ) }
134
+ mul( v ) { this.set( this.x * v.x, this.y * v.y ) }
135
+ div( v ) { this.set( this.x / v.x, this.y / v.y ) }
136
+ };
137
+
138
+ LX.vec2 = vec2;
139
+
140
+ // Other utils
141
+
119
142
  function set_as_draggable(domEl) {
120
143
 
121
144
  let offsetX;
@@ -2996,7 +3019,7 @@ class Panel {
2996
3019
  };
2997
3020
 
2998
3021
  // Process inline widgets
2999
- if(this._inline_widgets_left > 0)
3022
+ if(this._inline_widgets_left > 0 && !options.skipInlineCount)
3000
3023
  {
3001
3024
  if(!this._inlineWidgets) {
3002
3025
  this._inlineWidgets = [];
@@ -3749,7 +3772,7 @@ class Panel {
3749
3772
  element.querySelector(".lexoptions").style.width = (event.currentTarget.clientWidth) + 2 + 'px';
3750
3773
  element.querySelector(".lexoptions").toggleAttribute('hidden');
3751
3774
  list.focus();
3752
- }, { buttonClass: 'array' });
3775
+ }, { buttonClass: 'array', skipInlineCount: true });
3753
3776
 
3754
3777
  this.clearQueue();
3755
3778
 
package/demo.js CHANGED
@@ -2,8 +2,6 @@ import { LX } from 'lexgui';
2
2
  import 'lexgui/components/codeeditor.js';
3
3
  import 'lexgui/components/timeline.js';
4
4
 
5
- console.log(LX, LX.CodeEditor, LX.Timeline)
6
-
7
5
  // Init library and get main area
8
6
  let area = LX.init();
9
7
 
@@ -3,11 +3,21 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Area Tabs Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
7
16
  </head>
8
- <body></body>
9
- <script src="../build/lexgui.js"></script>
10
- <script>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
11
21
 
12
22
  // init library and get main area
13
23
  let area = LX.init();
@@ -3,21 +3,31 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI AssetView Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
7
16
  </head>
8
- <body></body>
9
- <script src="../build/lexgui.js"></script>
10
- <script src="../build/components/codeeditor.js"></script>
11
- <script>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
21
+ import 'lexgui/components/codeeditor.js';
12
22
 
13
- // init library and get main area
23
+ // Init library and get main area
14
24
  let area = LX.init();
15
25
 
16
- // split main area
26
+ // Split main area
17
27
  var [topArea, bottomArea] = area.split({type: 'vertical', sizes:["60vh","40vh"]});
18
28
  bottomArea.setLimitBox(0, 450);
19
29
 
20
- // add canvas to topArea
30
+ // Add canvas to topArea
21
31
  var canvas = document.createElement('canvas');
22
32
  canvas.id = "mycanvas";
23
33
  canvas.width = topArea.root.clientWidth;
@@ -26,7 +36,7 @@
26
36
  canvas.style.height = "100%";
27
37
  topArea.attach( canvas );
28
38
 
29
- // add on resize event to control canvas size
39
+ // Add on resize event to control canvas size
30
40
  topArea.onresize = function( bounding ) {
31
41
  canvas.width = bounding.width;
32
42
  canvas.height = bounding.height;
@@ -3,12 +3,22 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Code Editor Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
7
- <script src="../build/lexgui.js"></script>
8
- <script src="../build/components/codeeditor.js"></script>
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
9
16
  </head>
10
17
  <body></body>
11
- <script>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
21
+ import 'lexgui/components/codeeditor.js';
12
22
 
13
23
  // init library and get main area
14
24
  let area = LX.init();
@@ -3,11 +3,21 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Dialogs Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
7
16
  </head>
8
- <body></body>
9
- <script src="../build/lexgui.js"></script>
10
- <script>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
11
21
 
12
22
  // Init library and get main area
13
23
  let area = LX.init({ skip_default_area: true });
@@ -0,0 +1,77 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
+ <title>LexGUI ImUI Demo</title>
6
+ <link rel="stylesheet" href="../build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "../build/lexgui.module.js",
12
+ "lexgui/components/": "../build/components/"
13
+ }
14
+ }
15
+ </script>
16
+ </head>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
21
+ import 'lexgui/components/imui.js';
22
+
23
+ // init library and get main area
24
+ let area = LX.init();
25
+
26
+ // add canvas to area
27
+ var canvas = document.createElement('canvas');
28
+ canvas.id = "mycanvas";
29
+ canvas.width = area.root.clientWidth;
30
+ canvas.height = area.root.clientHeight;
31
+ canvas.style.width = "100%";
32
+ canvas.style.height = "100%";
33
+ area.attach( canvas );
34
+
35
+ // add on resize event to control canvas size
36
+ area.onresize = function( bounding ) {
37
+ canvas.width = bounding.width;
38
+ canvas.height = bounding.height;
39
+ };
40
+
41
+ let im_ui = new LX.ImUI( canvas );
42
+
43
+ function loop( time ) {
44
+
45
+ var ctx = canvas.getContext("2d");
46
+
47
+ ctx.fillStyle = "#b7a9b1";
48
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
49
+
50
+ ctx.font = "48px Monospace";
51
+ ctx.fillStyle = "#ff1999";
52
+
53
+ const text = "Lexgui.js @jxarco";
54
+ ctx.fillText(text, 300, 225);
55
+
56
+ if( im_ui.Button( "First button", 50, 50 ) )
57
+ {
58
+ console.log("Button clicked!");
59
+ }
60
+
61
+ im_ui.Slider( "A very cool slider", 50, 100, false, (v) => {
62
+ console.log("Slider value: " + v);
63
+ } );
64
+
65
+ im_ui.Checkbox( "First checkbox", 50, 150, false, (v) => {
66
+ console.log("Checkbox value: " + v);
67
+ } );
68
+
69
+ im_ui.endFrame();
70
+
71
+ requestAnimationFrame(loop);
72
+ }
73
+
74
+ requestAnimationFrame(loop);
75
+
76
+ </script>
77
+ </html>
@@ -3,7 +3,8 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Examples</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
6
+ <link rel="stylesheet" href="../build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
7
8
  <style>
8
9
  iframe { border: none; }
9
10
  .lexexamplespanel {
@@ -11,10 +12,19 @@
11
12
  margin-top: 6px;
12
13
  }
13
14
  </style>
15
+ <script type="importmap">
16
+ {
17
+ "imports": {
18
+ "lexgui": "../build/lexgui.module.js",
19
+ "lexgui/components/": "../build/components/"
20
+ }
21
+ }
22
+ </script>
14
23
  </head>
15
- <body></body>
16
- <script src="../build/lexgui.js"></script>
17
- <script>
24
+ <body></body>
25
+ <script type="module">
26
+
27
+ import { LX } from 'lexgui';
18
28
 
19
29
  // Init library and get main area
20
30
  let area = LX.init();
@@ -37,8 +47,10 @@
37
47
  'Area Tabs',
38
48
  'Asset View',
39
49
  'Code Editor',
40
- 'Overlay Area',
41
50
  'Dialogs',
51
+ 'Immediate UI',
52
+ 'Node Graph',
53
+ 'Overlay Area'
42
54
  ];
43
55
 
44
56
  let panel = leftArea.addPanel({ className: "lexexamplespanel" });
@@ -46,7 +58,7 @@
46
58
 
47
59
  let iframe = document.createElement('iframe');
48
60
  iframe.id = iframe.name = 'viewer';
49
- iframe.src = "area_tabs.html";
61
+ iframe.src = examples[0].replace(" ", "_").toLowerCase() + ".html";
50
62
  iframe.style.width = "100%";
51
63
  iframe.style.height = "100%";
52
64
  rightArea.root.appendChild(iframe);
@@ -3,12 +3,22 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Node Graph Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
7
- <script src="../build/lexgui.js"></script>
8
- <script src="../build/components/nodegraph.js"></script>
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
9
16
  </head>
10
- <body></body>
11
- <script>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
21
+ import 'lexgui/components/nodegraph.js';
12
22
 
13
23
  // init library and get main area
14
24
  let area = LX.init();
@@ -3,12 +3,22 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5
5
  <title>LexGUI Overlay Timeline Demo</title>
6
- <link rel="stylesheet" href="../build/lexgui.css">
6
+ <link rel="stylesheet" href="https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.css">
7
+ <link rel="icon" href="../images/icon.png">
8
+ <script type="importmap">
9
+ {
10
+ "imports": {
11
+ "lexgui": "https://cdn.skypack.dev/lexgui@^0.1.1/build/lexgui.module.js",
12
+ "lexgui/components/": "https://cdn.skypack.dev/lexgui@^0.1.1/build/components/"
13
+ }
14
+ }
15
+ </script>
7
16
  </head>
8
- <body></body>
9
- <script src="../build/lexgui.js"></script>
10
- <script src="../build/components/timeline.js"></script>
11
- <script>
17
+ <body></body>
18
+ <script type="module">
19
+
20
+ import { LX } from 'lexgui';
21
+ import 'lexgui/components/timeline.js';
12
22
 
13
23
  // init library and get main area
14
24
  let area = LX.init();
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lexgui",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "JS library to create web graphical user interfaces",
5
5
  "type": "module",
6
6
  "main": "./build/lexgui.js",