lexgui 0.1.46 → 0.4.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.
- package/build/components/codeeditor.js +12 -10
- package/build/components/timeline.js +47 -25
- package/build/lexgui.css +1220 -384
- package/build/lexgui.js +9388 -7800
- package/build/lexgui.min.css +1 -0
- package/build/lexgui.min.js +1 -0
- package/build/lexgui.module.js +2237 -668
- package/build/lexgui.module.min.js +1 -0
- package/changelog.md +56 -2
- package/demo.js +86 -873
- package/examples/index.html +0 -3
- package/examples/previews/side_bar.png +0 -0
- package/examples/side_bar.html +43 -11
- package/package.json +1 -1
|
@@ -237,6 +237,8 @@ class CodeEditor {
|
|
|
237
237
|
static CODE_MIN_FONT_SIZE = 9;
|
|
238
238
|
static CODE_MAX_FONT_SIZE = 22;
|
|
239
239
|
|
|
240
|
+
static LINE_GUTTER_WIDTH = 48;
|
|
241
|
+
|
|
240
242
|
/**
|
|
241
243
|
* @param {*} options
|
|
242
244
|
* name:
|
|
@@ -380,7 +382,7 @@ class CodeEditor {
|
|
|
380
382
|
this.selections = {};
|
|
381
383
|
|
|
382
384
|
// Css char synchronization
|
|
383
|
-
this.xPadding = "
|
|
385
|
+
this.xPadding = CodeEditor.LINE_GUTTER_WIDTH + "px";
|
|
384
386
|
|
|
385
387
|
// Add main cursor
|
|
386
388
|
this._addCursor( 0, 0, true, true );
|
|
@@ -390,7 +392,6 @@ class CodeEditor {
|
|
|
390
392
|
this.codeScroller = this.tabs.area.root;
|
|
391
393
|
this.firstLineInViewport = 0;
|
|
392
394
|
this.lineScrollMargin = new LX.vec2( 20, 20 ); // [ mUp, mDown ]
|
|
393
|
-
window.scroller = this.codeScroller;
|
|
394
395
|
|
|
395
396
|
let lastScrollTopValue = -1;
|
|
396
397
|
|
|
@@ -2456,10 +2457,11 @@ class CodeEditor {
|
|
|
2456
2457
|
|
|
2457
2458
|
// We are out of the viewport and max length is different? Resize scrollbars...
|
|
2458
2459
|
const maxLineLength = this.getMaxLineLength();
|
|
2459
|
-
const numViewportChars = Math.floor( this.codeScroller.clientWidth / this.charWidth );
|
|
2460
|
+
const numViewportChars = Math.floor( ( this.codeScroller.clientWidth - CodeEditor.LINE_GUTTER_WIDTH ) / this.charWidth );
|
|
2460
2461
|
if( maxLineLength >= numViewportChars && maxLineLength != this._lastMaxLineLength )
|
|
2461
2462
|
{
|
|
2462
2463
|
this.resize( maxLineLength );
|
|
2464
|
+
this.setScrollLeft( 1e4 );
|
|
2463
2465
|
}
|
|
2464
2466
|
|
|
2465
2467
|
// Manage autocomplete
|
|
@@ -3478,7 +3480,7 @@ class CodeEditor {
|
|
|
3478
3480
|
// Add horizontal scroll
|
|
3479
3481
|
|
|
3480
3482
|
doAsync(() => {
|
|
3481
|
-
var viewportSizeX = ( this.codeScroller.clientWidth + this.getScrollLeft() ) -
|
|
3483
|
+
var viewportSizeX = ( this.codeScroller.clientWidth + this.getScrollLeft() ) - CodeEditor.LINE_GUTTER_WIDTH; // Gutter offset
|
|
3482
3484
|
if( (cursor.position * this.charWidth) >= viewportSizeX )
|
|
3483
3485
|
this.setScrollLeft( this.getScrollLeft() + this.charWidth );
|
|
3484
3486
|
});
|
|
@@ -3735,7 +3737,7 @@ class CodeEditor {
|
|
|
3735
3737
|
|
|
3736
3738
|
// Update max viewport
|
|
3737
3739
|
const maxLineLength = pMaxLength ?? this.getMaxLineLength();
|
|
3738
|
-
const scrollWidth = maxLineLength * this.charWidth;
|
|
3740
|
+
const scrollWidth = maxLineLength * this.charWidth + CodeEditor.LINE_GUTTER_WIDTH;
|
|
3739
3741
|
const scrollHeight = this.code.lines.length * this.lineHeight;
|
|
3740
3742
|
|
|
3741
3743
|
this._lastMaxLineLength = maxLineLength;
|
|
@@ -3750,9 +3752,9 @@ class CodeEditor {
|
|
|
3750
3752
|
|
|
3751
3753
|
resizeScrollBars() {
|
|
3752
3754
|
|
|
3753
|
-
const totalLinesInViewport = ((this.codeScroller.offsetHeight
|
|
3755
|
+
const totalLinesInViewport = ((this.codeScroller.offsetHeight) / this.lineHeight)|0;
|
|
3754
3756
|
|
|
3755
|
-
if( totalLinesInViewport
|
|
3757
|
+
if( totalLinesInViewport >= this.code.lines.length )
|
|
3756
3758
|
{
|
|
3757
3759
|
this.codeScroller.classList.remove( 'with-vscrollbar' );
|
|
3758
3760
|
this.vScrollbar.root.classList.add( 'scrollbar-unused' );
|
|
@@ -3765,10 +3767,10 @@ class CodeEditor {
|
|
|
3765
3767
|
this.vScrollbar.thumb.style.height = (this.vScrollbar.thumb.size * 100.0) + "%";
|
|
3766
3768
|
}
|
|
3767
3769
|
|
|
3768
|
-
const numViewportChars = Math.floor( this.codeScroller.clientWidth / this.charWidth );
|
|
3770
|
+
const numViewportChars = Math.floor( ( this.codeScroller.clientWidth - CodeEditor.LINE_GUTTER_WIDTH ) / this.charWidth );
|
|
3769
3771
|
const maxLineLength = this._lastMaxLineLength;
|
|
3770
3772
|
|
|
3771
|
-
if( numViewportChars
|
|
3773
|
+
if( numViewportChars >= maxLineLength )
|
|
3772
3774
|
{
|
|
3773
3775
|
this.codeScroller.classList.remove( 'with-hscrollbar' );
|
|
3774
3776
|
this.hScrollbar.root.classList.add( 'scrollbar-unused' );
|
|
@@ -4055,7 +4057,7 @@ class CodeEditor {
|
|
|
4055
4057
|
// Show box
|
|
4056
4058
|
this.autocomplete.classList.toggle('show', true);
|
|
4057
4059
|
this.autocomplete.classList.toggle('no-scrollbar', !(this.autocomplete.scrollHeight > this.autocomplete.offsetHeight));
|
|
4058
|
-
this.autocomplete.style.left = (cursor._left +
|
|
4060
|
+
this.autocomplete.style.left = (cursor._left + CodeEditor.LINE_GUTTER_WIDTH - this.getScrollLeft()) + "px";
|
|
4059
4061
|
this.autocomplete.style.top = (cursor._top + 28 + this.lineHeight - this.getScrollTop()) + "px";
|
|
4060
4062
|
|
|
4061
4063
|
this.isAutoCompleteActive = true;
|
|
@@ -142,6 +142,13 @@ class Timeline {
|
|
|
142
142
|
this.resizeCanvas( [ bounding.width, bounding.height + this.header_offset ] );
|
|
143
143
|
}
|
|
144
144
|
this.resize(this.size);
|
|
145
|
+
|
|
146
|
+
// update color theme
|
|
147
|
+
this.updateTheme();
|
|
148
|
+
LX.addSignal( "@on_new_color_scheme", (el, value) => {
|
|
149
|
+
// Retrieve again the color using LX.getThemeColor, which checks the applied theme
|
|
150
|
+
this.updateTheme();
|
|
151
|
+
} )
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
/**
|
|
@@ -507,7 +514,7 @@ class Timeline {
|
|
|
507
514
|
|
|
508
515
|
// Begin drawing
|
|
509
516
|
ctx.beginPath();
|
|
510
|
-
ctx.fillStyle = Timeline.FONT_COLOR
|
|
517
|
+
ctx.fillStyle = Timeline.FONT_COLOR;
|
|
511
518
|
ctx.globalAlpha = this.opacity;
|
|
512
519
|
|
|
513
520
|
for( let x = startx; x <= endx; x += tickX )
|
|
@@ -550,8 +557,8 @@ class Timeline {
|
|
|
550
557
|
let max_tracks = Math.ceil( (h - timeline_height + this.currentScrollInPixels) / line_height );
|
|
551
558
|
|
|
552
559
|
ctx.save();
|
|
553
|
-
ctx.fillStyle =
|
|
554
|
-
ctx.globalAlpha =
|
|
560
|
+
ctx.fillStyle = Timeline.TRACK_COLOR_SECONDARY;
|
|
561
|
+
ctx.globalAlpha = 0.3 * this.opacity;
|
|
555
562
|
for(let i = 0; i <= max_tracks; i+=2)
|
|
556
563
|
{
|
|
557
564
|
ctx.fillRect(0, timeline_height + i * line_height - this.currentScrollInPixels, w, line_height );
|
|
@@ -559,7 +566,7 @@ class Timeline {
|
|
|
559
566
|
ctx.globalAlpha = this.opacity;
|
|
560
567
|
|
|
561
568
|
//bg lines
|
|
562
|
-
ctx.strokeStyle =
|
|
569
|
+
ctx.strokeStyle = Timeline.TRACK_COLOR_TERCIARY;
|
|
563
570
|
ctx.beginPath();
|
|
564
571
|
|
|
565
572
|
let pos = this.timeToX( 0 );
|
|
@@ -670,15 +677,15 @@ class Timeline {
|
|
|
670
677
|
ctx.font = "11px " + Timeline.FONT;//"11px Calibri";
|
|
671
678
|
ctx.textAlign = "center";
|
|
672
679
|
//ctx.textBaseline = "middle";
|
|
673
|
-
ctx.fillStyle = Timeline.COLOR_INACTIVE
|
|
680
|
+
ctx.fillStyle = Timeline.COLOR_INACTIVE;
|
|
674
681
|
ctx.fillText( (Math.floor(this.currentTime*10)*0.1).toFixed(1), posx, this.topMargin * 0.6 );
|
|
675
682
|
|
|
676
683
|
// Selections
|
|
677
684
|
ctx.strokeStyle = ctx.fillStyle = Timeline.FONT_COLOR;
|
|
678
685
|
ctx.translate( this.position[0], this.position[1] + this.topMargin )
|
|
679
686
|
if(this.boxSelection) {
|
|
680
|
-
ctx.globalAlpha = 0.15;
|
|
681
|
-
ctx.fillStyle =
|
|
687
|
+
ctx.globalAlpha = 0.15 * this.opacity;
|
|
688
|
+
ctx.fillStyle = Timeline.BOX_SELECTION_COLOR;
|
|
682
689
|
ctx.strokeRect( this.boxSelectionStart[0], this.boxSelectionStart[1], this.boxSelectionEnd[0] - this.boxSelectionStart[0], this.boxSelectionEnd[1] - this.boxSelectionStart[1]);
|
|
683
690
|
ctx.fillRect( this.boxSelectionStart[0], this.boxSelectionStart[1], this.boxSelectionEnd[0] - this.boxSelectionStart[0], this.boxSelectionEnd[1] - this.boxSelectionStart[1]);
|
|
684
691
|
ctx.stroke();
|
|
@@ -1077,16 +1084,16 @@ class Timeline {
|
|
|
1077
1084
|
let selectedClipArea = null;
|
|
1078
1085
|
|
|
1079
1086
|
if(track.enabled === false) {
|
|
1080
|
-
ctx.globalAlpha = 0.4;
|
|
1087
|
+
ctx.globalAlpha = 0.4 * this.opacity;
|
|
1081
1088
|
}
|
|
1082
1089
|
else {
|
|
1083
|
-
ctx.globalAlpha = 0.2;
|
|
1090
|
+
ctx.globalAlpha = 0.2 * this.opacity;
|
|
1084
1091
|
}
|
|
1085
1092
|
|
|
1086
1093
|
ctx.font = Math.floor( trackHeight * 0.8) + "px" + Timeline.FONT;
|
|
1087
1094
|
ctx.textAlign = "left";
|
|
1088
1095
|
ctx.textBaseline = "middle";
|
|
1089
|
-
ctx.fillStyle = Timeline.TRACK_SELECTED_LIGHT
|
|
1096
|
+
ctx.fillStyle = Timeline.TRACK_SELECTED_LIGHT;
|
|
1090
1097
|
|
|
1091
1098
|
// Fill track background if it's selected
|
|
1092
1099
|
if(track.isSelected) {
|
|
@@ -1094,7 +1101,7 @@ class Timeline {
|
|
|
1094
1101
|
}
|
|
1095
1102
|
|
|
1096
1103
|
let clips = track.clips;
|
|
1097
|
-
let trackAlpha =
|
|
1104
|
+
let trackAlpha = this.opacity;
|
|
1098
1105
|
|
|
1099
1106
|
if(!clips) {
|
|
1100
1107
|
return;
|
|
@@ -1137,7 +1144,7 @@ class Timeline {
|
|
|
1137
1144
|
ctx.fillStyle = 'rgba(' + color.join(',') + ', 0.8)';
|
|
1138
1145
|
}
|
|
1139
1146
|
else {
|
|
1140
|
-
ctx.globalAlpha = 0.8;
|
|
1147
|
+
ctx.globalAlpha = 0.8 * this.opacity;
|
|
1141
1148
|
}
|
|
1142
1149
|
|
|
1143
1150
|
// Draw fade-in and fade-out
|
|
@@ -1304,22 +1311,37 @@ class Timeline {
|
|
|
1304
1311
|
this.updateLeftPanel();
|
|
1305
1312
|
this.resize();
|
|
1306
1313
|
}
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* updates theme (light - dark) based on LX's current theme
|
|
1317
|
+
*/
|
|
1318
|
+
updateTheme( ){
|
|
1319
|
+
Timeline.BACKGROUND_COLOR = LX.getThemeColor("global-blur-background");
|
|
1320
|
+
Timeline.TRACK_COLOR_PRIMARY = LX.getThemeColor("global-color-primary");
|
|
1321
|
+
Timeline.TRACK_COLOR_SECONDARY = LX.getThemeColor("global-color-secondary");
|
|
1322
|
+
Timeline.TRACK_COLOR_TERCIARY = LX.getThemeColor("global-color-terciary");
|
|
1323
|
+
Timeline.TRACK_COLOR_QUATERNARY = LX.getThemeColor("global-color-quaternary");
|
|
1324
|
+
Timeline.FONT = LX.getThemeColor("global-font");
|
|
1325
|
+
Timeline.FONT_COLOR = LX.getThemeColor("global-text-primary");
|
|
1326
|
+
}
|
|
1307
1327
|
};
|
|
1308
1328
|
|
|
1309
|
-
Timeline.BACKGROUND_COLOR = LX.getThemeColor("global-
|
|
1310
|
-
Timeline.TRACK_COLOR_PRIMARY = LX.getThemeColor("global-
|
|
1311
|
-
Timeline.TRACK_COLOR_SECONDARY = LX.getThemeColor("global-color-
|
|
1329
|
+
Timeline.BACKGROUND_COLOR = LX.getThemeColor("global-blur-background");
|
|
1330
|
+
Timeline.TRACK_COLOR_PRIMARY = LX.getThemeColor("global-color-primary");
|
|
1331
|
+
Timeline.TRACK_COLOR_SECONDARY = LX.getThemeColor("global-color-secondary");
|
|
1332
|
+
Timeline.TRACK_COLOR_TERCIARY = LX.getThemeColor("global-color-terciary");
|
|
1333
|
+
Timeline.TRACK_COLOR_QUATERNARY = LX.getThemeColor("global-color-quaternary");
|
|
1312
1334
|
Timeline.TRACK_SELECTED = LX.getThemeColor("global-selected");
|
|
1313
1335
|
Timeline.TRACK_SELECTED_LIGHT = LX.getThemeColor("global-selected-light");
|
|
1314
1336
|
Timeline.FONT = LX.getThemeColor("global-font");
|
|
1315
|
-
Timeline.FONT_COLOR = LX.getThemeColor("global-text");
|
|
1316
|
-
Timeline.COLOR = LX.getThemeColor("global-selected-dark")
|
|
1337
|
+
Timeline.FONT_COLOR = LX.getThemeColor("global-text-primary");
|
|
1338
|
+
Timeline.COLOR = LX.getThemeColor("global-selected-dark");
|
|
1317
1339
|
Timeline.COLOR_SELECTED = Timeline.COLOR_HOVERED = "rgba(250,250,20,1)";///"rgba(250,250,20,1)";
|
|
1318
1340
|
// Timeline.COLOR_HOVERED = LX.getThemeColor("global-selected");
|
|
1319
1341
|
Timeline.COLOR_INACTIVE = "rgba(250,250,250,0.7)";
|
|
1320
1342
|
Timeline.COLOR_LOCK = "rgba(255,125,125,0.7)";
|
|
1321
1343
|
Timeline.COLOR_EDITED = "rgba(20,230,20,0.7)"//"rgba(125,250,250, 1)";
|
|
1322
|
-
|
|
1344
|
+
Timeline.BOX_SELECTION_COLOR = "#AAA";
|
|
1323
1345
|
LX.Timeline = Timeline;
|
|
1324
1346
|
|
|
1325
1347
|
/**
|
|
@@ -1651,13 +1673,13 @@ class KeyFramesTimeline extends Timeline {
|
|
|
1651
1673
|
|
|
1652
1674
|
|
|
1653
1675
|
if(track.isSelected) {
|
|
1654
|
-
ctx.globalAlpha = 0.2;
|
|
1655
|
-
ctx.fillStyle = Timeline.TRACK_SELECTED
|
|
1676
|
+
ctx.globalAlpha = 0.2 * this.opacity;
|
|
1677
|
+
ctx.fillStyle = Timeline.TRACK_SELECTED;
|
|
1656
1678
|
ctx.fillRect(0, 0, ctx.canvas.width, trackHeight );
|
|
1657
1679
|
}
|
|
1658
1680
|
|
|
1659
|
-
ctx.fillStyle = Timeline.COLOR
|
|
1660
|
-
ctx.globalAlpha =
|
|
1681
|
+
ctx.fillStyle = Timeline.COLOR;
|
|
1682
|
+
ctx.globalAlpha = this.opacity;
|
|
1661
1683
|
|
|
1662
1684
|
let keyframes = track.times;
|
|
1663
1685
|
|
|
@@ -4247,12 +4269,12 @@ class CurvesTimeline extends Timeline {
|
|
|
4247
4269
|
|
|
4248
4270
|
if(keyframes) {
|
|
4249
4271
|
if(track.isSelected){
|
|
4250
|
-
ctx.globalAlpha = 0.2;
|
|
4251
|
-
ctx.fillStyle = Timeline.TRACK_SELECTED_LIGHT
|
|
4272
|
+
ctx.globalAlpha = 0.2 * this.opacity;
|
|
4273
|
+
ctx.fillStyle = Timeline.TRACK_SELECTED_LIGHT;
|
|
4252
4274
|
ctx.fillRect(0, 0, ctx.canvas.width, trackHeight );
|
|
4253
4275
|
}
|
|
4254
4276
|
|
|
4255
|
-
ctx.globalAlpha =
|
|
4277
|
+
ctx.globalAlpha = this.opacity;
|
|
4256
4278
|
|
|
4257
4279
|
//draw lines
|
|
4258
4280
|
ctx.strokeStyle = "white";
|