lexgui 0.1.1 → 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.
- package/README.md +19 -5
- package/build/components/imui.js +315 -0
- package/build/components/timeline.js +24 -28
- package/build/lexgui.js +26 -3
- package/build/lexgui.module.js +26 -3
- package/examples/immediate_ui.html +77 -0
- package/examples/index.html +7 -6
- package/examples/previews/asset_view.png +0 -0
- package/examples/previews/code_editor.png +0 -0
- package/examples/previews/node_graph.png +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
**lexgui.js** is a lightweight JavaScript library that allows you to create web interfaces using only JavaScript, HTML, and CSS. This library provides an easy-to-use API for building dynamic and interactive user interfaces without the need for complex frameworks or libraries. With lexgui.js, you can create custom UI components, handle user interactions, and update the interface dynamically.
|
|
4
4
|
|
|
5
5
|
<img src="data/Screenshot.png" alt="Screenshot" style="width: 100%"/>
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
<img src="data/
|
|
9
|
-
|
|
6
|
+
<table>
|
|
7
|
+
<tr>
|
|
8
|
+
<td valign="top"><img src="data/Screenshot_Godot.png"/></td>
|
|
9
|
+
<td valign="top"><img src="data/Screenshot_Code.png"/></td>
|
|
10
|
+
</tr>
|
|
11
|
+
</table>
|
|
10
12
|
|
|
11
13
|
## Docs
|
|
12
14
|
|
|
@@ -16,12 +18,24 @@ The library documentation is in progress but you can check it [here](https://jxa
|
|
|
16
18
|
|
|
17
19
|
Look at this [examples](https://jxarco.github.io/lexgui.js/examples/) to see how to create the different widgets and components!
|
|
18
20
|
|
|
21
|
+
## Projects using lexgui.js
|
|
22
|
+
|
|
23
|
+
### [Animics](https://github.com/upf-gti/SignON-editor) (EU H2020 SignON project)
|
|
24
|
+
|
|
25
|
+
<img src="data/scriptAnimation_signon.png" alt="scriptAnimation_signon"/>
|
|
26
|
+
|
|
27
|
+
### [Performs](https://github.com/upf-gti/SignON-realizer) (EU H2020 SignON project)
|
|
28
|
+
|
|
29
|
+
<img src="data/realizer_signon.png" alt="scriptAnimation_signon"/>
|
|
30
|
+
|
|
19
31
|
## Contributors
|
|
20
32
|
|
|
21
33
|
* Alex Rodríguez @jxarco
|
|
22
34
|
* Eva Valls @evallsg
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
## Feedback/Issues
|
|
37
|
+
|
|
38
|
+
You can use the [repository issues section](https://github.com/jxarco/lexgui.js/issues) or simply write any feedback to alexroco.30@gmail.com.
|
|
25
39
|
|
|
26
40
|
## Component Features
|
|
27
41
|
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { LX } from 'lexgui';
|
|
2
|
+
|
|
3
|
+
if(!LX) {
|
|
4
|
+
throw("lexgui.js missing!");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
LX.components.push( 'ImUI' );
|
|
8
|
+
|
|
9
|
+
function swapElements (obj, a, b) {
|
|
10
|
+
[obj[a], obj[b]] = [obj[b], obj[a]];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function swapArrayElements (array, id0, id1) {
|
|
14
|
+
[array[id0], array[id1]] = [array[id1], array[id0]];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @class ImUI
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
class ImUI {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {*} options
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
constructor( canvas, options = {} ) {
|
|
29
|
+
|
|
30
|
+
console.assert( canvas );
|
|
31
|
+
|
|
32
|
+
// To capture key events
|
|
33
|
+
canvas.tabIndex = -1;
|
|
34
|
+
|
|
35
|
+
canvas.addEventListener( 'keydown', this._processKey.bind(this), true);
|
|
36
|
+
canvas.addEventListener( 'mousedown', this._processMouse.bind(this) );
|
|
37
|
+
canvas.addEventListener( 'mouseup', this._processMouse.bind(this) );
|
|
38
|
+
canvas.addEventListener( 'mousemove', this._processMouse.bind(this) );
|
|
39
|
+
canvas.addEventListener( 'click', this._processMouse.bind(this) );
|
|
40
|
+
|
|
41
|
+
// this.font = new FontFace("Ubuntu", "url(../data/Ubuntu-Bold.ttf)");
|
|
42
|
+
// this.font.load().then(
|
|
43
|
+
// ( font ) => {
|
|
44
|
+
// document.fonts.add( font );
|
|
45
|
+
// if( options.onready ) options.onready();
|
|
46
|
+
// },
|
|
47
|
+
// (err) => {
|
|
48
|
+
// console.error(err);
|
|
49
|
+
// },
|
|
50
|
+
// );
|
|
51
|
+
|
|
52
|
+
// Widgets
|
|
53
|
+
|
|
54
|
+
this.widgets = { };
|
|
55
|
+
|
|
56
|
+
// Mouse state
|
|
57
|
+
|
|
58
|
+
this.mousePosition = new LX.vec2();
|
|
59
|
+
|
|
60
|
+
this.root = this.canvas = canvas;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_processKey(e) {
|
|
64
|
+
|
|
65
|
+
var key = e.key ?? e.detail.key;
|
|
66
|
+
console.log( key );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_processMouse(e) {
|
|
70
|
+
|
|
71
|
+
if( e.type == 'mousedown' )
|
|
72
|
+
{
|
|
73
|
+
this.mouseDown = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
else if( e.type == 'mouseup' )
|
|
77
|
+
{
|
|
78
|
+
this._processClick(e);
|
|
79
|
+
this.mouseDown = false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
else if( e.type == 'mousemove' )
|
|
83
|
+
{
|
|
84
|
+
this.mousePosition.set( e.clientX, e.clientY );
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_processClick( e ) {
|
|
89
|
+
|
|
90
|
+
this.eventClick = e;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @method Button
|
|
95
|
+
* @param {String} text
|
|
96
|
+
* @param {Number} x
|
|
97
|
+
* @param {Number} y
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
Button( text, x, y, callback ) {
|
|
101
|
+
|
|
102
|
+
const ctx = this.canvas.getContext("2d");
|
|
103
|
+
|
|
104
|
+
// Element properties
|
|
105
|
+
|
|
106
|
+
let fontSize = 16;
|
|
107
|
+
ctx.font = fontSize + "px Arial";
|
|
108
|
+
|
|
109
|
+
let padding = new LX.vec2( 12, 8 );
|
|
110
|
+
let position = new LX.vec2( x, y );
|
|
111
|
+
|
|
112
|
+
const metrics = ctx.measureText( text );
|
|
113
|
+
let size = new LX.vec2( metrics.width, metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent );
|
|
114
|
+
|
|
115
|
+
// Get mouse state
|
|
116
|
+
|
|
117
|
+
const hovered = this.mousePosition.x >= position.x && this.mousePosition.x <= (position.x + size.x + padding.x * 2.0)
|
|
118
|
+
&& this.mousePosition.y >= position.y && this.mousePosition.y <= (position.y + size.y + padding.y * 2.0);
|
|
119
|
+
|
|
120
|
+
const active = hovered && this.mouseDown;
|
|
121
|
+
|
|
122
|
+
// Draw button
|
|
123
|
+
|
|
124
|
+
ctx.fillStyle = active ? "#666" : (hovered ? "#444" : "#222");
|
|
125
|
+
ctx.fillRect( position.x, position.y, size.x + padding.x * 2.0, size.y + padding.y * 2.0 );
|
|
126
|
+
|
|
127
|
+
// Draw text
|
|
128
|
+
|
|
129
|
+
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
130
|
+
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
131
|
+
|
|
132
|
+
if( !hovered )
|
|
133
|
+
{
|
|
134
|
+
document.body.style.cursor = "default";
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Pointer cursor on hover
|
|
139
|
+
document.body.style.cursor = "pointer";
|
|
140
|
+
|
|
141
|
+
if( this.eventClick )
|
|
142
|
+
{
|
|
143
|
+
if(callback) callback();
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @method Slider
|
|
152
|
+
* @param {String} text
|
|
153
|
+
* @param {Number} x
|
|
154
|
+
* @param {Number} y
|
|
155
|
+
* @param {Number} value
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
Slider( text, x, y, value = 0, callback ) {
|
|
159
|
+
|
|
160
|
+
const ctx = this.canvas.getContext("2d");
|
|
161
|
+
|
|
162
|
+
// Store slider value
|
|
163
|
+
|
|
164
|
+
if(!this.widgets[ text ])
|
|
165
|
+
this.widgets[ text ] = { value: value };
|
|
166
|
+
else
|
|
167
|
+
value = this.widgets[ text ].value;
|
|
168
|
+
|
|
169
|
+
// Element properties
|
|
170
|
+
|
|
171
|
+
let fontSize = 16;
|
|
172
|
+
ctx.font = fontSize + "px Arial";
|
|
173
|
+
|
|
174
|
+
let padding = new LX.vec2( 12, 8 );
|
|
175
|
+
let position = new LX.vec2( x, y );
|
|
176
|
+
|
|
177
|
+
const metrics = ctx.measureText( text );
|
|
178
|
+
let size = new LX.vec2( metrics.width, metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent );
|
|
179
|
+
|
|
180
|
+
// Get mouse state
|
|
181
|
+
|
|
182
|
+
const hovered = this.mousePosition.x >= position.x && this.mousePosition.x <= (position.x + size.x + padding.x * 2.0)
|
|
183
|
+
&& this.mousePosition.y >= position.y && this.mousePosition.y <= (position.y + size.y + padding.y * 2.0);
|
|
184
|
+
|
|
185
|
+
const active = hovered && this.mouseDown;
|
|
186
|
+
|
|
187
|
+
// Draw box
|
|
188
|
+
|
|
189
|
+
ctx.fillStyle = hovered ? "#444" : "#222";
|
|
190
|
+
ctx.fillRect( position.x, position.y, size.x + padding.x * 2.0, size.y + padding.y * 2.0 );
|
|
191
|
+
|
|
192
|
+
// Draw thumb
|
|
193
|
+
|
|
194
|
+
let thumbSize = new LX.vec2( 12, size.y );
|
|
195
|
+
|
|
196
|
+
const min = position.x;
|
|
197
|
+
const max = position.x + size.x + padding.x * 2.0 - thumbSize.x;
|
|
198
|
+
|
|
199
|
+
if(active)
|
|
200
|
+
{
|
|
201
|
+
value = LX.UTILS.clamp((this.mousePosition.x - min - thumbSize.x * 0.5) / (max - min), 0.0, 1.0);
|
|
202
|
+
this.widgets[ text ].value = value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let thumbPos = new LX.vec2( min + (max - position.x) * value, position.y );
|
|
206
|
+
|
|
207
|
+
ctx.fillStyle = active ? "#bbb" : (hovered ? "#777" : "#888");
|
|
208
|
+
ctx.fillRect( thumbPos.x, thumbPos.y, thumbSize.x, thumbSize.y + padding.y * 2.0 );
|
|
209
|
+
|
|
210
|
+
// Draw text
|
|
211
|
+
|
|
212
|
+
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
213
|
+
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
214
|
+
|
|
215
|
+
if( !hovered )
|
|
216
|
+
{
|
|
217
|
+
document.body.style.cursor = "default";
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Pointer cursor on hover
|
|
222
|
+
document.body.style.cursor = "pointer";
|
|
223
|
+
|
|
224
|
+
if( active )
|
|
225
|
+
{
|
|
226
|
+
if(callback) callback( value );
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @method Checkbox
|
|
232
|
+
* @param {String} text
|
|
233
|
+
* @param {Number} x
|
|
234
|
+
* @param {Number} y
|
|
235
|
+
* @param {Number} value
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
Checkbox( text, x, y, value = false, callback ) {
|
|
239
|
+
|
|
240
|
+
const ctx = this.canvas.getContext("2d");
|
|
241
|
+
|
|
242
|
+
// Store slider value
|
|
243
|
+
|
|
244
|
+
if(!this.widgets[ text ])
|
|
245
|
+
this.widgets[ text ] = { value: value };
|
|
246
|
+
else
|
|
247
|
+
value = this.widgets[ text ].value;
|
|
248
|
+
|
|
249
|
+
// Element properties
|
|
250
|
+
|
|
251
|
+
let fontSize = 16;
|
|
252
|
+
ctx.font = fontSize + "px Arial";
|
|
253
|
+
|
|
254
|
+
let padding = new LX.vec2( 12, 8 );
|
|
255
|
+
let position = new LX.vec2( x, y );
|
|
256
|
+
|
|
257
|
+
const metrics = ctx.measureText( text );
|
|
258
|
+
let size = new LX.vec2( metrics.width, metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent );
|
|
259
|
+
|
|
260
|
+
let boxMargin = 12;
|
|
261
|
+
let fullSize = new LX.vec2(boxMargin * 2.0, 0);
|
|
262
|
+
fullSize.add( size );
|
|
263
|
+
|
|
264
|
+
// Get mouse state
|
|
265
|
+
|
|
266
|
+
const boxStartX = position.x + size.x + padding.x + boxMargin;
|
|
267
|
+
const boxStartY = position.y + padding.y;
|
|
268
|
+
const hovered = this.mousePosition.x >= boxStartX && this.mousePosition.x <= (boxStartX + size.y)
|
|
269
|
+
&& this.mousePosition.y >= boxStartY && this.mousePosition.y <= (boxStartY + size.y);
|
|
270
|
+
|
|
271
|
+
const active = hovered && this.mouseDown;
|
|
272
|
+
const pressed = hovered && this.eventClick;
|
|
273
|
+
|
|
274
|
+
// Draw button
|
|
275
|
+
|
|
276
|
+
ctx.fillStyle = active ? "#666" : (hovered ? "#444" : "#222");
|
|
277
|
+
ctx.fillRect( position.x, position.y, fullSize.x + padding.x * 2.0, fullSize.y + padding.y * 2.0 );
|
|
278
|
+
|
|
279
|
+
// Draw checkbox
|
|
280
|
+
|
|
281
|
+
if( pressed )
|
|
282
|
+
{
|
|
283
|
+
value = !value;
|
|
284
|
+
this.widgets[ text ].value = value;
|
|
285
|
+
if(callback) callback( value );
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
ctx.fillStyle = value ? (active ? "#ddd" : (hovered ? "#6074e7" : "#3e57e4")) :
|
|
289
|
+
(active ? "#bbb" : (hovered ? "#777" : "#888"));
|
|
290
|
+
ctx.fillRect( position.x + size.x + padding.x + boxMargin, position.y + padding.y, size.y, size.y );
|
|
291
|
+
|
|
292
|
+
// Draw text
|
|
293
|
+
|
|
294
|
+
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
295
|
+
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
296
|
+
|
|
297
|
+
// Pointer cursor on hover
|
|
298
|
+
document.body.style.cursor = hovered ? "pointer" : "default";
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @method endFrame
|
|
303
|
+
* @description Clears the information stored during the last frame
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
endFrame() {
|
|
307
|
+
|
|
308
|
+
this.eventClick = null;
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
LX.ImUI = ImUI;
|
|
314
|
+
|
|
315
|
+
export { ImUI };
|
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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.
|
|
1105
|
-
|
|
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.
|
|
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
|
|
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(
|
|
1123
|
-
ctx.
|
|
1124
|
-
|
|
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.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
|
|
package/build/lexgui.module.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var LX = {
|
|
11
|
-
version: "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
|
|
|
@@ -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>
|
package/examples/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<style>
|
|
9
9
|
iframe { border: none; }
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
<script type="importmap">
|
|
16
16
|
{
|
|
17
17
|
"imports": {
|
|
18
|
-
"lexgui": "
|
|
19
|
-
"lexgui/components/": "
|
|
18
|
+
"lexgui": "../build/lexgui.module.js",
|
|
19
|
+
"lexgui/components/": "../build/components/"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
</script>
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
'Area Tabs',
|
|
48
48
|
'Asset View',
|
|
49
49
|
'Code Editor',
|
|
50
|
-
'Overlay Area',
|
|
51
50
|
'Dialogs',
|
|
52
|
-
'
|
|
51
|
+
'Immediate UI',
|
|
52
|
+
'Node Graph',
|
|
53
|
+
'Overlay Area'
|
|
53
54
|
];
|
|
54
55
|
|
|
55
56
|
let panel = leftArea.addPanel({ className: "lexexamplespanel" });
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
|
|
58
59
|
let iframe = document.createElement('iframe');
|
|
59
60
|
iframe.id = iframe.name = 'viewer';
|
|
60
|
-
iframe.src = "
|
|
61
|
+
iframe.src = examples[0].replace(" ", "_").toLowerCase() + ".html";
|
|
61
62
|
iframe.style.width = "100%";
|
|
62
63
|
iframe.style.height = "100%";
|
|
63
64
|
rightArea.root.appendChild(iframe);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|