lexgui 0.1.32 → 0.1.34
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 +1 -1
- package/build/components/timeline.js +2059 -1443
- package/build/components/videoeditor.js +191 -100
- package/build/lexgui.css +40 -17
- package/build/lexgui.js +326 -256
- package/build/lexgui.module.js +367 -202
- package/changelog.md +14 -0
- package/demo.js +4 -13
- package/examples/timeline.html +39 -24
- package/examples/video_editor.html +30 -13
- package/examples/video_editor2.html +118 -0
- package/package.json +1 -1
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.34",
|
|
12
12
|
ready: false,
|
|
13
13
|
components: [], // specific pre-build components
|
|
14
14
|
signals: {} // events and triggers
|
|
@@ -21,8 +21,11 @@ LX.MOUSE_RIGHT_CLICK = 2;
|
|
|
21
21
|
LX.MOUSE_DOUBLE_CLICK = 2;
|
|
22
22
|
LX.MOUSE_TRIPLE_CLICK = 3;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
LX.CURVE_MOVEOUT_CLAMP = 0;
|
|
25
|
+
LX.CURVE_MOVEOUT_DELETE = 1;
|
|
26
|
+
|
|
27
|
+
function clamp( num, min, max ) { return Math.min( Math.max( num, min ), max ); }
|
|
28
|
+
function round( num, n ) { return +num.toFixed( n ); }
|
|
26
29
|
|
|
27
30
|
function getSupportedDOMName( string )
|
|
28
31
|
{
|
|
@@ -624,6 +627,7 @@ class TreeEvent {
|
|
|
624
627
|
this.node = node;
|
|
625
628
|
this.value = value;
|
|
626
629
|
this.multiple = false; // Multiple selection
|
|
630
|
+
this.panel = null;
|
|
627
631
|
}
|
|
628
632
|
|
|
629
633
|
string() {
|
|
@@ -744,6 +748,27 @@ class Area {
|
|
|
744
748
|
{
|
|
745
749
|
this.root.classList.add("overlay-" + overlay);
|
|
746
750
|
|
|
751
|
+
if(options.left) {
|
|
752
|
+
this.root.style.left = options.left;
|
|
753
|
+
}
|
|
754
|
+
if(options.right) {
|
|
755
|
+
this.root.style.right = options.right;
|
|
756
|
+
}
|
|
757
|
+
if(options.top) {
|
|
758
|
+
this.root.style.top = options.top;
|
|
759
|
+
}
|
|
760
|
+
if(options.bottom) {
|
|
761
|
+
this.root.style.bottom = options.bottom;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
const draggable = options.draggable ?? true;
|
|
765
|
+
if( draggable )
|
|
766
|
+
makeDraggable( root );
|
|
767
|
+
|
|
768
|
+
if( options.resizeable ) {
|
|
769
|
+
root.classList.add("resizeable");
|
|
770
|
+
}
|
|
771
|
+
|
|
747
772
|
if(options.resize)
|
|
748
773
|
{
|
|
749
774
|
this.split_bar = document.createElement("div");
|
|
@@ -2575,7 +2600,8 @@ LX.ADD_CUSTOM_WIDGET = ADD_CUSTOM_WIDGET;
|
|
|
2575
2600
|
|
|
2576
2601
|
class NodeTree {
|
|
2577
2602
|
|
|
2578
|
-
constructor(domEl, data, options) {
|
|
2603
|
+
constructor( domEl, data, options ) {
|
|
2604
|
+
|
|
2579
2605
|
this.domEl = domEl;
|
|
2580
2606
|
this.data = data;
|
|
2581
2607
|
this.onevent = options.onevent;
|
|
@@ -2583,10 +2609,10 @@ class NodeTree {
|
|
|
2583
2609
|
this.selected = [];
|
|
2584
2610
|
|
|
2585
2611
|
if(data.constructor === Object)
|
|
2586
|
-
this._create_item(null, data);
|
|
2612
|
+
this._create_item( null, data );
|
|
2587
2613
|
else
|
|
2588
2614
|
for( let d of data )
|
|
2589
|
-
this._create_item(null, d);
|
|
2615
|
+
this._create_item( null, d );
|
|
2590
2616
|
}
|
|
2591
2617
|
|
|
2592
2618
|
_create_item( parent, node, level = 0, selectedId ) {
|
|
@@ -2653,32 +2679,32 @@ class NodeTree {
|
|
|
2653
2679
|
return;
|
|
2654
2680
|
}
|
|
2655
2681
|
|
|
2656
|
-
if(!e.shiftKey) {
|
|
2657
|
-
list.querySelectorAll("li").forEach( e => { e.classList.remove('selected'); } );
|
|
2682
|
+
if( !e.shiftKey ) {
|
|
2683
|
+
list.querySelectorAll( "li" ).forEach( e => { e.classList.remove( 'selected' ); } );
|
|
2658
2684
|
this.selected.length = 0;
|
|
2659
2685
|
}
|
|
2660
2686
|
|
|
2661
2687
|
// Add or remove
|
|
2662
2688
|
const idx = this.selected.indexOf( node );
|
|
2663
2689
|
if( idx > -1 ) {
|
|
2664
|
-
item.classList.remove('selected');
|
|
2665
|
-
this.selected.splice(idx, 1);
|
|
2690
|
+
item.classList.remove( 'selected' );
|
|
2691
|
+
this.selected.splice( idx, 1 );
|
|
2666
2692
|
}else {
|
|
2667
|
-
item.classList.add('selected');
|
|
2693
|
+
item.classList.add( 'selected' );
|
|
2668
2694
|
this.selected.push( node );
|
|
2669
2695
|
}
|
|
2670
2696
|
|
|
2671
2697
|
// Only Show children...
|
|
2672
|
-
if(is_parent && node.id.length > 1 /* Strange case... */) {
|
|
2698
|
+
if( is_parent && node.id.length > 1 /* Strange case... */) {
|
|
2673
2699
|
node.closed = false;
|
|
2674
|
-
if(that.onevent) {
|
|
2700
|
+
if( that.onevent ) {
|
|
2675
2701
|
const event = new TreeEvent(TreeEvent.NODE_CARETCHANGED, node, node.closed);
|
|
2676
2702
|
that.onevent( event );
|
|
2677
2703
|
}
|
|
2678
2704
|
that.frefresh( node.id );
|
|
2679
2705
|
}
|
|
2680
2706
|
|
|
2681
|
-
if(that.onevent) {
|
|
2707
|
+
if( that.onevent ) {
|
|
2682
2708
|
const event = new TreeEvent(TreeEvent.NODE_SELECTED, e.shiftKey ? this.selected : node );
|
|
2683
2709
|
event.multiple = e.shiftKey;
|
|
2684
2710
|
that.onevent( event );
|
|
@@ -2686,15 +2712,17 @@ class NodeTree {
|
|
|
2686
2712
|
});
|
|
2687
2713
|
|
|
2688
2714
|
item.addEventListener("dblclick", function() {
|
|
2715
|
+
|
|
2689
2716
|
if( that.options.rename ?? true )
|
|
2690
2717
|
{
|
|
2691
2718
|
// Trigger rename
|
|
2692
2719
|
node.rename = true;
|
|
2693
2720
|
that.refresh();
|
|
2694
2721
|
}
|
|
2722
|
+
|
|
2695
2723
|
if( that.onevent )
|
|
2696
2724
|
{
|
|
2697
|
-
const event = new TreeEvent(TreeEvent.NODE_DBLCLICKED, node);
|
|
2725
|
+
const event = new TreeEvent( TreeEvent.NODE_DBLCLICKED, node );
|
|
2698
2726
|
that.onevent( event );
|
|
2699
2727
|
}
|
|
2700
2728
|
});
|
|
@@ -2704,19 +2732,88 @@ class NodeTree {
|
|
|
2704
2732
|
if(that.onevent) {
|
|
2705
2733
|
const event = new TreeEvent(TreeEvent.NODE_CONTEXTMENU, this.selected.length > 1 ? this.selected : node, e);
|
|
2706
2734
|
event.multiple = this.selected.length > 1;
|
|
2735
|
+
|
|
2736
|
+
LX.addContextMenu( event.multiple ? "Selected Nodes" : event.node.id, event.value, m => {
|
|
2737
|
+
event.panel = m;
|
|
2738
|
+
});
|
|
2739
|
+
|
|
2707
2740
|
that.onevent( event );
|
|
2741
|
+
|
|
2742
|
+
if( ( this.options.addDefault ?? false ) == true )
|
|
2743
|
+
{
|
|
2744
|
+
if( event.panel.items )
|
|
2745
|
+
{
|
|
2746
|
+
event.panel.add( "" );
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
event.panel.add( "Select Children", () => {
|
|
2750
|
+
|
|
2751
|
+
const selectChildren = ( n ) => {
|
|
2752
|
+
|
|
2753
|
+
if( n.closed )
|
|
2754
|
+
{
|
|
2755
|
+
return;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
for( let child of n.children ?? [] )
|
|
2759
|
+
{
|
|
2760
|
+
if( !child )
|
|
2761
|
+
{
|
|
2762
|
+
continue;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
let nodeItem = this.domEl.querySelector( '#' + child.id );
|
|
2766
|
+
nodeItem.classList.add('selected');
|
|
2767
|
+
this.selected.push( child );
|
|
2768
|
+
selectChildren( child );
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
|
|
2772
|
+
// Add childs of the clicked node
|
|
2773
|
+
selectChildren( node );
|
|
2774
|
+
|
|
2775
|
+
} );
|
|
2776
|
+
|
|
2777
|
+
// event.panel.add( "Clone", { callback: () => {
|
|
2778
|
+
|
|
2779
|
+
// } } );
|
|
2780
|
+
|
|
2781
|
+
event.panel.add( "Delete", { callback: () => {
|
|
2782
|
+
|
|
2783
|
+
// It's the root node
|
|
2784
|
+
if( !node.parent )
|
|
2785
|
+
{
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
if( that.onevent ) {
|
|
2790
|
+
const event = new TreeEvent( TreeEvent.NODE_DELETED, node, e );
|
|
2791
|
+
that.onevent( event );
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
// Delete nodes now
|
|
2795
|
+
let childs = node.parent.children;
|
|
2796
|
+
const index = childs.indexOf( node );
|
|
2797
|
+
childs.splice( index, 1 );
|
|
2798
|
+
|
|
2799
|
+
this.refresh();
|
|
2800
|
+
} } );
|
|
2801
|
+
}
|
|
2708
2802
|
}
|
|
2709
2803
|
});
|
|
2710
2804
|
|
|
2711
2805
|
item.addEventListener("keydown", e => {
|
|
2712
|
-
|
|
2713
|
-
|
|
2806
|
+
|
|
2807
|
+
if( node.rename )
|
|
2808
|
+
return;
|
|
2809
|
+
|
|
2714
2810
|
e.preventDefault();
|
|
2811
|
+
|
|
2715
2812
|
if( e.key == "Delete" )
|
|
2716
2813
|
{
|
|
2717
2814
|
// Send event now so we have the info in selected array..
|
|
2718
|
-
if(that.onevent) {
|
|
2719
|
-
const event = new TreeEvent(TreeEvent.NODE_DELETED, this.selected.length > 1 ? this.selected : node, e);
|
|
2815
|
+
if( that.onevent ) {
|
|
2816
|
+
const event = new TreeEvent( TreeEvent.NODE_DELETED, this.selected.length > 1 ? this.selected : node, e );
|
|
2720
2817
|
event.multiple = this.selected.length > 1;
|
|
2721
2818
|
that.onevent( event );
|
|
2722
2819
|
}
|
|
@@ -2734,8 +2831,8 @@ class NodeTree {
|
|
|
2734
2831
|
}
|
|
2735
2832
|
else if( e.key == "ArrowUp" || e.key == "ArrowDown" ) // Unique or zero selected
|
|
2736
2833
|
{
|
|
2737
|
-
var selected = this.selected.length > 1 ? (e.key == "ArrowUp" ? this.selected.shift() : this.selected.pop()) : this.selected[0];
|
|
2738
|
-
var el = this.domEl.querySelector("#" + LX.getSupportedDOMName( selected.id ) );
|
|
2834
|
+
var selected = this.selected.length > 1 ? ( e.key == "ArrowUp" ? this.selected.shift() : this.selected.pop() ) : this.selected[ 0 ];
|
|
2835
|
+
var el = this.domEl.querySelector( "#" + LX.getSupportedDOMName( selected.id ) );
|
|
2739
2836
|
var sibling = e.key == "ArrowUp" ? el.previousSibling : el.nextSibling;
|
|
2740
2837
|
if( sibling ) sibling.click();
|
|
2741
2838
|
}
|
|
@@ -3227,6 +3324,10 @@ class Panel {
|
|
|
3227
3324
|
{
|
|
3228
3325
|
let domName = document.createElement('div');
|
|
3229
3326
|
domName.className = "lexwidgetname";
|
|
3327
|
+
if( options.justifyName )
|
|
3328
|
+
{
|
|
3329
|
+
domName.classList.add( "float-" + options.justifyName );
|
|
3330
|
+
}
|
|
3230
3331
|
domName.innerHTML = name || "";
|
|
3231
3332
|
domName.title = options.title ?? domName.innerHTML;
|
|
3232
3333
|
domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
|
|
@@ -3532,8 +3633,9 @@ class Panel {
|
|
|
3532
3633
|
* placeholder: Add input placeholder
|
|
3533
3634
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3534
3635
|
* inputWidth: Width of the text input
|
|
3535
|
-
* float: Justify text
|
|
3536
3636
|
* skipReset: Don't add the reset value button when value changes
|
|
3637
|
+
* float: Justify input text content
|
|
3638
|
+
* justifyName: Justify name content
|
|
3537
3639
|
*/
|
|
3538
3640
|
|
|
3539
3641
|
addText( name, value, callback, options = {} ) {
|
|
@@ -3857,7 +3959,10 @@ class Panel {
|
|
|
3857
3959
|
|
|
3858
3960
|
if(options.selected == b.value)
|
|
3859
3961
|
buttonEl.classList.add("selected");
|
|
3860
|
-
|
|
3962
|
+
|
|
3963
|
+
if(b.id)
|
|
3964
|
+
buttonEl.id = b.id;
|
|
3965
|
+
|
|
3861
3966
|
buttonEl.innerHTML = (b.icon ? "<a class='" + b.icon +"'></a>" : "") + "<span>" + (b.icon ? "" : b.value) + "</span>";
|
|
3862
3967
|
|
|
3863
3968
|
if(options.disabled)
|
|
@@ -4017,37 +4122,39 @@ class Panel {
|
|
|
4017
4122
|
|
|
4018
4123
|
addDropdown( name, values, value, callback, options = {} ) {
|
|
4019
4124
|
|
|
4020
|
-
let widget = this.create_widget(name, Widget.DROPDOWN, options);
|
|
4125
|
+
let widget = this.create_widget( name, Widget.DROPDOWN, options );
|
|
4126
|
+
|
|
4021
4127
|
widget.onGetValue = () => {
|
|
4022
|
-
return element.querySelector("li.selected").getAttribute('value');
|
|
4128
|
+
return element.querySelector( "li.selected" ).getAttribute( 'value' );
|
|
4023
4129
|
};
|
|
4130
|
+
|
|
4024
4131
|
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4025
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4026
|
-
if(btn) btn.style.display = (newValue != wValue.iValue ? "block" : "none");
|
|
4132
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4133
|
+
if( btn ) btn.style.display = ( newValue != wValue.iValue ? "block" : "none" );
|
|
4027
4134
|
value = newValue;
|
|
4028
|
-
list.querySelectorAll('li').forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
|
|
4029
|
-
if( !skipCallback ) this._trigger( new IEvent(name, value, null), callback );
|
|
4135
|
+
list.querySelectorAll( 'li' ).forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
|
|
4136
|
+
if( !skipCallback ) this._trigger( new IEvent( name, value, null ), callback );
|
|
4030
4137
|
};
|
|
4031
4138
|
|
|
4032
4139
|
let element = widget.domEl;
|
|
4033
4140
|
let that = this;
|
|
4034
4141
|
|
|
4035
4142
|
// Add reset functionality
|
|
4036
|
-
if(widget.name && !(options.skipReset ?? false))
|
|
4143
|
+
if(widget.name && !( options.skipReset ?? false ))
|
|
4037
4144
|
{
|
|
4038
|
-
Panel._add_reset_property(element.domName, function() {
|
|
4145
|
+
Panel._add_reset_property( element.domName, function() {
|
|
4039
4146
|
value = wValue.iValue;
|
|
4040
|
-
list.querySelectorAll('li').forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
|
|
4147
|
+
list.querySelectorAll( 'li' ).forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
|
|
4041
4148
|
this.style.display = "none";
|
|
4042
4149
|
});
|
|
4043
4150
|
}
|
|
4044
4151
|
|
|
4045
|
-
let container = document.createElement('div');
|
|
4152
|
+
let container = document.createElement( 'div' );
|
|
4046
4153
|
container.className = "lexdropdown";
|
|
4047
4154
|
container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
4048
4155
|
|
|
4049
4156
|
// Add widget value
|
|
4050
|
-
let wValue = document.createElement('div');
|
|
4157
|
+
let wValue = document.createElement( 'div' );
|
|
4051
4158
|
wValue.className = "lexdropdown lexoption";
|
|
4052
4159
|
wValue.name = name;
|
|
4053
4160
|
wValue.iValue = value;
|
|
@@ -4058,14 +4165,15 @@ class Panel {
|
|
|
4058
4165
|
|
|
4059
4166
|
this.queue(container);
|
|
4060
4167
|
|
|
4061
|
-
let selectedOption = this.addButton(null, buttonName, (value, event) => {
|
|
4168
|
+
let selectedOption = this.addButton( null, buttonName, (value, event) => {
|
|
4062
4169
|
if( list.unfocus_event ) {
|
|
4063
4170
|
delete list.unfocus_event;
|
|
4064
4171
|
return;
|
|
4065
4172
|
}
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4173
|
+
const topPosition = selectedOption.getBoundingClientRect().y;
|
|
4174
|
+
list.style.top = (topPosition + selectedOption.offsetHeight) + 'px';
|
|
4175
|
+
list.style.width = (event.currentTarget.clientWidth) + 'px';
|
|
4176
|
+
list.toggleAttribute('hidden');
|
|
4069
4177
|
list.focus();
|
|
4070
4178
|
}, { buttonClass: 'array', skipInlineCount: true });
|
|
4071
4179
|
|
|
@@ -4209,7 +4317,14 @@ class Panel {
|
|
|
4209
4317
|
* @param {Function} callback Callback function on change
|
|
4210
4318
|
* @param {*} options:
|
|
4211
4319
|
* skipReset: Don't add the reset value button when value changes
|
|
4212
|
-
|
|
4320
|
+
* bgColor: Widget background color
|
|
4321
|
+
* pointsColor: Curve points color
|
|
4322
|
+
* lineColor: Curve line color
|
|
4323
|
+
* noOverlap: Points do not overlap, replacing themselves if necessary
|
|
4324
|
+
* allowAddValues: Support adding values on click
|
|
4325
|
+
* smooth: Curve smoothness
|
|
4326
|
+
* moveOutAction: Clamp or delete points moved out of the curve (LX.CURVE_MOVEOUT_CLAMP, LX.CURVE_MOVEOUT_DELETE)
|
|
4327
|
+
*/
|
|
4213
4328
|
|
|
4214
4329
|
addCurve( name, values, callback, options = {} ) {
|
|
4215
4330
|
|
|
@@ -4219,34 +4334,36 @@ class Panel {
|
|
|
4219
4334
|
|
|
4220
4335
|
let that = this;
|
|
4221
4336
|
let widget = this.create_widget(name, Widget.CURVE, options);
|
|
4337
|
+
|
|
4222
4338
|
widget.onGetValue = () => {
|
|
4223
|
-
return JSON.parse(JSON.stringify(
|
|
4339
|
+
return JSON.parse(JSON.stringify(curveInstance.element.value));
|
|
4224
4340
|
};
|
|
4341
|
+
|
|
4225
4342
|
widget.onSetValue = ( newValue, skipCallback ) => {
|
|
4226
|
-
let btn = element.querySelector(".lexwidgetname .lexicon");
|
|
4227
|
-
if(btn) btn.style.display = (newValue !=
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
if( !skipCallback ) that._trigger( new IEvent(name,
|
|
4343
|
+
let btn = element.querySelector( ".lexwidgetname .lexicon" );
|
|
4344
|
+
if( btn ) btn.style.display = ( newValue != curveInstance.element.value ? "block" : "none" );
|
|
4345
|
+
curveInstance.element.value = JSON.parse( JSON.stringify( newValue ) );
|
|
4346
|
+
curveInstance.redraw();
|
|
4347
|
+
if( !skipCallback ) that._trigger( new IEvent( name, curveInstance.element.value, null ), callback );
|
|
4231
4348
|
};
|
|
4232
4349
|
|
|
4233
4350
|
let element = widget.domEl;
|
|
4234
|
-
let defaultValues = JSON.parse(JSON.stringify(values));
|
|
4351
|
+
let defaultValues = JSON.parse( JSON.stringify( values ) );
|
|
4235
4352
|
|
|
4236
4353
|
// Add reset functionality
|
|
4237
4354
|
if( !(options.skipReset ?? false) )
|
|
4238
4355
|
{
|
|
4239
4356
|
Panel._add_reset_property(element.domName, function(e) {
|
|
4240
4357
|
this.style.display = "none";
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
that._trigger( new IEvent(name,
|
|
4358
|
+
curveInstance.element.value = JSON.parse( JSON.stringify( defaultValues ) );
|
|
4359
|
+
curveInstance.redraw();
|
|
4360
|
+
that._trigger( new IEvent( name, curveInstance.element.value, e ), callback );
|
|
4244
4361
|
});
|
|
4245
4362
|
}
|
|
4246
4363
|
|
|
4247
4364
|
// Add widget value
|
|
4248
4365
|
|
|
4249
|
-
var container = document.createElement('div');
|
|
4366
|
+
var container = document.createElement( 'div' );
|
|
4250
4367
|
container.className = "lexcurve";
|
|
4251
4368
|
container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
|
|
4252
4369
|
|
|
@@ -4255,16 +4372,18 @@ class Panel {
|
|
|
4255
4372
|
if(btn) btn.style.display = (v != defaultValues ? "block" : "none");
|
|
4256
4373
|
that._trigger( new IEvent(name, v, e), callback );
|
|
4257
4374
|
};
|
|
4375
|
+
|
|
4258
4376
|
options.name = name;
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4377
|
+
|
|
4378
|
+
let curveInstance = new Curve( this, values, options );
|
|
4379
|
+
container.appendChild( curveInstance.element );
|
|
4380
|
+
element.appendChild( container );
|
|
4262
4381
|
|
|
4263
4382
|
// Resize
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
widget.onresize =
|
|
4267
|
-
widget.
|
|
4383
|
+
curveInstance.canvas.width = container.offsetWidth;
|
|
4384
|
+
curveInstance.redraw();
|
|
4385
|
+
widget.onresize = curveInstance.redraw.bind( curveInstance );
|
|
4386
|
+
widget.curveInstance = curveInstance;
|
|
4268
4387
|
return widget;
|
|
4269
4388
|
}
|
|
4270
4389
|
|
|
@@ -4713,19 +4832,19 @@ class Panel {
|
|
|
4713
4832
|
flag.id = "checkbox"+simple_guidGenerator();
|
|
4714
4833
|
flag.innerHTML = "<a class='fa-solid fa-check' style='display: " + (flag.value ? "block" : "none") + "'></a>";
|
|
4715
4834
|
|
|
4716
|
-
if(options.disabled) {
|
|
4835
|
+
if( options.disabled ) {
|
|
4717
4836
|
flag.disabled = true;
|
|
4718
4837
|
toggle.className += " disabled";
|
|
4719
4838
|
}
|
|
4720
4839
|
|
|
4721
|
-
toggle.appendChild(flag);
|
|
4840
|
+
toggle.appendChild( flag );
|
|
4722
4841
|
|
|
4723
|
-
let value_name = document.createElement('span');
|
|
4842
|
+
let value_name = document.createElement( 'span' );
|
|
4724
4843
|
value_name.id = "checkboxtext";
|
|
4725
4844
|
value_name.innerHTML = "On";
|
|
4726
4845
|
|
|
4727
|
-
container.appendChild(toggle);
|
|
4728
|
-
container.appendChild(value_name);
|
|
4846
|
+
container.appendChild( toggle );
|
|
4847
|
+
container.appendChild( value_name );
|
|
4729
4848
|
|
|
4730
4849
|
toggle.addEventListener( "click" , e => {
|
|
4731
4850
|
|
|
@@ -4733,7 +4852,7 @@ class Panel {
|
|
|
4733
4852
|
if( flag.disabled )
|
|
4734
4853
|
return;
|
|
4735
4854
|
|
|
4736
|
-
const skipCallback = e.detail;
|
|
4855
|
+
const skipCallback = ( e.detail.constructor == Number ? null : e.detail );
|
|
4737
4856
|
|
|
4738
4857
|
let check = toggle.querySelector( ".checkbox a" );
|
|
4739
4858
|
|
|
@@ -5426,6 +5545,11 @@ class Panel {
|
|
|
5426
5545
|
callback( files[ 0 ] );
|
|
5427
5546
|
});
|
|
5428
5547
|
|
|
5548
|
+
input.addEventListener( 'cancel', function( e ) {
|
|
5549
|
+
|
|
5550
|
+
callback( null );
|
|
5551
|
+
});
|
|
5552
|
+
|
|
5429
5553
|
element.appendChild( input );
|
|
5430
5554
|
|
|
5431
5555
|
this.queue( element );
|
|
@@ -6388,69 +6512,71 @@ LX.addContextMenu = addContextMenu;
|
|
|
6388
6512
|
|
|
6389
6513
|
class Curve {
|
|
6390
6514
|
|
|
6391
|
-
constructor(panel, value, options = {}) {
|
|
6515
|
+
constructor( panel, value, options = {} ) {
|
|
6392
6516
|
|
|
6393
|
-
let element = document.createElement("div");
|
|
6394
|
-
element.className = "curve " + (options.className ? options.className : "");
|
|
6517
|
+
let element = document.createElement( "div" );
|
|
6518
|
+
element.className = "curve " + ( options.className ? options.className : "" );
|
|
6395
6519
|
element.style.minHeight = "50px";
|
|
6396
6520
|
element.style.width = options.width || "100%";
|
|
6521
|
+
element.style.minWidth = "50px";
|
|
6522
|
+
element.style.minHeight = "20px";
|
|
6397
6523
|
|
|
6398
|
-
element.bgcolor = options.
|
|
6399
|
-
element.pointscolor = options.
|
|
6400
|
-
element.linecolor = options.
|
|
6401
|
-
|
|
6524
|
+
element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
|
|
6525
|
+
element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
|
|
6526
|
+
element.linecolor = options.lineColor || "#555";
|
|
6402
6527
|
element.value = value || [];
|
|
6403
|
-
element.xrange = options.xrange || [0,1]; //min,max
|
|
6404
|
-
element.yrange = options.yrange || [0,1]; //min,max
|
|
6528
|
+
element.xrange = options.xrange || [ 0, 1 ]; // min, max
|
|
6529
|
+
element.yrange = options.yrange || [ 0, 1 ]; // min, max
|
|
6405
6530
|
element.defaulty = options.defaulty != null ? options.defaulty : 0.0;
|
|
6406
|
-
element.
|
|
6407
|
-
element.show_samples = options.
|
|
6408
|
-
element.allow_add_values = options.
|
|
6409
|
-
element.draggable_x = options.
|
|
6410
|
-
element.draggable_y = options.
|
|
6411
|
-
element.smooth = (options.smooth && typeof(options.smooth) == 'number' ? options.smooth : 0.3) || false;
|
|
6412
|
-
element.
|
|
6413
|
-
element.style.minWidth = "50px";
|
|
6414
|
-
element.style.minHeight = "20px";
|
|
6531
|
+
element.no_overlap = options.noOverlap || false;
|
|
6532
|
+
element.show_samples = options.showSamples || 0;
|
|
6533
|
+
element.allow_add_values = options.allowAddValues ?? true;
|
|
6534
|
+
element.draggable_x = options.draggableX ?? true;
|
|
6535
|
+
element.draggable_y = options.draggableY ?? true;
|
|
6536
|
+
element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
|
|
6537
|
+
element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
|
|
6415
6538
|
|
|
6416
6539
|
this.element = element;
|
|
6417
6540
|
|
|
6418
|
-
let canvas = document.createElement("canvas");
|
|
6541
|
+
let canvas = document.createElement( "canvas" );
|
|
6419
6542
|
canvas.width = options.width || 200;
|
|
6420
6543
|
canvas.height = options.height || 50;
|
|
6421
6544
|
element.appendChild( canvas );
|
|
6422
6545
|
this.canvas = canvas;
|
|
6423
6546
|
|
|
6424
|
-
element.addEventListener("mousedown", onmousedown);
|
|
6547
|
+
element.addEventListener( "mousedown", onmousedown );
|
|
6425
6548
|
|
|
6426
|
-
element.getValueAt = function(x) {
|
|
6549
|
+
element.getValueAt = function( x ) {
|
|
6427
6550
|
|
|
6428
|
-
if(x < element.xrange[0] || x > element.xrange[1])
|
|
6551
|
+
if( x < element.xrange[ 0 ] || x > element.xrange[ 1 ] )
|
|
6552
|
+
{
|
|
6429
6553
|
return element.defaulty;
|
|
6554
|
+
}
|
|
6430
6555
|
|
|
6431
|
-
var last = [ element.xrange[0], element.defaulty ];
|
|
6556
|
+
var last = [ element.xrange[ 0 ], element.defaulty ];
|
|
6432
6557
|
var f = 0;
|
|
6433
|
-
for(var i = 0; i < element.value.length; i += 1)
|
|
6558
|
+
for( var i = 0; i < element.value.length; i += 1 )
|
|
6434
6559
|
{
|
|
6435
|
-
var v = element.value[i];
|
|
6436
|
-
if(x == v[0]) return v[1];
|
|
6437
|
-
if(x < v[0])
|
|
6560
|
+
var v = element.value[ i ];
|
|
6561
|
+
if( x == v[ 0 ] ) return v[ 1 ];
|
|
6562
|
+
if( x < v[ 0 ] )
|
|
6438
6563
|
{
|
|
6439
|
-
f = (x - last[0]) / (v[0] - last[0]);
|
|
6440
|
-
return last[1] * (1-f) + v[1] * f;
|
|
6564
|
+
f = ( x - last[ 0 ] ) / (v[ 0 ] - last[ 0 ]);
|
|
6565
|
+
return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
|
|
6441
6566
|
}
|
|
6567
|
+
|
|
6442
6568
|
last = v;
|
|
6443
6569
|
}
|
|
6444
6570
|
|
|
6445
|
-
v = [ element.xrange[1], element.defaulty ];
|
|
6446
|
-
f = (x - last[0]) / (v[0] - last[0]);
|
|
6447
|
-
return last[1] * (1-f) + v[1] * f;
|
|
6571
|
+
v = [ element.xrange[ 1 ], element.defaulty ];
|
|
6572
|
+
f = (x - last[ 0 ]) / (v[ 0 ] - last[ 0 ]);
|
|
6573
|
+
return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
|
|
6448
6574
|
}
|
|
6449
6575
|
|
|
6450
|
-
element.resample = function(samples) {
|
|
6576
|
+
element.resample = function( samples ) {
|
|
6451
6577
|
|
|
6452
6578
|
var r = [];
|
|
6453
|
-
var dx = (element.xrange[1] - element.xrange[0]) / samples;
|
|
6579
|
+
var dx = (element.xrange[1] - element.xrange[ 0 ]) / samples;
|
|
6454
6580
|
for(var i = element.xrange[0]; i <= element.xrange[1]; i += dx)
|
|
6455
6581
|
{
|
|
6456
6582
|
r.push( element.getValueAt(i) );
|
|
@@ -6476,37 +6602,33 @@ class Curve {
|
|
|
6476
6602
|
function convert(v) {
|
|
6477
6603
|
return [ canvas.width * ( v[0] - element.xrange[0])/ (element.xrange[1]),
|
|
6478
6604
|
canvas.height * (v[1] - element.yrange[0])/ (element.yrange[1])];
|
|
6479
|
-
// return [ canvas.width * ( (element.xrange[1] - element.xrange[0]) * v[0] + element.xrange[0]),
|
|
6480
|
-
// canvas.height * ((element.yrange[1] - element.yrange[0]) * v[1] + element.yrange[0])];
|
|
6481
6605
|
}
|
|
6482
6606
|
|
|
6483
6607
|
//canvas to value
|
|
6484
6608
|
function unconvert(v) {
|
|
6485
6609
|
return [(v[0] * element.xrange[1] / canvas.width + element.xrange[0]),
|
|
6486
6610
|
(v[1] * element.yrange[1] / canvas.height + element.yrange[0])];
|
|
6487
|
-
// return [(v[0] / canvas.width - element.xrange[0]) / (element.xrange[1] - element.xrange[0]),
|
|
6488
|
-
// (v[1] / canvas.height - element.yrange[0]) / (element.yrange[1] - element.yrange[0])];
|
|
6489
6611
|
}
|
|
6490
6612
|
|
|
6491
6613
|
var selected = -1;
|
|
6492
6614
|
|
|
6493
|
-
element.redraw = function(o = {} ) {
|
|
6615
|
+
element.redraw = function( o = {} ) {
|
|
6494
6616
|
|
|
6495
|
-
if(o.value) element.value = o.value;
|
|
6496
|
-
if(o.xrange) element.xrange = o.xrange;
|
|
6497
|
-
if(o.yrange) element.yrange = o.yrange;
|
|
6498
|
-
if(o.smooth) element.smooth = o.smooth;
|
|
6617
|
+
if( o.value ) element.value = o.value;
|
|
6618
|
+
if( o.xrange ) element.xrange = o.xrange;
|
|
6619
|
+
if( o.yrange ) element.yrange = o.yrange;
|
|
6620
|
+
if( o.smooth ) element.smooth = o.smooth;
|
|
6499
6621
|
var rect = canvas.parentElement.getBoundingClientRect();
|
|
6500
|
-
if(canvas.parentElement.parentElement) rect = canvas.parentElement.parentElement.getBoundingClientRect();
|
|
6501
|
-
if(rect && canvas.width != rect.width && rect.width && rect.width < 1000)
|
|
6622
|
+
if( canvas.parentElement.parentElement ) rect = canvas.parentElement.parentElement.getBoundingClientRect();
|
|
6623
|
+
if( rect && canvas.width != rect.width && rect.width && rect.width < 1000 )
|
|
6624
|
+
{
|
|
6502
6625
|
canvas.width = rect.width;
|
|
6503
|
-
|
|
6504
|
-
// canvas.height = rect.height;
|
|
6626
|
+
}
|
|
6505
6627
|
|
|
6506
|
-
var ctx = canvas.getContext("2d");
|
|
6507
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
6508
|
-
ctx.translate(0,canvas.height);
|
|
6509
|
-
ctx.scale(1
|
|
6628
|
+
var ctx = canvas.getContext( "2d" );
|
|
6629
|
+
ctx.setTransform( 1, 0, 0, 1, 0, 0 );
|
|
6630
|
+
ctx.translate( 0, canvas.height );
|
|
6631
|
+
ctx.scale( 1, -1 );
|
|
6510
6632
|
|
|
6511
6633
|
ctx.fillStyle = element.bgcolor;
|
|
6512
6634
|
ctx.fillRect(0,0,canvas.width,canvas.height);
|
|
@@ -6515,40 +6637,42 @@ class Curve {
|
|
|
6515
6637
|
ctx.beginPath();
|
|
6516
6638
|
|
|
6517
6639
|
//draw line
|
|
6518
|
-
var pos = convert([element.xrange[0],element.defaulty]);
|
|
6519
|
-
ctx.moveTo( pos[0], pos[1] );
|
|
6520
|
-
let values = [pos[0], pos[1]];
|
|
6640
|
+
var pos = convert([ element.xrange[ 0 ],element.defaulty ]);
|
|
6641
|
+
ctx.moveTo( pos[ 0 ], pos[ 1 ] );
|
|
6642
|
+
let values = [pos[ 0 ], pos[ 1 ]];
|
|
6521
6643
|
|
|
6522
6644
|
for(var i in element.value) {
|
|
6523
6645
|
var value = element.value[i];
|
|
6524
6646
|
pos = convert(value);
|
|
6525
|
-
values.push(pos[0]);
|
|
6526
|
-
values.push(pos[1]);
|
|
6647
|
+
values.push(pos[ 0 ]);
|
|
6648
|
+
values.push(pos[ 1 ]);
|
|
6527
6649
|
if(!element.smooth)
|
|
6528
|
-
ctx.lineTo( pos[0], pos[1] );
|
|
6650
|
+
ctx.lineTo( pos[ 0 ], pos[ 1 ] );
|
|
6529
6651
|
}
|
|
6530
6652
|
|
|
6531
|
-
pos = convert([element.xrange[1],element.defaulty]);
|
|
6532
|
-
values.push(pos[0]);
|
|
6533
|
-
values.push(pos[1]);
|
|
6534
|
-
if(!element.smooth)
|
|
6535
|
-
|
|
6653
|
+
pos = convert([ element.xrange[ 1 ], element.defaulty ]);
|
|
6654
|
+
values.push(pos[ 0 ]);
|
|
6655
|
+
values.push(pos[ 1 ]);
|
|
6656
|
+
if( !element.smooth )
|
|
6657
|
+
{
|
|
6658
|
+
ctx.lineTo( pos[ 0 ], pos[ 1 ] );
|
|
6536
6659
|
ctx.stroke();
|
|
6537
|
-
}
|
|
6538
|
-
|
|
6539
|
-
|
|
6660
|
+
}
|
|
6661
|
+
else
|
|
6662
|
+
{
|
|
6663
|
+
LX.UTILS.drawSpline( ctx, values, element.smooth );
|
|
6540
6664
|
}
|
|
6541
6665
|
|
|
6542
|
-
//
|
|
6543
|
-
for(var i = 0; i < element.value.length; i += 1) {
|
|
6544
|
-
var value = element.value[i];
|
|
6545
|
-
pos = convert(value);
|
|
6546
|
-
if(selected == i)
|
|
6666
|
+
// Draw points
|
|
6667
|
+
for( var i = 0; i < element.value.length; i += 1 ) {
|
|
6668
|
+
var value = element.value[ i ];
|
|
6669
|
+
pos = convert( value );
|
|
6670
|
+
if( selected == i )
|
|
6547
6671
|
ctx.fillStyle = "white";
|
|
6548
6672
|
else
|
|
6549
6673
|
ctx.fillStyle = element.pointscolor;
|
|
6550
6674
|
ctx.beginPath();
|
|
6551
|
-
ctx.arc( pos[0], pos[1], selected == i ? 4 : 3, 0, Math.PI * 2);
|
|
6675
|
+
ctx.arc( pos[ 0 ], pos[ 1 ], selected == i ? 4 : 3, 0, Math.PI * 2);
|
|
6552
6676
|
ctx.fill();
|
|
6553
6677
|
}
|
|
6554
6678
|
|
|
@@ -6557,120 +6681,134 @@ class Curve {
|
|
|
6557
6681
|
ctx.fillStyle = "#888";
|
|
6558
6682
|
for(var i = 0; i < samples.length; i += 1)
|
|
6559
6683
|
{
|
|
6560
|
-
var value = [ i * ((element.xrange[1] - element.xrange[0]) / element.show_samples) + element.xrange[0], samples[i] ];
|
|
6684
|
+
var value = [ i * ((element.xrange[ 1 ] - element.xrange[ 0 ]) / element.show_samples) + element.xrange[ 0 ], samples[ i ] ];
|
|
6561
6685
|
pos = convert(value);
|
|
6562
6686
|
ctx.beginPath();
|
|
6563
|
-
ctx.arc( pos[0], pos[1], 2, 0, Math.PI * 2);
|
|
6687
|
+
ctx.arc( pos[ 0 ], pos[ 1 ], 2, 0, Math.PI * 2);
|
|
6564
6688
|
ctx.fill();
|
|
6565
6689
|
}
|
|
6566
6690
|
}
|
|
6567
6691
|
}
|
|
6568
6692
|
|
|
6569
|
-
var last_mouse = [0,0];
|
|
6693
|
+
var last_mouse = [ 0, 0 ];
|
|
6570
6694
|
|
|
6571
|
-
function onmousedown(
|
|
6572
|
-
document.addEventListener("mousemove",onmousemove);
|
|
6573
|
-
document.addEventListener("mouseup",onmouseup);
|
|
6695
|
+
function onmousedown( e ) {
|
|
6696
|
+
document.addEventListener( "mousemove", onmousemove );
|
|
6697
|
+
document.addEventListener( "mouseup", onmouseup );
|
|
6574
6698
|
|
|
6575
6699
|
var rect = canvas.getBoundingClientRect();
|
|
6576
|
-
var mousex =
|
|
6577
|
-
var mousey =
|
|
6700
|
+
var mousex = e.clientX - rect.left;
|
|
6701
|
+
var mousey = e.clientY - rect.top;
|
|
6578
6702
|
|
|
6579
|
-
selected = computeSelected(mousex,canvas.height-mousey);
|
|
6703
|
+
selected = computeSelected( mousex, canvas.height - mousey );
|
|
6580
6704
|
|
|
6581
6705
|
if(selected == -1 && element.allow_add_values) {
|
|
6582
|
-
var v = unconvert([mousex,canvas.height-mousey]);
|
|
6706
|
+
var v = unconvert([ mousex, canvas.height-mousey ]);
|
|
6583
6707
|
element.value.push(v);
|
|
6584
6708
|
sortValues();
|
|
6585
6709
|
selected = element.value.indexOf(v);
|
|
6586
6710
|
}
|
|
6587
6711
|
|
|
6588
|
-
last_mouse = [mousex,mousey];
|
|
6712
|
+
last_mouse = [ mousex, mousey ];
|
|
6589
6713
|
element.redraw();
|
|
6590
|
-
|
|
6591
|
-
|
|
6714
|
+
e.preventDefault();
|
|
6715
|
+
e.stopPropagation();
|
|
6592
6716
|
}
|
|
6593
6717
|
|
|
6594
|
-
function onmousemove(
|
|
6718
|
+
function onmousemove( e ) {
|
|
6719
|
+
|
|
6595
6720
|
var rect = canvas.getBoundingClientRect();
|
|
6596
|
-
var mousex =
|
|
6597
|
-
var mousey =
|
|
6721
|
+
var mousex = e.clientX - rect.left;
|
|
6722
|
+
var mousey = e.clientY - rect.top;
|
|
6598
6723
|
|
|
6599
|
-
if(mousex < 0) mousex = 0;
|
|
6600
|
-
else if(mousex > canvas.width) mousex = canvas.width;
|
|
6601
|
-
if(mousey < 0) mousey = 0;
|
|
6602
|
-
else if(mousey > canvas.height) mousey = canvas.height;
|
|
6724
|
+
if( mousex < 0 ) mousex = 0;
|
|
6725
|
+
else if( mousex > canvas.width ) mousex = canvas.width;
|
|
6726
|
+
if( mousey < 0 ) mousey = 0;
|
|
6727
|
+
else if( mousey > canvas.height ) mousey = canvas.height;
|
|
6603
6728
|
|
|
6604
|
-
//
|
|
6605
|
-
|
|
6729
|
+
// Dragging to remove
|
|
6730
|
+
const currentMouseDiff = [ e.clientX - rect.left, e.clientY - rect.top ];
|
|
6731
|
+
if( selected != -1 && distance( currentMouseDiff, [ mousex, mousey ] ) > canvas.height * 0.5 )
|
|
6606
6732
|
{
|
|
6607
|
-
element.
|
|
6608
|
-
|
|
6733
|
+
if( element.move_out == LX.CURVE_MOVEOUT_DELETE)
|
|
6734
|
+
{
|
|
6735
|
+
element.value.splice( selected, 1 );
|
|
6736
|
+
}
|
|
6737
|
+
else
|
|
6738
|
+
{
|
|
6739
|
+
const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
|
|
6740
|
+
let value = element.value[ selected ];
|
|
6741
|
+
value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 1 ] : element.xrange[ 0 ] );
|
|
6742
|
+
value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
|
|
6743
|
+
}
|
|
6744
|
+
|
|
6745
|
+
onmouseup( e );
|
|
6609
6746
|
return;
|
|
6610
6747
|
}
|
|
6611
6748
|
|
|
6612
|
-
var dx = element.draggable_x ? last_mouse[0] - mousex : 0;
|
|
6613
|
-
var dy = element.draggable_y ? last_mouse[1] - mousey : 0;
|
|
6614
|
-
var delta = unconvert([-dx,dy]);
|
|
6615
|
-
if(selected != -1) {
|
|
6616
|
-
var minx = element.xrange[0];
|
|
6617
|
-
var maxx = element.xrange[1];
|
|
6749
|
+
var dx = element.draggable_x ? last_mouse[ 0 ] - mousex : 0;
|
|
6750
|
+
var dy = element.draggable_y ? last_mouse[ 1 ] - mousey : 0;
|
|
6751
|
+
var delta = unconvert([ -dx, dy ]);
|
|
6618
6752
|
|
|
6619
|
-
|
|
6753
|
+
if( selected != -1 ) {
|
|
6754
|
+
var minx = element.xrange[ 0 ];
|
|
6755
|
+
var maxx = element.xrange[ 1 ];
|
|
6756
|
+
|
|
6757
|
+
if( element.no_overlap )
|
|
6620
6758
|
{
|
|
6621
|
-
if(selected > 0) minx = element.value[selected-1][0];
|
|
6622
|
-
if(selected < (element.value.length-1) ) maxx = element.value[selected+1][0];
|
|
6759
|
+
if( selected > 0) minx = element.value[ selected - 1 ][ 0 ];
|
|
6760
|
+
if( selected < ( element.value.length - 1 ) ) maxx = element.value[ selected + 1 ][ 0 ];
|
|
6623
6761
|
}
|
|
6624
6762
|
|
|
6625
6763
|
var v = element.value[selected];
|
|
6626
|
-
v[0] += delta[0];
|
|
6627
|
-
v[1] += delta[1];
|
|
6628
|
-
if(v[0] < minx) v[0] = minx;
|
|
6629
|
-
else if(v[0] > maxx) v[0] = maxx;
|
|
6630
|
-
if(v[1] < element.yrange[0]) v[1] = element.yrange[0];
|
|
6631
|
-
else if(v[1] > element.yrange[1]) v[1] = element.yrange[1];
|
|
6764
|
+
v[ 0 ] += delta[ 0 ];
|
|
6765
|
+
v[ 1 ] += delta[ 1 ];
|
|
6766
|
+
if(v[ 0 ] < minx) v[ 0 ] = minx;
|
|
6767
|
+
else if(v[ 0 ] > maxx) v[ 0 ] = maxx;
|
|
6768
|
+
if(v[ 1 ] < element.yrange[ 0 ]) v[ 1 ] = element.yrange[ 0 ];
|
|
6769
|
+
else if(v[ 1 ] > element.yrange[ 1 ]) v[ 1 ] = element.yrange[ 1 ];
|
|
6632
6770
|
}
|
|
6633
6771
|
|
|
6634
6772
|
sortValues();
|
|
6635
6773
|
element.redraw();
|
|
6636
|
-
last_mouse[0] = mousex;
|
|
6637
|
-
last_mouse[1] = mousey;
|
|
6638
|
-
onchange(
|
|
6774
|
+
last_mouse[ 0 ] = mousex;
|
|
6775
|
+
last_mouse[ 1 ] = mousey;
|
|
6776
|
+
onchange( e );
|
|
6639
6777
|
|
|
6640
|
-
|
|
6641
|
-
|
|
6778
|
+
e.preventDefault();
|
|
6779
|
+
e.stopPropagation();
|
|
6642
6780
|
}
|
|
6643
6781
|
|
|
6644
|
-
function onmouseup(
|
|
6782
|
+
function onmouseup( e ) {
|
|
6645
6783
|
selected = -1;
|
|
6646
6784
|
element.redraw();
|
|
6647
6785
|
document.removeEventListener("mousemove", onmousemove);
|
|
6648
6786
|
document.removeEventListener("mouseup", onmouseup);
|
|
6649
|
-
onchange(
|
|
6650
|
-
|
|
6651
|
-
|
|
6787
|
+
onchange(e);
|
|
6788
|
+
e.preventDefault();
|
|
6789
|
+
e.stopPropagation();
|
|
6652
6790
|
}
|
|
6653
6791
|
|
|
6654
|
-
function onchange(e) {
|
|
6655
|
-
if(options.callback)
|
|
6656
|
-
options.callback.call(element, element.value, e);
|
|
6792
|
+
function onchange( e ) {
|
|
6793
|
+
if( options.callback )
|
|
6794
|
+
options.callback.call( element, element.value, e );
|
|
6657
6795
|
}
|
|
6658
6796
|
|
|
6659
6797
|
function distance(a,b) { return Math.sqrt( Math.pow(b[0]-a[0],2) + Math.pow(b[1]-a[1],2) ); };
|
|
6660
6798
|
|
|
6661
|
-
function computeSelected(x,y) {
|
|
6799
|
+
function computeSelected( x, y ) {
|
|
6662
6800
|
|
|
6663
|
-
var
|
|
6664
|
-
var
|
|
6801
|
+
var minDistance = 100000;
|
|
6802
|
+
var maxDistance = 8; //pixels
|
|
6665
6803
|
var selected = -1;
|
|
6666
|
-
for(var i=0; i < element.value.length; i++)
|
|
6804
|
+
for( var i = 0; i < element.value.length; i++ )
|
|
6667
6805
|
{
|
|
6668
|
-
var value = element.value[i];
|
|
6669
|
-
var pos = convert(value);
|
|
6670
|
-
var dist = distance([x,y],pos);
|
|
6671
|
-
if(dist <
|
|
6806
|
+
var value = element.value[ i ];
|
|
6807
|
+
var pos = convert( value );
|
|
6808
|
+
var dist = distance( [ x,y ], pos );
|
|
6809
|
+
if( dist < minDistance && dist < maxDistance )
|
|
6672
6810
|
{
|
|
6673
|
-
|
|
6811
|
+
minDistance = dist;
|
|
6674
6812
|
selected = i;
|
|
6675
6813
|
}
|
|
6676
6814
|
}
|
|
@@ -6679,19 +6817,23 @@ class Curve {
|
|
|
6679
6817
|
|
|
6680
6818
|
function sortValues() {
|
|
6681
6819
|
var v = null;
|
|
6682
|
-
if(selected != -1)
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6820
|
+
if( selected != -1 )
|
|
6821
|
+
{
|
|
6822
|
+
v = element.value[ selected ];
|
|
6823
|
+
}
|
|
6824
|
+
element.value.sort(function( a,b ) { return a[ 0 ] - b[ 0 ]; });
|
|
6825
|
+
if( v )
|
|
6826
|
+
{
|
|
6827
|
+
selected = element.value.indexOf( v );
|
|
6828
|
+
}
|
|
6687
6829
|
}
|
|
6688
6830
|
|
|
6689
6831
|
element.redraw();
|
|
6690
6832
|
return this;
|
|
6691
6833
|
}
|
|
6692
6834
|
|
|
6693
|
-
redraw(options = {}) {
|
|
6694
|
-
this.element.redraw(options);
|
|
6835
|
+
redraw( options = {} ) {
|
|
6836
|
+
this.element.redraw( options );
|
|
6695
6837
|
}
|
|
6696
6838
|
}
|
|
6697
6839
|
|
|
@@ -6706,6 +6848,7 @@ class AssetViewEvent {
|
|
|
6706
6848
|
static ASSET_CLONED = 4;
|
|
6707
6849
|
static ASSET_DBLCLICKED = 5;
|
|
6708
6850
|
static ENTER_FOLDER = 6;
|
|
6851
|
+
static ASSET_CHECKED = 7;
|
|
6709
6852
|
|
|
6710
6853
|
constructor( type, item, value ) {
|
|
6711
6854
|
this.type = type || TreeEvent.NONE;
|
|
@@ -6723,6 +6866,7 @@ class AssetViewEvent {
|
|
|
6723
6866
|
case AssetViewEvent.ASSET_CLONED: return "assetview_event_cloned";
|
|
6724
6867
|
case AssetViewEvent.ASSET_DBLCLICKED: return "assetview_event_dblclicked";
|
|
6725
6868
|
case AssetViewEvent.ENTER_FOLDER: return "assetview_event_enter_folder";
|
|
6869
|
+
case AssetViewEvent.ASSET_CHECKED: return "assetview_event_checked";
|
|
6726
6870
|
}
|
|
6727
6871
|
}
|
|
6728
6872
|
};
|
|
@@ -6746,7 +6890,7 @@ class AssetView {
|
|
|
6746
6890
|
constructor( options = {} ) {
|
|
6747
6891
|
|
|
6748
6892
|
this.rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
6749
|
-
this.layout = AssetView.LAYOUT_CONTENT;
|
|
6893
|
+
this.layout = options.layout ?? AssetView.LAYOUT_CONTENT;
|
|
6750
6894
|
this.contentPage = 1;
|
|
6751
6895
|
|
|
6752
6896
|
if(options.root_path)
|
|
@@ -7081,6 +7225,27 @@ class AssetView {
|
|
|
7081
7225
|
itemEl.tabIndex = -1;
|
|
7082
7226
|
that.content.appendChild(itemEl);
|
|
7083
7227
|
|
|
7228
|
+
if(item.selected != undefined) {
|
|
7229
|
+
let span = document.createElement('span');
|
|
7230
|
+
span.className = "lexcheckbox";
|
|
7231
|
+
let checkbox_input = document.createElement('input');
|
|
7232
|
+
checkbox_input.type = "checkbox";
|
|
7233
|
+
checkbox_input.className = "checkbox";
|
|
7234
|
+
checkbox_input.checked = item.selected;
|
|
7235
|
+
checkbox_input.addEventListener('change', (e, v) => {
|
|
7236
|
+
item.selected = !item.selected;
|
|
7237
|
+
if(that.onevent) {
|
|
7238
|
+
const event = new AssetViewEvent(AssetViewEvent.ASSET_CHECKED, e.shiftKey ? [item] : item );
|
|
7239
|
+
event.multiple = !!e.shiftKey;
|
|
7240
|
+
that.onevent( event );
|
|
7241
|
+
}
|
|
7242
|
+
e.stopPropagation();
|
|
7243
|
+
e.stopImmediatePropagation();
|
|
7244
|
+
})
|
|
7245
|
+
span.appendChild(checkbox_input);
|
|
7246
|
+
itemEl.appendChild(span);
|
|
7247
|
+
|
|
7248
|
+
}
|
|
7084
7249
|
let title = document.createElement('span');
|
|
7085
7250
|
title.className = "lexassettitle";
|
|
7086
7251
|
title.innerText = item.id;
|