Algorick commited on
Commit
b61c694
·
verified ·
1 Parent(s): fdaac23

dc8a5bcb540e

Browse files
Files changed (6) hide show
  1. web/app.js +17 -2
  2. web/i18n/en.json +16 -4
  3. web/index.html +37 -11
  4. web/mobile.js +25 -2
  5. web/poster.js +62 -2
  6. web/style.css +78 -15
web/app.js CHANGED
@@ -519,7 +519,7 @@ function setMode(mode) {
519
  $$(".modes [role=tab]").forEach((t) => t.setAttribute("aria-selected", String(t.dataset.mode === mode)));
520
  const cfg = MODES[mode];
521
  $("#mode-hint").textContent = cfg.hint;
522
- $("#prompt").placeholder = cfg.placeholder;
523
  $("#generate-label").textContent = cfg.button;
524
  $("#ref-add-label").textContent = mode === "ristila" ? "Foto" : "Foto";
525
  const supports = state.model === BOTH ? !["modifica", "continua"].includes(mode)
@@ -577,7 +577,8 @@ function refsChanged() {
577
  async function addFiles(files) {
578
  const images = [...files].filter((f) => f.type.startsWith("image/"));
579
  if (!images.length) return;
580
- if (state.mode === "crea") setMode(images.length > 1 ? "modifica" : "ristila");
 
581
  const max = MODES[state.mode].maxRefs;
582
  if (state.mode === "ristila" || state.mode === "continua") state.refs = [];
583
  for (const f of images) {
@@ -590,9 +591,22 @@ async function addFiles(files) {
590
  toast(e.message);
591
  }
592
  }
 
593
  $("#prompt").focus();
594
  }
595
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  function useAsRef(item, mode) {
597
  state.refs = [{ file: "outputs/" + item.file, nome: titleOf(item) }];
598
  setView("studio");
@@ -1879,6 +1893,7 @@ function wire() {
1879
  $$(".modes [role=tab]").forEach((t) => t.addEventListener("click", () => setMode(t.dataset.mode)));
1880
  $$(".views button[data-view]").forEach((b) => b.addEventListener("click", () => setView(b.dataset.view)));
1881
  $("#file-input").addEventListener("change", (e) => { addFiles(e.target.files); e.target.value = ""; });
 
1882
 
1883
  const stage = $("#stage");
1884
  let depth = 0;
 
519
  $$(".modes [role=tab]").forEach((t) => t.setAttribute("aria-selected", String(t.dataset.mode === mode)));
520
  const cfg = MODES[mode];
521
  $("#mode-hint").textContent = cfg.hint;
522
+ $("#prompt").placeholder = matchMedia("(max-width: 760px)").matches ? cfg.placeholder.replace("a destra", "in «Stile e impostazioni»") : cfg.placeholder;
523
  $("#generate-label").textContent = cfg.button;
524
  $("#ref-add-label").textContent = mode === "ristila" ? "Foto" : "Foto";
525
  const supports = state.model === BOTH ? !["modifica", "continua"].includes(mode)
 
577
  async function addFiles(files) {
578
  const images = [...files].filter((f) => f.type.startsWith("image/"));
579
  if (!images.length) return;
580
+ const fromScratch = state.mode === "crea";
581
+ if (fromScratch) setMode(images.length > 1 ? "modifica" : "ristila");
582
  const max = MODES[state.mode].maxRefs;
583
  if (state.mode === "ristila" || state.mode === "continua") state.refs = [];
584
  for (const f of images) {
 
591
  toast(e.message);
592
  }
593
  }
594
+ if (fromScratch && images.length === 1 && state.refs.length) { askStart(); return; }
595
  $("#prompt").focus();
596
  }
597
 
598
+ function askStart() {
599
+ const dlg = $("#start-dlg");
600
+ dlg.returnValue = "";
601
+ dlg.showModal();
602
+ dlg.addEventListener("close", () => {
603
+ const mode = dlg.returnValue;
604
+ if (mode && mode !== state.mode) setMode(mode);
605
+ refsChanged();
606
+ $("#prompt").focus();
607
+ }, { once: true });
608
+ }
609
+
610
  function useAsRef(item, mode) {
611
  state.refs = [{ file: "outputs/" + item.file, nome: titleOf(item) }];
612
  setView("studio");
 
1893
  $$(".modes [role=tab]").forEach((t) => t.addEventListener("click", () => setMode(t.dataset.mode)));
1894
  $$(".views button[data-view]").forEach((b) => b.addEventListener("click", () => setView(b.dataset.view)));
1895
  $("#file-input").addEventListener("change", (e) => { addFiles(e.target.files); e.target.value = ""; });
1896
+ $("#empty-file").addEventListener("change", (e) => { addFiles(e.target.files); e.target.value = ""; });
1897
 
1898
  const stage = $("#stage");
1899
  let depth = 0;
web/i18n/en.json CHANGED
@@ -77,7 +77,6 @@
77
  "Clicca per vederla a grandezza reale e scorrerla": "Click to see it full size and pan around",
78
  "Clicca per vederla a grandezza reale e scorrerla. ← → per passare alle altre.": "Click to see it full size and pan around. ← → to move between images.",
79
  "Colore": "Color",
80
- "Colori": "Colors",
81
  "Com'è fatto": "How it was made",
82
  "Come funziona": "How it works",
83
  "Come la foto": "Like the photo",
@@ -99,7 +98,6 @@
99
  "Copia prompt": "Copy prompt",
100
  "Cosa cambiare: «togli la persona a sinistra», «metti un cappello rosso». Con più foto: «il gatto della foto 2 sul divano della foto 1».": "What to change: “remove the person on the left”, “add a red hat”. With more photos: “the cat from photo 2 on the sofa from photo 1”.",
101
  "Cosa vuoi fare": "What do you want to do",
102
- "Cosa vuoi vedere oggi?": "What do you want to see today?",
103
  "Crea": "Create",
104
  "Crea il tuo stile": "Create your style",
105
  "Crea la scena": "Create the scene",
@@ -171,7 +169,7 @@
171
  "Genera": "Generate",
172
  "Gestionale web con barra laterale, card, grafici e tabelle.": "Web admin app with sidebar, cards, charts and tables.",
173
  "Gomma (E)": "Eraser (E)",
174
- "Grafica": "Graphics",
175
  "Grana da stampa": "Print grain",
176
  "Guarda da sola": "View on its own",
177
  "Guarda se la foto è una foto o un disegno e cosa chiede lo stile. Se serve capire l'immagine (disegno → foto, Funko…) passa da solo a Klein.": "Checks whether the image is a photo or a drawing and what the style asks for. When the image needs to be understood (drawing → photo, Funko…) it switches to Klein on its own.",
@@ -643,5 +641,19 @@
643
  "English": "English",
644
  "Scegli uno stile": "Choose a style",
645
  "Stile e impostazioni": "Style and settings",
646
- "Scrivi un'idea qui sotto. Per partire da una tua foto scegli Ristila o Modifica. Le immagini restano sul tuo telefono.": "Write an idea below. To start from one of your photos, pick Restyle or Edit. Your images stay on your phone."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  }
 
77
  "Clicca per vederla a grandezza reale e scorrerla": "Click to see it full size and pan around",
78
  "Clicca per vederla a grandezza reale e scorrerla. ← → per passare alle altre.": "Click to see it full size and pan around. ← → to move between images.",
79
  "Colore": "Color",
 
80
  "Com'è fatto": "How it was made",
81
  "Come funziona": "How it works",
82
  "Come la foto": "Like the photo",
 
98
  "Copia prompt": "Copy prompt",
99
  "Cosa cambiare: «togli la persona a sinistra», «metti un cappello rosso». Con più foto: «il gatto della foto 2 sul divano della foto 1».": "What to change: “remove the person on the left”, “add a red hat”. With more photos: “the cat from photo 2 on the sofa from photo 1”.",
100
  "Cosa vuoi fare": "What do you want to do",
 
101
  "Crea": "Create",
102
  "Crea il tuo stile": "Create your style",
103
  "Crea la scena": "Create the scene",
 
169
  "Genera": "Generate",
170
  "Gestionale web con barra laterale, card, grafici e tabelle.": "Web admin app with sidebar, cards, charts and tables.",
171
  "Gomma (E)": "Eraser (E)",
172
+ "Grafica": "Look",
173
  "Grana da stampa": "Print grain",
174
  "Guarda da sola": "View on its own",
175
  "Guarda se la foto è una foto o un disegno e cosa chiede lo stile. Se serve capire l'immagine (disegno → foto, Funko…) passa da solo a Klein.": "Checks whether the image is a photo or a drawing and what the style asks for. When the image needs to be understood (drawing → photo, Funko…) it switches to Klein on its own.",
 
641
  "English": "English",
642
  "Scegli uno stile": "Choose a style",
643
  "Stile e impostazioni": "Style and settings",
644
+ "Loghi": "Logos",
645
+ "Cosa modificare": "What to edit",
646
+ "Clicca un testo per correggerlo. Trascina loghi e foto per spostarli, tira l'angolo per ridimensionarli.": "Click a text to edit it. Drag logos and photos to move them, pull the corner to resize.",
647
+ "Tocca un testo per correggerlo, trascina loghi e foto per spostarli": "Tap a text to edit it, drag logos and photos to move them",
648
+ "Scrivi cosa vuoi generare o carica un'immagine": "Describe what you want to create, or upload an image",
649
+ "Con un'idea scritta qui sotto nasce un'immagine nuova. Con una tua foto puoi cambiarle stile, modificarla o farne il punto di partenza di una storia.": "Write an idea below to create a new image. With one of your photos you can restyle it, edit it or make it the start of a story.",
650
+ "Carica un'immagine": "Upload an image",
651
+ "oppure trascinala qui": "or drop it here",
652
+ "Cosa vuoi fare con questa foto?": "What do you want to do with this photo?",
653
+ "Stessa foto, stile nuovo: anime, fumetto, Funko, dipinto…": "Same photo, new style: anime, comic, Funko, painting…",
654
+ "Scrivi cosa cambiare: togli, aggiungi, sostituisci. Anche solo in una zona.": "Write what to change: remove, add, replace. Even just one area.",
655
+ "Puoi anche ingrandirla, scontornarla o vettorizzarla con i pulsanti sotto la foto.": "You can also upscale, cut out or vectorize it with the buttons under the photo.",
656
+ "Scegli uno stile in «Stile e impostazioni». Con Z-Image descrivi anche in breve chi c'è nella foto: «uomo con barba lunga, maglietta nera e chitarra rossa».": "Pick a style in «Style and settings». With Z-Image also briefly describe who's in the photo: “man with a long beard, black t-shirt and red guitar”.",
657
+ "Zona e impostazioni": "Area and settings",
658
+ "Dipingi una zona": "Paint an area"
659
  }
web/index.html CHANGED
@@ -125,9 +125,14 @@
125
  </nav>
126
  <div class="stage" id="stage" data-state="vuoto">
127
  <div class="empty">
128
- <h1>Cosa vuoi vedere oggi?</h1>
129
- <p class="empty-desk">Descrivi un'idea qui sotto, oppure trascina qui una foto per cambiarle stile o modificarla. Le immagini restano sul tuo dispositivo.</p>
130
- <p class="empty-phone">Scrivi un'idea qui sotto. Per partire da una tua foto scegli Ristila o Modifica. Le immagini restano sul tuo telefono.</p>
 
 
 
 
 
131
  </div>
132
 
133
  <div class="base" id="base">
@@ -239,7 +244,7 @@
239
 
240
  <div class="next-bar" id="next-bar" hidden>
241
  <img id="next-thumb" alt="">
242
- <p><b>Nuova versione pronta.</b> Vuoi continuare a lavorare su questa?</p>
243
  <button type="button" class="link" id="next-stay">Resta sull'originale</button>
244
  <button type="button" class="save-btn" id="next-use"><svg><use href="#i-check"/></svg><span>Continua con questa</span></button>
245
  </div>
@@ -378,19 +383,28 @@
378
  <div class="pp-frame" id="pp-frame" hidden><span class="pp-handle"></span></div>
379
  </div>
380
  </div>
381
- <p class="pp-hint">Trascina loghi e foto per spostarli, tira l'angolo per ridimensionarli. Canc li toglie.</p>
 
382
  <div class="poster-empty" id="poster-empty" hidden></div>
383
  </section>
384
 
385
  <aside class="poster-panel" aria-label="Locandina">
 
 
 
 
 
 
 
 
386
  <div class="poster-scroll">
387
- <section class="panel">
388
  <h2>Template</h2>
389
  <div class="pp-templates" id="pp-templates" role="radiogroup" aria-label="Template"></div>
390
  <p class="panel-note" id="pp-template-desc"></p>
391
  </section>
392
 
393
- <section class="panel">
394
  <div class="panel-head">
395
  <h2>Immagine</h2>
396
  <button type="button" class="link" id="pp-bg-remove">Togli</button>
@@ -407,7 +421,7 @@
407
  <input type="range" id="pp-bg-zoom" min="1" max="2" step="0.01" value="1">
408
  </section>
409
 
410
- <section class="panel">
411
  <h2>Loghi e foto</h2>
412
  <div class="pp-two-btn">
413
  <label class="wide-btn file-btn">
@@ -447,7 +461,7 @@
447
  </div>
448
  </section>
449
 
450
- <section class="panel">
451
  <div class="panel-head">
452
  <h2>Testi</h2>
453
  <button type="button" class="link" id="pp-clear-texts">Svuota</button>
@@ -470,7 +484,7 @@
470
  </label>
471
  </section>
472
 
473
- <section class="panel">
474
  <h2>Carattere</h2>
475
  <div class="font-list" id="pp-fonts" role="radiogroup" aria-label="Carattere"></div>
476
  <label class="row-label" for="pp-text-scale">Dimensione testi</label>
@@ -482,7 +496,7 @@
482
  </div>
483
  </section>
484
 
485
- <section class="panel">
486
  <h2>Formato</h2>
487
  <div class="segmented small" id="pp-format" role="radiogroup" aria-label="Formato della locandina"></div>
488
  <div id="pp-shade-row">
@@ -584,6 +598,18 @@
584
  </div>
585
  </dialog>
586
 
 
 
 
 
 
 
 
 
 
 
 
 
587
  <dialog class="sheet info-sheet" id="info-dlg" aria-labelledby="info-title">
588
  <form method="dialog">
589
  <h2 id="info-title">Info sull'immagine</h2>
 
125
  </nav>
126
  <div class="stage" id="stage" data-state="vuoto">
127
  <div class="empty">
128
+ <h1>Scrivi cosa vuoi generare o carica un'immagine</h1>
129
+ <p>Con un'idea scritta qui sotto nasce un'immagine nuova. Con una tua foto puoi cambiarle stile, modificarla o farne il punto di partenza di una storia.</p>
130
+ <label class="empty-upload">
131
+ <input type="file" id="empty-file" accept="image/*" multiple>
132
+ <svg><use href="#i-upload"/></svg>
133
+ <span>Carica un'immagine</span>
134
+ </label>
135
+ <small class="empty-desk">oppure trascinala qui</small>
136
  </div>
137
 
138
  <div class="base" id="base">
 
244
 
245
  <div class="next-bar" id="next-bar" hidden>
246
  <img id="next-thumb" alt="">
247
+ <p><b>Nuova versione pronta.</b> <span class="nb-ask">Vuoi continuare a lavorare su questa?</span></p>
248
  <button type="button" class="link" id="next-stay">Resta sull'originale</button>
249
  <button type="button" class="save-btn" id="next-use"><svg><use href="#i-check"/></svg><span>Continua con questa</span></button>
250
  </div>
 
383
  <div class="pp-frame" id="pp-frame" hidden><span class="pp-handle"></span></div>
384
  </div>
385
  </div>
386
+ <p class="pp-hint">Clicca un testo per correggerlo. Trascina loghi e foto per spostarli, tira l'angolo per ridimensionarli.</p>
387
+ <p class="pp-hint pp-hint-phone">Tocca un testo per correggerlo, trascina loghi e foto per spostarli</p>
388
  <div class="poster-empty" id="poster-empty" hidden></div>
389
  </section>
390
 
391
  <aside class="poster-panel" aria-label="Locandina">
392
+ <div class="poster-tabs" id="poster-tabs" role="tablist" aria-label="Cosa modificare">
393
+ <button type="button" role="tab" data-tab="testi" aria-selected="true">Testi</button>
394
+ <button type="button" role="tab" data-tab="modello" aria-selected="false">Modello</button>
395
+ <button type="button" role="tab" data-tab="immagine" aria-selected="false">Immagine</button>
396
+ <button type="button" role="tab" data-tab="loghi" aria-selected="false">Loghi</button>
397
+ <button type="button" role="tab" data-tab="stile" aria-selected="false">Grafica</button>
398
+ <button type="button" role="tab" data-tab="formato" aria-selected="false">Formato</button>
399
+ </div>
400
  <div class="poster-scroll">
401
+ <section class="panel" data-tab="modello">
402
  <h2>Template</h2>
403
  <div class="pp-templates" id="pp-templates" role="radiogroup" aria-label="Template"></div>
404
  <p class="panel-note" id="pp-template-desc"></p>
405
  </section>
406
 
407
+ <section class="panel" data-tab="immagine">
408
  <div class="panel-head">
409
  <h2>Immagine</h2>
410
  <button type="button" class="link" id="pp-bg-remove">Togli</button>
 
421
  <input type="range" id="pp-bg-zoom" min="1" max="2" step="0.01" value="1">
422
  </section>
423
 
424
+ <section class="panel" data-tab="loghi">
425
  <h2>Loghi e foto</h2>
426
  <div class="pp-two-btn">
427
  <label class="wide-btn file-btn">
 
461
  </div>
462
  </section>
463
 
464
+ <section class="panel" data-tab="testi">
465
  <div class="panel-head">
466
  <h2>Testi</h2>
467
  <button type="button" class="link" id="pp-clear-texts">Svuota</button>
 
484
  </label>
485
  </section>
486
 
487
+ <section class="panel" data-tab="stile">
488
  <h2>Carattere</h2>
489
  <div class="font-list" id="pp-fonts" role="radiogroup" aria-label="Carattere"></div>
490
  <label class="row-label" for="pp-text-scale">Dimensione testi</label>
 
496
  </div>
497
  </section>
498
 
499
+ <section class="panel" data-tab="formato">
500
  <h2>Formato</h2>
501
  <div class="segmented small" id="pp-format" role="radiogroup" aria-label="Formato della locandina"></div>
502
  <div id="pp-shade-row">
 
598
  </div>
599
  </dialog>
600
 
601
+ <dialog class="sheet start-sheet" id="start-dlg" aria-labelledby="start-title">
602
+ <form method="dialog">
603
+ <h2 id="start-title">Cosa vuoi fare con questa foto?</h2>
604
+ <div class="action-list">
605
+ <button type="submit" class="action-item" value="ristila"><svg><use href="#i-palette"/></svg><b>Ristila</b><small>Stessa foto, stile nuovo: anime, fumetto, Funko, dipinto…</small></button>
606
+ <button type="submit" class="action-item" value="modifica"><svg><use href="#i-wand"/></svg><b>Modifica</b><small>Scrivi cosa cambiare: togli, aggiungi, sostituisci. Anche solo in una zona.</small></button>
607
+ <button type="submit" class="action-item" value="continua"><svg><use href="#i-book"/></svg><b>Continua la storia</b><small>Una scena nuova con gli stessi personaggi e lo stesso stile.</small></button>
608
+ </div>
609
+ <p class="panel-note">Puoi anche ingrandirla, scontornarla o vettorizzarla con i pulsanti sotto la foto.</p>
610
+ </form>
611
+ </dialog>
612
+
613
  <dialog class="sheet info-sheet" id="info-dlg" aria-labelledby="info-title">
614
  <form method="dialog">
615
  <h2 id="info-title">Info sull'immagine</h2>
web/mobile.js CHANGED
@@ -64,10 +64,21 @@
64
  /* ---------- riepilogo delle impostazioni sul pulsante ---------- */
65
 
66
  const summary = $("#settings-summary");
 
67
  function syncSummary() {
68
- const style = $$("#pills .pill").find((p) => /^(Stile|Style)$/.test(p.querySelector(".pill-k")?.textContent.trim() || ""));
69
- const value = style?.querySelector(".pill-v")?.textContent.trim() || "";
 
 
 
 
 
 
 
 
 
70
  const none = !value || /^(Nessuno|None|Come la foto|Like the photo)$/.test(value);
 
71
  summary.textContent = none ? "Scegli uno stile" : value;
72
  $("#settings-btn").classList.toggle("is-empty", none);
73
  }
@@ -201,6 +212,18 @@
201
  openMore();
202
  }, true);
