-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcss_test.html
More file actions
542 lines (477 loc) · 21.8 KB
/
css_test.html
File metadata and controls
542 lines (477 loc) · 21.8 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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas View CSS Test - All Button Styles</title>
<link rel="stylesheet" href="src/css/canvas_view.css">
<style>
body {
font-family: Arial, sans-serif;
background: #2a2a2a;
color: #ffffff;
margin: 20px;
line-height: 1.6;
}
.test-section {
margin: 30px 0;
padding: 20px;
background: #353535;
border-radius: 8px;
border: 1px solid #444;
}
.test-section h2 {
color: #4a90e2;
margin-top: 0;
border-bottom: 1px solid #555;
padding-bottom: 10px;
}
.test-section h3 {
color: #ffffff;
margin: 20px 0 10px 0;
}
.demo-row {
margin: 15px 0;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.demo-label {
min-width: 150px;
color: #cccccc;
font-size: 14px;
}
.test-controls {
margin: 20px 0;
}
.test-controls button {
margin: 5px;
padding: 8px 16px;
background: #4a6cd4;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.test-controls button:hover {
background: #5a7ce4;
}
/* Custom Slider Styles to match ComfyUI aesthetic */
input[type="range"] {
-webkit-appearance: none;
appearance: none;
width: 80px; /* Default width from painter-slider-container */
height: 7px;
background: #222;
border-radius: 5px;
outline: none;
margin: 0;
padding: 0;
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
background: #cccccc;
border-radius: 50%;
border: 2px solid #555;
cursor: pointer;
margin-top: -4.5px; /* Center thumb on track */
transition: background 0.2s;
}
input[type="range"]::-moz-range-thumb {
width: 16px;
height: 16px;
background: #cccccc;
border-radius: 50%;
border: 2px solid #555;
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb:hover {
background: #e0e0e0;
}
input[type="range"]::-moz-range-thumb:hover {
background: #e0e0e0;
}
input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 7px;
background: #222;
border-radius: 5px;
}
input[type="range"]::-moz-range-track {
width: 100%;
height: 7px;
background: #222;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Canvas View CSS Test Page</h1>
<p>This page demonstrates all button styles from <code>src/css/canvas_view.css</code></p>
<div class="test-controls">
<button onclick="toggleLoadingState()">Toggle Loading State</button>
<button onclick="toggleDisabledState()">Toggle Disabled State</button>
<button onclick="toggleClipboardSwitch()">Toggle Clipboard Switch</button>
</div>
<!-- CanvasView Full Control Panel -->
<div class="test-section">
<h2>CanvasView Control Panel Layout</h2>
<div class="painter-controls" style="position: relative; flex-wrap: wrap; padding: 10px; background: #383838;">
<!-- Group 1: Main Controls -->
<div class="painter-button-group">
<button class="painter-button icon-button" title="Open in Editor">⛶</button>
<button class="painter-button icon-button" title="Show shortcuts">?</button>
<button class="painter-button primary">Add Image</button>
<button class="painter-button primary">Import Input</button>
<div class="painter-clipboard-group">
<button class="painter-button primary">Paste Image</button>
<label class="clipboard-switch" id="test-clipboard-switch">
<input type="checkbox">
<span class="switch-track"></span>
<span class="switch-labels">
<span class="text-clipspace">Clipspace</span>
<span class="text-system">System</span>
</span>
<span class="switch-knob">
<span class="switch-icon">
<img src="" alt="clipboard icon" style="width: 20px; height: 20px;">
</span>
</span>
</label>
</div>
</div>
<div class="painter-separator"></div>
<!-- Group 2: Layer Management -->
<div class="painter-button-group">
<button class="painter-button">Output Area Size</button>
<button class="painter-button requires-selection">Remove Layer</button>
<button class="painter-button requires-selection">Layer Up</button>
<button class="painter-button requires-selection">Layer Down</button>
<button class="painter-button requires-selection">Fuse</button>
</div>
<div class="painter-separator"></div>
<!-- Group 3: Transformations -->
<div class="painter-button-group">
<button class="painter-button requires-selection">Rotate +90°</button>
<button class="painter-button requires-selection">Scale +5%</button>
<button class="painter-button requires-selection">Scale -5%</button>
<button class="painter-button requires-selection">Mirror H</button>
<button class="painter-button requires-selection">Mirror V</button>
</div>
<div class="painter-separator"></div>
<!-- Group 4: Tools -->
<div class="painter-button-group">
<button class="painter-button matting-button requires-selection">Matting<div class="matting-spinner"></div></button>
<button class="painter-button">Undo</button>
<button class="painter-button">Redo</button>
</div>
<div class="painter-separator"></div>
<!-- Group 5: Masking -->
<div class="painter-button-group" id="test-mask-controls">
<label class="clipboard-switch mask-switch" title="Toggle mask overlay visibility" style="min-width: 56px; max-width: 56px; width: 56px;">
<input type="checkbox" checked="">
<span class="switch-track"></span>
<span class="switch-labels" style="font-size: 11px;">
<span class="text-clipspace" style="padding-right: 22px;">On</span>
<span class="text-system" style="padding-left: 20px;">Off</span>
</span>
<span class="switch-knob">
<span class="switch-icon" style="display: flex; align-items: center; justify-content: center; width: 16px; height: 16px;">
<!-- Icon would be loaded here by JS -->
</span>
</span>
</label>
<button class="painter-button">Edit Mask</button>
<button class="painter-button" id="test-mask-mode-btn" onclick="toggleTestMaskControls()">Draw Mask</button>
<div class="painter-slider-container mask-control" style="display: none;">
<label>Size:</label>
<input type="range" min="1" max="200" value="20">
<div class="slider-value">20px</div>
</div>
<div class="painter-slider-container mask-control" style="display: none;">
<label>Strength:</label>
<input type="range" min="0" max="1" step="0.05" value="0.5">
<div class="slider-value">50%</div>
</div>
<div class="painter-slider-container mask-control" style="display: none;">
<label>Hardness:</label>
<input type="range" min="0" max="1" step="0.05" value="0.5">
<div class="slider-value">50%</div>
</div>
<button class="painter-button mask-control" style="display: none;">Clear Mask</button>
</div>
<div class="painter-separator"></div>
<!-- Group 6: Dev/Debug -->
<div class="painter-button-group">
<button class="painter-button success">Run GC</button>
<button class="painter-button danger">Clear Cache</button>
</div>
</div>
</div>
<!-- Basic Buttons -->
<div class="test-section">
<h2>Basic Painter Buttons</h2>
<div class="demo-row">
<span class="demo-label">Normal Button:</span>
<button class="painter-button">Normal Button</button>
<button class="painter-button">Another Button</button>
<button class="painter-button">Third Button</button>
</div>
<div class="demo-row">
<span class="demo-label">Primary Button:</span>
<button class="painter-button primary">Primary Button</button>
<button class="painter-button primary">Save</button>
<button class="painter-button primary">Apply</button>
</div>
<div class="demo-row">
<span class="demo-label">Disabled Buttons:</span>
<button class="painter-button" disabled>Disabled Normal</button>
<button class="painter-button primary" disabled>Disabled Primary</button>
</div>
<div class="demo-row">
<span class="demo-label">Matting Buttons:</span>
<button class="painter-button matting-button" id="mattingBtn1">
Matting Tool
<div class="matting-spinner"></div>
</button>
<button class="painter-button matting-button" id="mattingBtn2">
Process Image
<div class="matting-spinner"></div>
</button>
</div>
</div>
<!-- Button Groups -->
<div class="test-section">
<h2>Button Groups and Controls</h2>
<h3>Painter Controls Container</h3>
<div class="painter-controls">
<button class="painter-button">Tool 1</button>
<button class="painter-button">Tool 2</button>
<button class="painter-button primary">Active Tool</button>
<div class="painter-separator"></div>
<button class="painter-button">Option A</button>
<button class="painter-button">Option B</button>
</div>
<h3>Button Group</h3>
<div class="painter-button-group">
<button class="painter-button">Group 1</button>
<button class="painter-button">Group 2</button>
<button class="painter-button primary">Group 3</button>
</div>
<h3>Clipboard Group</h3>
<div class="painter-clipboard-group">
<button class="painter-button">Copy</button>
<button class="painter-button">Paste</button>
<button class="painter-button primary">Clear</button>
</div>
</div>
<!-- Clipboard Switch -->
<div class="test-section">
<h2>Clipboard Switch</h2>
<div class="demo-row">
<span class="demo-label">Clipboard Switch:</span>
<label class="clipboard-switch" id="clipboardSwitch">
<input type="checkbox">
<span class="switch-track"></span>
<span class="switch-knob">
<span class="switch-icon">
<img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTkgMTZIMTVWMTBIOVYxNloiIGZpbGw9IiM0YTkwZTIiLz4KPHBhdGggZD0iTTcgMTZIMTdWMTBIN1YxNloiIHN0cm9rZT0iIzRhOTBlMiIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJub25lIi8+Cjwvc3ZnPgo=" alt="clipboard">
</span>
</span>
<span class="switch-labels">
<span class="text-system">System</span>
<span class="text-clipspace">Clipspace</span>
</span>
</label>
</div>
</div>
<!-- Sliders -->
<div class="test-section">
<h2>Sliders and Controls</h2>
<div class="painter-controls">
<div class="painter-slider-container">
<label>Opacity:</label>
<input type="range" min="0" max="100" value="50">
<span>50%</span>
</div>
<div class="painter-separator"></div>
<div class="painter-slider-container">
<label>Size:</label>
<input type="range" min="1" max="100" value="25">
<span>25px</span>
</div>
</div>
</div>
<!-- Container Examples -->
<div class="test-section">
<h2>Container Examples</h2>
<h3>Normal Container</h3>
<div class="painter-container" style="padding: 20px; margin: 10px 0;">
<p>This is a normal painter container</p>
<button class="painter-button">Button inside container</button>
</div>
<h3>Container with Focus</h3>
<div class="painter-container has-focus" style="padding: 20px; margin: 10px 0;">
<p>This container has focus (white border)</p>
<button class="painter-button primary">Focused container button</button>
</div>
<h3>Drag Over Container</h3>
<div class="painter-container drag-over" style="padding: 20px; margin: 10px 0;">
<p>This container is in drag-over state (green dashed border)</p>
<button class="painter-button">Drag target button</button>
</div>
</div>
<!-- Modal Example -->
<div class="test-section">
<h2>Modal and Dialog</h2>
<button onclick="showModal()" class="painter-button primary">Show Modal Example</button>
<h3>Dialog Example</h3>
<div class="painter-dialog" style="display: inline-block; margin: 10px 0;">
<h4>Sample Dialog</h4>
<p>Enter values:</p>
<input type="text" placeholder="Width" value="100">
<input type="text" placeholder="Height" value="100">
<br>
<button>OK</button>
<button>Cancel</button>
</div>
</div>
<!-- Hidden Modal -->
<div class="painter-modal-backdrop" id="testModal" style="display: none;">
<div class="painter-modal-content">
<div class="painterMainContainer">
<div class="painter-controls">
<button class="painter-button" onclick="hideModal()">Close Modal</button>
<button class="painter-button primary">Save</button>
<div class="painter-separator"></div>
<button class="painter-button">Option 1</button>
<button class="painter-button">Option 2</button>
</div>
<div class="painterCanvasContainer" style="padding: 20px; display: flex; align-items: center; justify-content: center;">
<div>
<h3>Modal Content Area</h3>
<p>This is the main content area of the modal.</p>
<div class="painter-button-group">
<button class="painter-button">Action 1</button>
<button class="painter-button">Action 2</button>
<button class="painter-button primary">Primary Action</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- This is where the tooltip will be rendered -->
<div class="painter-tooltip" id="live-tooltip" style="display: none;"></div>
<script>
// Toggle loading state for matting buttons
function toggleLoadingState() {
const mattingBtns = document.querySelectorAll('.matting-button');
mattingBtns.forEach(btn => {
btn.classList.toggle('loading');
});
}
// Toggle disabled state for all buttons
function toggleDisabledState() {
const buttons = document.querySelectorAll('.painter-button:not(.matting-button)');
buttons.forEach(btn => {
btn.disabled = !btn.disabled;
});
}
// Toggle clipboard switch
function toggleClipboardSwitch() {
const checkbox = document.querySelector('#clipboardSwitch input[type="checkbox"]');
checkbox.checked = !checkbox.checked;
}
// Show modal
function showModal() {
document.getElementById('testModal').style.display = 'flex';
}
// Hide modal
function hideModal() {
document.getElementById('testModal').style.display = 'none';
}
// --- Live Tooltip Logic ---
const tooltipButton = document.querySelector('button[title="Show shortcuts"]');
const tooltipContainer = document.getElementById('live-tooltip');
let shortcutsHtml = '';
// Pre-fetch the shortcuts content
fetch('src/templates/standard_shortcuts.html')
.then(response => response.text())
.then(html => {
shortcutsHtml = html;
})
.catch(error => {
console.error('Error fetching shortcuts:', error);
shortcutsHtml = '<p>Error loading shortcuts.</p>';
});
tooltipButton.addEventListener('mouseenter', (e) => {
if (!shortcutsHtml || !tooltipContainer) return;
tooltipContainer.innerHTML = shortcutsHtml;
tooltipContainer.style.visibility = 'hidden';
tooltipContainer.style.display = 'block';
const buttonRect = e.target.getBoundingClientRect();
const tooltipRect = tooltipContainer.getBoundingClientRect();
let left = buttonRect.left;
let top = buttonRect.bottom + 5;
// Adjust position to stay within viewport
if (left + tooltipRect.width > window.innerWidth) {
left = window.innerWidth - tooltipRect.width - 10;
}
if (top + tooltipRect.height > window.innerHeight) {
top = buttonRect.top - tooltipRect.height - 5;
}
if (left < 10) left = 10;
if (top < 10) top = 10;
tooltipContainer.style.left = `${left}px`;
tooltipContainer.style.top = `${top}px`;
tooltipContainer.style.visibility = 'visible';
});
tooltipButton.addEventListener('mouseleave', () => {
if (tooltipContainer) {
tooltipContainer.style.display = 'none';
}
});
// Close modal when clicking backdrop
document.getElementById('testModal').addEventListener('click', function(e) {
if (e.target === this) {
hideModal();
}
});
// --- Icon Loading and Interactive Logic ---
const icons = {
system: `data:image/svg+xml;charset=utf-8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path d="M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm5 15H7v-2h10v2zm0-4H7v-2h10v2zm0-4H7V7h10v2z"/></svg>')}`,
clipspace: `data:image/svg+xml;charset=utf-8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff"><path d="M17 7H7c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zm0 12H7V9h10v10z"/><path d="M19 3H9c-1.1 0-2 .9-2 2v2h2V5h10v10h-2v2h2c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"/></svg>')}`
};
function updateClipboardIcon(switchElement) {
const isChecked = switchElement.querySelector('input').checked;
const iconImg = switchElement.querySelector('.switch-icon img');
iconImg.src = isChecked ? icons.clipspace : icons.system;
}
document.addEventListener('DOMContentLoaded', () => {
const clipboardSwitch = document.getElementById('test-clipboard-switch');
if (clipboardSwitch) {
updateClipboardIcon(clipboardSwitch);
clipboardSwitch.querySelector('input').addEventListener('change', () => {
updateClipboardIcon(clipboardSwitch);
});
}
});
// Function to toggle mask controls in the test layout
function toggleTestMaskControls() {
const maskBtn = document.getElementById('test-mask-mode-btn');
const maskControlsContainer = document.getElementById('test-mask-controls');
const controls = maskControlsContainer.querySelectorAll('.mask-control');
const isActive = maskBtn.classList.toggle('primary');
controls.forEach(control => {
control.style.display = isActive ? 'flex' : 'none';
});
}
</script>
</body>
</html>