forked from cifertech/DisplayKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
447 lines (418 loc) · 18.7 KB
/
index.html
File metadata and controls
447 lines (418 loc) · 18.7 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>DisplayKit - TFT_eSPI + U8g2 UI Builder</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app-shell">
<div class="sidebar">
<div class="sidebar-header">
<div style="flex: 1;">
<h2>DisplayKit</h2>
<div class="brand-subtitle">by CiferTech</div>
</div>
</div>
<div class="sidebar-card highlight">
<div class="sidebar-card-title">Project Links</div>
<a class="link-chip" href="https://github.com/cifertech/DisplayKit" target="_blank" rel="noreferrer">
<span class="icon">↗</span> GitHub Repo
</a>
<a class="link-chip" href="https://www.patreon.com/cifertech" target="_blank" rel="noreferrer">
<span class="icon">❤️</span> Support on Patreon
</a>
</div>
<div class="sidebar-card note">
<div class="sidebar-card-title">Workflow tips</div>
<ul>
<li>Use Snap-to-grid for pixel-perfect layouts.</li>
<li>Duplicate elements to iterate fast.</li>
<li>Export JSON often for versioning.</li>
</ul>
</div>
<div class="section-title">Display</div>
<div class="prop-group">
<div class="prop-row">
<div>
<label for="dispWidth">Width</label>
<input type="number" id="dispWidth" value="240" min="1" />
</div>
<div>
<label for="dispHeight">Height</label>
<input type="number" id="dispHeight" value="320" min="1" />
</div>
</div>
<div class="prop-row">
<div>
<label for="displayDriver">Driver</label>
<select id="displayDriver">
<option value="tft">TFT_eSPI</option>
<option value="u8g2">U8g2 OLED</option>
</select>
</div>
<div>
<label for="u8g2Preset">U8g2 Display</label>
<select id="u8g2Preset">
</select>
</div>
</div>
<button class="btn small secondary icon-btn-ghost" id="applyRes" title="Apply resolution">
<span>Apply</span>
</button>
</div>
<div class="section-title">Screens</div>
<div class="prop-group">
<label for="screenSelect">Current screen</label>
<div class="prop-row">
<div>
<select id="screenSelect"></select>
</div>
<button class="btn small secondary icon-btn-ghost" id="addScreenBtn" title="Add screen">
<svg viewBox="0 0 24 24" aria-hidden="true">
<line x1="12" y1="6" x2="12" y2="18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<line x1="6" y1="12" x2="18" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</button>
</div>
</div>
<div class="prop-group">
<label for="screenFnName">Function name</label>
<div class="prop-row fn-row">
<div>
<input type="text" id="screenFnName" placeholder="drawHomeScreen" />
</div>
<button class="btn small secondary icon-btn-ghost" id="deleteScreenBtn" title="Delete screen">
<svg viewBox="0 0 24 24" aria-hidden="true">
<polyline points="9,6 10,4 14,4 15,6" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" />
<rect x="7" y="6" width="10" height="12" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<line x1="10" y1="10" x2="10" y2="14" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<line x1="14" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</button>
</div>
</div>
<div class="sidebar-card">
<div class="sidebar-card-title">Basic Shapes</div>
<div class="btn-group">
<button class="btn small chip-btn" data-add="rect" title="Rect">
<span class="icon-box shape">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="7" width="14" height="10" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="roundrect" title="Round Rect">
<span class="icon-box shape">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="7" width="14" height="10" rx="5" ry="5" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="circle" title="Circle">
<span class="icon-box shape">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="6" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="line" title="Line">
<span class="icon-box shape">
<svg viewBox="0 0 24 24" aria-hidden="true">
<line x1="5" y1="18" x2="19" y2="6" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="divider" title="Divider">
<span class="icon-box shape">
<svg viewBox="0 0 24 24" aria-hidden="true">
<line x1="5" y1="12" x2="19" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</button>
</div>
</div>
<div class="sidebar-card">
<div class="sidebar-card-title">UI Elements</div>
<div class="btn-group">
<button class="btn small chip-btn" data-add="label" title="Label">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="7" width="14" height="10" rx="3" ry="3" stroke="currentColor" stroke-width="2" fill="none" />
<line x1="8" y1="11" x2="16" y2="11" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="button" title="Button">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="6" y="9" width="12" height="6" rx="3" ry="3" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="progress" title="Progress">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="10" width="14" height="4" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<rect x="6" y="11" width="7" height="2" rx="1" ry="1" fill="currentColor" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="slider" title="Slider">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<line x1="6" y1="12" x2="18" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<circle cx="10" cy="12" r="3" stroke="currentColor" stroke-width="2" fill="var(--bg-tertiary)" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="toggle" title="Toggle">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="9" width="14" height="6" rx="3" ry="3" stroke="currentColor" stroke-width="2" fill="none" />
<circle cx="15" cy="12" r="2.5" stroke="currentColor" stroke-width="2" fill="var(--bg-tertiary)" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="card" title="Card">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="7" width="14" height="10" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<line x1="7" y1="11" x2="17" y2="11" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</button>
<button class="btn small chip-btn" data-add="header" title="Header">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="7" width="14" height="4" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
</span>
</button>
<button class="btn small chip-btn" id="addImageBtn" title="Image">
<span class="icon-box ui">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="4" y="6" width="16" height="12" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<circle cx="10" cy="11" r="1.5" stroke="currentColor" stroke-width="1.5" fill="none" />
<polyline points="7,16 11,12 16,16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</span>
</button>
</div>
</div>
<div class="section-title">Scene</div>
<div class="sidebar-card">
<div class="sidebar-card-title">Background</div>
<div class="bg-color-row">
<div class="bg-presets">
<button class="bg-chip" data-bg-color="#000000">
<span class="bg-chip-swatch" style="background:#000000"></span>
<span>Black</span>
</button>
<button class="bg-chip" data-bg-color="#ffffff">
<span class="bg-chip-swatch" style="background:#ffffff"></span>
<span>White</span>
</button>
<button class="bg-chip" data-bg-color="#111827">
<span class="bg-chip-swatch" style="background:#111827"></span>
<span>Dark gray</span>
</button>
<button class="bg-chip" data-bg-color="#e5e7eb">
<span class="bg-chip-swatch" style="background:#e5e7eb"></span>
<span>Light gray</span>
</button>
<button class="bg-chip bg-chip-custom" id="bgColorCustom">
<span class="bg-chip-swatch" style="background:conic-gradient(red, orange, yellow, green, cyan, blue, magenta, red)"></span>
<span>Custom</span>
</button>
</div>
</div>
<input type="color" id="bgColor" value="#000000" style="display:none" />
</div>
<div class="section-title">Grid & Snap</div>
<div class="prop-group">
<label class="toggle-label">
<input type="checkbox" id="snapCheckbox" class="toggle-input" />
Snap to grid
</label>
<div class="prop-row">
<div>
<label for="gridSize">Grid size (px)</label>
<input type="number" id="gridSize" value="4" min="1" />
</div>
</div>
</div>
<div class="prop-group">
<label class="toggle-label">
<input type="checkbox" id="useSpriteCheckbox" class="toggle-input" />
Use sprite (TFT_eSprite) for screens
</label>
</div>
<div class="prop-group">
<button class="btn secondary small" id="clearAll">Clear all (screen)</button>
</div>
</div>
<div class="main">
<div class="top-bar">
<div class="top-left">
<div class="top-left-primary">
<span id="displayInfo">TFT_eSPI · 240x320 px</span>
<span class="pill">Multi-screen · Drag to position · Click to edit</span>
</div>
<div class="status-chips">
<span class="pill soft">Drag to move</span>
<span class="pill soft">⌘ / Ctrl + Z to undo</span>
<span class="pill soft">Export JSON for versioning</span>
</div>
</div>
<div class="top-right">
<a class="btn small github" href="https://github.com/cifertech/DisplayKit" target="_blank" rel="noreferrer">
GitHub
</a>
<a class="btn small patreon" href="https://www.patreon.com/cifertech" target="_blank" rel="noreferrer">
Patreon
</a>
<button class="btn small secondary" id="themeToggle" title="Toggle theme">
<span id="themeIcon">🌙</span>
</button>
<button class="btn small secondary" id="undoBtn">Undo</button>
<button class="btn small secondary" id="redoBtn">Redo</button>
<button class="btn small secondary" id="duplicateBtn">Duplicate</button>
<div class="slider-inline">
<span>Zoom</span>
<input type="range" id="zoomSlider" min="50" max="200" value="75" />
</div>
<button class="btn small secondary" id="exportJsonBtn">Export JSON</button>
<button class="btn small secondary" id="importJsonBtn">Import JSON</button>
</div>
</div>
<div class="workspace">
<div class="preview-wrapper">
<div class="preview-frame">
<div id="preview"></div>
</div>
</div>
<div class="properties">
<div class="section-title">Selected Element</div>
<div id="noSelection">No element selected</div>
<div id="propsPanel" style="display: none">
<div class="prop-group">
<label id="propTypeLabel">Type</label>
<div class="pill" id="elementTypePill"></div>
</div>
<div class="prop-group">
<div class="prop-row">
<div>
<label for="propX">X</label>
<input type="number" id="propX" />
</div>
<div>
<label for="propY">Y</label>
<input type="number" id="propY" />
</div>
</div>
<div class="prop-row">
<div>
<label for="propW">W</label>
<input type="number" id="propW" />
</div>
<div>
<label for="propH">H</label>
<input type="number" id="propH" />
</div>
</div>
</div>
<div class="prop-group" id="textGroup">
<label for="propText">Text</label>
<input type="text" id="propText" />
<div class="prop-row">
<div>
<label for="propTextSize">Text size (TFT)</label>
<input type="number" id="propTextSize" min="1" max="10" />
</div>
</div>
</div>
<div class="prop-group" id="fontGroup">
<label for="propFont">Font (U8g2)</label>
<select id="propFont"></select>
</div>
<div class="prop-group" id="valueGroup" style="display: none">
<label for="propValue">Value / Level (0–100)</label>
<input type="number" id="propValue" min="0" max="100" />
</div>
<div class="prop-group">
<label>Colors</label>
<div class="prop-row">
<div class="pill">
<input type="color" id="propFillColor" />
<span>Fill</span>
</div>
<div class="pill">
<input type="color" id="propStrokeColor" />
<span>Stroke</span>
</div>
<div class="pill">
<input type="color" id="propTextColor" />
<span>Text</span>
</div>
</div>
</div>
<div class="prop-group" id="actionGroup" style="display:none;">
<label for="propAction">On click</label>
<select id="propAction">
<option value="">None</option>
<option value="goto">Go to screen…</option>
</select>
<div class="prop-row">
<div>
<label for="propActionTarget">Target screen</label>
<select id="propActionTarget"></select>
</div>
</div>
</div>
<div class="prop-group">
<label>Align to screen</label>
<div class="btn-group">
<button class="btn small secondary" id="alignLeftBtn">Left</button>
<button class="btn small secondary" id="alignHCenterBtn">H-Center</button>
<button class="btn small secondary" id="alignRightBtn">Right</button>
<button class="btn small secondary" id="alignTopBtn">Top</button>
<button class="btn small secondary" id="alignVCenterBtn">V-Center</button>
<button class="btn small secondary" id="alignBottomBtn">Bottom</button>
</div>
</div>
<div class="prop-group" style="display: flex; justify-content: flex-end;">
<button class="btn secondary small icon-btn-ghost" id="deleteElement" title="Delete element">
<svg viewBox="0 0 24 24" aria-hidden="true">
<polyline points="9,6 10,4 14,4 15,6" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" />
<rect x="7" y="6" width="10" height="12" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<line x1="10" y1="10" x2="10" y2="14" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
<line x1="14" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
</svg>
</button>
</div>
</div>
</div>
</div>
<div class="code-panel">
<div style="display: flex; justify-content: space-between; align-items: center">
<div class="section-title">Generated Code (TFT_eSPI / U8g2)</div>
<div>
<button class="btn small secondary" id="copyCode">
<svg viewBox="0 0 24 24" aria-hidden="true" style="width:14px;height:14px;margin-right:4px">
<rect x="9" y="9" width="11" height="11" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
<rect x="4" y="4" width="11" height="11" rx="2" ry="2" stroke="currentColor" stroke-width="2" fill="none" />
</svg>
<span>Copy</span>
</button>
</div>
</div>
<textarea id="codeOutput" spellcheck="false"></textarea>
</div>
</div>
</div>
<input type="file" id="imageInput" accept="image/*" style="display: none" />
<input type="file" id="importJsonInput" accept="application/json" style="display:none" />
<script src="app.js"></script>
</body>
</html>