203
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  /* ---------- tasto indietro: viste, fogli e finestre ---------- */
205
 
206
  const setView = window.setView;
 
64
  /* ---------- riepilogo delle impostazioni sul pulsante ---------- */
65
 
66
  const summary = $("#settings-summary");
67
+ const label = $("#settings-btn .settings-text small");
68
  function syncSummary() {
69
+ const pills = $$("#pills .pill");
70
+ const find = (re) => pills.find((p) => re.test(p.querySelector(".pill-k")?.textContent.trim() || ""));
71
+ const zone = find(/^(Zona|Area)$/);
72
+ if (zone) {
73
+ const on = zone.classList.contains("on");
74
+ label.textContent = "Zona e impostazioni";
75
+ summary.textContent = on ? "Solo la parte dipinta" : "Dipingi una zona";
76
+ $("#settings-btn").classList.toggle("is-empty", !on);
77
+ return;
78
+ }
79
+ const value = find(/^(Stile|Style)$/)?.querySelector(".pill-v")?.textContent.trim() || "";
80
  const none = !value || /^(Nessuno|None|Come la foto|Like the photo)$/.test(value);
81
+ label.textContent = "Stile e impostazioni";
82
  summary.textContent = none ? "Scegli uno stile" : value;
83
  $("#settings-btn").classList.toggle("is-empty", none);
84
  }
 
