perfect-gui 4.9.9 → 4.10.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/dist/perfect-gui.mjs +646 -421
- package/dist/perfect-gui.umd.js +404 -293
- package/package.json +1 -1
- package/src/Slider.js +242 -0
- package/src/index.js +20 -6
- package/src/styles/_button.js +21 -0
- package/src/styles/_color.js +36 -0
- package/src/styles/_folder.js +56 -0
- package/src/styles/_image.js +54 -0
- package/src/styles/_list.js +35 -0
- package/src/styles/_slider.js +92 -0
- package/src/styles/_switch.js +35 -0
- package/src/styles/_vector2.js +63 -0
- package/src/styles/styles.js +156 -0
- package/src/styles.js +0 -421
package/dist/perfect-gui.mjs
CHANGED
|
@@ -1,200 +1,325 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
border-radius: 10px;
|
|
56
|
-
box-sizing: border-box;
|
|
57
|
-
border: 1px solid #2f2f2f;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.p-gui--collapsed {
|
|
61
|
-
height: 0;
|
|
62
|
-
padding: 21px 10px 0 10px;
|
|
63
|
-
overflow: hidden;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.p-gui__header {
|
|
67
|
-
position: absolute;
|
|
68
|
-
top: 0;
|
|
69
|
-
left: 0;
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 20px;
|
|
72
|
-
background-color: rgba(0, 0, 0, .8);
|
|
73
|
-
cursor: grab;
|
|
74
|
-
color: grey;
|
|
75
|
-
font-size: 10px;
|
|
76
|
-
line-height: 20px;
|
|
77
|
-
padding-left: 12px;
|
|
78
|
-
box-sizing: border-box;
|
|
79
|
-
touch-action: none;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.p-gui__header-close {
|
|
83
|
-
width: 20px;
|
|
84
|
-
height: 20px;
|
|
85
|
-
position: absolute;
|
|
86
|
-
top: 0;
|
|
87
|
-
right: 5px;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
|
|
90
|
-
background-size: 50% 50%;
|
|
91
|
-
background-position: center;
|
|
92
|
-
background-repeat: no-repeat;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.p-gui--collapsed .p-gui__header-close {
|
|
96
|
-
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.p-gui__image-container {
|
|
100
|
-
width: 100%;
|
|
101
|
-
padding: 3px;
|
|
102
|
-
display: flex;
|
|
103
|
-
justify-content: flex-start;
|
|
104
|
-
flex-wrap: wrap;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.p-gui__image {
|
|
108
|
-
background-size: cover;
|
|
109
|
-
cursor: pointer;
|
|
110
|
-
position: relative;
|
|
111
|
-
margin: 1px 2.5px 19px 2.5px;
|
|
112
|
-
border-radius: var(--main-border-radius);
|
|
113
|
-
flex: 0 0 calc(33.333% - 5px);
|
|
114
|
-
height: 90px;
|
|
115
|
-
background-position: center;
|
|
1
|
+
class A {
|
|
2
|
+
constructor(e = {}, t) {
|
|
3
|
+
if (this.propReferences = [], typeof e != "object")
|
|
4
|
+
throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
|
|
5
|
+
let o = typeof e.name == "string" && e.name || " ";
|
|
6
|
+
this.isObject = !1;
|
|
7
|
+
let a = null;
|
|
8
|
+
this.obj = e.obj, this.prop = e.prop;
|
|
9
|
+
let l = typeof e.value == "number" ? e.value : null;
|
|
10
|
+
if (this.min = e.min ?? 0, this.max = e.max ?? 1, this.step = e.step || (this.max - this.min) / 100, l !== null)
|
|
11
|
+
(this.prop != null || this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
|
|
12
|
+
else if (this.prop != null && this.obj != null) {
|
|
13
|
+
if (typeof this.prop != "string")
|
|
14
|
+
throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof this.prop}.`);
|
|
15
|
+
if (typeof this.obj != "object")
|
|
16
|
+
throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof this.obj}.`);
|
|
17
|
+
o == " " && (o = this.prop), a = this.propReferences.push(this.obj[this.prop]) - 1, this.isObject = !0;
|
|
18
|
+
} else
|
|
19
|
+
(this.prop != null && this.obj == null || this.prop == null && this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), l = (this.max - this.min) / 2;
|
|
20
|
+
this.imageContainer = null;
|
|
21
|
+
const i = document.createElement("div");
|
|
22
|
+
i.className = "p-gui__slider";
|
|
23
|
+
const r = document.createElement("div");
|
|
24
|
+
r.className = "p-gui__slider-name", r.textContent = o, i.append(r), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), i.append(this.ctrlDiv);
|
|
25
|
+
const n = document.createElement("div");
|
|
26
|
+
return n.className = "p-gui__slider-bar", this.ctrlDiv.append(n), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", n.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : l, i.append(this.valueInput), setTimeout(() => {
|
|
27
|
+
const s = this.handle.offsetWidth;
|
|
28
|
+
this.handle.position = this._mapLinear(this.valueInput.value, this.min, this.max, s / 2, 88 - s / 2), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
|
|
29
|
+
}, 0), this.valueInput.addEventListener("change", () => {
|
|
30
|
+
this._updateHandlePositionFromValue(), this._triggerCallbacks();
|
|
31
|
+
}), this.ctrlDiv.addEventListener("pointerdown", (s) => {
|
|
32
|
+
this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = s.clientX, this._updateHandlePositionFromPointer(s, !0);
|
|
33
|
+
}), window.addEventListener("pointerup", (s) => {
|
|
34
|
+
this.ctrlDiv.pointerDown = !1;
|
|
35
|
+
}), window.addEventListener("pointermove", (s) => {
|
|
36
|
+
this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = s.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(s));
|
|
37
|
+
}), this.isObject && Object.defineProperty(this.obj, this.prop, {
|
|
38
|
+
set: (s) => {
|
|
39
|
+
this.propReferences[a] = s, this.valueInput.value = s, this._updateHandlePositionFromValue(), typeof t == "function" && t(parseFloat(this.valueInput.value));
|
|
40
|
+
},
|
|
41
|
+
get: () => this.propReferences[a]
|
|
42
|
+
}), i;
|
|
43
|
+
}
|
|
44
|
+
_updateHandlePositionFromPointer(e, t = !1) {
|
|
45
|
+
const o = this.ctrlDiv.offsetWidth, a = this.handle.offsetWidth, l = e.clientX - this.ctrlDiv.prevPosition;
|
|
46
|
+
let i;
|
|
47
|
+
const r = parseFloat(this.valueInput.value);
|
|
48
|
+
t ? i = e.offsetX : i = this.handle.position + l, i = Math.max(a / 2, Math.min(i, o - a / 2));
|
|
49
|
+
let n = this.min + (this.max - this.min) * (i - a / 2) / (o - a);
|
|
50
|
+
n > r ? n = this._quantizeFloor(n, this.step) : n = this._quantizeCeil(n, this.step), n = parseFloat(n.toFixed(9));
|
|
51
|
+
const s = parseFloat((r + this.step).toFixed(9)), d = parseFloat((r - this.step).toFixed(9));
|
|
52
|
+
if (n >= s || n <= d) {
|
|
53
|
+
const f = this._countDecimals(this.step);
|
|
54
|
+
n = n.toFixed(f), this.valueInput.value = n, this.ctrlDiv.prevPosition = e.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${i}px)`, this.handle.position = i, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks();
|
|
116
55
|
}
|
|
56
|
+
}
|
|
57
|
+
_countDecimals(e) {
|
|
58
|
+
const t = e.toString(), o = t.indexOf(".");
|
|
59
|
+
return o === -1 ? 0 : t.length - o - 1;
|
|
60
|
+
}
|
|
61
|
+
_updateHandlePositionFromValue() {
|
|
62
|
+
const e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth;
|
|
63
|
+
let o = this._mapLinear(this.valueInput.value, this.min, this.max, t / 2, e - t / 2);
|
|
64
|
+
o = Math.max(t / 2, Math.min(o, e - t / 2)), this.handle.style.transform = `translate(-50%, -50%) translateX(${o}px)`, this.handle.position = o, this.filling.style.width = this.handle.position + "px";
|
|
65
|
+
}
|
|
66
|
+
_triggerCallbacks() {
|
|
67
|
+
this.isObject ? this.obj[this.prop] = parseFloat(this.valueInput.value) : typeof callback == "function" && callback(parseFloat(this.valueInput.value)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
68
|
+
}
|
|
69
|
+
_mapLinear(e, t, o, a, l) {
|
|
70
|
+
return a + (e - t) * (l - a) / (o - t);
|
|
71
|
+
}
|
|
72
|
+
_quantize(e, t) {
|
|
73
|
+
return t * Math.round(e / t);
|
|
74
|
+
}
|
|
75
|
+
_quantizeCeil(e, t) {
|
|
76
|
+
return t * Math.ceil(e / t);
|
|
77
|
+
}
|
|
78
|
+
_quantizeFloor(e, t) {
|
|
79
|
+
return t * Math.floor(e / t);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const E = (
|
|
83
|
+
/* css */
|
|
84
|
+
`
|
|
85
|
+
.p-gui__button {
|
|
86
|
+
background: var(--color-accent);
|
|
87
|
+
text-align: center;
|
|
88
|
+
color: white;
|
|
89
|
+
border: none;
|
|
90
|
+
border: 1px solid transparent;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
transition: var(--transition) background, var(--transition) border-color;
|
|
93
|
+
}
|
|
117
94
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
height: 100%;
|
|
124
|
-
content: '';
|
|
125
|
-
border: 1px solid #06FF89;
|
|
126
|
-
box-sizing: border-box;
|
|
127
|
-
border-radius: var(--main-border-radius);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.p-gui__image-text {
|
|
131
|
-
position: absolute;
|
|
132
|
-
bottom: -15px;
|
|
133
|
-
color: #eee;
|
|
134
|
-
text-shadow: 0 -1px 0 #111;
|
|
135
|
-
white-space: nowrap;
|
|
136
|
-
width: 100%;
|
|
137
|
-
overflow: hidden;
|
|
138
|
-
text-overflow: ellipsis;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.p-gui__button,
|
|
142
|
-
.p-gui__switch,
|
|
143
|
-
.p-gui__list,
|
|
144
|
-
.p-gui__vector2,
|
|
145
|
-
.p-gui__color {
|
|
146
|
-
width: 100%;
|
|
147
|
-
padding: 7px 13px;
|
|
148
|
-
color: white;
|
|
149
|
-
cursor: pointer;
|
|
150
|
-
position: relative;
|
|
151
|
-
box-sizing: border-box;
|
|
152
|
-
margin-bottom: 3px;
|
|
153
|
-
margin: 3px;
|
|
154
|
-
|
|
155
|
-
border: 1px solid var(--color-border-2);
|
|
156
|
-
border-radius: var(--main-border-radius);
|
|
157
|
-
}
|
|
95
|
+
.p-gui__button:hover {
|
|
96
|
+
background: var(--color-accent-hover);
|
|
97
|
+
color: var(--color-text-light);
|
|
98
|
+
border-color: rgba(255, 255, 255, 0.2);
|
|
99
|
+
}
|
|
158
100
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
.p-gui__button:hover {
|
|
177
|
-
background: var(--color-accent-hover);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.p-gui__switch {
|
|
181
|
-
background: rgba(255, 255, 255, .05);
|
|
182
|
-
}
|
|
101
|
+
.p-gui__folder .p-gui__button {
|
|
102
|
+
margin-inline: 0;
|
|
103
|
+
}
|
|
104
|
+
`
|
|
105
|
+
), U = (
|
|
106
|
+
/* css */
|
|
107
|
+
`
|
|
108
|
+
.p-gui__slider {
|
|
109
|
+
position: relative;
|
|
110
|
+
min-height: 14px;
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: space-between;
|
|
114
|
+
gap: 10px;
|
|
115
|
+
color: var(--color-text-dark);
|
|
116
|
+
transition: color var(--transition);
|
|
117
|
+
}
|
|
183
118
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
119
|
+
.p-gui__slider:hover {
|
|
120
|
+
color: var(--color-text-light);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.p-gui__slider-name {
|
|
124
|
+
width: 50%;
|
|
125
|
+
text-overflow: ellipsis;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.p-gui__slider-ctrl {
|
|
130
|
+
-webkit-appearance: none;
|
|
131
|
+
padding: 0;
|
|
132
|
+
font: inherit;
|
|
133
|
+
outline: none;
|
|
134
|
+
box-sizing: border-box;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
position: relative;
|
|
137
|
+
right: 0;
|
|
138
|
+
height: 14px;
|
|
139
|
+
margin: 0 0 0 auto;
|
|
140
|
+
width: 37%;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.p-gui__slider-bar {
|
|
144
|
+
position: absolute;
|
|
145
|
+
top: 50%;
|
|
146
|
+
left: 0;
|
|
147
|
+
height: 2px;
|
|
148
|
+
background: rgba(255, 255, 255, .2);
|
|
149
|
+
width: 100%;
|
|
150
|
+
transform: translateY(-50%);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.p-gui__slider-filling {
|
|
154
|
+
position: absolute;
|
|
155
|
+
top: -25%;
|
|
156
|
+
left: 0;
|
|
157
|
+
height: 150%;
|
|
158
|
+
background: var(--color-accent);
|
|
159
|
+
width: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.p-gui__slider:hover .p-gui__slider-filling {
|
|
163
|
+
background: var(--color-accent-hover);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.p-gui__slider-handle {
|
|
167
|
+
width: 15px;
|
|
168
|
+
height: 8px;
|
|
169
|
+
position: absolute;
|
|
170
|
+
top: 50%;
|
|
171
|
+
left: 0;
|
|
172
|
+
border-radius: 2px;
|
|
173
|
+
transform: translate(-50%, -50%);
|
|
174
|
+
pointer-events: none;
|
|
175
|
+
background: var(--color-text-dark);
|
|
176
|
+
box-shadow: 0 0 2px rgba(0, 0, 0, .5);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.p-gui__slider:hover .p-gui__slider-handle {
|
|
180
|
+
background: var(--color-text-light);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.p-gui__slider-value {
|
|
184
|
+
display: inline-block;
|
|
185
|
+
right: 7px;
|
|
186
|
+
width: 13%;
|
|
187
|
+
border: none;
|
|
188
|
+
color: white;
|
|
189
|
+
border-radius: 2px;
|
|
190
|
+
background: rgba(255, 255, 255, 0.1);
|
|
191
|
+
padding: 2px 4px;
|
|
192
|
+
color: inherit;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.p-gui__slider-value:focus {
|
|
196
|
+
outline: none;
|
|
197
|
+
}
|
|
198
|
+
`
|
|
199
|
+
), j = (
|
|
200
|
+
/* css */
|
|
201
|
+
`
|
|
202
|
+
.p-gui__list {
|
|
203
|
+
cursor: default;
|
|
204
|
+
color: var(--color-text-dark);
|
|
205
|
+
transition: var(--transition) color;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.p-gui__list:hover {
|
|
209
|
+
color: var(--color-text-light);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.p-gui__list-dropdown {
|
|
213
|
+
background: rgba(255, 255, 255,.05);
|
|
214
|
+
color: white;
|
|
215
|
+
padding: 0 12px 0 5px;
|
|
216
|
+
top: 0px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.p-gui__list-dropdown {
|
|
220
|
+
position: absolute;
|
|
221
|
+
right: 5px;
|
|
222
|
+
top: 0;
|
|
223
|
+
bottom: 0;
|
|
224
|
+
margin: auto;
|
|
225
|
+
height: 21px;
|
|
226
|
+
cursor: pointer;
|
|
227
|
+
border-radius: 3px;
|
|
228
|
+
border: 1px solid var(--color-border-2);
|
|
229
|
+
outline: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.p-gui__list-dropdown:hover {
|
|
233
|
+
background: rgba(255, 255, 255, .1);
|
|
234
|
+
}
|
|
235
|
+
`
|
|
236
|
+
), k = (
|
|
237
|
+
/* css */
|
|
238
|
+
`
|
|
239
|
+
.p-gui__switch {
|
|
240
|
+
background: rgba(255, 255, 255, .05);
|
|
241
|
+
color: var(--color-text-dark);
|
|
242
|
+
transition: var(--transition) background, var(--transition) color;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.p-gui__switch:hover {
|
|
246
|
+
background: rgba(255, 255, 255, .1);
|
|
247
|
+
color: var(--color-text-light);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.p-gui__folder .p-gui__switch {
|
|
251
|
+
margin-inline: 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.p-gui__switch-checkbox {
|
|
255
|
+
width: 5px;
|
|
256
|
+
height: 5px;
|
|
257
|
+
background-color: rgba(0, 0, 0, .5);
|
|
258
|
+
border: 1px solid grey;
|
|
259
|
+
position: absolute;
|
|
260
|
+
top: 0;
|
|
261
|
+
right: 10px;
|
|
262
|
+
bottom: 0;
|
|
263
|
+
margin: auto;
|
|
264
|
+
border-radius: 50%;
|
|
265
|
+
pointer-events: none;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.p-gui__switch-checkbox--active {
|
|
269
|
+
background-color: #00ff89;
|
|
270
|
+
box-shadow: 0 0 7px #00ff89;
|
|
271
|
+
}
|
|
272
|
+
`
|
|
273
|
+
), I = (
|
|
274
|
+
/* css */
|
|
275
|
+
`
|
|
276
|
+
.p-gui__color {
|
|
277
|
+
cursor: default;
|
|
278
|
+
color: var(--color-text-dark);
|
|
279
|
+
transition: var(--transition) color;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.p-gui__color:hover {
|
|
283
|
+
color: var(--color-text-light);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.p-gui__color-picker {
|
|
287
|
+
position: absolute;
|
|
288
|
+
right: 5px;
|
|
289
|
+
top: 0;
|
|
290
|
+
bottom: 0;
|
|
291
|
+
margin: auto;
|
|
292
|
+
height: 21px;
|
|
293
|
+
cursor: pointer;
|
|
294
|
+
border-radius: 3px;
|
|
295
|
+
border: 1px solid var(--color-border-2);
|
|
296
|
+
outline: none;
|
|
297
|
+
-webkit-appearance: none;
|
|
298
|
+
padding: 0;
|
|
299
|
+
background-color: transparent;
|
|
300
|
+
border: 1px solid #222222;
|
|
301
|
+
overflow: hidden;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.p-gui__color-picker::-webkit-color-swatch-wrapper {
|
|
305
|
+
padding: 0;
|
|
306
|
+
}
|
|
307
|
+
.p-gui__color-picker::-webkit-color-swatch {
|
|
308
|
+
border: none;
|
|
309
|
+
}
|
|
310
|
+
`
|
|
311
|
+
), C = (
|
|
312
|
+
/* css */
|
|
313
|
+
`
|
|
194
314
|
.p-gui__vector2 {
|
|
195
315
|
background: transparent;
|
|
196
316
|
aspect-ratio: 1;
|
|
197
317
|
padding-bottom: 0;
|
|
318
|
+
color: var(--color-text-dark);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.p-gui__vector2:hover {
|
|
322
|
+
color: var(--color-text-light);
|
|
198
323
|
}
|
|
199
324
|
|
|
200
325
|
.p-gui__vector2-area {
|
|
@@ -242,125 +367,71 @@ function A(y) {
|
|
|
242
367
|
pointer-events: none;
|
|
243
368
|
}
|
|
244
369
|
|
|
245
|
-
.p-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
background-color: rgba(0, 0, 0, .5);
|
|
249
|
-
border: 1px solid grey;
|
|
370
|
+
.p-gui__vector-value {
|
|
371
|
+
display: inline-block;
|
|
372
|
+
right: 7px;
|
|
250
373
|
position: absolute;
|
|
251
|
-
top: 0;
|
|
252
|
-
right: 10px;
|
|
253
|
-
bottom: 0;
|
|
254
|
-
margin: auto;
|
|
255
|
-
border-radius: 50%;
|
|
256
|
-
pointer-events: none;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.p-gui__switch-checkbox--active {
|
|
260
|
-
background-color: #00ff89;
|
|
261
|
-
box-shadow: 0 0 7px #00ff89;
|
|
262
374
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
375
|
+
`
|
|
376
|
+
), R = (
|
|
377
|
+
/* css */
|
|
378
|
+
`
|
|
379
|
+
.p-gui__image-container {
|
|
380
|
+
width: 100%;
|
|
381
|
+
padding: 3px;
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: flex-start;
|
|
384
|
+
flex-wrap: wrap;
|
|
385
|
+
box-sizing: border-box;
|
|
267
386
|
}
|
|
268
387
|
|
|
269
|
-
.p-
|
|
270
|
-
|
|
271
|
-
position: absolute;
|
|
272
|
-
right: 5px;
|
|
273
|
-
top: 0;
|
|
274
|
-
bottom: 0;
|
|
275
|
-
margin: auto;
|
|
276
|
-
height: 21px;
|
|
388
|
+
.p-gui__image {
|
|
389
|
+
background-size: cover;
|
|
277
390
|
cursor: pointer;
|
|
278
|
-
border-radius: 3px;
|
|
279
|
-
border: 1px solid var(--color-border-2);
|
|
280
|
-
outline: none;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.p-gui__list-dropdown {
|
|
284
|
-
background: rgba(255, 255, 255,.05);
|
|
285
|
-
color: white;
|
|
286
|
-
padding: 0 12px;
|
|
287
|
-
top: 0px;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.p-gui__list-dropdown:hover {
|
|
291
|
-
background: rgba(255, 255, 255, .1);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.p-gui__color-picker {
|
|
295
|
-
-webkit-appearance: none;
|
|
296
|
-
padding: 0;
|
|
297
|
-
background-color: transparent;
|
|
298
|
-
border: 1px solid #222222;
|
|
299
|
-
overflow: hidden;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
.p-gui__color-picker::-webkit-color-swatch-wrapper {
|
|
303
|
-
padding: 0;
|
|
304
|
-
}
|
|
305
|
-
.p-gui__color-picker::-webkit-color-swatch {
|
|
306
|
-
border: none;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.p-gui__slider {
|
|
310
|
-
box-sizing: border-box;
|
|
311
|
-
width: calc(100% - 10px);
|
|
312
|
-
margin: 0 auto 10px auto;
|
|
313
|
-
padding: 7px 0;
|
|
314
|
-
color: white;
|
|
315
391
|
position: relative;
|
|
316
|
-
|
|
392
|
+
margin: 1px 2.5px 19px 2.5px;
|
|
393
|
+
border-radius: var(--main-border-radius);
|
|
394
|
+
flex: 0 0 calc(33.333% - 5px);
|
|
395
|
+
height: 90px;
|
|
396
|
+
background-position: center;
|
|
397
|
+
color: var(--color-text-dark);
|
|
398
|
+
transition: var(--transition) color;
|
|
317
399
|
}
|
|
318
|
-
|
|
319
|
-
.p-
|
|
320
|
-
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
opacity: .8;
|
|
325
|
-
background: var(--color-accent);
|
|
326
|
-
box-sizing: border-box;
|
|
327
|
-
cursor: pointer;
|
|
400
|
+
|
|
401
|
+
.p-gui__image:hover {
|
|
402
|
+
color: var(--color-text-text);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.p-gui__image::after {
|
|
328
406
|
position: absolute;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
height: 5px;
|
|
407
|
+
top: 0;
|
|
408
|
+
left: 0;
|
|
332
409
|
width: 100%;
|
|
333
|
-
|
|
410
|
+
height: 100%;
|
|
411
|
+
content: '';
|
|
412
|
+
border: 1px solid transparent;
|
|
413
|
+
box-sizing: border-box;
|
|
334
414
|
border-radius: var(--main-border-radius);
|
|
415
|
+
transition: var(--transition) border-color;
|
|
335
416
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
.p-gui__slider-ctrl::-webkit-slider-runnable-track {
|
|
339
|
-
height: 13px;
|
|
340
|
-
border: none;
|
|
341
|
-
border-radius: 0;
|
|
342
|
-
background-color: transparent; /* supprimé définie sur l'input */
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/* Curseur */
|
|
346
|
-
.p-gui__slider-ctrl::-webkit-slider-thumb {
|
|
347
|
-
-webkit-appearance: none; /* également nécessaire sur le curseur */
|
|
348
|
-
width: 15px;
|
|
349
|
-
height: 7px;
|
|
350
|
-
border: none; /* pris en compte sur Webkit et Edge */
|
|
351
|
-
background: white; /* pris en compte sur Webkit only */
|
|
352
|
-
position: relative;
|
|
353
|
-
top: 3px;
|
|
354
|
-
border-radius: 1px;
|
|
417
|
+
.p-gui__image--selected::after {
|
|
418
|
+
border-color: #06FF89;
|
|
355
419
|
}
|
|
356
420
|
|
|
357
|
-
.p-
|
|
358
|
-
.p-gui__vector-value {
|
|
359
|
-
display: inline-block;
|
|
421
|
+
.p-gui__image-text {
|
|
360
422
|
position: absolute;
|
|
361
|
-
|
|
423
|
+
bottom: -15px;
|
|
424
|
+
text-shadow: 0 -1px 0 #111;
|
|
425
|
+
white-space: nowrap;
|
|
426
|
+
width: 100%;
|
|
427
|
+
overflow: hidden;
|
|
428
|
+
text-overflow: ellipsis;
|
|
429
|
+
|
|
362
430
|
}
|
|
363
|
-
|
|
431
|
+
`
|
|
432
|
+
), P = (
|
|
433
|
+
/* css */
|
|
434
|
+
`
|
|
364
435
|
.p-gui__folder {
|
|
365
436
|
width: 100%;
|
|
366
437
|
position: relative;
|
|
@@ -372,6 +443,7 @@ function A(y) {
|
|
|
372
443
|
border: 1px solid grey;
|
|
373
444
|
padding: 0 3px 3px 3px;
|
|
374
445
|
border-radius: var(--main-border-radius);
|
|
446
|
+
box-sizing: border-box;
|
|
375
447
|
}
|
|
376
448
|
|
|
377
449
|
.p-gui__folder:last-of-type {
|
|
@@ -414,16 +486,161 @@ function A(y) {
|
|
|
414
486
|
.p-gui__folder--closed .p-gui__folder-arrow {
|
|
415
487
|
transform: rotate(0deg);
|
|
416
488
|
}
|
|
489
|
+
`
|
|
490
|
+
);
|
|
491
|
+
function F(v) {
|
|
492
|
+
return (
|
|
493
|
+
/* css */
|
|
417
494
|
`
|
|
495
|
+
.p-gui {
|
|
496
|
+
--main-border-radius: 5px;
|
|
497
|
+
--color-bg: #121212;
|
|
498
|
+
--color-border: #484848;
|
|
499
|
+
--color-border-2: rgba(255,255,255,.1);
|
|
500
|
+
--color-text-light: #ffffff;
|
|
501
|
+
--color-text-dark: #bbbbbb;
|
|
502
|
+
--color-accent: #1681ca;
|
|
503
|
+
--color-accent-hover: #218fda;
|
|
504
|
+
--transition: .1s linear;
|
|
505
|
+
|
|
506
|
+
position: ${v};
|
|
507
|
+
top: 0;
|
|
508
|
+
left: 0;
|
|
509
|
+
transform: translate3d(0,0,0);
|
|
510
|
+
padding-top: 21px;
|
|
511
|
+
padding-inline: 3px;
|
|
512
|
+
background: var(--color-bg);
|
|
513
|
+
display: block;
|
|
514
|
+
justify-content: center;
|
|
515
|
+
flex-wrap: wrap;
|
|
516
|
+
font-family: "Arial Rounded MT Bold", Arial, sans-serif;
|
|
517
|
+
width: 290px;
|
|
518
|
+
overflow: auto;
|
|
519
|
+
box-shadow: 0 0 2px black;
|
|
520
|
+
box-sizing: border-box;
|
|
521
|
+
z-index: 99999;
|
|
522
|
+
user-select: none;
|
|
523
|
+
border-bottom-right-radius: 3px;
|
|
524
|
+
border-bottom-left-radius: 3px;
|
|
525
|
+
cursor: auto;
|
|
526
|
+
border-radius: var(--main-border-radius);
|
|
527
|
+
border: 1px solid var(--color-border);
|
|
528
|
+
line-height: normal;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.p-gui * {
|
|
532
|
+
font-size: 11px;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.p-gui::-webkit-scrollbar,
|
|
536
|
+
.p-gui *::-webkit-scrollbar {
|
|
537
|
+
width: 10px;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.p-gui::-webkit-scrollbar-track,
|
|
541
|
+
.p-gui *::-webkit-scrollbar-track {
|
|
542
|
+
background: #2f2f2f;
|
|
543
|
+
border-radius: 3px;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.p-gui::-webkit-scrollbar-thumb,
|
|
547
|
+
.p-gui *::-webkit-scrollbar-thumb {
|
|
548
|
+
background: #757576;
|
|
549
|
+
border-radius: 10px;
|
|
550
|
+
box-sizing: border-box;
|
|
551
|
+
border: 1px solid #2f2f2f;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.p-gui--collapsed {
|
|
555
|
+
height: 0;
|
|
556
|
+
padding: 21px 10px 0 10px;
|
|
557
|
+
overflow: hidden;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.p-gui__header {
|
|
561
|
+
position: absolute;
|
|
562
|
+
top: 0;
|
|
563
|
+
left: 0;
|
|
564
|
+
width: 100%;
|
|
565
|
+
height: 20px;
|
|
566
|
+
background-color: rgba(0, 0, 0, .8);
|
|
567
|
+
cursor: grab;
|
|
568
|
+
color: grey;
|
|
569
|
+
font-size: 10px;
|
|
570
|
+
line-height: 20px;
|
|
571
|
+
padding-left: 12px;
|
|
572
|
+
box-sizing: border-box;
|
|
573
|
+
touch-action: none;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.p-gui__header-close {
|
|
577
|
+
width: 20px;
|
|
578
|
+
height: 20px;
|
|
579
|
+
position: absolute;
|
|
580
|
+
top: 0;
|
|
581
|
+
right: 5px;
|
|
582
|
+
cursor: pointer;
|
|
583
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
|
|
584
|
+
background-size: 50% 50%;
|
|
585
|
+
background-position: center;
|
|
586
|
+
background-repeat: no-repeat;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.p-gui--collapsed .p-gui__header-close {
|
|
590
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.p-gui__slider,
|
|
594
|
+
.p-gui__button,
|
|
595
|
+
.p-gui__switch,
|
|
596
|
+
.p-gui__list,
|
|
597
|
+
.p-gui__vector2,
|
|
598
|
+
.p-gui__color {
|
|
599
|
+
width: 100%;
|
|
600
|
+
padding: 7px;
|
|
601
|
+
cursor: pointer;
|
|
602
|
+
position: relative;
|
|
603
|
+
box-sizing: border-box;
|
|
604
|
+
margin-block: 3px;
|
|
605
|
+
border: 1px solid var(--color-border-2);
|
|
606
|
+
border-radius: var(--main-border-radius);
|
|
607
|
+
transition: var(--transition) border-color;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.p-gui__slider:hover,
|
|
611
|
+
.p-gui__button:hover,
|
|
612
|
+
.p-gui__switch:hover,
|
|
613
|
+
.p-gui__list:hover,
|
|
614
|
+
.p-gui__vector2:hover,
|
|
615
|
+
.p-gui__color:hover {
|
|
616
|
+
border-color: rgba(255,255,255,.2);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
${E}
|
|
620
|
+
|
|
621
|
+
${R}
|
|
622
|
+
|
|
623
|
+
${j}
|
|
624
|
+
|
|
625
|
+
${k}
|
|
626
|
+
|
|
627
|
+
${U}
|
|
628
|
+
|
|
629
|
+
${I}
|
|
630
|
+
|
|
631
|
+
${C}
|
|
632
|
+
|
|
633
|
+
${P}
|
|
634
|
+
`
|
|
418
635
|
);
|
|
419
636
|
}
|
|
420
|
-
class
|
|
637
|
+
class y {
|
|
421
638
|
constructor(e = {}) {
|
|
422
639
|
if (this.firstParent = this, e.container ? (this.container = typeof e.container == "string" ? document.querySelector(e.container) : e.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], e.isFolder) {
|
|
423
640
|
this._folderConstructor(e.folderOptions);
|
|
424
641
|
return;
|
|
425
642
|
}
|
|
426
|
-
typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${
|
|
643
|
+
typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = e.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${F(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
|
|
427
644
|
}
|
|
428
645
|
_styleInstance() {
|
|
429
646
|
let e = this._getScrollbarWidth(this.container);
|
|
@@ -490,86 +707,94 @@ class v {
|
|
|
490
707
|
o = e.path;
|
|
491
708
|
else
|
|
492
709
|
throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
|
|
493
|
-
let a = o.replace(/^.*[\\\/]/, ""),
|
|
494
|
-
e.name == null ?
|
|
495
|
-
const
|
|
710
|
+
let a = o.replace(/^.*[\\\/]/, ""), l;
|
|
711
|
+
e.name == null ? l = a : l = typeof e.name == "string" && e.name || " ";
|
|
712
|
+
const i = e.selected === !0, r = e.selectionBorder !== !1;
|
|
496
713
|
let n = "";
|
|
497
714
|
e.width && (typeof e.width == "number" && (e.width += "px"), n += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), n += `height: ${e.height}; `), this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer));
|
|
498
715
|
const s = document.createElement("div");
|
|
499
|
-
s.className = "p-gui__image", s.style = "background-image: url(" + o + "); " + n, this.imageContainer.append(s),
|
|
500
|
-
const
|
|
501
|
-
return
|
|
502
|
-
let
|
|
503
|
-
for (let c = 0; c <
|
|
504
|
-
|
|
505
|
-
|
|
716
|
+
s.className = "p-gui__image", s.style = "background-image: url(" + o + "); " + n, this.imageContainer.append(s), i && r && s.classList.add("p-gui__image--selected");
|
|
717
|
+
const d = document.createElement("div");
|
|
718
|
+
return d.className = "p-gui__image-text", d.textContent = l, s.append(d), s.addEventListener("click", () => {
|
|
719
|
+
let f = s.parentElement.querySelectorAll(".p-gui__image--selected");
|
|
720
|
+
for (let c = 0; c < f.length; c++)
|
|
721
|
+
f[c].classList.remove("p-gui__image--selected");
|
|
722
|
+
r && s.classList.add("p-gui__image--selected"), typeof t == "function" && t({ path: o, text: l }), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
506
723
|
}), s;
|
|
507
724
|
}
|
|
508
725
|
slider(e = {}, t) {
|
|
726
|
+
const o = new A(e, t);
|
|
727
|
+
this.wrapper.append(o);
|
|
728
|
+
}
|
|
729
|
+
sliderOld(e = {}, t) {
|
|
509
730
|
if (typeof e != "object")
|
|
510
731
|
throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
|
|
511
|
-
let o = typeof e.name == "string" && e.name || " ", a = !1,
|
|
732
|
+
let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n = typeof e.value == "number" ? e.value : null, s = e.min ?? 0, d = e.max ?? 1, f = e.step || (d - s) / 100;
|
|
512
733
|
if (n !== null)
|
|
513
|
-
(
|
|
514
|
-
else if (
|
|
515
|
-
if (typeof
|
|
516
|
-
throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof
|
|
517
|
-
if (typeof
|
|
518
|
-
throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof
|
|
519
|
-
o == " " && (o =
|
|
734
|
+
(r != null || i != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
|
|
735
|
+
else if (r != null && i != null) {
|
|
736
|
+
if (typeof r != "string")
|
|
737
|
+
throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof r}.`);
|
|
738
|
+
if (typeof i != "object")
|
|
739
|
+
throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof i}.`);
|
|
740
|
+
o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
|
|
520
741
|
} else
|
|
521
|
-
(
|
|
742
|
+
(r != null && i == null || r == null && i != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), n = (d - s) / 2;
|
|
522
743
|
this.imageContainer = null;
|
|
523
744
|
const c = document.createElement("div");
|
|
524
|
-
c.className = "p-gui__slider",
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
745
|
+
c.className = "p-gui__slider", this.wrapper.append(c);
|
|
746
|
+
const u = document.createElement("div");
|
|
747
|
+
u.className = "p-gui__slider-name", u.textContent = o, c.append(u);
|
|
748
|
+
const p = document.createElement("input");
|
|
749
|
+
p.className = "p-gui__slider-ctrl", p.setAttribute("type", "range"), p.setAttribute("min", s), p.setAttribute("max", d), p.setAttribute("step", f), p.setAttribute("value", a ? i[r] : n), c.append(p);
|
|
750
|
+
const g = document.createElement("input");
|
|
751
|
+
g.className = "p-gui__slider-value", g.value = String(a ? i[r] : n), c.append(g), g.addEventListener("change", () => {
|
|
752
|
+
p.value = parseFloat(g.value);
|
|
753
|
+
}), p.addEventListener("input", () => {
|
|
754
|
+
g.value = p.value, a ? i[r] = parseFloat(p.value) : typeof t == "function" && t(parseFloat(p.value)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
755
|
+
}), a && Object.defineProperty(i, r, {
|
|
756
|
+
set: (h) => {
|
|
757
|
+
this.propReferences[l] = h, p.value = h, g.textContent = String(h), typeof t == "function" && t(parseFloat(p.value));
|
|
533
758
|
},
|
|
534
|
-
get: () => this.propReferences[
|
|
759
|
+
get: () => this.propReferences[l]
|
|
535
760
|
});
|
|
536
761
|
}
|
|
537
762
|
toggle(e = {}, t) {
|
|
538
763
|
if (typeof e != "object")
|
|
539
764
|
throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);
|
|
540
|
-
let o = typeof e.name == "string" && e.name || " ", a = !1,
|
|
765
|
+
let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n = typeof e.value == "boolean" ? e.value : null;
|
|
541
766
|
if (n !== null)
|
|
542
|
-
(
|
|
543
|
-
else if (
|
|
544
|
-
if (typeof
|
|
545
|
-
throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof
|
|
546
|
-
if (typeof
|
|
547
|
-
throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof
|
|
548
|
-
o == " " && (o =
|
|
767
|
+
(r != null || i != null) && console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
|
|
768
|
+
else if (r != null && i != null) {
|
|
769
|
+
if (typeof r != "string")
|
|
770
|
+
throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof r}.`);
|
|
771
|
+
if (typeof i != "object")
|
|
772
|
+
throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof i}.`);
|
|
773
|
+
o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
|
|
549
774
|
} else
|
|
550
|
-
(
|
|
775
|
+
(r != null && i == null || r == null && i == null) && console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');
|
|
551
776
|
this.imageContainer = null;
|
|
552
777
|
const s = document.createElement("div");
|
|
553
778
|
s.textContent = o, s.className = "p-gui__switch", this.wrapper.append(s), s.addEventListener("click", (c) => {
|
|
554
|
-
const
|
|
555
|
-
let
|
|
556
|
-
|
|
779
|
+
const u = c.target.childNodes[1];
|
|
780
|
+
let p = !0;
|
|
781
|
+
u.classList.contains("p-gui__switch-checkbox--active") && (p = !1), u.classList.toggle("p-gui__switch-checkbox--active"), a ? i[r] = p : typeof t == "function" && t(p), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
557
782
|
});
|
|
558
|
-
let
|
|
559
|
-
const
|
|
560
|
-
|
|
783
|
+
let d = (() => a ? i[r] ? " p-gui__switch-checkbox--active" : "" : n ? " p-gui__switch-checkbox--active" : "")();
|
|
784
|
+
const f = document.createElement("div");
|
|
785
|
+
f.className = "p-gui__switch-checkbox" + d, s.append(f), a && Object.defineProperty(i, r, {
|
|
561
786
|
set: (c) => {
|
|
562
|
-
this.propReferences[
|
|
787
|
+
this.propReferences[l] = c, c ? f.classList.add("p-gui__switch-checkbox--active") : f.classList.remove("p-gui__switch-checkbox--active"), typeof t == "function" && t(c);
|
|
563
788
|
},
|
|
564
|
-
get: () => this.propReferences[
|
|
789
|
+
get: () => this.propReferences[l]
|
|
565
790
|
});
|
|
566
791
|
}
|
|
567
792
|
list(e = {}, t) {
|
|
568
793
|
if (typeof e != "object")
|
|
569
794
|
throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);
|
|
570
|
-
let o = typeof e.name == "string" ? e.name : " ", a = !1,
|
|
571
|
-
if (t = typeof t == "function" ? t : null, e.value !== void 0 || e.value === void 0 &&
|
|
572
|
-
(
|
|
795
|
+
let o = typeof e.name == "string" ? e.name : " ", a = !1, l = null, i = e.obj, r = e.prop, n = Array.isArray(e.values) ? e.values : null, s, d = typeof n[0] != "string";
|
|
796
|
+
if (t = typeof t == "function" ? t : null, e.value !== void 0 || e.value === void 0 && i === void 0 && r === void 0)
|
|
797
|
+
(r != null || i != null) && console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'), s = (() => {
|
|
573
798
|
if (!n)
|
|
574
799
|
return null;
|
|
575
800
|
if (typeof e.value == "string")
|
|
@@ -577,137 +802,137 @@ class v {
|
|
|
577
802
|
if (typeof e.value == "number")
|
|
578
803
|
return e.value;
|
|
579
804
|
})();
|
|
580
|
-
else if (
|
|
581
|
-
if (typeof
|
|
582
|
-
throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof
|
|
583
|
-
if (typeof
|
|
584
|
-
throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof
|
|
805
|
+
else if (r != null && i != null) {
|
|
806
|
+
if (typeof r != "string")
|
|
807
|
+
throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof r}.`);
|
|
808
|
+
if (typeof i != "object")
|
|
809
|
+
throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof i}.`);
|
|
585
810
|
s = (() => {
|
|
586
811
|
if (!n)
|
|
587
812
|
return null;
|
|
588
|
-
if (typeof r
|
|
589
|
-
return
|
|
590
|
-
if (typeof r
|
|
591
|
-
return
|
|
592
|
-
})(),
|
|
813
|
+
if (typeof i[r] == "string")
|
|
814
|
+
return d ? n.find((u) => u.value === i[r]).value : n.indexOf(i[r]);
|
|
815
|
+
if (typeof i[r] == "number")
|
|
816
|
+
return d ? n.find((u) => u.value === i[r]).value : i[r];
|
|
817
|
+
})(), l = this.propReferences.push(i[r]) - 1, a = !0;
|
|
593
818
|
} else
|
|
594
|
-
(
|
|
819
|
+
(r != null && i == null || r == null && i == null) && console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');
|
|
595
820
|
this.imageContainer = null;
|
|
596
|
-
let
|
|
597
|
-
|
|
821
|
+
let f = document.createElement("div");
|
|
822
|
+
f.className = "p-gui__list", f.textContent = o, this.wrapper.append(f);
|
|
598
823
|
let c = document.createElement("select");
|
|
599
|
-
|
|
600
|
-
a ? r
|
|
601
|
-
}), n && n.forEach((
|
|
602
|
-
const g =
|
|
824
|
+
f.append(c), c.className = "p-gui__list-dropdown", c.addEventListener("change", (u) => {
|
|
825
|
+
a ? i[r] = u.target.value : t && t(u.target.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
826
|
+
}), n && n.forEach((u, p) => {
|
|
827
|
+
const g = d ? u.name : u, h = d ? u.value : u;
|
|
603
828
|
let m = document.createElement("option");
|
|
604
|
-
m.setAttribute("value",
|
|
605
|
-
}), a && Object.defineProperty(
|
|
606
|
-
set: (
|
|
607
|
-
let
|
|
608
|
-
|
|
829
|
+
m.setAttribute("value", h), m.textContent = g, c.append(m), (!d && s == p || d && s == h) && m.setAttribute("selected", "");
|
|
830
|
+
}), a && Object.defineProperty(i, r, {
|
|
831
|
+
set: (u) => {
|
|
832
|
+
let p, g, h;
|
|
833
|
+
d ? (h = n.find((x) => x.value == u), g = (h == null ? void 0 : h.value) || n[0].value, p = n.indexOf(h)) : (typeof u == "string" && (p = n.indexOf(u), g = u), typeof u == "number" && (p = u, g = n[u])), this.propReferences[l] = d ? g : u;
|
|
609
834
|
const m = c.querySelector("[selected]");
|
|
610
|
-
m && m.removeAttribute("selected"), c.querySelectorAll("option")[
|
|
835
|
+
m && m.removeAttribute("selected"), c.querySelectorAll("option")[p].setAttribute("selected", ""), typeof t == "function" && t(d ? h : g, p);
|
|
611
836
|
},
|
|
612
|
-
get: () => this.propReferences[
|
|
837
|
+
get: () => this.propReferences[l]
|
|
613
838
|
});
|
|
614
839
|
}
|
|
615
840
|
vector2(e = {}, t) {
|
|
616
841
|
if (typeof e != "object")
|
|
617
842
|
throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
|
|
618
843
|
let o = typeof e.name == "string" && e.name || " ";
|
|
619
|
-
const a = e.x.min ?? 0,
|
|
844
|
+
const a = e.x.min ?? 0, l = e.x.max ?? 1, i = e.y.min ?? 0, r = e.y.max ?? 1, n = e.x.obj, s = e.x.prop, d = this.propReferences.push(n[s]) - 1, f = e.y.obj, c = e.y.prop, u = this.propReferences.push(f[c]) - 1;
|
|
620
845
|
t = typeof t == "function" ? t : null, this.imageContainer = null;
|
|
621
|
-
const
|
|
622
|
-
|
|
846
|
+
const p = document.createElement("div");
|
|
847
|
+
p.className = "p-gui__vector2", p.textContent = o, this.wrapper.append(p);
|
|
623
848
|
const g = document.createElement("div");
|
|
624
|
-
g.className = "p-gui__vector-value", g.textContent = n[s] + ", " +
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
n[s] = parseFloat(this._mapLinear(b.offsetX, 0,
|
|
849
|
+
g.className = "p-gui__vector-value", g.textContent = n[s] + ", " + f[c], p.append(g);
|
|
850
|
+
const h = document.createElement("div");
|
|
851
|
+
h.className = "p-gui__vector2-area", p.append(h), h.addEventListener("click", (b) => {
|
|
852
|
+
n[s] = parseFloat(this._mapLinear(b.offsetX, 0, h.clientWidth, a, l).toFixed(2)), f[c] = parseFloat(this._mapLinear(b.offsetY, 0, h.clientHeight, r, i).toFixed(2)), t && t(n[s], n[c]), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
628
853
|
});
|
|
629
854
|
let m = !1;
|
|
630
|
-
|
|
855
|
+
h.addEventListener("pointerdown", (b) => {
|
|
631
856
|
m = !0;
|
|
632
|
-
}),
|
|
857
|
+
}), h.addEventListener("pointerup", () => {
|
|
633
858
|
m = !1;
|
|
634
|
-
}),
|
|
635
|
-
m && (n[s] = parseFloat(this._mapLinear(b.offsetX, 0,
|
|
859
|
+
}), h.addEventListener("pointermove", (b) => {
|
|
860
|
+
m && (n[s] = parseFloat(this._mapLinear(b.offsetX, 0, h.clientWidth, a, l).toFixed(2)), f[c] = parseFloat(this._mapLinear(b.offsetY, 0, h.clientHeight, r, i).toFixed(2)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate(), t && t(n[s], n[c]));
|
|
636
861
|
});
|
|
637
|
-
const _ = document.createElement("div");
|
|
638
|
-
_.className = "p-gui__vector2-line p-gui__vector2-line-x", u.append(_);
|
|
639
|
-
const w = document.createElement("div");
|
|
640
|
-
w.className = "p-gui__vector2-line p-gui__vector2-line-y", u.append(w);
|
|
641
862
|
const x = document.createElement("div");
|
|
642
|
-
x.className = "p-gui__vector2-
|
|
863
|
+
x.className = "p-gui__vector2-line p-gui__vector2-line-x", h.append(x);
|
|
864
|
+
const w = document.createElement("div");
|
|
865
|
+
w.className = "p-gui__vector2-line p-gui__vector2-line-y", h.append(w);
|
|
866
|
+
const _ = document.createElement("div");
|
|
867
|
+
_.className = "p-gui__vector2-dot", h.append(_), _.style.left = this._mapLinear(n[s], a, l, 0, h.clientWidth) + "px", _.style.top = this._mapLinear(f[c], i, r, h.clientHeight, 0) + "px", Object.defineProperty(n, s, {
|
|
643
868
|
set: (b) => {
|
|
644
|
-
this.propReferences[
|
|
869
|
+
this.propReferences[d] = b, _.style.left = this._mapLinear(b, a, l, 0, h.clientWidth) + "px", g.textContent = String(b) + ", " + f[c];
|
|
645
870
|
},
|
|
646
|
-
get: () => this.propReferences[
|
|
647
|
-
}), Object.defineProperty(
|
|
871
|
+
get: () => this.propReferences[d]
|
|
872
|
+
}), Object.defineProperty(f, c, {
|
|
648
873
|
set: (b) => {
|
|
649
|
-
this.propReferences[
|
|
874
|
+
this.propReferences[u] = b, _.style.top = this._mapLinear(b, i, r, h.clientHeight, 0) + "px", g.textContent = n[s] + ", " + String(b);
|
|
650
875
|
},
|
|
651
|
-
get: () => this.propReferences[
|
|
876
|
+
get: () => this.propReferences[u]
|
|
652
877
|
});
|
|
653
878
|
}
|
|
654
879
|
color(e = {}, t) {
|
|
655
880
|
if (typeof e != "object")
|
|
656
881
|
throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);
|
|
657
|
-
let o = typeof e.name == "string" && e.name || " ", a = !1,
|
|
882
|
+
let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n;
|
|
658
883
|
if (typeof e.value == "string" && (e.value.length != 7 || e.value[0] != "#" ? console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`) : n = e.value), n || (n = "#000000"), e.value !== void 0)
|
|
659
|
-
(
|
|
660
|
-
else if (
|
|
661
|
-
if (typeof
|
|
662
|
-
throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof
|
|
663
|
-
if (typeof
|
|
664
|
-
throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof
|
|
665
|
-
o == " " && (o =
|
|
884
|
+
(r != null || i != null) && console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
|
|
885
|
+
else if (r != null && i != null) {
|
|
886
|
+
if (typeof r != "string")
|
|
887
|
+
throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof r}.`);
|
|
888
|
+
if (typeof i != "object")
|
|
889
|
+
throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof i}.`);
|
|
890
|
+
o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
|
|
666
891
|
} else
|
|
667
|
-
(
|
|
892
|
+
(r != null && i == null || r == null && i == null) && console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');
|
|
668
893
|
this.imageContainer = null;
|
|
669
894
|
const s = document.createElement("div");
|
|
670
895
|
s.className = "p-gui__color", s.textContent = o, this.wrapper.append(s);
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
a ? r
|
|
674
|
-
}), a && Object.defineProperty(
|
|
675
|
-
set: (
|
|
676
|
-
this.propReferences[
|
|
896
|
+
const d = document.createElement("input");
|
|
897
|
+
d.className = "p-gui__color-picker", d.setAttribute("type", "color"), d.value = n, s.append(d), typeof t == "function" && d.addEventListener("input", () => {
|
|
898
|
+
a ? i[r] = d.value : typeof t == "function" && t(d.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
|
|
899
|
+
}), a && Object.defineProperty(i, r, {
|
|
900
|
+
set: (f) => {
|
|
901
|
+
this.propReferences[l] = f, d.value = f, typeof t == "function" && t(f);
|
|
677
902
|
},
|
|
678
|
-
get: () => this.propReferences[
|
|
903
|
+
get: () => this.propReferences[l]
|
|
679
904
|
});
|
|
680
905
|
}
|
|
681
906
|
folder(e = {}) {
|
|
682
|
-
let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null,
|
|
907
|
+
let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null, l = e.maxHeight || null;
|
|
683
908
|
this.imageContainer = null;
|
|
684
|
-
let
|
|
685
|
-
this.folders.length == 0 && (
|
|
686
|
-
let
|
|
687
|
-
|
|
909
|
+
let i = "p-gui__folder";
|
|
910
|
+
this.folders.length == 0 && (i += " p-gui__folder--first"), t && (i += " p-gui__folder--closed");
|
|
911
|
+
let r = a ? `background-color: ${a};` : "";
|
|
912
|
+
r += l ? `max-height: ${l}px;` : "";
|
|
688
913
|
const n = document.createElement("div");
|
|
689
|
-
n.className =
|
|
914
|
+
n.className = i, n.style = r, this.wrapper.append(n);
|
|
690
915
|
const s = document.createElement("div");
|
|
691
916
|
s.innerHTML = `<span class="p-gui__folder-arrow"></span>${o}`, s.className = "p-gui__folder-header", n.append(s), s.addEventListener("click", () => {
|
|
692
917
|
n.classList.toggle("p-gui__folder--closed");
|
|
693
918
|
});
|
|
694
|
-
let
|
|
919
|
+
let d = new y({ isFolder: !0, folderOptions: {
|
|
695
920
|
wrapper: n,
|
|
696
921
|
parent: this,
|
|
697
922
|
firstParent: this.firstParent
|
|
698
923
|
} });
|
|
699
|
-
return this.folders.push(
|
|
924
|
+
return this.folders.push(d), d;
|
|
700
925
|
}
|
|
701
926
|
_makeDraggable() {
|
|
702
927
|
var e = this;
|
|
703
928
|
this.header.addEventListener("pointerdown", t), this.header.addEventListener("pointerup", a);
|
|
704
|
-
function t(
|
|
705
|
-
|
|
929
|
+
function t(l) {
|
|
930
|
+
l.preventDefault(), e.position.initX = e.position.x, e.position.initY = e.position.y, e.position.prevX = l.clientX, e.position.prevY = l.clientY, document.addEventListener("pointermove", o);
|
|
706
931
|
}
|
|
707
|
-
function o(
|
|
708
|
-
|
|
932
|
+
function o(l) {
|
|
933
|
+
l.preventDefault(), e.hasBeenDragged || (e.hasBeenDragged = !0, e.wrapper.setAttribute("data-dragged", "true")), e.position.x = e.position.initX + l.clientX - e.position.prevX, e.position.y = e.position.initY + l.clientY - e.position.prevY, e.wrapper.style.transform = "translate3d(" + e.position.x + "px," + e.position.y + "px,0)";
|
|
709
934
|
}
|
|
710
|
-
function a(
|
|
935
|
+
function a(l) {
|
|
711
936
|
document.removeEventListener("pointermove", o);
|
|
712
937
|
}
|
|
713
938
|
}
|
|
@@ -717,10 +942,10 @@ class v {
|
|
|
717
942
|
kill() {
|
|
718
943
|
this.wrapper.remove();
|
|
719
944
|
}
|
|
720
|
-
_mapLinear(e, t, o, a,
|
|
721
|
-
return a + (e - t) * (
|
|
945
|
+
_mapLinear(e, t, o, a, l) {
|
|
946
|
+
return a + (e - t) * (l - a) / (o - t);
|
|
722
947
|
}
|
|
723
948
|
}
|
|
724
949
|
export {
|
|
725
|
-
|
|
950
|
+
y as default
|
|
726
951
|
};
|