lexgui 0.1.2 → 0.1.4
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/components/codeeditor.js +74 -90
- package/build/components/imui.js +34 -31
- package/build/lexgui.js +40 -27
- package/build/lexgui.module.js +38 -25
- package/examples/area_tabs.html +3 -3
- package/examples/asset_view.html +3 -3
- package/examples/code_editor.html +3 -3
- package/examples/dialogs.html +3 -3
- package/examples/node_graph.html +3 -3
- package/examples/overlay_area.html +3 -3
- package/package.json +1 -1
|
@@ -530,43 +530,83 @@ class CodeEditor {
|
|
|
530
530
|
return this.code.lines.join(min ? ' ' : '\n');
|
|
531
531
|
}
|
|
532
532
|
|
|
533
|
-
setText(text)
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let num_lines = new_lines.length;
|
|
539
|
-
console.assert(num_lines > 0);
|
|
540
|
-
const first_line = new_lines.shift();
|
|
541
|
-
num_lines--;
|
|
533
|
+
setText( text ) {
|
|
534
|
+
|
|
535
|
+
console.assert( text.length > 0 );
|
|
536
|
+
let new_lines = text.split('\n');
|
|
542
537
|
|
|
538
|
+
this.code.lines = [].concat(new_lines);
|
|
539
|
+
|
|
540
|
+
let cursor = this.cursors.children[0];
|
|
541
|
+
let lastLine = new_lines.pop();
|
|
542
|
+
|
|
543
|
+
this.cursorToLine(cursor, new_lines.length); // Already substracted 1
|
|
544
|
+
this.cursorToPosition(cursor, lastLine.length);
|
|
545
|
+
|
|
546
|
+
this.processLines();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
appendText( text ) {
|
|
550
|
+
|
|
543
551
|
let cursor = this.cursors.children[0];
|
|
544
552
|
let lidx = cursor.line;
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
//
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
553
|
+
|
|
554
|
+
if( this.selection ) {
|
|
555
|
+
this.deleteSelection(cursor);
|
|
556
|
+
lidx = cursor.line;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
this.endSelection();
|
|
560
|
+
|
|
561
|
+
const new_lines = text.split('\n');
|
|
562
|
+
|
|
563
|
+
// Pasting Multiline...
|
|
564
|
+
if(new_lines.length != 1)
|
|
565
|
+
{
|
|
566
|
+
let num_lines = new_lines.length;
|
|
567
|
+
console.assert(num_lines > 0);
|
|
568
|
+
const first_line = new_lines.shift();
|
|
569
|
+
num_lines--;
|
|
570
|
+
|
|
571
|
+
const remaining = this.code.lines[lidx].slice(cursor.position);
|
|
572
|
+
|
|
573
|
+
// Add first line
|
|
574
|
+
this.code.lines[lidx] = [
|
|
575
|
+
this.code.lines[lidx].slice(0, cursor.position),
|
|
576
|
+
first_line
|
|
577
|
+
].join('');
|
|
578
|
+
|
|
579
|
+
this.cursorToPosition(cursor, (cursor.position + first_line.length));
|
|
580
|
+
|
|
581
|
+
// Enter next lines...
|
|
582
|
+
|
|
583
|
+
let _text = null;
|
|
584
|
+
|
|
585
|
+
for( var i = 0; i < new_lines.length; ++i ) {
|
|
586
|
+
_text = new_lines[i];
|
|
587
|
+
this.cursorToLine(cursor, cursor.line++, true);
|
|
588
|
+
// Add remaining...
|
|
589
|
+
if( i == (new_lines.length - 1) )
|
|
590
|
+
_text += remaining;
|
|
591
|
+
this.code.lines.splice( 1 + lidx + i, 0, _text);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if(_text) this.cursorToPosition(cursor, _text.length);
|
|
595
|
+
this.cursorToLine(cursor, cursor.line + num_lines);
|
|
596
|
+
this.processLines(lidx);
|
|
597
|
+
}
|
|
598
|
+
// Pasting one line...
|
|
599
|
+
else
|
|
600
|
+
{
|
|
601
|
+
this.code.lines[lidx] = [
|
|
602
|
+
this.code.lines[lidx].slice(0, cursor.position),
|
|
603
|
+
new_lines[0],
|
|
604
|
+
this.code.lines[lidx].slice(cursor.position)
|
|
605
|
+
].join('');
|
|
606
|
+
|
|
607
|
+
this.cursorToPosition(cursor, (cursor.position + new_lines[0].length));
|
|
608
|
+
this.processLine(lidx);
|
|
565
609
|
}
|
|
566
|
-
|
|
567
|
-
if (_text) this.cursorToPosition(cursor, _text.length);
|
|
568
|
-
this.cursorToLine(cursor, cursor.line + num_lines);
|
|
569
|
-
this.processLines(lidx);
|
|
570
610
|
}
|
|
571
611
|
|
|
572
612
|
loadFile( file ) {
|
|
@@ -1069,64 +1109,8 @@ class CodeEditor {
|
|
|
1069
1109
|
this.onsave( this.getText() );
|
|
1070
1110
|
return;
|
|
1071
1111
|
case 'v': // paste
|
|
1072
|
-
|
|
1073
|
-
if( this.selection ) {
|
|
1074
|
-
this.deleteSelection(cursor);
|
|
1075
|
-
lidx = cursor.line;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
this.endSelection();
|
|
1079
|
-
|
|
1080
1112
|
let text = await navigator.clipboard.readText();
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
// Pasting Multiline...
|
|
1084
|
-
if(new_lines.length != 1)
|
|
1085
|
-
{
|
|
1086
|
-
let num_lines = new_lines.length;
|
|
1087
|
-
console.assert(num_lines > 0);
|
|
1088
|
-
const first_line = new_lines.shift();
|
|
1089
|
-
num_lines--;
|
|
1090
|
-
|
|
1091
|
-
const remaining = this.code.lines[lidx].slice(cursor.position);
|
|
1092
|
-
|
|
1093
|
-
// Add first line
|
|
1094
|
-
this.code.lines[lidx] = [
|
|
1095
|
-
this.code.lines[lidx].slice(0, cursor.position),
|
|
1096
|
-
first_line
|
|
1097
|
-
].join('');
|
|
1098
|
-
|
|
1099
|
-
this.cursorToPosition(cursor, (cursor.position + first_line.length));
|
|
1100
|
-
|
|
1101
|
-
// Enter next lines...
|
|
1102
|
-
|
|
1103
|
-
let _text = null;
|
|
1104
|
-
|
|
1105
|
-
for( var i = 0; i < new_lines.length; ++i ) {
|
|
1106
|
-
_text = new_lines[i];
|
|
1107
|
-
this.cursorToLine(cursor, cursor.line++, true);
|
|
1108
|
-
// Add remaining...
|
|
1109
|
-
if( i == (new_lines.length - 1) )
|
|
1110
|
-
_text += remaining;
|
|
1111
|
-
this.code.lines.splice( 1 + lidx + i, 0, _text);
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
if(_text) this.cursorToPosition(cursor, _text.length);
|
|
1115
|
-
this.cursorToLine(cursor, cursor.line + num_lines);
|
|
1116
|
-
this.processLines(lidx);
|
|
1117
|
-
}
|
|
1118
|
-
// Pasting one line...
|
|
1119
|
-
else
|
|
1120
|
-
{
|
|
1121
|
-
this.code.lines[lidx] = [
|
|
1122
|
-
this.code.lines[lidx].slice(0, cursor.position),
|
|
1123
|
-
new_lines[0],
|
|
1124
|
-
this.code.lines[lidx].slice(cursor.position)
|
|
1125
|
-
].join('');
|
|
1126
|
-
|
|
1127
|
-
this.cursorToPosition(cursor, (cursor.position + new_lines[0].length));
|
|
1128
|
-
this.processLine(lidx);
|
|
1129
|
-
}
|
|
1113
|
+
this.appendText(text);
|
|
1130
1114
|
return;
|
|
1131
1115
|
case 'x': // cut line
|
|
1132
1116
|
const to_copy = this.code.lines.splice(lidx, 1)[0];
|
package/build/components/imui.js
CHANGED
|
@@ -56,6 +56,7 @@ class ImUI {
|
|
|
56
56
|
// Mouse state
|
|
57
57
|
|
|
58
58
|
this.mousePosition = new LX.vec2();
|
|
59
|
+
this.setPointerCursor = false;
|
|
59
60
|
|
|
60
61
|
this.root = this.canvas = canvas;
|
|
61
62
|
}
|
|
@@ -121,22 +122,17 @@ class ImUI {
|
|
|
121
122
|
|
|
122
123
|
// Draw button
|
|
123
124
|
|
|
125
|
+
ctx.beginPath();
|
|
124
126
|
ctx.fillStyle = active ? "#666" : (hovered ? "#444" : "#222");
|
|
125
|
-
ctx.
|
|
127
|
+
ctx.roundRect( position.x, position.y, size.x + padding.x * 2.0, size.y + padding.y * 2.0, [8, 8, 8, 8] );
|
|
128
|
+
ctx.fill();
|
|
126
129
|
|
|
127
130
|
// Draw text
|
|
128
131
|
|
|
129
132
|
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
130
133
|
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
document.body.style.cursor = "default";
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Pointer cursor on hover
|
|
139
|
-
document.body.style.cursor = "pointer";
|
|
135
|
+
this.setPointerCursor |= hovered;
|
|
140
136
|
|
|
141
137
|
if( this.eventClick )
|
|
142
138
|
{
|
|
@@ -176,50 +172,53 @@ class ImUI {
|
|
|
176
172
|
|
|
177
173
|
const metrics = ctx.measureText( text );
|
|
178
174
|
let size = new LX.vec2( metrics.width, metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent );
|
|
175
|
+
let fullSize = size.add( padding.mul( 2.0 ) );
|
|
179
176
|
|
|
180
177
|
// Get mouse state
|
|
181
178
|
|
|
182
|
-
const hovered = this.mousePosition.x >= position.x && this.mousePosition.x <= (position.x +
|
|
183
|
-
&& this.mousePosition.y >= position.y && this.mousePosition.y <= (position.y +
|
|
179
|
+
const hovered = this.mousePosition.x >= position.x && this.mousePosition.x <= (position.x + fullSize.x)
|
|
180
|
+
&& this.mousePosition.y >= position.y && this.mousePosition.y <= (position.y + fullSize.y);
|
|
184
181
|
|
|
185
182
|
const active = hovered && this.mouseDown;
|
|
186
183
|
|
|
187
184
|
// Draw box
|
|
188
185
|
|
|
186
|
+
ctx.beginPath();
|
|
189
187
|
ctx.fillStyle = hovered ? "#444" : "#222";
|
|
190
|
-
ctx.
|
|
191
|
-
|
|
192
|
-
// Draw thumb
|
|
188
|
+
ctx.roundRect( position.x, position.y, fullSize.x, fullSize.y, [8, 8, 8, 8] );
|
|
189
|
+
ctx.fill();
|
|
193
190
|
|
|
194
|
-
|
|
191
|
+
// Draw value
|
|
195
192
|
|
|
196
193
|
const min = position.x;
|
|
197
|
-
const max = position.x +
|
|
194
|
+
const max = position.x + fullSize.x;
|
|
198
195
|
|
|
199
196
|
if(active)
|
|
200
197
|
{
|
|
201
|
-
value = LX.UTILS.clamp((this.mousePosition.x - min
|
|
198
|
+
value = LX.UTILS.clamp((this.mousePosition.x - min) / (max - min), 0.0, 1.0);
|
|
202
199
|
this.widgets[ text ].value = value;
|
|
203
200
|
}
|
|
204
201
|
|
|
205
|
-
let
|
|
202
|
+
let valueSize = new LX.vec2( fullSize.x * value, size.y );
|
|
206
203
|
|
|
207
|
-
ctx.
|
|
208
|
-
ctx.
|
|
204
|
+
ctx.beginPath();
|
|
205
|
+
ctx.fillStyle = hovered ? "#6074e7" : "#3e57e4";
|
|
206
|
+
if( valueSize.x > ( fullSize.x - 8 ) ) // 8: radius
|
|
207
|
+
{
|
|
208
|
+
ctx.roundRect( position.x, position.y, valueSize.x, valueSize.y + padding.y * 2.0, [8, 8, 8, 8] );
|
|
209
|
+
ctx.fill();
|
|
210
|
+
}
|
|
211
|
+
else
|
|
212
|
+
{
|
|
213
|
+
ctx.fillRect( position.x, position.y, valueSize.x, valueSize.y + padding.y * 2.0 );
|
|
214
|
+
}
|
|
209
215
|
|
|
210
216
|
// Draw text
|
|
211
217
|
|
|
212
218
|
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
213
219
|
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
214
220
|
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
document.body.style.cursor = "default";
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Pointer cursor on hover
|
|
222
|
-
document.body.style.cursor = "pointer";
|
|
221
|
+
this.setPointerCursor |= hovered;
|
|
223
222
|
|
|
224
223
|
if( active )
|
|
225
224
|
{
|
|
@@ -259,7 +258,7 @@ class ImUI {
|
|
|
259
258
|
|
|
260
259
|
let boxMargin = 12;
|
|
261
260
|
let fullSize = new LX.vec2(boxMargin * 2.0, 0);
|
|
262
|
-
fullSize.add( size );
|
|
261
|
+
fullSize.add( size, fullSize );
|
|
263
262
|
|
|
264
263
|
// Get mouse state
|
|
265
264
|
|
|
@@ -294,8 +293,7 @@ class ImUI {
|
|
|
294
293
|
ctx.fillStyle = hovered ? "#fff" : "#ddd";
|
|
295
294
|
ctx.fillText( text, position.x + padding.x, position.y + metrics.actualBoundingBoxAscent + padding.y );
|
|
296
295
|
|
|
297
|
-
|
|
298
|
-
document.body.style.cursor = hovered ? "pointer" : "default";
|
|
296
|
+
this.setPointerCursor |= hovered;
|
|
299
297
|
}
|
|
300
298
|
|
|
301
299
|
/**
|
|
@@ -307,6 +305,11 @@ class ImUI {
|
|
|
307
305
|
|
|
308
306
|
this.eventClick = null;
|
|
309
307
|
|
|
308
|
+
// Pointer cursor on hover
|
|
309
|
+
document.body.style.cursor = this.setPointerCursor ? "pointer" : "default";
|
|
310
|
+
|
|
311
|
+
// Clear info
|
|
312
|
+
this.setPointerCursor = false;
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
315
|
|
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.4",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -126,17 +126,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
126
126
|
|
|
127
127
|
constructor(x, y) {
|
|
128
128
|
this.x = x ?? 0;
|
|
129
|
-
this.y = y ?? 0;
|
|
129
|
+
this.y = y ?? (x ?? 0);
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
get xy() { return [ this.x, this.y]; }
|
|
133
133
|
get yx() { return [ this.y, this.x]; }
|
|
134
|
-
|
|
135
|
-
set( x, y ) { this.x = x; this.y = y; }
|
|
136
|
-
add( v ) {
|
|
137
|
-
sub( v ) {
|
|
138
|
-
mul( v ) {
|
|
139
|
-
div( v ) {
|
|
134
|
+
|
|
135
|
+
set ( x, y ) { this.x = x; this.y = y; }
|
|
136
|
+
add ( v, v0 = new vec2() ) { v0.set( this.x + v.x, this.y + v.y ); return v0; }
|
|
137
|
+
sub ( v, v0 = new vec2() ) { v0.set( this.x - v.x, this.y - v.y ); return v0; }
|
|
138
|
+
mul ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2(v) } v = v0.set( this.x * v.x, this.y * v.y ); return v0; }
|
|
139
|
+
div ( v, v0 = new vec2() ) { v0.set( this.x / v.x, this.y / v.y ); return v0; }
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
LX.vec2 = vec2;
|
|
@@ -3049,6 +3049,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3049
3049
|
|
|
3050
3050
|
options.placeholder = placeholder.constructor == String ? placeholder : "Filter properties..";
|
|
3051
3051
|
options.skipWidget = options.skipWidget ?? true;
|
|
3052
|
+
options.skipInlineCount = true;
|
|
3052
3053
|
|
|
3053
3054
|
let widget = this.create_widget(null, Widget.TEXT, options);
|
|
3054
3055
|
let element = widget.domEl;
|
|
@@ -3264,6 +3265,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3264
3265
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3265
3266
|
* inputWidth: Width of the text input
|
|
3266
3267
|
* float: Justify text
|
|
3268
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3267
3269
|
*/
|
|
3268
3270
|
|
|
3269
3271
|
addText( name, value, callback, options = {} ) {
|
|
@@ -3280,7 +3282,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3280
3282
|
let element = widget.domEl;
|
|
3281
3283
|
|
|
3282
3284
|
// Add reset functionality
|
|
3283
|
-
if(widget.name && !(options.
|
|
3285
|
+
if(widget.name && !(options.skipReset ?? false)) {
|
|
3284
3286
|
Panel._add_reset_property(element.domName, function() {
|
|
3285
3287
|
wValue.value = wValue.iValue;
|
|
3286
3288
|
this.style.display = "none";
|
|
@@ -3391,7 +3393,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3391
3393
|
let element = widget.domEl;
|
|
3392
3394
|
|
|
3393
3395
|
// Add reset functionality
|
|
3394
|
-
if(widget.name && !(options.
|
|
3396
|
+
if(widget.name && !(options.skipReset ?? false)) {
|
|
3395
3397
|
Panel._add_reset_property(element.domName, function() {
|
|
3396
3398
|
wValue.value = wValue.iValue;
|
|
3397
3399
|
this.style.display = "none";
|
|
@@ -3719,6 +3721,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3719
3721
|
* @param {*} options:
|
|
3720
3722
|
* filter: Add a search bar to the widget [false]
|
|
3721
3723
|
* disabled: Make the widget disabled [false]
|
|
3724
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3722
3725
|
*/
|
|
3723
3726
|
|
|
3724
3727
|
addDropdown( name, values, value, callback, options = {} ) {
|
|
@@ -3739,7 +3742,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3739
3742
|
let that = this;
|
|
3740
3743
|
|
|
3741
3744
|
// Add reset functionality
|
|
3742
|
-
if(widget.name)
|
|
3745
|
+
if(widget.name && !(options.skipReset ?? false))
|
|
3743
3746
|
{
|
|
3744
3747
|
Panel._add_reset_property(element.domName, function() {
|
|
3745
3748
|
value = wValue.iValue;
|
|
@@ -3750,7 +3753,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3750
3753
|
|
|
3751
3754
|
let container = document.createElement('div');
|
|
3752
3755
|
container.className = "lexdropdown";
|
|
3753
|
-
container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
3756
|
+
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
3754
3757
|
|
|
3755
3758
|
// Add widget value
|
|
3756
3759
|
let wValue = document.createElement('div');
|
|
@@ -3857,7 +3860,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3857
3860
|
});
|
|
3858
3861
|
|
|
3859
3862
|
// Add string option
|
|
3860
|
-
if(
|
|
3863
|
+
if( iValue.constructor != Object ) {
|
|
3861
3864
|
option.style.flexDirection = 'unset';
|
|
3862
3865
|
option.innerHTML = "<a class='fa-solid fa-check'></a><span>" + iValue + "</span>";
|
|
3863
3866
|
option.value = iValue;
|
|
@@ -3910,6 +3913,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3910
3913
|
* @param {Array of Array} values Array of 2N Arrays of each value of the curve
|
|
3911
3914
|
* @param {Function} callback Callback function on change
|
|
3912
3915
|
* @param {*} options:
|
|
3916
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3913
3917
|
*/
|
|
3914
3918
|
|
|
3915
3919
|
addCurve( name, values, callback, options = {} ) {
|
|
@@ -3935,12 +3939,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3935
3939
|
let defaultValues = JSON.parse(JSON.stringify(values));
|
|
3936
3940
|
|
|
3937
3941
|
// Add reset functionality
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3942
|
+
if( !(options.skipReset ?? false) )
|
|
3943
|
+
{
|
|
3944
|
+
Panel._add_reset_property(element.domName, function(e) {
|
|
3945
|
+
this.style.display = "none";
|
|
3946
|
+
curve_instance.element.value = JSON.parse(JSON.stringify(defaultValues));
|
|
3947
|
+
curve_instance.redraw();
|
|
3948
|
+
that._trigger( new IEvent(name, curve_instance.element.value, e), callback );
|
|
3949
|
+
});
|
|
3950
|
+
}
|
|
3944
3951
|
|
|
3945
3952
|
// Add widget value
|
|
3946
3953
|
|
|
@@ -4134,23 +4141,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4134
4141
|
for( let i = 0; i < values.length; ++i )
|
|
4135
4142
|
{
|
|
4136
4143
|
const value = values[i];
|
|
4137
|
-
|
|
4144
|
+
let baseclass = options.innerValues ? 'dropdown' : value.constructor;
|
|
4138
4145
|
|
|
4139
4146
|
this.sameLine(2);
|
|
4140
4147
|
|
|
4141
4148
|
switch(baseclass)
|
|
4142
4149
|
{
|
|
4143
4150
|
case String:
|
|
4144
|
-
this.addText(i+"", value, function(value, event) {
|
|
4151
|
+
this.addText(i + "", value, function(value, event) {
|
|
4145
4152
|
values[i] = value;
|
|
4146
4153
|
callback( values );
|
|
4147
|
-
}, { nameWidth: itemNameWidth, inputWidth: "95%",
|
|
4154
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4148
4155
|
break;
|
|
4149
4156
|
case Number:
|
|
4150
|
-
this.addNumber(i+"", value, function(value, event) {
|
|
4157
|
+
this.addNumber(i + "", value, function(value, event) {
|
|
4158
|
+
values[i] = value;
|
|
4159
|
+
callback( values );
|
|
4160
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4161
|
+
break;
|
|
4162
|
+
case 'dropdown':
|
|
4163
|
+
this.addDropdown(i + "", options.innerValues, value, function(value, event) {
|
|
4151
4164
|
values[i] = value;
|
|
4152
4165
|
callback( values );
|
|
4153
|
-
}, { nameWidth: itemNameWidth, inputWidth: "95%",
|
|
4166
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4154
4167
|
break;
|
|
4155
4168
|
}
|
|
4156
4169
|
|
|
@@ -4158,11 +4171,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4158
4171
|
values.splice(values.indexOf( value ), 1);
|
|
4159
4172
|
updateItems();
|
|
4160
4173
|
this._trigger( new IEvent(name, values, event), callback );
|
|
4161
|
-
}, { title: "Remove item", className: '
|
|
4174
|
+
}, { title: "Remove item", className: 'micro'} );
|
|
4162
4175
|
}
|
|
4163
4176
|
|
|
4164
4177
|
buttonName = "Add item";
|
|
4165
|
-
buttonName += "<a class='fa-solid fa-plus' style='float:right; margin-right: 6px;'></a>";
|
|
4178
|
+
buttonName += "<a class='fa-solid fa-plus' style='float:right; margin-right: 6px; margin-top: 2px;'></a>";
|
|
4166
4179
|
this.addButton(null, buttonName, (v, event) => {
|
|
4167
4180
|
values.push( "" );
|
|
4168
4181
|
updateItems();
|
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.4",
|
|
12
12
|
ready: false,
|
|
13
13
|
components: [], // specific pre-build components
|
|
14
14
|
signals: {} // events and triggers
|
|
@@ -122,17 +122,17 @@ class vec2 {
|
|
|
122
122
|
|
|
123
123
|
constructor(x, y) {
|
|
124
124
|
this.x = x ?? 0;
|
|
125
|
-
this.y = y ?? 0;
|
|
125
|
+
this.y = y ?? (x ?? 0);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
get xy() { return [ this.x, this.y]; }
|
|
129
129
|
get yx() { return [ this.y, this.x]; }
|
|
130
130
|
|
|
131
|
-
set( x, y ) { this.x = x; this.y = y; }
|
|
132
|
-
add( v ) {
|
|
133
|
-
sub( v ) {
|
|
134
|
-
mul( v ) {
|
|
135
|
-
div( v ) {
|
|
131
|
+
set ( x, y ) { this.x = x; this.y = y; }
|
|
132
|
+
add ( v, v0 = new vec2() ) { v0.set( this.x + v.x, this.y + v.y ); return v0; }
|
|
133
|
+
sub ( v, v0 = new vec2() ) { v0.set( this.x - v.x, this.y - v.y ); return v0; }
|
|
134
|
+
mul ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2(v) } v = v0.set( this.x * v.x, this.y * v.y ); return v0; }
|
|
135
|
+
div ( v, v0 = new vec2() ) { v0.set( this.x / v.x, this.y / v.y ); return v0; }
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
LX.vec2 = vec2;
|
|
@@ -3045,6 +3045,7 @@ class Panel {
|
|
|
3045
3045
|
|
|
3046
3046
|
options.placeholder = placeholder.constructor == String ? placeholder : "Filter properties..";
|
|
3047
3047
|
options.skipWidget = options.skipWidget ?? true;
|
|
3048
|
+
options.skipInlineCount = true;
|
|
3048
3049
|
|
|
3049
3050
|
let widget = this.create_widget(null, Widget.TEXT, options);
|
|
3050
3051
|
let element = widget.domEl;
|
|
@@ -3260,6 +3261,7 @@ class Panel {
|
|
|
3260
3261
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3261
3262
|
* inputWidth: Width of the text input
|
|
3262
3263
|
* float: Justify text
|
|
3264
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3263
3265
|
*/
|
|
3264
3266
|
|
|
3265
3267
|
addText( name, value, callback, options = {} ) {
|
|
@@ -3276,7 +3278,7 @@ class Panel {
|
|
|
3276
3278
|
let element = widget.domEl;
|
|
3277
3279
|
|
|
3278
3280
|
// Add reset functionality
|
|
3279
|
-
if(widget.name && !(options.
|
|
3281
|
+
if(widget.name && !(options.skipReset ?? false)) {
|
|
3280
3282
|
Panel._add_reset_property(element.domName, function() {
|
|
3281
3283
|
wValue.value = wValue.iValue;
|
|
3282
3284
|
this.style.display = "none";
|
|
@@ -3387,7 +3389,7 @@ class Panel {
|
|
|
3387
3389
|
let element = widget.domEl;
|
|
3388
3390
|
|
|
3389
3391
|
// Add reset functionality
|
|
3390
|
-
if(widget.name && !(options.
|
|
3392
|
+
if(widget.name && !(options.skipReset ?? false)) {
|
|
3391
3393
|
Panel._add_reset_property(element.domName, function() {
|
|
3392
3394
|
wValue.value = wValue.iValue;
|
|
3393
3395
|
this.style.display = "none";
|
|
@@ -3715,6 +3717,7 @@ class Panel {
|
|
|
3715
3717
|
* @param {*} options:
|
|
3716
3718
|
* filter: Add a search bar to the widget [false]
|
|
3717
3719
|
* disabled: Make the widget disabled [false]
|
|
3720
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3718
3721
|
*/
|
|
3719
3722
|
|
|
3720
3723
|
addDropdown( name, values, value, callback, options = {} ) {
|
|
@@ -3735,7 +3738,7 @@ class Panel {
|
|
|
3735
3738
|
let that = this;
|
|
3736
3739
|
|
|
3737
3740
|
// Add reset functionality
|
|
3738
|
-
if(widget.name)
|
|
3741
|
+
if(widget.name && !(options.skipReset ?? false))
|
|
3739
3742
|
{
|
|
3740
3743
|
Panel._add_reset_property(element.domName, function() {
|
|
3741
3744
|
value = wValue.iValue;
|
|
@@ -3746,7 +3749,7 @@ class Panel {
|
|
|
3746
3749
|
|
|
3747
3750
|
let container = document.createElement('div');
|
|
3748
3751
|
container.className = "lexdropdown";
|
|
3749
|
-
container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
3752
|
+
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
3750
3753
|
|
|
3751
3754
|
// Add widget value
|
|
3752
3755
|
let wValue = document.createElement('div');
|
|
@@ -3853,7 +3856,7 @@ class Panel {
|
|
|
3853
3856
|
});
|
|
3854
3857
|
|
|
3855
3858
|
// Add string option
|
|
3856
|
-
if(
|
|
3859
|
+
if( iValue.constructor != Object ) {
|
|
3857
3860
|
option.style.flexDirection = 'unset';
|
|
3858
3861
|
option.innerHTML = "<a class='fa-solid fa-check'></a><span>" + iValue + "</span>";
|
|
3859
3862
|
option.value = iValue;
|
|
@@ -3906,6 +3909,7 @@ class Panel {
|
|
|
3906
3909
|
* @param {Array of Array} values Array of 2N Arrays of each value of the curve
|
|
3907
3910
|
* @param {Function} callback Callback function on change
|
|
3908
3911
|
* @param {*} options:
|
|
3912
|
+
* skipReset: Don't add the reset value button when value changes
|
|
3909
3913
|
*/
|
|
3910
3914
|
|
|
3911
3915
|
addCurve( name, values, callback, options = {} ) {
|
|
@@ -3931,12 +3935,15 @@ class Panel {
|
|
|
3931
3935
|
let defaultValues = JSON.parse(JSON.stringify(values));
|
|
3932
3936
|
|
|
3933
3937
|
// Add reset functionality
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3938
|
+
if( !(options.skipReset ?? false) )
|
|
3939
|
+
{
|
|
3940
|
+
Panel._add_reset_property(element.domName, function(e) {
|
|
3941
|
+
this.style.display = "none";
|
|
3942
|
+
curve_instance.element.value = JSON.parse(JSON.stringify(defaultValues));
|
|
3943
|
+
curve_instance.redraw();
|
|
3944
|
+
that._trigger( new IEvent(name, curve_instance.element.value, e), callback );
|
|
3945
|
+
});
|
|
3946
|
+
}
|
|
3940
3947
|
|
|
3941
3948
|
// Add widget value
|
|
3942
3949
|
|
|
@@ -4130,23 +4137,29 @@ class Panel {
|
|
|
4130
4137
|
for( let i = 0; i < values.length; ++i )
|
|
4131
4138
|
{
|
|
4132
4139
|
const value = values[i];
|
|
4133
|
-
|
|
4140
|
+
let baseclass = options.innerValues ? 'dropdown' : value.constructor;
|
|
4134
4141
|
|
|
4135
4142
|
this.sameLine(2);
|
|
4136
4143
|
|
|
4137
4144
|
switch(baseclass)
|
|
4138
4145
|
{
|
|
4139
4146
|
case String:
|
|
4140
|
-
this.addText(i+"", value, function(value, event) {
|
|
4147
|
+
this.addText(i + "", value, function(value, event) {
|
|
4141
4148
|
values[i] = value;
|
|
4142
4149
|
callback( values );
|
|
4143
|
-
}, { nameWidth: itemNameWidth, inputWidth: "95%",
|
|
4150
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4144
4151
|
break;
|
|
4145
4152
|
case Number:
|
|
4146
|
-
this.addNumber(i+"", value, function(value, event) {
|
|
4153
|
+
this.addNumber(i + "", value, function(value, event) {
|
|
4154
|
+
values[i] = value;
|
|
4155
|
+
callback( values );
|
|
4156
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4157
|
+
break;
|
|
4158
|
+
case 'dropdown':
|
|
4159
|
+
this.addDropdown(i + "", options.innerValues, value, function(value, event) {
|
|
4147
4160
|
values[i] = value;
|
|
4148
4161
|
callback( values );
|
|
4149
|
-
}, { nameWidth: itemNameWidth, inputWidth: "95%",
|
|
4162
|
+
}, { nameWidth: itemNameWidth, inputWidth: "95%", skipReset: true });
|
|
4150
4163
|
break;
|
|
4151
4164
|
}
|
|
4152
4165
|
|
|
@@ -4154,11 +4167,11 @@ class Panel {
|
|
|
4154
4167
|
values.splice(values.indexOf( value ), 1);
|
|
4155
4168
|
updateItems();
|
|
4156
4169
|
this._trigger( new IEvent(name, values, event), callback );
|
|
4157
|
-
}, { title: "Remove item", className: '
|
|
4170
|
+
}, { title: "Remove item", className: 'micro'} );
|
|
4158
4171
|
}
|
|
4159
4172
|
|
|
4160
4173
|
buttonName = "Add item";
|
|
4161
|
-
buttonName += "<a class='fa-solid fa-plus' style='float:right; margin-right: 6px;'></a>";
|
|
4174
|
+
buttonName += "<a class='fa-solid fa-plus' style='float:right; margin-right: 6px; margin-top: 2px;'></a>";
|
|
4162
4175
|
this.addButton(null, buttonName, (v, event) => {
|
|
4163
4176
|
values.push( "" );
|
|
4164
4177
|
updateItems();
|
package/examples/area_tabs.html
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
package/examples/asset_view.html
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
package/examples/dialogs.html
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
package/examples/node_graph.html
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
|
@@ -3,13 +3,13 @@
|
|
|
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="
|
|
6
|
+
<link rel="stylesheet" href="../build/lexgui.css">
|
|
7
7
|
<link rel="icon" href="../images/icon.png">
|
|
8
8
|
<script type="importmap">
|
|
9
9
|
{
|
|
10
10
|
"imports": {
|
|
11
|
-
"lexgui": "
|
|
12
|
-
"lexgui/components/": "
|
|
11
|
+
"lexgui": "../build/lexgui.module.js",
|
|
12
|
+
"lexgui/components/": "../build/components/"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|