212
  openMore();
213
  }, true);
214
 
215
+ /* ---------- locandina: una scheda alla volta, anteprima sempre visibile ---------- */
216
+
217
+ const posterTabs = $$("#poster-tabs [data-tab]");
218
+ function showTab(tab) {
219
+ posterTabs.forEach((b) => b.setAttribute("aria-selected", String(b.dataset.tab === tab)));
220
+ $$(".poster-scroll > .panel").forEach((p) => p.toggleAttribute("data-active", p.dataset.tab === tab));
221
+ $(".poster-scroll").scrollTop = 0;
222
+ }
223
+ posterTabs.forEach((b) => b.addEventListener("click", () => showTab(b.dataset.tab)));
224
+ document.addEventListener("poster:campo", () => { if (phone.matches) showTab("testi"); });
225
+ showTab("testi");
226
+
227
  /* ---------- tasto indietro: viste, fogli e finestre ---------- */
228
 
229
  const setView = window.setView;
web/poster.js CHANGED
@@ -63,6 +63,7 @@
63
  let layers = [];
64
  const processed = new Map();
65
  let rects = new Map();
 
66
  let selected = null;
67
  let bgImg = null;
68
  let grain = null;
@@ -694,8 +695,30 @@
694
  ctx.restore();
695
  }
