lexgui 0.6.9 → 0.6.10

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.
@@ -162,7 +162,7 @@ class Timeline {
162
162
  const playbtn = header.addButton("playBtn", '', (value, event) => {
163
163
  this.changeState();
164
164
  }, { buttonClass: "accept", title: "Play", hideName: true, icon: "Play@solid", swap: "Pause@solid" });
165
- playbtn.root.setState(this.playing, true);
165
+ playbtn.setState(this.playing, true);
166
166
 
167
167
  header.addButton("stopBtn", '', (value, event) => {
168
168
  this.setState(false, true); // skip callback of set state
@@ -972,7 +972,7 @@ class Timeline {
972
972
  setState(state, skipCallback = false) {
973
973
  this.playing = state;
974
974
 
975
- this.header.widgets.playBtn.root.setState(this.playing, true);
975
+ this.header.widgets.playBtn.setState(this.playing, true);
976
976
 
977
977
  if(this.onStateChange && !skipCallback) {
978
978
  this.onStateChange(this.playing);
@@ -1290,7 +1290,7 @@ class Timeline {
1290
1290
  * @param {obj} options set some values for the track instance (groups and trackIdx not included)
1291
1291
  * @returns
1292
1292
  */
1293
- instantiateTrack(options = {}) {
1293
+ instantiateTrack(options = {}, clone = false) {
1294
1294
  return {
1295
1295
  isTrack: true,
1296
1296
  id: options.id ?? ( Math.floor(performance.now().toString()) + "_" + Math.floor(Math.random() * 0xffff) ), //must be unique, at least inside a group
@@ -1307,13 +1307,12 @@ class Timeline {
1307
1307
  * @param {obj} animation data with which to generate an animationClip
1308
1308
  * @returns
1309
1309
  */
1310
- instantiateAnimationClip(options) {
1310
+ instantiateAnimationClip(options, clone = false) {
1311
1311
  options = options ?? {};
1312
1312
  const animationClip = {
1313
1313
  id: options.id ?? (options.name ?? "animationClip"),
1314
1314
  duration: options.duration ?? 0,
1315
1315
  tracks: [],
1316
- tracksPerGroup: options.tracksPerGroup ?? {},
1317
1316
  data: options.data ?? null, // user defined data
1318
1317
  };
1319
1318
  return animationClip;
@@ -1433,42 +1432,42 @@ class KeyFramesTimeline extends Timeline {
1433
1432
  * id, dim, values, times, selected, edited, hovered
1434
1433
  * @returns
1435
1434
  */
1436
- instantiateTrack(options ={}){
1435
+ instantiateTrack(options ={}, clone = false){
1437
1436
  const track = super.instantiateTrack(options);
1438
1437
  track.dim = Math.max(1,options.dim ?? 1); // >= 1
1439
1438
  track.groupId = null,
1440
1439
  track.groupTrackIdx = -1, // track Idx inside group only if in group
1441
1440
 
1442
- track.values = new Float32Array(0);
1441
+ track.values = new Float32Array(0);
1443
1442
  track.times = new Float32Array(0);
1444
1443
  track.selected = [];
1445
1444
  track.edited = [];
1446
1445
  track.hovered = [];
1447
1446
 
1448
1447
  if ( options.values && options.times ){
1449
- track.values = options.values;
1450
- track.times = options.times;
1448
+ track.values = clone ? options.values.slice() : options.values;
1449
+ track.times = clone ? options.times.slice() : options.times;
1451
1450
 
1452
1451
  const numFrames = track.times.length;
1453
1452
  if ( options.selected && options.selected.length == numFrames ){
1454
- track.selected = options.selected;
1453
+ track.selected = clone ? options.selected.slice() : options.selected;
1455
1454
  }else{
1456
1455
  track.selected = (new Array(numFrames)).fill(false);
1457
1456
  }
1458
1457
  if ( options.edited && options.edited.length == numFrames ){
1459
- track.edited = options.edited;
1458
+ track.edited = clone ? options.edited.slice() : options.edited;
1460
1459
  }else{
1461
1460
  track.edited = (new Array(numFrames)).fill(false);
1462
1461
  }
1463
1462
  if ( options.hovered && options.hovered.length == numFrames ){
1464
- track.hovered = options.hovered;
1463
+ track.hovered = clone ? options.hovered.slice() : options.hovered;
1465
1464
  }else{
1466
1465
  track.hovered = (new Array(numFrames)).fill(false);
1467
1466
  }
1468
1467
  }
1469
1468
 
1470
1469
  track.curves = options.curves ?? this.defaultCurves; // only works if dim == 1
1471
- track.curvesRange = options.curvesRange ?? this.defaultCurvesRange.slice(0);
1470
+ track.curvesRange = ( options.curvesRange ?? this.defaultCurvesRange ).slice();
1472
1471
  return track;
1473
1472
  }
1474
1473
 
@@ -1477,9 +1476,11 @@ class KeyFramesTimeline extends Timeline {
1477
1476
  * @param {obj} animation data with which to generate an animationClip
1478
1477
  * @returns
1479
1478
  */
1480
- instantiateAnimationClip(animation) {
1479
+ instantiateAnimationClip(animation, clone = false) {
1481
1480
 
1482
- const animationClip = super.instantiateAnimationClip(animation);
1481
+ const animationClip = super.instantiateAnimationClip(animation, clone);
1482
+
1483
+ animationClip.tracksPerGroup = {};
1483
1484
 
1484
1485
  if (animation && animation.tracks) {
1485
1486
  const tracksPerGroup = {};
@@ -1496,18 +1497,13 @@ class KeyFramesTimeline extends Timeline {
1496
1497
  else{ valueDim = 1; }
1497
1498
  }
1498
1499
 
1499
- let leftOver = values.length % valueDim; // just in case values have an incorrect length
1500
- let amounEntries = Math.min( times.length, values.length - leftOver );
1501
- times = times.slice(0, amounEntries);
1502
- values = values.slice(0, amounEntries * valueDim);
1503
-
1504
1500
  let baseName = track.id ?? track.name;
1505
1501
  const [groupId, trackId] = baseName ? this._getValidTrackName(baseName) : [null, null];
1506
1502
 
1507
1503
  const toInstantiate = Object.assign({}, track);
1508
1504
  toInstantiate.id = trackId;
1509
1505
  toInstantiate.dim = valueDim;
1510
- const trackInfo = this.instantiateTrack(toInstantiate);
1506
+ const trackInfo = this.instantiateTrack(toInstantiate, clone);
1511
1507
 
1512
1508
  // manual group insertion
1513
1509
  if ( groupId ){
@@ -1525,13 +1521,34 @@ class KeyFramesTimeline extends Timeline {
1525
1521
 
1526
1522
  animationClip.tracks.push(trackInfo);
1527
1523
 
1528
- if ( times.length ){ duration = Math.max( duration, times[times.length-1]); }
1524
+ if ( trackInfo.times.length ){ duration = Math.max( duration, trackInfo.times[trackInfo.times.length-1]); }
1529
1525
  }
1530
1526
 
1531
1527
  animationClip.tracksPerGroup = tracksPerGroup;
1532
1528
  if ( !animation || !animation.duration ){
1533
1529
  animationClip.duration = duration;
1534
1530
  }
1531
+
1532
+ // overwrite trackspergroup
1533
+ if ( animation.tracksPerGroup ){
1534
+
1535
+ // ungroup all tracks (just in case)
1536
+ animationClip.tracks.forEach( (v,i,arr) =>{ v.groupId = null; v.groupTrackIdx = -1; } );
1537
+
1538
+ animationClip.tracksPerGroup = {};
1539
+ let tpg = animation.tracksPerGroup;
1540
+ for( let groupId in tpg ){
1541
+ const source = tpg[groupId];
1542
+ const target = [];
1543
+ for( let ti = 0; ti < source.length; ++ti ){
1544
+ const trackInfo = animationClip.tracks[ source[ti].trackIdx ]; // redo references
1545
+ target[ti] = trackInfo;
1546
+ trackInfo.groupId = groupId;
1547
+ trackInfo.groupTrackIdx = ti; // index of track in group
1548
+ }
1549
+ animationClip.tracksPerGroup[ groupId ] = target;
1550
+ }
1551
+ }
1535
1552
  }
1536
1553
 
1537
1554
  return animationClip;
@@ -3042,6 +3059,10 @@ LX.KeyFramesTimeline = KeyFramesTimeline;
3042
3059
  */
3043
3060
 
3044
3061
  class ClipsTimeline extends Timeline {
3062
+ static CLONEREASON_COPY = 1;
3063
+ static CLONEREASON_PASTE = 2;
3064
+ static CLONEREASON_HISTORY = 3;
3065
+ static CLONEREASON_TRACKCLONE = 4;
3045
3066
 
3046
3067
  /**
3047
3068
  * @param {string} name
@@ -3063,14 +3084,14 @@ class ClipsTimeline extends Timeline {
3063
3084
  * @param {obj} animation data with which to generate an animationClip
3064
3085
  * @returns
3065
3086
  */
3066
- instantiateAnimationClip(animation) {
3087
+ instantiateAnimationClip(animation, clone = false) {
3067
3088
 
3068
3089
  const animationClip = super.instantiateAnimationClip(animation);
3069
3090
 
3070
3091
  if (animation && animation.tracks){
3071
3092
  for( let i = 0; i < animation.tracks.length; ++i ) {
3072
3093
 
3073
- const trackInfo = this.instantiateTrack( animation.tracks[i] );
3094
+ const trackInfo = this.instantiateTrack( animation.tracks[i], clone );
3074
3095
  trackInfo.trackIdx = animationClip.tracks.length;
3075
3096
 
3076
3097
  animationClip.tracks.push(trackInfo);
@@ -3080,6 +3101,47 @@ class ClipsTimeline extends Timeline {
3080
3101
  return animationClip;
3081
3102
  }
3082
3103
 
3104
+ /**
3105
+ *
3106
+ * @param {obj} options set some values for the track instance (groups and trackIdx not included)
3107
+ * @returns
3108
+ */
3109
+ instantiateTrack(options = {}, clone = false) {
3110
+ const track = super.instantiateTrack(options);
3111
+
3112
+ track.trackIdx = this.animationClip.tracks.length;
3113
+
3114
+ track.selected = [];
3115
+ track.edited = [];
3116
+ track.hovered = [];
3117
+
3118
+ if( options.clips ){
3119
+ track.clips = clone ? this.cloneClips(options.clips, 0, ClipsTimeline.CLONEREASON_TRACKCLONE) : options.clips;
3120
+ }else{
3121
+ track.clips = [];
3122
+ }
3123
+
3124
+ const numClips = track.clips.length;
3125
+
3126
+ if ( options.selected && options.selected.length == numClips ){
3127
+ track.selected = clone ? options.selected.slice() : options.selected;
3128
+ }else{
3129
+ track.selected = (new Array(numClips)).fill(false);
3130
+ }
3131
+ if ( options.edited && options.edited.length == numClips ){
3132
+ track.edited = clone ? options.edited.slice() : options.edited;
3133
+ }else{
3134
+ track.edited = (new Array(numClips)).fill(false);
3135
+ }
3136
+ if ( options.hovered && options.hovered.length == numClips ){
3137
+ track.hovered = clone ? options.hovered.slice() : options.hovered;
3138
+ }else{
3139
+ track.hovered = (new Array(numClips)).fill(false);
3140
+ }
3141
+
3142
+ return track;
3143
+ }
3144
+
3083
3145
  // use default updateleftpanel
3084
3146
  // generateSelectedItemsTreeData(){}
3085
3147
 
@@ -3128,42 +3190,6 @@ class ClipsTimeline extends Timeline {
3128
3190
 
3129
3191
  this.updateLeftPanel();
3130
3192
  }
3131
-
3132
- /**
3133
- *
3134
- * @param {obj} options set some values for the track instance (groups and trackIdx not included)
3135
- * @returns
3136
- */
3137
- instantiateTrack(options = {}) {
3138
- const track = super.instantiateTrack(options);
3139
-
3140
- track.trackIdx = this.animationClip.tracks.length;
3141
-
3142
- track.clips = options.clips ?? [];
3143
- track.selected = [];
3144
- track.edited = [];
3145
- track.hovered = [];
3146
-
3147
- const numClips = track.clips.length;
3148
-
3149
- if ( options.selected && options.selected.length == numClips ){
3150
- track.selected = options.selected;
3151
- }else{
3152
- track.selected = (new Array(numClips)).fill(false);
3153
- }
3154
- if ( options.edited && options.edited.length == numClips ){
3155
- track.edited = options.edited;
3156
- }else{
3157
- track.edited = (new Array(numClips)).fill(false);
3158
- }
3159
- if ( options.hovered && options.hovered.length == numClips ){
3160
- track.hovered = options.hovered;
3161
- }else{
3162
- track.hovered = (new Array(numClips)).fill(false);
3163
- }
3164
-
3165
- return track;
3166
- }
3167
3193
 
3168
3194
  unHoverAll(){
3169
3195
  if(this.lastHovered){
@@ -3236,6 +3262,10 @@ class ClipsTimeline extends Timeline {
3236
3262
  let localY = e.localY;
3237
3263
  let track = e.track;
3238
3264
 
3265
+ if ( e.button > 0 ){
3266
+ return;
3267
+ }
3268
+
3239
3269
  if(e.ctrlKey && track) { // move clips
3240
3270
 
3241
3271
  let x = e.offsetX;
@@ -3748,18 +3778,16 @@ class ClipsTimeline extends Timeline {
3748
3778
  }
3749
3779
 
3750
3780
 
3751
- // Overwrite style with small font size if it's zoomed out
3752
- if( this.pixelsPerSecond < 200) {
3753
- ctx.font = this.pixelsPerSecond * 0.06 +"px" + Timeline.FONT;
3754
- }
3755
-
3756
- const text = clip.id ?? ""; //clip.id.replaceAll("_", " ").replaceAll("-", " ");
3781
+ let text = clip.id ?? ""; //clip.id.replaceAll("_", " ").replaceAll("-", " ");
3757
3782
  const textInfo = ctx.measureText( text );
3758
3783
 
3759
- // Draw clip name if it's readable
3760
- if(this.pixelsPerSecond > 100) {
3761
- ctx.fillText( text, x + (w - textInfo.width)*0.5, y + offset + trackHeight * 0.5);
3784
+ let textWidth = textInfo.width;
3785
+ if ( textWidth > w && textWidth > 0){
3786
+ let amount = Math.floor( w * text.length / textWidth );
3787
+ text = text.substr( 0, amount );
3788
+ textWidth = w;
3762
3789
  }
3790
+ ctx.fillText( text, x + (w - textWidth)*0.5, y + offset + trackHeight * 0.5);
3763
3791
 
3764
3792
  ctx.fillStyle = track.hovered[j] ? "white" : "#f5f5f5"//track.hovered[j] ? "white" : Timeline.FONT_COLOR_QUATERNARY;
3765
3793
  ctx.strokeStyle = "rgba(125,125,125,0.4)";
@@ -4029,9 +4057,10 @@ class ClipsTimeline extends Timeline {
4029
4057
  * User defined. Used when copying and pasting
4030
4058
  * @param {Array of clips} clipsToClone array of original clips. Do not modify clips in this array
4031
4059
  * @param {float} timeOffset Value of time that should be added (or subtracted) from the timing attributes
4060
+ * @param {int} reason Flag to signal the reason of the clone
4032
4061
  * @returns {Array of clips}
4033
4062
  */
4034
- cloneClips( clipsToClone, timeOffset ){
4063
+ cloneClips( clipsToClone, timeOffset, reason = 0 ){
4035
4064
  let clipsToReturn = JSON.parse(JSON.stringify(clipsToClone))
4036
4065
  for(let i = 0; i < clipsToReturn.length; ++i){
4037
4066
  let clip = clipsToReturn[i];
@@ -4064,7 +4093,7 @@ class ClipsTimeline extends Timeline {
4064
4093
  }
4065
4094
 
4066
4095
  globalStart = Math.max(0, globalStart);
4067
- this.clipboard = this.cloneClips( clipsToCopy, -globalStart );
4096
+ this.clipboard = this.cloneClips( clipsToCopy, -globalStart, ClipsTimeline.CLONEREASON_COPY );
4068
4097
  }
4069
4098
 
4070
4099
  pasteContent( time = this.currentTime ) {
@@ -4075,7 +4104,7 @@ class ClipsTimeline extends Timeline {
4075
4104
 
4076
4105
  time = Math.max(0, time);
4077
4106
 
4078
- let clipsToAdd = this.cloneClips( this.clipboard, time );
4107
+ let clipsToAdd = this.cloneClips( this.clipboard, time, ClipsTimeline.CLONEREASON_PASTE );
4079
4108
  this.addClips(clipsToAdd, 0);
4080
4109
  }
4081
4110
 
@@ -4124,7 +4153,7 @@ class ClipsTimeline extends Timeline {
4124
4153
  */
4125
4154
  historyGenerateTrackStep( trackIdx ){
4126
4155
  const track = this.animationClip.tracks[trackIdx];
4127
- const clips = this.cloneClips(track.clips, 0);
4156
+ const clips = this.cloneClips(track.clips, 0, ClipsTimeline.CLONEREASON_HISTORY);
4128
4157
 
4129
4158
  const undoStep = {
4130
4159
  trackIdx: trackIdx, // already done by saveState
package/build/lexgui.css CHANGED
@@ -3765,9 +3765,9 @@ meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
3765
3765
 
3766
3766
  .lexlayers {
3767
3767
  display: grid;
3768
- grid-template-columns: 18px 18px 18px 18px 18px 18px 18px 18px;
3768
+ grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
3769
3769
  grid-gap: 6px 8px;
3770
- justify-content: center;
3770
+ max-width: calc(26px * 8); /* 8 layers max */
3771
3771
  }
3772
3772
 
3773
3773
  .lexlayer {
@@ -3775,6 +3775,7 @@ meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
3775
3775
  background-color: var(--layer-color);
3776
3776
  color: var(--global-text-primary);
3777
3777
  text-align: center;
3778
+ place-self: center;
3778
3779
  line-height: 19px;
3779
3780
  width: 18px;
3780
3781
  height: 18px;
@@ -4585,9 +4586,10 @@ ul.lexassetscontent {
4585
4586
  }
4586
4587
 
4587
4588
  .lexassetscontent .lexitemdesc {
4588
- position: absolute;
4589
+ position: fixed;
4589
4590
  font-weight: 600;
4590
- background-color: #afafaf;
4591
+ white-space: nowrap;
4592
+ background-color: var(--global-text-secondary);
4591
4593
  color: var(--global-color-primary);
4592
4594
  font-size: var(--global-font-size);
4593
4595
  border-radius: 6px;