696
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  function paint(cv, W, H, templateId, main) {
698
  const ctx = cv.getContext("2d");
 
 
699
  ctx.save();
700
  ctx.clearRect(0, 0, W, H);
701
  const ready = layers.filter((l) => processed.has(l.id));
@@ -719,9 +742,34 @@
719
  ctx.fillRect(0, 0, W, H);
720
  }
721
  ctx.restore();
 
722
  return drawn;
723
  }
724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
725
  function render() {
726
  pending = 0;
727
  const cv = canvas();
@@ -812,11 +860,17 @@
812
  function wireCanvas() {
813
  const wrap = $("#poster-wrap");
814
  let drag = null;
 
815
  wrap.addEventListener("pointerdown", (e) => {
816
  const [x, y] = canvasPoint(e);
817
  const onHandle = e.target.closest(".pp-handle");
818
  const layer = onHandle ? selected : hit(x, y);
819
- if (!layer) { if (selected) select(null); return; }
 
 
 
 
 
820
  if (layer !== selected) select(layer);
821
  pinLayer(layer);
822
  const [W, H] = FORMATS[S.format];
@@ -828,7 +882,9 @@
828
  wrap.addEventListener("pointermove", (e) => {
829
  if (!drag) {
830
  const [x, y] = canvasPoint(e);
831
- wrap.classList.toggle("can-move", Boolean(hit(x, y)));
 
 
832
  return;
833
  }
834
  const [x, y] = canvasPoint(e);
@@ -850,6 +906,10 @@
850
  renderLayerList();
851
  };
852
  wrap.addEventListener("pointerup", end);
 
 
 
 
853
  wrap.addEventListener("pointercancel", end);
854
  window.addEventListener("resize", () => syncOverlay());
855
  document.addEventListener("keydown", (e) => {
 
63
  let layers = [];
64
  const processed = new Map();
65
  let rects = new Map();
66
+ let textRects = [];
67
  let selected = null;
68
  let bgImg = null;
69
  let grain = null;
 
695
  ctx.restore();
696
  }
697
 
698
+ /** Registra dove finisce ogni testo, per portare al campo giusto chi lo tocca. */
699
+ function recordTexts(ctx, out) {
700
+ const fill = ctx.fillText;
701
+ ctx.fillText = function (text, x, y, maxWidth) {
702
+ const m = ctx.measureText(text);
703
+ const w = Math.min(m.width, maxWidth ?? Infinity);
704
+ const align = ctx.textAlign;
705
+ const left = align === "center" ? x - w / 2 : align === "right" || align === "end" ? x - w : x;
706
+ const top = y - (m.actualBoundingBoxAscent || 0);
707
+ const h = (m.actualBoundingBoxAscent || 0) + (m.actualBoundingBoxDescent || 0);
708
+ const t = ctx.getTransform();
709
+ const pts = [[left, top], [left + w, top], [left, top + h], [left + w, top + h]].map(([px, py]) => [t.a * px + t.c * py + t.e, t.b * px + t.d * py + t.f]);
710
+ const xs = pts.map((p) => p[0]);
711
+ const ys = pts.map((p) => p[1]);
712
+ out.push({ text: String(text), x: Math.min(...xs), y: Math.min(...ys), w: Math.max(...xs) - Math.min(...xs), h: Math.max(...ys) - Math.min(...ys) });
713
+ return fill.call(ctx, text, x, y, maxWidth);
714
+ };
715
+ return () => { delete ctx.fillText; };
716
+ }
717
+
718
  function paint(cv, W, H, templateId, main) {
719
  const ctx = cv.getContext("2d");
720
+ const texts = [];
721
+ const stop = main ? recordTexts(ctx, texts) : null;
722
  ctx.save();
723
  ctx.clearRect(0, 0, W, H);
724
  const ready = layers.filter((l) => processed.has(l.id));
 
742
  ctx.fillRect(0, 0, W, H);
743
  }
744
  ctx.restore();
745
+ if (stop) { stop(); textRects = texts; }
746
  return drawn;
747
  }
748
 
749
+ const norm = (v) => v.toLocaleLowerCase("it-IT").replace(/\s+/g, " ").trim();
750
+ function fieldAt(x, y) {
751
+ const pad = 20;
752
+ const hits = textRects.filter((r) => x >= r.x - pad && x <= r.x + r.w + pad && y >= r.y - pad && y <= r.y + r.h + pad);
753
+ for (const r of hits.reverse()) {
754
+ const shown = norm(r.text);
755
+ if (shown.length < 2) continue;
756
+ for (const id of FIELDS) {
757
+ const values = id === "lineup" ? (S.texts.lineup || "").split("\n") : [S.texts[id] || ""];
758
+ if (values.some((v) => { const n = norm(v); return n.length > 1 && (n.includes(shown) || shown.includes(n)); })) return id;
759
+ }
760
+ }
761
+ return null;
762
+ }
763
+
764
+ function focusField(id) {
765
+ document.dispatchEvent(new CustomEvent("poster:campo", { detail: id }));
766
+ const input = $(`#pp-${id}`);
767
+ input.scrollIntoView({ block: "center", behavior: "smooth" });
768
+ input.focus({ preventScroll: true });
769
+ input.closest("label")?.classList.add("flash");
770
+ setTimeout(() => input.closest("label")?.classList.remove("flash"), 900);
771
+ }
772
+
773
  function render() {
774
  pending = 0;
775
  const cv = canvas();
 
860
  function wireCanvas() {
861
  const wrap = $("#poster-wrap");
862
  let drag = null;
863
+ let tapField = null;
864
  wrap.addEventListener("pointerdown", (e) => {
865
  const [x, y] = canvasPoint(e);
866
  const onHandle = e.target.closest(".pp-handle");
867
  const layer = onHandle ? selected : hit(x, y);
868
+ if (!layer) {
869
+ if (selected) select(null);
870
+ tapField = fieldAt(x, y);
871
+ return;
872
+ }
873
+ tapField = null;
874
  if (layer !== selected) select(layer);
875
  pinLayer(layer);
876
  const [W, H] = FORMATS[S.format];
 
882
  wrap.addEventListener("pointermove", (e) => {
883
  if (!drag) {
884
  const [x, y] = canvasPoint(e);
885
+ const over = hit(x, y);
886
+ wrap.classList.toggle("can-move", Boolean(over));
887
+ wrap.classList.toggle("can-edit", !over && Boolean(fieldAt(x, y)));
888
  return;
889
  }
890
  const [x, y] = canvasPoint(e);
 
906
  renderLayerList();
907
  };
908
  wrap.addEventListener("pointerup", end);
909
+ wrap.addEventListener("click", () => {
910
+ if (tapField) focusField(tapField);
911
+ tapField = null;
912
+ });
913
  wrap.addEventListener("pointercancel", end);
914
  window.addEventListener("resize", () => syncOverlay());
915
  document.addEventListener("keydown", (e) => {
web/style.css CHANGED
@@ -225,16 +225,41 @@ kbd {
225
  }
226
  .stage > * { grid-area: 1 / 1; }
227
 
228
- .empty { max-width: 460px; text-align: center; padding: 24px; }
229
  .empty h1 {
230
  margin: 0 0 10px;
231
  font-family: var(--serif);
232
  font-weight: 400;
233
- font-size: clamp(30px, 3.4vw, 44px);
234
- line-height: 1.1;
 
235
  letter-spacing: -0.01em;
236
  }
237
  .empty p { margin: 0; color: var(--muted); font-size: 15px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  .shot { margin: 0; width: 100%; height: 100%; min-height: 0; padding: 18px; display: none; place-items: center; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
240
  .shot img {
@@ -370,7 +395,7 @@ body[data-stage="confronto"] .shot-actions.compare-actions { display: flex; }
370
  body[data-stage="confronto"] .shot-actions.single-actions { display: none; }
371
  .back { color: var(--text); }
372
 
373
- .stage[data-state="vuoto"] .empty { display: block; }
374
  .stage:not([data-state="vuoto"]) .empty { display: none; }
375
  .stage[data-state="foto"] .shot { display: grid; }
376
  .stage[data-state="lavoro"] .develop { display: grid; }
@@ -1733,7 +1758,10 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1733
  }
1734
 
1735
  /* Elementi che esistono solo sul telefono. */
1736
- .nav-icon, .nav-menu, .menu-top, .more-btn, .compare-count, .empty-phone { display: none; }
 
 
 
1737
 
1738
  /* ---------- telefono: un'app a schermo, non una pagina da scorrere ---------- */
1739
 
@@ -1809,10 +1837,9 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1809
  .session { display: none !important; }
1810
  .stage { flex: 1; min-height: 0; height: auto; border-radius: 18px; }
1811
  .empty { padding: 20px 22px; }
1812
- .empty h1 { font-size: 26px; }
1813
  .empty p { font-size: 14px; line-height: 1.5; }
1814
  .empty .empty-desk { display: none; }
1815
- .empty .empty-phone { display: block; }
1816
  .shot { padding: 10px; }
1817
  .develop { padding: 14px; gap: 12px; }
1818
  .develop-title { font-size: 18px; }
@@ -1833,9 +1860,13 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1833
  #act-back span { display: none; }
1834
  .compare-hint { display: none; }
1835
  .base-bar { flex-wrap: wrap; }
1836
- .base-bar .shot-actions { width: 100%; overflow-x: auto; scrollbar-width: none; }
1837
  .base-bar .shot-actions::-webkit-scrollbar { display: none; }
1838
  .base-bar .act { height: 40px; flex: none; border: 1px solid var(--line); border-radius: 12px; }
 
 
 
 
1839
 
1840
  /* confronto: una alla volta, scorrendo di lato */
1841
  .stage[data-state="confronto"] .compare { display: flex; }
@@ -1883,10 +1914,14 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
1883
  .modes button { justify-content: center; gap: 5px; height: 36px; padding: 0 4px; font-size: 13px; }
1884
  .modes button svg { width: 14px; height: 14px; }
1885
  .mode-hint { display: none; }
1886
- .next-bar { flex-wrap: wrap; }
1887
- .composer-body { flex-direction: column; align-items: stretch; gap: 8px; }
1888
- .composer-body > :not(.refs) { width: 100%; flex: none; }
1889
- .refs { max-width: 100%; }
 
 
 
 
1890
  .prompt-area { padding: 0 4px; }
1891
  #prompt, #prompt-it { width: 100%; min-height: 46px; max-height: 30vh; font-size: 16px; line-height: 1.4; }
1892
  #prompt:placeholder-shown { min-height: 74px; }
@@ -2010,10 +2045,38 @@ body[data-scope="cestino"] .selection-bar [data-scope]:not([data-scope="cestino"
2010
  /* ---------- locandina ---------- */
2011
 
2012
  .poster { display: flex; flex-direction: column; }
2013
- .poster-stage { flex: 0 0 auto; height: 44%; min-height: 0; margin: 0; border-bottom: 1px solid var(--line); }
2014
- .poster-canvas-wrap { padding: 12px; }
2015
- .poster-panel { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; border: 0; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2016
  .poster-scroll { overflow-y: auto; padding: 4px var(--pad) 16px; }
 
 
 
 
2017
  .poster-actions { padding: 10px var(--pad); }
2018
 
2019
  /* ---------- finestre ---------- */
 
225
  }
226
  .stage > * { grid-area: 1 / 1; }
227
 
228
+ .empty { max-width: 560px; text-align: center; padding: 24px; }
229
  .empty h1 {
230
  margin: 0 0 10px;
231
  font-family: var(--serif);
232
  font-weight: 400;
233
+ font-size: clamp(26px, 2.6vw, 36px);
234
+ line-height: 1.15;
235
+ text-wrap: balance;
236
  letter-spacing: -0.01em;
237
  }
238
  .empty p { margin: 0; color: var(--muted); font-size: 15px; }
239
+ .empty { display: none; }
240
+ .stage[data-state="vuoto"] .empty { display: grid; justify-items: center; }
241
+ .empty-upload {
242
+ display: inline-flex;
243
+ align-items: center;
244
+ gap: 8px;
245
+ margin-top: 20px;
246
+ height: 44px;
247
+ padding: 0 18px;
248
+ border: 1px solid var(--line-strong);
249
+ border-radius: 12px;
250
+ background: var(--surface);
251
+ color: var(--text);
252
+ font-weight: 500;
253
+ cursor: pointer;
254
+ transition: border-color 0.15s, background 0.15s;
255
+ }
256
+ .empty-upload:hover { border-color: var(--accent); background: var(--surface-2); }
257
+ .empty-upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
258
+ .empty-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
259
+ .empty-upload svg { width: 18px; height: 18px; color: var(--accent); }
260
+ .empty small { margin-top: 8px; color: var(--faint); font-size: 12.5px; }
261
+ .start-sheet .action-list { margin-bottom: 4px; }
262
+ .start-sheet .panel-note { margin: 8px 0 0; }
263
 
264
  .shot { margin: 0; width: 100%; height: 100%; min-height: 0; padding: 18px; display: none; place-items: center; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
265
  .shot img {
 
395
  body[data-stage="confronto"] .shot-actions.single-actions { display: none; }
396
  .back { color: var(--text); }
397
 
398
+ .stage[data-state="vuoto"] .empty { display: grid; justify-items: center; }
399
  .stage:not([data-state="vuoto"]) .empty { display: none; }
400
  .stage[data-state="foto"] .shot { display: grid; }
401
  .stage[data-state="lavoro"] .develop { display: grid; }
 
1758
  }
1759
 
1760
  /* Elementi che esistono solo sul telefono. */
1761
+ .nav-icon, .nav-menu, .menu-top, .more-btn, .compare-count, .empty-phone, .poster-tabs, .pp-hint-phone { display: none; }
1762
+ .poster-canvas-wrap.can-edit { cursor: text; }
1763
+ .pp-fields label.flash { animation: flash 0.9s var(--ease); }
1764
+ @keyframes flash { 30% { color: var(--accent); } }
1765
 
1766
  /* ---------- telefono: un'app a schermo, non una pagina da scorrere ---------- */
1767
 
 
1837
  .session { display: none !important; }
1838
  .stage { flex: 1; min-height: 0; height: auto; border-radius: 18px; }
1839
  .empty { padding: 20px 22px; }
1840
+ .empty h1 { font-size: 24px; }
1841
  .empty p { font-size: 14px; line-height: 1.5; }
1842
  .empty .empty-desk { display: none; }
 
1843
  .shot { padding: 10px; }
1844
  .develop { padding: 14px; gap: 12px; }
1845
  .develop-title { font-size: 18px; }
 
1860
  #act-back span { display: none; }
1861
  .compare-hint { display: none; }
1862
  .base-bar { flex-wrap: wrap; }
1863
+ .base-bar .shot-actions { width: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
1864
  .base-bar .shot-actions::-webkit-scrollbar { display: none; }
1865
  .base-bar .act { height: 40px; flex: none; border: 1px solid var(--line); border-radius: 12px; }
1866
+ .base-bar .act { width: auto; padding: 0 12px; }
1867
+ .base-bar .act span, .more-btn span { display: inline; }
1868
+ .more-btn { width: auto; }
1869
+ .base-bar .shot-meta { display: none; }
1870
 
1871
  /* confronto: una alla volta, scorrendo di lato */
1872
  .stage[data-state="confronto"] .compare { display: flex; }
 
1914
  .modes button { justify-content: center; gap: 5px; height: 36px; padding: 0 4px; font-size: 13px; }
1915
  .modes button svg { width: 14px; height: 14px; }
1916
  .mode-hint { display: none; }
1917
+ .next-bar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; padding: 8px 10px; margin-bottom: 6px; }
1918
+ .next-bar img, .next-bar .nb-ask { display: none; }
1919
+ .next-bar p { font-size: 13px; }
1920
+ .next-bar #next-use { grid-row: 1 / 3; grid-column: 2; height: 40px; }
1921
+ .next-bar #next-stay { justify-self: start; font-size: 12.5px; }
1922
+ .composer-body { flex-direction: row; align-items: flex-start; gap: 8px; }
1923
+ .composer-body > :not(.refs) { flex: 1; min-width: 0; width: auto; }
1924
+ .refs { flex: none; max-width: 46%; }
1925
  .prompt-area { padding: 0 4px; }
1926
  #prompt, #prompt-it { width: 100%; min-height: 46px; max-height: 30vh; font-size: 16px; line-height: 1.4; }
1927
  #prompt:placeholder-shown { min-height: 74px; }
 
2045
  /* ---------- locandina ---------- */
2046
 
2047
  .poster { display: flex; flex-direction: column; }
2048
+ .poster-stage { position: relative; flex: 0 0 auto; height: 46%; min-height: 0; margin: 0; border-bottom: 1px solid var(--line); }
2049
+ .poster-canvas-wrap { padding: 12px 12px 26px; }
2050
+ .pp-hint { display: none; }
2051
+ .pp-hint-phone { display: block; bottom: 6px; }
2052
+ body[data-keyboard] .poster-stage { height: 42%; }
2053
+ body[data-keyboard] .pp-hint-phone, body[data-keyboard] .poster-tabs, body[data-keyboard] .poster-actions { display: none; }
2054
+ .poster-panel { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border: 0; }
2055
+ .poster-tabs {
2056
+ display: flex;
2057
+ gap: 4px;
2058
+ padding: 8px var(--pad);
2059
+ overflow-x: auto;
2060
+ scrollbar-width: none;
2061
+ border-bottom: 1px solid var(--line);
2062
+ }
2063
+ .poster-tabs::-webkit-scrollbar { display: none; }
2064
+ .poster-tabs button {
2065
+ flex: none;
2066
+ height: 36px;
2067
+ padding: 0 14px;
2068
+ border: 1px solid var(--line);
2069
+ border-radius: 999px;
2070
+ background: transparent;
2071
+ color: var(--muted);
2072
+ font-size: 14px;
2073
+ }
2074
+ .poster-tabs button[aria-selected="true"] { border-color: transparent; background: var(--text); color: var(--bg); font-weight: 500; }
2075
  .poster-scroll { overflow-y: auto; padding: 4px var(--pad) 16px; }
2076
+ .poster-scroll > .panel:not([data-active]) { display: none; }
2077
+ .poster-scroll > .panel { border-top: 0; padding-top: 8px; }
2078
+ .poster-scroll > .panel > h2:first-child, .poster-scroll > .panel > .panel-head > h2 { display: none; }
2079
+ .poster-scroll > .panel > .panel-head { justify-content: flex-end; min-height: 0; }
2080
  .poster-actions { padding: 10px var(--pad); }
2081
 
2082
  /* ---------- finestre ---------- */