mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Merge pull request #11669 from davidmann4/feat/crop-task-bar-10890
Crop: Contextual Task Bar under the crop frame, as a reusable task-bar widget (#10890)
This commit is contained in:
54 files changed
+1011
-7
No files matched your search
+1
-1
@@ -35,7 +35,7 @@ next to them.
|
||||
| `epaint_default_fonts::EGUI_ICONS` (build input; deflated into `OUT_DIR/egui_fonts/egui-icons.ttf.deflate`, registered by `crates/ui-egui/src/egui_fonts.rs`) | egui-icons, five-glyph subset of emoji-icon-font | John Slegers | [egui fork at 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts), [original](https://github.com/jslegers/emoji-icon-font); egui subset, unmodified here | MIT; Copyright (c) 2014 John Slegers; full upstream notice in [NOTICE](NOTICE) |
|
||||
| `assets/fonts/Inter-Regular.ttf`, `Inter-Medium.ttf`, `Inter-SemiBold.ttf` | Inter 4.001 (UI font) | The Inter Project Authors (Rasmus Andersson) | <https://github.com/rsms/inter> | SIL OFL 1.1, [`assets/fonts/OFL-Inter.txt`](assets/fonts/OFL-Inter.txt) |
|
||||
| `assets/fonts/JetBrainsMono-Regular.ttf` | JetBrains Mono 2.305 (numeric font) | The JetBrains Mono Project Authors | <https://github.com/JetBrains/JetBrainsMono> | SIL OFL 1.1, [`assets/fonts/OFL-JetBrainsMono.txt`](assets/fonts/OFL-JetBrainsMono.txt) |
|
||||
| `assets/icons/*.svg` except `slice-knife.svg`, `slice-select.svg`, `font-similar.svg`, `font-variable.svg`, `sampler.svg`, `artboard.svg`, `perspective-crop.svg`, `frame-placeholder.svg`, `ellipse-dashed.svg`, `gradient.svg`, `type-mask.svg`, `type-mask-vertical.svg`, `text-warp.svg`, `clip-below.svg`, `clip-release.svg`, `layer-mask.svg`, `adjustment-layer.svg`, `brush-replace.svg`, `history-brush.svg`, `quick-selection.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg`, `direct-select.svg`, `convert-point.svg`, `pen-add-anchor.svg`, `pen-delete-anchor.svg`, `pen-freeform.svg`, `pen-curvature.svg`, `bandage-sparkle.svg`, `painting-symmetry.svg`, `symmetry-*.svg`, `path-op-*.svg` and `marquee-{row,column}.svg`, `align-edge-*.svg` and `distribute-*.svg`, `crop-overlay-*.svg` (113 files; `star-filled.svg` is `star.svg` with a solid fill) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
|
||||
| `assets/icons/*.svg` except `slice-knife.svg`, `slice-select.svg`, `font-similar.svg`, `font-variable.svg`, `sampler.svg`, `artboard.svg`, `perspective-crop.svg`, `frame-placeholder.svg`, `ellipse-dashed.svg`, `gradient.svg`, `type-mask.svg`, `type-mask-vertical.svg`, `text-warp.svg`, `clip-below.svg`, `clip-release.svg`, `layer-mask.svg`, `adjustment-layer.svg`, `brush-replace.svg`, `history-brush.svg`, `quick-selection.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg`, `direct-select.svg`, `convert-point.svg`, `pen-add-anchor.svg`, `pen-delete-anchor.svg`, `pen-freeform.svg`, `pen-curvature.svg`, `bandage-sparkle.svg`, `painting-symmetry.svg`, `symmetry-*.svg`, `path-op-*.svg` and `marquee-{row,column}.svg`, `align-edge-*.svg` and `distribute-*.svg`, `crop-overlay-*.svg` (115 files; `star-filled.svg` is `star.svg` with a solid fill) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
|
||||
| `assets/icons/{check,chevron-down,chevron-left,chevron-right,chevron-up,chevrons-left,chevrons-right,circle,clock,compass,info,link,link-2,lock,minus,monitor,moon,move,navigation,plus,search,square,trash,triangle,type,x,zoom-in}.svg` | Lucide icons derived from Feather (subset of the row above) | Cole Bemis (Feather), Lucide Contributors | <https://github.com/feathericons/feather> via Lucide | MIT (Feather) and ISC (Lucide), [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
|
||||
| `assets/icons/slice-knife.svg` | Slice tool glyph | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
|
||||
| `assets/icons/slice-select.svg` | Slice Select tool glyph | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M12 17v5" />
|
||||
<path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 450 B |
@@ -0,0 +1,14 @@
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
||||
<path d="M3 3v5h5" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 297 B |
@@ -72,6 +72,7 @@ pub const SHELL_COMMANDS: &[(&str, &str, &[&str], Option<&str>)] = &[
|
||||
("window.togglePanels", "Show/Hide All Panels", &[], Some("Tab")),
|
||||
("window.toggle.dock", "Show/Hide Panels", &[], Some("Shift+Tab")),
|
||||
("window.toggle.options", "Options", &["Window"], None),
|
||||
("window.toggle.contextualTaskBar", "Contextual Task Bar", &["Window"], None),
|
||||
// Photoshop's Ctrl+Tab and Ctrl+Shift+Tab, on macOS too (⌘Tab belongs to the system, #2340).
|
||||
("window.nextDocument", "Next Document", &[], Some("Ctrl+Tab")),
|
||||
("window.previousDocument", "Previous Document", &[], Some("Ctrl+Shift+Tab")),
|
||||
|
||||
@@ -169,6 +169,8 @@ impl PhotocraftApp {
|
||||
// A real UI pass consumes the one in-flight synthetic batch (see `inject_synthetic`).
|
||||
self.begin_synthetic_pass(&ctx);
|
||||
self.hover_layer = None;
|
||||
// The contextual task bar reports itself again if this frame draws it (#10890).
|
||||
self.ui.task_bar_shown = None;
|
||||
i18n::set_current(i18n::Lang::from_pref(&self.session.prefs().interface.language));
|
||||
// Fonts registered via set_fonts only take effect next frame; named families would panic now.
|
||||
if !self.fonts_ready {
|
||||
|
||||
@@ -1368,6 +1368,20 @@ fn paint_primary_overlays(app: &mut PhotocraftApp, ui: &mut egui::Ui, view: &mut
|
||||
crate::slice_ui::draw_overlay(app, painter, xf);
|
||||
crate::frame_tool::draw_overlay(app, painter, xf);
|
||||
crate::frame_tool::task_bar(app, ui, xf);
|
||||
// The Crop tool's contextual task bar under its frame (#10890), on the frame's own tile only:
|
||||
// the other tiles would map the active document's frame with their own transform.
|
||||
if app.session.active_index() == Some(idx) {
|
||||
// Done asks for a fit of the cropped document (`commit_crop`): like a view menu row
|
||||
// above, the stored camera wins over this frame's copy, or the write-back drops it.
|
||||
let before = app.ui.views.get(idx).cloned();
|
||||
crate::crop_task_bar::draw(app, ui, xf);
|
||||
if let Some(now) = app.ui.views.get(idx)
|
||||
&& Some(now) != before.as_ref()
|
||||
{
|
||||
*view = now.clone();
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
crate::artboard_tool::draw_overlay(app, painter, xf);
|
||||
// Snap lines last: over the transform preview's pixels and the other overlays, which would
|
||||
// otherwise hide where the moving content lines up.
|
||||
|
||||
@@ -605,6 +605,19 @@ fn crop_fill_param(p: &Value) -> std::result::Result<Option<bool>, String> {
|
||||
|
||||
// -- panels: Histogram, masks targets, docking, Color panel --
|
||||
|
||||
/// The `panels` patch with its `task_bar` merged into the bar's current place, so `{"at": [x, y]}`
|
||||
/// keeps a pin and `{"pinned": true}` keeps a dragged position (#10890).
|
||||
fn panels_patch(app: &PhotocraftApp, patch: Option<&Value>) -> std::result::Result<Option<Value>, String> {
|
||||
let Some(mut patch) = patch.cloned() else { return Ok(None) };
|
||||
if let Some(obj) = patch.as_object_mut()
|
||||
&& let Some(bar) = obj.get("task_bar")
|
||||
{
|
||||
let merged = merged_object(&app.ui.panels.task_bar, Some(bar), "panels.task_bar")?;
|
||||
obj.insert("task_bar".into(), serde_json::to_value(merged).map_err(|e| e.to_string())?);
|
||||
}
|
||||
Ok(Some(patch))
|
||||
}
|
||||
|
||||
struct PanelSet {
|
||||
histogram_panel: Option<crate::histogram_panel::HistogramPanelState>,
|
||||
histogram_range: Option<Option<[u8; 2]>>,
|
||||
@@ -629,7 +642,7 @@ impl PanelSet {
|
||||
histogram_panel: merged_object(&app.ui.histogram_panel, p.get("histogramPanel"), "histogramPanel")?,
|
||||
histogram_range: histogram_range_param(p)?,
|
||||
histogram_refresh: bool_field(p, "histogramRefresh")?,
|
||||
panels: merged_object(&app.ui.panels, p.get("panels"), "panels")?,
|
||||
panels: merged_object(&app.ui.panels, panels_patch(app, p.get("panels"))?.as_ref(), "panels")?,
|
||||
mask_target: bool_field(p, "maskTarget")?,
|
||||
updates_open: bool_field(p, "updatesOpen")?,
|
||||
vector_mask_target: bool_field(p, "vectorMaskTarget")?,
|
||||
|
||||
@@ -29,6 +29,9 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value {
|
||||
dialogs.push(json!({"id": SHELL_DIALOG, "kind": kind, "title": crate::workspace_ui::title(kind), "fields": fields}));
|
||||
}
|
||||
dialogs.extend(crate::discard_ui::inspect(app));
|
||||
// Last frame's task bar rect, unless the bar can't show now (hidden by `ui.set` before the
|
||||
// next draw).
|
||||
let task_bar_rect = app.ui.task_bar_shown.filter(|_| crate::crop_task_bar::eligible(app));
|
||||
json!({
|
||||
"window": {"width": screen.width(), "height": screen.height(), "pixelsPerPoint": ctx.pixels_per_point()},
|
||||
"scratch": photocraft_raster::spill::stats(),
|
||||
@@ -92,6 +95,15 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value {
|
||||
})
|
||||
}),
|
||||
"panels": app.ui.panels,
|
||||
// The contextual task bar (#10890): Window › Contextual Task Bar, whether it shows now and
|
||||
// where (screen points), and its place (pinned, dragged-to corner).
|
||||
"taskBar": json!({
|
||||
"enabled": app.ui.panels.context_task_bar,
|
||||
"visible": task_bar_rect.is_some(),
|
||||
"rect": task_bar_rect,
|
||||
"pinned": app.ui.panels.task_bar.pinned,
|
||||
"at": app.ui.panels.task_bar.at,
|
||||
}),
|
||||
"dockTabs": app.ui.dock_tabs,
|
||||
"dock": app.ui.dock,
|
||||
"docking": app.ui.docking,
|
||||
|
||||
@@ -826,6 +826,12 @@
|
||||
Timeline المخطط الزمني
|
||||
Tool Presets الإعدادات المسبقة للأدوات
|
||||
Tools الأدوات
|
||||
Contextual Task Bar شريط المهام السياقي
|
||||
Hide bar إخفاء الشريط
|
||||
Reset bar position إعادة تعيين موضع الشريط
|
||||
Pin bar position تثبيت موضع الشريط
|
||||
Move bar نقل الشريط
|
||||
More options مزيد من الخيارات
|
||||
About PhotoCraft حول PhotoCraft
|
||||
PhotoCraft Website موقع PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft على GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -778,6 +778,12 @@
|
||||
Timeline Vremenska linija
|
||||
Tool Presets Predlošci alata
|
||||
Tools Alati
|
||||
Contextual Task Bar Kontekstualna traka zadataka
|
||||
Hide bar Sakrij traku
|
||||
Reset bar position Vrati položaj trake
|
||||
Pin bar position Zakači položaj trake
|
||||
Move bar Pomjeri traku
|
||||
More options Više opcija
|
||||
About PhotoCraft O PhotoCraftu
|
||||
PhotoCraft Website Web stranica PhotoCrafta
|
||||
PhotoCraft on GitHub PhotoCraft na GitHubu
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -938,6 +938,12 @@
|
||||
Timeline Časová osa
|
||||
Tool Presets Přednastavení nástrojů
|
||||
Tools Nástroje
|
||||
Contextual Task Bar Kontextový panel úloh
|
||||
Hide bar Skrýt panel
|
||||
Reset bar position Obnovit polohu panelu
|
||||
Pin bar position Připnout polohu panelu
|
||||
Move bar Přesunout panel
|
||||
More options Další možnosti
|
||||
About PhotoCraft O aplikaci PhotoCraft
|
||||
PhotoCraft Website Web PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft na GitHubu
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -542,6 +542,12 @@
|
||||
Timeline Tidslinje
|
||||
Tool Presets Værktøjsforudindstillinger
|
||||
Tools Værktøjer
|
||||
Contextual Task Bar Kontekstafhængig opgavelinje
|
||||
Hide bar Skjul linjen
|
||||
Reset bar position Nulstil linjens placering
|
||||
Pin bar position Fastgør linjens placering
|
||||
Move bar Flyt linjen
|
||||
More options Flere indstillinger
|
||||
Libraries Biblioteker
|
||||
3D 3D
|
||||
Toolbars Værktøjslinjer
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -901,6 +901,12 @@
|
||||
Timeline Zeitleiste
|
||||
Tool Presets Werkzeugvorgaben
|
||||
Tools Werkzeuge
|
||||
Contextual Task Bar Kontextbezogene Taskleiste
|
||||
Hide bar Leiste ausblenden
|
||||
Reset bar position Leistenposition zurücksetzen
|
||||
Pin bar position Leistenposition fixieren
|
||||
Move bar Leiste verschieben
|
||||
More options Weitere Optionen
|
||||
About PhotoCraft Über PhotoCraft
|
||||
PhotoCraft Website PhotoCraft-Website
|
||||
PhotoCraft on GitHub PhotoCraft auf GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -266,6 +266,12 @@
|
||||
Info Πληροφορίες
|
||||
Actions Ενέργειες
|
||||
Tools Εργαλεία
|
||||
Contextual Task Bar Γραμμή εργασιών περιβάλλοντος
|
||||
Hide bar Απόκρυψη γραμμής
|
||||
Reset bar position Επαναφορά θέσης γραμμής
|
||||
Pin bar position Καρφίτσωμα θέσης γραμμής
|
||||
Move bar Μετακίνηση γραμμής
|
||||
More options Περισσότερες επιλογές
|
||||
Zoom In Μεγέθυνση
|
||||
Zoom Out Σμίκρυνση
|
||||
Fit on Screen Προσαρμογή στην οθόνη
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 47 and column 53.
|
@@ -875,6 +875,12 @@
|
||||
Timeline Línea de tiempo
|
||||
Tool Presets Ajustes preestablecidos de herramienta
|
||||
Tools Herramientas
|
||||
Contextual Task Bar Barra de tareas contextual
|
||||
Hide bar Ocultar barra
|
||||
Reset bar position Restablecer posición de la barra
|
||||
Pin bar position Fijar posición de la barra
|
||||
Move bar Mover barra
|
||||
More options Más opciones
|
||||
About PhotoCraft Acerca de PhotoCraft
|
||||
PhotoCraft Website Sitio web de PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft en GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -543,6 +543,12 @@
|
||||
Timeline Aikajana
|
||||
Tool Presets Työkalujen esiasetukset
|
||||
Tools Työkalut
|
||||
Contextual Task Bar Kontekstuaalinen tehtäväpalkki
|
||||
Hide bar Piilota palkki
|
||||
Reset bar position Palauta palkin sijainti
|
||||
Pin bar position Kiinnitä palkin sijainti
|
||||
Move bar Siirrä palkkia
|
||||
More options Lisää vaihtoehtoja
|
||||
Libraries Kirjastot
|
||||
3D 3D
|
||||
Toolbars Työkalurivit
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -891,6 +891,12 @@
|
||||
Timeline Montage
|
||||
Tool Presets Préréglages d'outils
|
||||
Tools Outils
|
||||
Contextual Task Bar Barre des tâches contextuelle
|
||||
Hide bar Masquer la barre
|
||||
Reset bar position Réinitialiser la position de la barre
|
||||
Pin bar position Épingler la position de la barre
|
||||
Move bar Déplacer la barre
|
||||
More options Plus d'options
|
||||
About PhotoCraft À propos de PhotoCraft
|
||||
PhotoCraft Website Site web de PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft sur GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -237,6 +237,12 @@
|
||||
Info जानकारी
|
||||
Timeline टाइमलाइन
|
||||
Tools टूल्स
|
||||
Contextual Task Bar प्रासंगिक कार्य पट्टी
|
||||
Hide bar पट्टी छिपाएँ
|
||||
Reset bar position पट्टी की स्थिति रीसेट करें
|
||||
Pin bar position पट्टी की स्थिति पिन करें
|
||||
Move bar पट्टी खिसकाएँ
|
||||
More options अधिक विकल्प
|
||||
Options विकल्प
|
||||
Status Bar स्टेटस बार
|
||||
Move Tool मूव टूल
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -908,6 +908,12 @@
|
||||
Titling Alternates Címbetű-változatok
|
||||
Tool Presets Eszköz-előbeállítások
|
||||
Tools Eszközök
|
||||
Contextual Task Bar Környezetfüggő feladatsáv
|
||||
Hide bar Sáv elrejtése
|
||||
Reset bar position Sáv helyzetének visszaállítása
|
||||
Pin bar position Sáv helyzetének rögzítése
|
||||
Move bar Sáv áthelyezése
|
||||
More options További beállítások
|
||||
Trace Contour… Kontúrkövetés…
|
||||
Transform Symmetry Szimmetria alakítása
|
||||
Tree… Fa…
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -887,6 +887,12 @@
|
||||
Timeline Timeline
|
||||
Tool Presets Preset Alat
|
||||
Tools Alat
|
||||
Contextual Task Bar Bilah Tugas Kontekstual
|
||||
Hide bar Sembunyikan bilah
|
||||
Reset bar position Atur ulang posisi bilah
|
||||
Pin bar position Sematkan posisi bilah
|
||||
Move bar Pindahkan bilah
|
||||
More options Opsi lainnya
|
||||
About PhotoCraft Tentang PhotoCraft
|
||||
PhotoCraft Website Situs Web PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft di GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -918,6 +918,12 @@
|
||||
Timeline Timeline
|
||||
Tool Presets Predefiniti strumento
|
||||
Tools Strumenti
|
||||
Contextual Task Bar Barra delle attività contestuale
|
||||
Hide bar Nascondi barra
|
||||
Reset bar position Ripristina posizione barra
|
||||
Pin bar position Blocca posizione barra
|
||||
Move bar Sposta barra
|
||||
More options Altre opzioni
|
||||
About PhotoCraft Informazioni su PhotoCraft
|
||||
PhotoCraft Website Sito web PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft su GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 79 and column 53.
|
@@ -932,6 +932,12 @@
|
||||
Timeline タイムライン
|
||||
Tool Presets ツールプリセット
|
||||
Tools ツール
|
||||
Contextual Task Bar コンテキストタスクバー
|
||||
Hide bar バーを隠す
|
||||
Reset bar position バーの位置をリセット
|
||||
Pin bar position バーの位置を固定
|
||||
Move bar バーを移動
|
||||
More options その他のオプション
|
||||
About PhotoCraft PhotoCraft について
|
||||
PhotoCraft Website PhotoCraft の Web サイト
|
||||
PhotoCraft on GitHub GitHub 上の PhotoCraft
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -888,6 +888,12 @@
|
||||
Timeline 타임라인
|
||||
Tool Presets 도구 사전 설정
|
||||
Tools 도구
|
||||
Contextual Task Bar 상황별 작업 표시줄
|
||||
Hide bar 막대 숨기기
|
||||
Reset bar position 막대 위치 재설정
|
||||
Pin bar position 막대 위치 고정
|
||||
Move bar 막대 이동
|
||||
More options 추가 옵션
|
||||
About PhotoCraft PhotoCraft 정보
|
||||
PhotoCraft Website PhotoCraft 웹사이트
|
||||
PhotoCraft on GitHub GitHub의 PhotoCraft
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 63 and column 53.
|
@@ -542,6 +542,12 @@
|
||||
Timeline Tidslinje
|
||||
Tool Presets Verktøyforvalg
|
||||
Tools Verktøy
|
||||
Contextual Task Bar Kontekstavhengig oppgavelinje
|
||||
Hide bar Skjul linjen
|
||||
Reset bar position Tilbakestill linjens plassering
|
||||
Pin bar position Fest linjens plassering
|
||||
Move bar Flytt linjen
|
||||
More options Flere alternativer
|
||||
Libraries Biblioteker
|
||||
3D 3D
|
||||
Toolbars Verktøylinjer
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -854,6 +854,12 @@
|
||||
Timeline Tijdlijn
|
||||
Tool Presets Gereedschapsvoorinstellingen
|
||||
Tools Gereedschappen
|
||||
Contextual Task Bar Contextuele taakbalk
|
||||
Hide bar Balk verbergen
|
||||
Reset bar position Balkpositie herstellen
|
||||
Pin bar position Balkpositie vastzetten
|
||||
Move bar Balk verplaatsen
|
||||
More options Meer opties
|
||||
About PhotoCraft Over PhotoCraft
|
||||
PhotoCraft Website Website van PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft op GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -908,6 +908,12 @@
|
||||
Timeline Oś czasu
|
||||
Tool Presets Ustawienia wstępne narzędzi
|
||||
Tools Narzędzia
|
||||
Contextual Task Bar Kontekstowy pasek zadań
|
||||
Hide bar Ukryj pasek
|
||||
Reset bar position Resetuj położenie paska
|
||||
Pin bar position Przypnij położenie paska
|
||||
Move bar Przesuń pasek
|
||||
More options Więcej opcji
|
||||
About PhotoCraft O programie PhotoCraft
|
||||
PhotoCraft Website Strona internetowa PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft na GitHubie
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -885,6 +885,12 @@
|
||||
Timeline Linha do tempo
|
||||
Tool Presets Predefinições de ferramentas
|
||||
Tools Ferramentas
|
||||
Contextual Task Bar Barra de tarefas contextual
|
||||
Hide bar Ocultar barra
|
||||
Reset bar position Redefinir posição da barra
|
||||
Pin bar position Fixar posição da barra
|
||||
Move bar Mover barra
|
||||
More options Mais opções
|
||||
About PhotoCraft Sobre o PhotoCraft
|
||||
PhotoCraft Website Site do PhotoCraft
|
||||
PhotoCraft on GitHub PhotoCraft no GitHub
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -710,6 +710,12 @@
|
||||
Timeline Шкала времени
|
||||
Tool Presets Наборы инструментов
|
||||
Tools Инструменты
|
||||
Contextual Task Bar Контекстная панель задач
|
||||
Hide bar Скрыть панель
|
||||
Reset bar position Сбросить положение панели
|
||||
Pin bar position Закрепить положение панели
|
||||
Move bar Переместить панель
|
||||
More options Другие параметры
|
||||
Libraries Библиотеки
|
||||
3D 3D
|
||||
Toolbars Панели инструментов
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -911,6 +911,12 @@
|
||||
Timeline Vremenska linija
|
||||
Tool Presets Šabloni alatki
|
||||
Tools Alatke
|
||||
Contextual Task Bar Kontekstualna traka zadataka
|
||||
Hide bar Sakrij traku
|
||||
Reset bar position Vrati položaj trake
|
||||
Pin bar position Zakači položaj trake
|
||||
Move bar Pomeri traku
|
||||
More options Više opcija
|
||||
About PhotoCraft O programu PhotoCraft
|
||||
PhotoCraft Website Veb-sajt PhotoCraft-a
|
||||
PhotoCraft on GitHub PhotoCraft na GitHub-u
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -540,6 +540,12 @@
|
||||
Timeline Tidslinje
|
||||
Tool Presets Verktygsförinställningar
|
||||
Tools Verktyg
|
||||
Contextual Task Bar Kontextuellt aktivitetsfält
|
||||
Hide bar Dölj fältet
|
||||
Reset bar position Återställ fältets position
|
||||
Pin bar position Fäst fältets position
|
||||
Move bar Flytta fältet
|
||||
More options Fler alternativ
|
||||
Libraries Bibliotek
|
||||
3D 3D
|
||||
Toolbars Verktygsfält
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -821,6 +821,12 @@
|
||||
Timeline Zaman Çizelgesi
|
||||
Tool Presets Araç Ön Ayarları
|
||||
Tools Araçlar
|
||||
Contextual Task Bar Bağlamsal Görev Çubuğu
|
||||
Hide bar Çubuğu gizle
|
||||
Reset bar position Çubuk konumunu sıfırla
|
||||
Pin bar position Çubuk konumunu sabitle
|
||||
Move bar Çubuğu taşı
|
||||
More options Diğer seçenekler
|
||||
About PhotoCraft PhotoCraft Hakkında
|
||||
PhotoCraft Website PhotoCraft Web Sitesi
|
||||
PhotoCraft on GitHub GitHub'da PhotoCraft
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -681,6 +681,12 @@
|
||||
Timeline Шкала часу
|
||||
Tool Presets Набори інструментів
|
||||
Tools Інструменти
|
||||
Contextual Task Bar Контекстна панель завдань
|
||||
Hide bar Сховати панель
|
||||
Reset bar position Скинути положення панелі
|
||||
Pin bar position Закріпити положення панелі
|
||||
Move bar Перемістити панель
|
||||
More options Інші параметри
|
||||
Libraries Бібліотеки
|
||||
3D 3D
|
||||
Toolbars Панелі інструментів
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 152 and column 53.
|
@@ -854,6 +854,12 @@
|
||||
Timeline Dòng thời gian
|
||||
Tool Presets Thiết lập sẵn công cụ
|
||||
Tools Công cụ
|
||||
Contextual Task Bar Thanh tác vụ theo ngữ cảnh
|
||||
Hide bar Ẩn thanh
|
||||
Reset bar position Đặt lại vị trí thanh
|
||||
Pin bar position Ghim vị trí thanh
|
||||
Move bar Di chuyển thanh
|
||||
More options Tùy chọn khác
|
||||
Workspace Không gian làm việc
|
||||
Move Tool Công cụ Di chuyển
|
||||
Rectangular Marquee Tool Công cụ Vùng chọn chữ nhật
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -917,6 +917,12 @@
|
||||
Timeline 时间轴
|
||||
Tool Presets 工具预设
|
||||
Tools 工具
|
||||
Contextual Task Bar 上下文任务栏
|
||||
Hide bar 隐藏栏
|
||||
Reset bar position 重置栏位置
|
||||
Pin bar position 固定栏位置
|
||||
Move bar 移动栏
|
||||
More options 更多选项
|
||||
About PhotoCraft 关于 PhotoCraft
|
||||
PhotoCraft Website PhotoCraft 网站
|
||||
PhotoCraft on GitHub PhotoCraft 的 GitHub 页面
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 63 and column 53.
|
@@ -916,6 +916,12 @@
|
||||
Timeline 時間軸
|
||||
Tool Presets 工具預設集
|
||||
Tools 工具
|
||||
Contextual Task Bar 內容相關工作列
|
||||
Hide bar 隱藏工作列
|
||||
Reset bar position 重設工作列位置
|
||||
Pin bar position 固定工作列位置
|
||||
Move bar 移動工作列
|
||||
More options 更多選項
|
||||
About PhotoCraft 關於 PhotoCraft
|
||||
PhotoCraft Website PhotoCraft 網站
|
||||
PhotoCraft on GitHub GitHub 上的 PhotoCraft
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -126,6 +126,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("pencil", include_bytes!("../../../assets/icons/pencil.svg")),
|
||||
("pentagon", include_bytes!("../../../assets/icons/pentagon.svg")),
|
||||
("perspective-crop", include_bytes!("../../../assets/icons/perspective-crop.svg")),
|
||||
("pin", include_bytes!("../../../assets/icons/pin.svg")),
|
||||
("pipette", include_bytes!("../../../assets/icons/pipette.svg")),
|
||||
("play", include_bytes!("../../../assets/icons/play.svg")),
|
||||
("pause", include_bytes!("../../../assets/icons/pause.svg")),
|
||||
@@ -135,6 +136,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("rectangle-horizontal", include_bytes!("../../../assets/icons/rectangle-horizontal.svg")),
|
||||
("rectangle-vertical", include_bytes!("../../../assets/icons/rectangle-vertical.svg")),
|
||||
("redo-2", include_bytes!("../../../assets/icons/redo-2.svg")),
|
||||
("rotate-ccw", include_bytes!("../../../assets/icons/rotate-ccw.svg")),
|
||||
("rotate-cw", include_bytes!("../../../assets/icons/rotate-cw.svg")),
|
||||
("ruler", include_bytes!("../../../assets/icons/ruler.svg")),
|
||||
("sampler", include_bytes!("../../../assets/icons/sampler.svg")),
|
||||
|
||||
@@ -286,6 +286,7 @@ pub use tools::crop_presets;
|
||||
pub use tools::crop_shield;
|
||||
pub use tools::crop_size;
|
||||
pub use tools::crop_straighten;
|
||||
pub use tools::crop_task_bar;
|
||||
pub use tools::crop_ui;
|
||||
pub use tools::direct_select;
|
||||
pub use tools::eraser_ui;
|
||||
|
||||
@@ -804,4 +804,5 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
|
||||
(&["Window"], "---", None, "---"),
|
||||
(&["Window"], "Options", None, "window.panel.options"),
|
||||
(&["Window"], "Tools", None, "window.panel.tools"),
|
||||
(&["Window"], "Contextual Task Bar", None, "window.panel.contextualTaskBar"),
|
||||
];
|
||||
@@ -10,6 +10,7 @@ pub(crate) fn panel_alias(id: &str) -> Option<&'static str> {
|
||||
"navigator" | "info" | "histogram" => "window.toggle.navigator",
|
||||
"tools" => "window.toggle.toolbar",
|
||||
"options" => "window.toggle.options",
|
||||
"contextualTaskBar" => "window.toggle.contextualTaskBar",
|
||||
"brushSettings" => "window.toggle.brushSettings",
|
||||
"brushes" => "window.toggle.brushes",
|
||||
_ => return None,
|
||||
@@ -803,6 +804,7 @@ fn toggle_panel(app: &mut PhotocraftApp, id: &str) -> Result<Value, String> {
|
||||
"navigator" => &mut panels.navigator,
|
||||
"toolbar" => &mut panels.toolbar,
|
||||
"options" => &mut panels.options_bar,
|
||||
"contextualTaskBar" => &mut panels.context_task_bar,
|
||||
"brushSettings" => &mut panels.brush_settings,
|
||||
"brushes" => &mut panels.brushes,
|
||||
"dock" => &mut panels.dock,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::menu_catalog::CATALOG;
|
||||
use crate::menus::is_live;
|
||||
|
||||
/// Minimum number of live catalog items. Raise it when parity grows; never lower it.
|
||||
pub const FLOOR: usize = 660;
|
||||
pub const FLOOR: usize = 661;
|
||||
|
||||
/// One top-level menu's coverage.
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
|
||||
@@ -199,6 +199,7 @@ pub(super) fn checked(app: &PhotocraftApp, id: &str) -> Option<bool> {
|
||||
"window.toggle.dock" => p.dock,
|
||||
"window.togglePanels" => p.toolbar || p.options_bar || p.dock,
|
||||
"window.toggle.options" => p.options_bar,
|
||||
"window.toggle.contextualTaskBar" => p.context_task_bar,
|
||||
"window.toggle.brushSettings" => p.brush_settings,
|
||||
"window.toggle.brushes" => p.brushes,
|
||||
_ => return None,
|
||||
|
||||
@@ -65,6 +65,26 @@ pub struct Panels {
|
||||
/// floating window rather than a modal so the canvas stays usable while a gradient is edited.
|
||||
#[serde(default)]
|
||||
pub gradient_editor: bool,
|
||||
/// Window › Contextual Task Bar (#10890): the small floating bar under the Crop tool's frame
|
||||
/// (`crop_task_bar`). Its ⋯ menu's Hide bar clears it too.
|
||||
#[serde(default = "yes")]
|
||||
pub context_task_bar: bool,
|
||||
/// Where that bar sits: following its frame, or dragged or pinned (`widgets::task_bar`).
|
||||
#[serde(default)]
|
||||
pub task_bar: TaskBarPlace,
|
||||
}
|
||||
|
||||
/// Where the contextual task bar sits (#10890). Part of [`Panels`], so it is kept with the panel
|
||||
/// layout across restarts, and `ui.set {panels: {task_bar: …}}` sets it.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TaskBarPlace {
|
||||
/// Pin bar position: the bar stays where it is while its frame changes.
|
||||
#[serde(default)]
|
||||
pub pinned: bool,
|
||||
/// The bar's top-left corner in points from the canvas area's top-left, once it was dragged
|
||||
/// by its grip or pinned; `None` follows the frame. Reset bar position clears both.
|
||||
#[serde(default)]
|
||||
pub at: Option<[f32; 2]>,
|
||||
}
|
||||
|
||||
impl Default for Panels {
|
||||
@@ -88,6 +108,8 @@ impl Default for Panels {
|
||||
rail: true,
|
||||
menu_bar: true,
|
||||
gradient_editor: false,
|
||||
context_task_bar: true,
|
||||
task_bar: TaskBarPlace::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,6 +427,10 @@ pub struct UiState {
|
||||
/// Frame tool (see `frame_tool`).
|
||||
#[serde(default)]
|
||||
pub frame_tool: crate::frame_tool::FrameToolUi,
|
||||
/// The contextual task bar as drawn in the last frame: its screen rect `[x0, y0, x1, y1]` in
|
||||
/// points, `None` while no bar shows (`ui.inspect` › `taskBar`).
|
||||
#[serde(skip)]
|
||||
pub task_bar_shown: Option<[f32; 4]>,
|
||||
/// Artboard tool (see `artboard_tool`).
|
||||
pub artboard_tool: crate::artboard_tool::ArtboardToolUi,
|
||||
/// Modifier Keys panel, custom pixel aspect ratios, workspace dialogs (see `workspace_ui`).
|
||||
@@ -580,6 +606,7 @@ impl Default for UiState {
|
||||
timeline: Default::default(),
|
||||
slices: Default::default(),
|
||||
frame_tool: Default::default(),
|
||||
task_bar_shown: None,
|
||||
artboard_tool: Default::default(),
|
||||
shell: Default::default(),
|
||||
layer_filter: Vec::new(),
|
||||
|
||||
@@ -14,6 +14,7 @@ pub mod crop_presets;
|
||||
pub mod crop_shield;
|
||||
pub mod crop_size;
|
||||
pub mod crop_straighten;
|
||||
pub mod crop_task_bar;
|
||||
pub mod crop_ui;
|
||||
pub mod direct_select;
|
||||
pub mod eraser_ui;
|
||||
|
||||
@@ -576,6 +576,8 @@ mod tests {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
let mut app = app();
|
||||
whr(&mut app, "", "", "", PX_PER_IN);
|
||||
// Only the options bar's dropdown: the contextual task bar shows the same one (#10890).
|
||||
app.ui.panels.context_task_bar = false;
|
||||
app
|
||||
});
|
||||
h.run_steps(4);
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//! The Crop tool's contextual task bar (#10890): what the Crop tool puts in the reusable bar of
|
||||
//! `widgets::task_bar`, under the crop frame, as in the reference application. Left to right:
|
||||
//!
|
||||
//! 1. the grip (the widget's);
|
||||
//! 2. *Generative Expand goes here* once generative fill comes through the shared AI layer (#41,
|
||||
//! #1199); until then it is left out, not shown disabled;
|
||||
//! 3. the preset dropdown: the options bar's own (`crop_presets::dropdown`), so the two stay in
|
||||
//! sync;
|
||||
//! 4. Straighten: the options bar's Straighten button;
|
||||
//! 5. the ⋯ menu (the widget's);
|
||||
//! 6. while a crop is pending ([`crop_ui::pending`]): Cancel and Done, which the options bar's
|
||||
//! cancel and commit buttons do.
|
||||
//!
|
||||
//! Shown while the Crop tool shows a frame on the active document, Window › Contextual Task Bar
|
||||
//! is ticked and no dialog is open.
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
use crate::canvas::ViewXform;
|
||||
use crate::crop_ui;
|
||||
use crate::state::Tool;
|
||||
use crate::widgets::task_bar;
|
||||
|
||||
/// The Straighten icon. TODO(#10888): the spirit-level glyph once that options-bar item lands.
|
||||
const STRAIGHTEN_ICON: &str = "ruler";
|
||||
|
||||
/// The crop frame on screen: the bounds of its (possibly turned) corners.
|
||||
fn frame_on_screen(app: &PhotocraftApp, xf: &ViewXform) -> Option<egui::Rect> {
|
||||
let r = app.ui.crop_rect?;
|
||||
let pts = crop_ui::corners(r, app.ui.crop_angle).map(|[x, y]| xf.to_screen(x as f32, y as f32));
|
||||
Some(egui::Rect::from_points(&pts))
|
||||
}
|
||||
|
||||
/// The bar shows: the Crop tool with a frame, the Window toggle on, no dialog over the canvas.
|
||||
fn wanted(app: &PhotocraftApp) -> bool {
|
||||
app.ui.tool == Tool::Crop && app.ui.panels.context_task_bar && app.ui.dialogs.is_empty() && app.session.active().is_some()
|
||||
}
|
||||
|
||||
/// Whether the bar can show now: [`wanted`] and a crop frame. `ui.inspect` checks it, so a bar
|
||||
/// hidden by `ui.set` before the next draw no longer reports last frame's rect.
|
||||
pub fn eligible(app: &PhotocraftApp) -> bool {
|
||||
wanted(app) && app.ui.crop_rect.is_some()
|
||||
}
|
||||
|
||||
/// Draws the bar under the active document's crop frame (the canvas's overlay pass calls it on
|
||||
/// that document's tile).
|
||||
pub fn draw(app: &mut PhotocraftApp, ui: &mut egui::Ui, xf: &ViewXform) {
|
||||
if !wanted(app) {
|
||||
return;
|
||||
}
|
||||
let Some(anchor) = frame_on_screen(app, xf) else { return };
|
||||
let ctx = ui.ctx().clone();
|
||||
let mut place = app.ui.panels.task_bar;
|
||||
let shown = task_bar::show(&ctx, &mut place, anchor, xf.rect, |ui, more| contents(app, ui, more));
|
||||
app.ui.panels.task_bar = place;
|
||||
let Some(shown) = shown else { return };
|
||||
if shown.hide {
|
||||
app.ui.panels.context_task_bar = false;
|
||||
return;
|
||||
}
|
||||
let r = shown.rect;
|
||||
app.ui.task_bar_shown = Some([r.min.x, r.min.y, r.max.x, r.max.y]);
|
||||
}
|
||||
|
||||
/// The Crop tool's controls in the bar.
|
||||
fn contents(app: &mut PhotocraftApp, ui: &mut egui::Ui, more: &mut task_bar::MoreMenu) {
|
||||
// Generative Expand (#41) goes here, before the preset dropdown.
|
||||
let before_ratio = crop_ui::preset_ratio(app);
|
||||
// Its own id: the options bar shows the same dropdown.
|
||||
ui.push_id("crop-task-bar", |ui| crate::crop_presets::dropdown(app, ui));
|
||||
if crop_ui::preset_ratio(app) != before_ratio {
|
||||
crop_ui::apply_ratio(app);
|
||||
}
|
||||
let armed = app.crop.straighten.armed;
|
||||
if crate::icons::button_with_icon_size_tip(ui, STRAIGHTEN_ICON, task_bar::BUTTON, 14.0, armed, tl!("Straighten"), false).clicked() {
|
||||
crate::crop_straighten::toggle(app);
|
||||
}
|
||||
more.show(ui);
|
||||
if crop_ui::pending(app) {
|
||||
if ui.button(tl!("Cancel")).clicked() {
|
||||
crop_ui::dismiss(app);
|
||||
}
|
||||
if ui.button(tl!("Done")).clicked() {
|
||||
crate::canvas::commit_crop(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ mod scrub;
|
||||
mod slider;
|
||||
pub mod swap_arrow;
|
||||
pub(super) mod tab_strip;
|
||||
pub mod task_bar;
|
||||
mod text_field;
|
||||
pub mod text_field_menu;
|
||||
pub mod tone;
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
//! The contextual task bar (#10890): a small floating bar on the canvas that offers the next steps
|
||||
//! for what is being edited, as in the reference application. A context (today the Crop tool,
|
||||
//! `crop_task_bar`) supplies only the controls in the middle; this module owns the rest, so other
|
||||
//! contexts (Remove Background #2815, selections #2708, #7633, #8106) can reuse it:
|
||||
//!
|
||||
//! - the **position rule**: centred under the context's anchor (the crop frame's screen bounds)
|
||||
//! with its top [`GAP`] points below the anchor's bottom edge, following the anchor while it
|
||||
//! changes; dragged by its grip (or pinned), it stays where it is, its left edge fixed while it
|
||||
//! grows; always clamped inside the canvas area;
|
||||
//! - the **grip**: two columns of three dots on the left, drawn in code;
|
||||
//! - the **⋯ menu**: Hide bar, Reset bar position, Pin bar position (the reference's Watch quick
|
||||
//! video entry is left out);
|
||||
//! - the **state**: [`TaskBarPlace`] in `Panels` (kept across restarts with the panel layout,
|
||||
//! read and set over the control channel), and Hide bar clears Window › Contextual Task Bar.
|
||||
//!
|
||||
//! As in the reference application its buttons have no tooltips, only a hover highlight; they
|
||||
//! still carry accessible names.
|
||||
|
||||
use egui::{Color32, CursorIcon, Id, Pos2, Rect, Sense, Stroke, Ui, Vec2, pos2, vec2};
|
||||
|
||||
use crate::state::TaskBarPlace;
|
||||
use crate::theme::Tokens;
|
||||
|
||||
/// The bar's top below its anchor's bottom edge, in points (measured: 11 screen px at 100%).
|
||||
pub const GAP: f32 = 11.0;
|
||||
|
||||
/// Height of the bar's buttons, in points.
|
||||
pub const BUTTON: f32 = 26.0;
|
||||
|
||||
/// The bar's one area: only one context shows a bar at a time.
|
||||
fn area_id() -> Id {
|
||||
Id::unique("pc-context-task-bar")
|
||||
}
|
||||
|
||||
/// The bar's ⋯ button, handed to the contents so they place it: the Crop tool shows Cancel and
|
||||
/// Done after it. Contents that never call [`Self::show`] get it at the end.
|
||||
pub struct MoreMenu {
|
||||
place: TaskBarPlace,
|
||||
shown: bool,
|
||||
hide: bool,
|
||||
picked: Option<TaskBarPlace>,
|
||||
}
|
||||
|
||||
impl MoreMenu {
|
||||
/// Draws the ⋯ button (and its menu while open) here.
|
||||
pub fn show(&mut self, ui: &mut Ui) {
|
||||
if std::mem::replace(&mut self.shown, true) {
|
||||
return;
|
||||
}
|
||||
let (hide, picked) = more_menu(ui, &self.place);
|
||||
self.hide |= hide;
|
||||
self.picked = picked.or(self.picked);
|
||||
}
|
||||
}
|
||||
|
||||
/// What the bar did this frame.
|
||||
pub struct Shown<R> {
|
||||
/// The bar's screen rect.
|
||||
pub rect: Rect,
|
||||
/// Hide bar was picked: the caller turns Window › Contextual Task Bar off.
|
||||
pub hide: bool,
|
||||
/// What the context's contents returned.
|
||||
pub inner: R,
|
||||
}
|
||||
|
||||
/// The size the bar had when it was last drawn (its contents decide it), or a guess before.
|
||||
fn last_size(ctx: &egui::Context) -> Vec2 {
|
||||
ctx.memory(|m| m.area_rect(area_id())).map_or(vec2(300.0, BUTTON + 8.0), |r| r.size())
|
||||
}
|
||||
|
||||
/// Where the bar's top-left goes: dragged or pinned at `place.at`, else centred [`GAP`] below
|
||||
/// `anchor`; clamped so a bar of `size` stays inside `area`. A non-finite saved place (a
|
||||
/// hand-edited preferences file, `ui.set`) counts as not placed.
|
||||
pub fn position(place: &TaskBarPlace, anchor: Rect, area: Rect, size: Vec2) -> Pos2 {
|
||||
let at = place.at.filter(|p| p.iter().all(|v| v.is_finite())).map(|[x, y]| area.min + vec2(x, y));
|
||||
let p = at.unwrap_or_else(|| pos2(anchor.center().x - size.x / 2.0, anchor.bottom() + GAP));
|
||||
clamp_into(p, size, area)
|
||||
}
|
||||
|
||||
/// `p` moved so a rect of `size` at it lies inside `area` (its left/top edge wins when it can't fit).
|
||||
fn clamp_into(p: Pos2, size: Vec2, area: Rect) -> Pos2 {
|
||||
let fit = |v: f32, lo: f32, hi: f32| if v.is_finite() { v.min(hi).max(lo) } else { lo };
|
||||
pos2(fit(p.x, area.left(), area.right() - size.x), fit(p.y, area.top(), area.bottom() - size.y))
|
||||
}
|
||||
|
||||
/// Draws the bar for `anchor` (screen rect) inside the canvas `area`: grip, then `contents`, which
|
||||
/// place the ⋯ button with [`MoreMenu::show`]. `place` is updated by a drag on the grip and by the
|
||||
/// menu; `None` when `area` is degenerate.
|
||||
pub fn show<R>(
|
||||
ctx: &egui::Context,
|
||||
place: &mut TaskBarPlace,
|
||||
anchor: Rect,
|
||||
area: Rect,
|
||||
contents: impl FnOnce(&mut Ui, &mut MoreMenu) -> R,
|
||||
) -> Option<Shown<R>> {
|
||||
if !(anchor.is_finite() && area.is_finite() && area.is_positive()) {
|
||||
return None;
|
||||
}
|
||||
let size = last_size(ctx);
|
||||
let at = position(place, anchor, area, size);
|
||||
// Pin bar position, or a pin set over the control channel: the bar freezes where it is now.
|
||||
if place.pinned && place.at.is_none() {
|
||||
place.at = Some((at - area.min).into());
|
||||
}
|
||||
let t = Tokens::get(ctx);
|
||||
let mut moved = None;
|
||||
let mut menu = MoreMenu { place: *place, shown: false, hide: false, picked: None };
|
||||
let out = egui::Area::new(area_id()).order(egui::Order::Middle).fixed_pos(at).constrain(false).show(ctx, |ui| {
|
||||
egui::Frame::NONE
|
||||
.fill(t.card)
|
||||
.stroke(Stroke::new(1.0, t.field_border))
|
||||
.corner_radius(t.radius)
|
||||
.inner_margin(egui::Margin::symmetric(4, 4))
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 4.0;
|
||||
if let Some(d) = grip(ui, t) {
|
||||
moved = Some(d);
|
||||
}
|
||||
let inner = contents(ui, &mut menu);
|
||||
menu.show(ui);
|
||||
inner
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner
|
||||
});
|
||||
let rect = out.response.rect;
|
||||
if let Some(d) = moved {
|
||||
// A dragged bar stays where it is dropped and no longer follows the frame.
|
||||
let p = clamp_into(at + d, rect.size(), area);
|
||||
place.at = Some((p - area.min).into());
|
||||
}
|
||||
if let Some(p) = menu.picked {
|
||||
*place = p;
|
||||
if place.pinned {
|
||||
place.at = Some((at - area.min).into());
|
||||
}
|
||||
}
|
||||
// The first frame only measures the contents: draw again at the measured size.
|
||||
if rect.size() != size {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
Some(Shown { rect, hide: menu.hide, inner: out.inner })
|
||||
}
|
||||
|
||||
/// The grip: two columns of three dots. Returns the drag's movement this frame.
|
||||
fn grip(ui: &mut Ui, t: Tokens) -> Option<Vec2> {
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(12.0, BUTTON), Sense::drag());
|
||||
let resp = resp.on_hover_cursor(CursorIcon::Grab);
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tl!("Move bar")));
|
||||
let dot: Color32 = if resp.hovered() || resp.dragged() { t.text } else { t.icon };
|
||||
for col in [-2.0, 2.0] {
|
||||
for row in [-4.0, 0.0, 4.0] {
|
||||
ui.painter().circle_filled(rect.center() + vec2(col, row), 1.1, dot);
|
||||
}
|
||||
}
|
||||
if resp.dragged() {
|
||||
ui.ctx().set_cursor_icon(CursorIcon::Grabbing);
|
||||
return Some(resp.drag_delta()).filter(|d| *d != Vec2::ZERO);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// The ⋯ button and its menu. Returns whether Hide bar was picked and the place Reset or Pin
|
||||
/// asks for.
|
||||
fn more_menu(ui: &mut Ui, place: &TaskBarPlace) -> (bool, Option<TaskBarPlace>) {
|
||||
let r = crate::icons::button_with_icon_size_tip(ui, "ellipsis", BUTTON, 14.0, false, tl!("More options"), false);
|
||||
let mut out = (false, None);
|
||||
egui::Popup::menu(&r).show(|ui| {
|
||||
ui.set_min_width(190.0);
|
||||
let item = |ui: &mut Ui, icon: &str, label: &str| {
|
||||
let mut atoms = egui::Atoms::default();
|
||||
atoms.push_right(crate::icons::image(icon, 14.0, Tokens::get(ui.ctx()).icon));
|
||||
atoms.push_right(label.to_owned());
|
||||
ui.add(egui::Button::new(atoms)).clicked()
|
||||
};
|
||||
if item(ui, "eye-off", tl!("Hide bar")) {
|
||||
out.0 = true;
|
||||
ui.close();
|
||||
}
|
||||
if item(ui, "rotate-ccw", tl!("Reset bar position")) {
|
||||
out.1 = Some(TaskBarPlace::default());
|
||||
ui.close();
|
||||
}
|
||||
if item(ui, "pin", tl!("Pin bar position")) {
|
||||
out.1 = Some(TaskBarPlace { pinned: true, ..*place });
|
||||
ui.close();
|
||||
}
|
||||
// The reference's Watch quick video entry opens a tutorial video: not offered.
|
||||
});
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const AREA: Rect = Rect { min: pos2(0.0, 40.0), max: pos2(800.0, 640.0) };
|
||||
const SIZE: Vec2 = vec2(300.0, 34.0);
|
||||
|
||||
#[test]
|
||||
fn follows_the_anchor_centred_eleven_points_below() {
|
||||
let anchor = Rect::from_min_max(pos2(100.0, 100.0), pos2(500.0, 400.0));
|
||||
assert_eq!(position(&TaskBarPlace::default(), anchor, AREA, SIZE), pos2(150.0, 411.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stays_inside_the_canvas_area() {
|
||||
// The frame's bottom edge past the window: the bar sits on the area's bottom edge.
|
||||
let low = Rect::from_min_max(pos2(-400.0, 300.0), pos2(100.0, 900.0));
|
||||
assert_eq!(position(&TaskBarPlace::default(), low, AREA, SIZE), pos2(0.0, 606.0));
|
||||
let right = Rect::from_min_max(pos2(700.0, 100.0), pos2(1200.0, 200.0));
|
||||
assert_eq!(position(&TaskBarPlace::default(), right, AREA, SIZE).x, 500.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_placed_bar_keeps_its_place_and_its_left_edge() {
|
||||
let anchor = Rect::from_min_max(pos2(100.0, 100.0), pos2(500.0, 400.0));
|
||||
let place = TaskBarPlace { pinned: false, at: Some([20.0, 30.0]) };
|
||||
assert_eq!(position(&place, anchor, AREA, SIZE), pos2(20.0, 70.0));
|
||||
let moved = anchor.translate(vec2(90.0, 50.0));
|
||||
assert_eq!(position(&place, moved, AREA, vec2(420.0, 34.0)), pos2(20.0, 70.0), "grows to the right, stays put");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hostile_places_never_leave_the_area() {
|
||||
let anchor = Rect::from_min_max(pos2(100.0, 100.0), pos2(500.0, 400.0));
|
||||
for at in [[f32::NAN, 0.0], [f32::INFINITY, 1.0], [1e30, -1e30]] {
|
||||
let p = position(&TaskBarPlace { pinned: true, at: Some(at) }, anchor, AREA, SIZE);
|
||||
assert!(AREA.contains(p), "{at:?} -> {p:?}");
|
||||
}
|
||||
// A bar wider than the area keeps its left edge on the area's.
|
||||
assert_eq!(position(&TaskBarPlace::default(), anchor, AREA, vec2(1200.0, 34.0)).x, 0.0);
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,8 @@ fn setup() -> Option<Harness> {
|
||||
app.run("edit.fill", json!({"color": "#ff0000"})).expect("fill");
|
||||
app.run("select.deselect", json!({})).expect("deselect");
|
||||
app.sync_views();
|
||||
// The options bar's Ratio dropdown: the contextual task bar shows the same one (#10890).
|
||||
app.ui.panels.context_task_bar = false;
|
||||
app.ui.extras.rulers = false;
|
||||
app.ui.extras.snap = false;
|
||||
app.ui.view.show.smart_guides = false;
|
||||
|
||||
@@ -49,6 +49,8 @@ fn setup() -> Option<Harness> {
|
||||
let app = h.state_mut();
|
||||
app.run("file.new", json!({"width": 200, "height": 100, "background": "white"})).expect("new");
|
||||
app.sync_views();
|
||||
// The options bar's Ratio dropdown: the contextual task bar shows the same one (#10890).
|
||||
app.ui.panels.context_task_bar = false;
|
||||
}
|
||||
control(&mut h, "ui.set", json!({"tool": "crop", "zoom": 1.0, "center": [100, 50]}));
|
||||
h.get_by_value("Ratio").click();
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
//! Crop tool: the contextual task bar under the crop frame (#10890).
|
||||
//!
|
||||
//! Measured in the reference application: the bar is centred under the frame with its top 11 px
|
||||
//! below the frame's bottom edge and follows the frame; dragged by its grip it stays where it was
|
||||
//! dropped; Reset bar position brings it back under the frame, Pin bar position keeps it where it
|
||||
//! is; Hide bar hides it and unticks Window › Contextual Task Bar; Cancel and Done show only
|
||||
//! while a crop is pending and do what the options bar's cancel and commit do.
|
||||
//!
|
||||
//! The whole app runs in an egui_kittest harness (no GPU needed); the bar's own buttons are
|
||||
//! pressed with pointer events, so a click must reach the bar and not the canvas under it.
|
||||
|
||||
use egui::{Modifiers, PointerButton, Pos2, Rect, Vec2, pos2, vec2};
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use photocraft_ui_egui::PhotocraftApp;
|
||||
use photocraft_ui_egui::canvas::ViewXform;
|
||||
use photocraft_ui_egui::control::{ControlRequest, Outcome, handle};
|
||||
use photocraft_ui_egui::crop_ui::{corners, pending};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
type Harness = egui_kittest::Harness<'static, PhotocraftApp>;
|
||||
|
||||
/// The bar's top below the frame's bottom edge, measured in the reference application (screen px
|
||||
/// at 100 %, points here).
|
||||
const GAP: f32 = 11.0;
|
||||
|
||||
/// The app in English with a 400 × 300 white document at 100 %, the Crop tool picked in Classic
|
||||
/// Mode (the frame moves over a fixed image, so the frame's screen place is easy to predict).
|
||||
fn harness() -> Harness {
|
||||
let mut h = Harness::builder().with_size(vec2(1100.0, 760.0)).with_max_steps(64).build_eframe(|cc| {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
|
||||
// English labels, whatever the system language.
|
||||
app.session.prefs.edit(|p| p.interface.language = "en".into());
|
||||
app.run("file.new", json!({"width": 400, "height": 300, "background": "white"})).expect("new");
|
||||
app.ui.extras.snap = false;
|
||||
app.ui.view.show.smart_guides = false;
|
||||
app.ui.tool_options.crop_shield.classic_mode = true;
|
||||
app
|
||||
});
|
||||
h.run_steps(4);
|
||||
control(&mut h, "ui.set", json!({"tool": "crop", "zoom": 1.0, "center": [200.0, 150.0]}));
|
||||
h.run_steps(6);
|
||||
h
|
||||
}
|
||||
|
||||
/// Runs one control-channel request, which must succeed, then lets the app draw.
|
||||
fn control(h: &mut Harness, method: &str, params: Value) -> Value {
|
||||
let ctx = h.ctx.clone();
|
||||
let (req, _rx) = ControlRequest::new(method, params.clone());
|
||||
let Outcome::Done(v) = handle(h.state_mut(), &ctx, &req) else { panic!("{method} {params}: not done") };
|
||||
assert_eq!(v["ok"], true, "{method} {params}: {v}");
|
||||
h.run_steps(6);
|
||||
v
|
||||
}
|
||||
|
||||
/// Draws a new crop frame from `a` to `b` (document px), as an agent does.
|
||||
fn draw_frame(h: &mut Harness, a: [f64; 2], b: [f64; 2]) {
|
||||
let events = json!([
|
||||
{"kind": "down", "x": a[0], "y": a[1]},
|
||||
{"kind": "move", "x": b[0], "y": b[1]},
|
||||
{"kind": "up", "x": b[0], "y": b[1]},
|
||||
]);
|
||||
control(h, "ui.pointer", json!({"events": events}));
|
||||
}
|
||||
|
||||
/// The crop frame's screen bounds, as the canvas maps it.
|
||||
fn frame_on_screen(h: &Harness) -> Rect {
|
||||
let app = h.state();
|
||||
let xf = ViewXform::active(app).expect("a view");
|
||||
let r = app.ui.crop_rect.expect("a crop frame");
|
||||
Rect::from_points(&corners(r, app.ui.crop_angle).map(|[x, y]| xf.to_screen(x as f32, y as f32)))
|
||||
}
|
||||
|
||||
/// The task bar's screen rect, as `ui.inspect` reports it.
|
||||
fn bar(h: &Harness) -> Option<Rect> {
|
||||
h.state().ui.task_bar_shown.map(|[x0, y0, x1, y1]| Rect::from_min_max(pos2(x0, y0), pos2(x1, y1)))
|
||||
}
|
||||
|
||||
fn assert_under_frame(h: &Harness, what: &str) {
|
||||
let (f, b) = (frame_on_screen(h), bar(h).unwrap_or_else(|| panic!("{what}: no bar")));
|
||||
assert!((b.top() - (f.bottom() + GAP)).abs() < 1.0, "{what}: bar top {} vs frame bottom {} + {GAP}", b.top(), f.bottom());
|
||||
assert!((b.center().x - f.center().x).abs() < 1.0, "{what}: bar centre {} vs frame centre {}", b.center().x, f.center().x);
|
||||
}
|
||||
|
||||
fn button(h: &mut Harness, at: Pos2, pressed: bool) {
|
||||
h.event(egui::Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
|
||||
h.run_steps(1);
|
||||
}
|
||||
|
||||
/// A real click at `at`: hover, press, release.
|
||||
fn click_at(h: &mut Harness, at: Pos2) {
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
h.run_steps(2);
|
||||
button(h, at, true);
|
||||
button(h, at, false);
|
||||
h.run_steps(4);
|
||||
}
|
||||
|
||||
/// The centre of the widget labelled `label` (which must exist).
|
||||
fn widget(h: &Harness, label: &str) -> Pos2 {
|
||||
h.get_by_label(label).rect().center()
|
||||
}
|
||||
|
||||
fn has(h: &Harness, label: &str) -> bool {
|
||||
h.query_by_label(label).is_some()
|
||||
}
|
||||
|
||||
/// Opens the bar's ⋯ menu and picks `entry`.
|
||||
fn menu(h: &mut Harness, entry: &str) {
|
||||
let more = widget(h, "More options");
|
||||
click_at(h, more);
|
||||
let at = widget(h, entry);
|
||||
click_at(h, at);
|
||||
}
|
||||
|
||||
/// Drags the bar by its grip by `d` screen points.
|
||||
fn drag_grip(h: &mut Harness, d: Vec2) {
|
||||
let from = widget(h, "Move bar");
|
||||
h.event(egui::Event::PointerMoved(from));
|
||||
h.run_steps(2);
|
||||
button(h, from, true);
|
||||
for i in 1..=8 {
|
||||
h.event(egui::Event::PointerMoved(from + d * (i as f32 / 8.0)));
|
||||
h.run_steps(1);
|
||||
}
|
||||
button(h, from + d, false);
|
||||
h.run_steps(4);
|
||||
}
|
||||
|
||||
fn window_item_checked(h: &mut Harness) -> Option<bool> {
|
||||
let items = control(h, "ui.menu.list", json!({}));
|
||||
let item = items["result"].as_array()?.iter().find(|i| i["id"] == "window.panel.contextualTaskBar")?.clone();
|
||||
item["checked"].as_bool()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sits_centred_eleven_points_under_the_frame_and_follows_it() {
|
||||
let mut h = harness();
|
||||
// The untouched default frame (the whole canvas).
|
||||
assert_under_frame(&h, "default frame");
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
assert_under_frame(&h, "drawn frame");
|
||||
// Moved: the bar comes along.
|
||||
let events = json!([
|
||||
{"kind": "down", "x": 150.0, "y": 110.0},
|
||||
{"kind": "move", "x": 210.0, "y": 150.0},
|
||||
{"kind": "up", "x": 210.0, "y": 150.0},
|
||||
]);
|
||||
control(&mut h, "ui.pointer", json!({"events": events}));
|
||||
assert_eq!(h.state().ui.crop_rect, Some([100.0, 70.0, 320.0, 240.0]), "the frame moved");
|
||||
assert_under_frame(&h, "moved frame");
|
||||
let v = control(&mut h, "ui.inspect", json!({}));
|
||||
assert_eq!(v["result"]["taskBar"]["visible"], true);
|
||||
assert_eq!(v["result"]["taskBar"]["enabled"], true);
|
||||
assert_eq!(v["result"]["taskBar"]["pinned"], false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shows_only_with_the_crop_tool() {
|
||||
let mut h = harness();
|
||||
assert!(bar(&h).is_some());
|
||||
control(&mut h, "ui.set", json!({"tool": "brush"}));
|
||||
assert!(bar(&h).is_none(), "another tool hides the bar");
|
||||
assert!(!has(&h, "More options"));
|
||||
// No document: no canvas, no bar (and `ui.inspect` doesn't report the last one drawn).
|
||||
control(&mut h, "ui.set", json!({"tool": "crop"}));
|
||||
assert!(bar(&h).is_some());
|
||||
h.state_mut().run("file.close", json!({})).expect("close");
|
||||
h.run_steps(6);
|
||||
assert!(h.state().session.active().is_none());
|
||||
assert!(bar(&h).is_none(), "closing the document clears the bar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dragged_bar_stays_put_and_reset_brings_it_back() {
|
||||
let mut h = harness();
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
let before = bar(&h).expect("bar");
|
||||
drag_grip(&mut h, vec2(-60.0, -120.0));
|
||||
let dropped = bar(&h).expect("bar");
|
||||
assert!((dropped.min - (before.min + vec2(-60.0, -120.0))).length() < 1.5, "{before:?} dragged to {dropped:?}");
|
||||
assert!(h.state().ui.panels.task_bar.at.is_some());
|
||||
assert_eq!(h.state().ui.crop_rect, Some([40.0, 30.0, 260.0, 200.0]), "dragging the bar doesn't touch the frame");
|
||||
// A new frame no longer moves it; its left edge stays.
|
||||
draw_frame(&mut h, [300.0, 200.0], [120.0, 60.0]);
|
||||
assert_eq!(bar(&h).expect("bar").left_top(), dropped.left_top());
|
||||
menu(&mut h, "Reset bar position");
|
||||
assert_eq!(h.state().ui.panels.task_bar, Default::default());
|
||||
assert_under_frame(&h, "after Reset bar position");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pin_keeps_the_bar_where_it_is() {
|
||||
let mut h = harness();
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
menu(&mut h, "Pin bar position");
|
||||
let pinned = bar(&h).expect("bar");
|
||||
assert!(h.state().ui.panels.task_bar.pinned);
|
||||
draw_frame(&mut h, [300.0, 200.0], [120.0, 60.0]);
|
||||
assert_eq!(bar(&h).expect("bar").left_top(), pinned.left_top(), "pinned: the frame changed, the bar didn't move");
|
||||
// Pinning over the control channel freezes it the same way.
|
||||
menu(&mut h, "Reset bar position");
|
||||
control(&mut h, "ui.set", json!({"panels": {"task_bar": {"pinned": true, "at": null}}}));
|
||||
let here = bar(&h).expect("bar");
|
||||
draw_frame(&mut h, [20.0, 20.0], [100.0, 80.0]);
|
||||
assert_eq!(bar(&h).expect("bar").left_top(), here.left_top());
|
||||
}
|
||||
|
||||
/// Runs one control-channel request without drawing after it.
|
||||
fn request(h: &mut Harness, method: &str, params: Value) -> Value {
|
||||
let ctx = h.ctx.clone();
|
||||
let (req, _rx) = ControlRequest::new(method, params.clone());
|
||||
let Outcome::Done(v) = handle(h.state_mut(), &ctx, &req) else { panic!("{method} {params}: not done") };
|
||||
v
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui_set_changes_only_the_place_fields_it_names() {
|
||||
let mut h = harness();
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
drag_grip(&mut h, vec2(-60.0, -120.0));
|
||||
let dropped = bar(&h).expect("bar");
|
||||
let at = h.state().ui.panels.task_bar.at;
|
||||
// Pinning keeps the dragged place: the bar doesn't jump back under the frame.
|
||||
control(&mut h, "ui.set", json!({"panels": {"task_bar": {"pinned": true}}}));
|
||||
assert_eq!(h.state().ui.panels.task_bar.at, at);
|
||||
assert!(h.state().ui.panels.task_bar.pinned);
|
||||
assert_eq!(bar(&h).expect("bar").left_top(), dropped.left_top());
|
||||
// Placing it keeps the pin.
|
||||
control(&mut h, "ui.set", json!({"panels": {"task_bar": {"at": [12.0, 34.0]}}}));
|
||||
assert_eq!(h.state().ui.panels.task_bar, photocraft_ui_egui::state::TaskBarPlace { pinned: true, at: Some([12.0, 34.0]) });
|
||||
// A field the bar doesn't have is refused, and nothing changes.
|
||||
let v = request(&mut h, "ui.set", json!({"panels": {"task_bar": {"pinned": false, "nope": 1}}}));
|
||||
assert_eq!(v["ok"], false, "{v}");
|
||||
assert!(h.state().ui.panels.task_bar.pinned);
|
||||
// Reset bar position over the control channel.
|
||||
control(&mut h, "ui.set", json!({"panels": {"task_bar": {"pinned": false, "at": null}}}));
|
||||
assert_eq!(h.state().ui.panels.task_bar, Default::default());
|
||||
assert_under_frame(&h, "after the reset");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bars_preset_dropdown_is_the_options_bars() {
|
||||
let mut h = harness();
|
||||
let b = bar(&h).expect("bar");
|
||||
assert_eq!(h.state().ui.crop_rect, Some([0.0, 0.0, 400.0, 300.0]), "the untouched frame is the canvas");
|
||||
// Both bars show the Ratio dropdown: open the task bar's.
|
||||
let ratio = h.get_all_by_value("Ratio").map(|n| n.rect().center()).find(|p| b.contains(*p)).expect("the task bar's Ratio dropdown");
|
||||
click_at(&mut h, ratio);
|
||||
h.get_by_label("1 : 1 (Square)").click();
|
||||
h.run_steps(6);
|
||||
let [x0, y0, x1, y1] = h.state().ui.crop_rect.expect("a frame");
|
||||
assert!(((x1 - x0) - (y1 - y0)).abs() < 1e-6, "a square frame: {:?}", h.state().ui.crop_rect);
|
||||
assert_eq!(h.get_all_by_value("1 : 1 (Square)").count(), 2, "the options bar shows the same preset");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inspect_reports_a_bar_hidden_before_the_next_draw_as_hidden() {
|
||||
let mut h = harness();
|
||||
assert!(bar(&h).is_some());
|
||||
for hide in [json!({"panels": {"context_task_bar": false}}), json!({"tool": "brush"})] {
|
||||
let v = request(&mut h, "ui.set", hide.clone());
|
||||
assert_eq!(v["ok"], true, "{v}");
|
||||
let v = request(&mut h, "ui.inspect", json!({}));
|
||||
assert_eq!(v["result"]["taskBar"]["visible"], false, "{hide}");
|
||||
assert_eq!(v["result"]["taskBar"]["rect"], Value::Null, "{hide}");
|
||||
control(&mut h, "ui.set", json!({"tool": "crop", "panels": {"context_task_bar": true}}));
|
||||
assert!(bar(&h).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_tiled_documents_the_bar_sits_on_the_active_tile() {
|
||||
let mut h = harness();
|
||||
h.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "white"})).expect("new");
|
||||
h.run_steps(4);
|
||||
let ctx = h.ctx.clone();
|
||||
photocraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "window.arrange.twoUpVertical", json!({})).expect("2-up");
|
||||
h.run_steps(6);
|
||||
// Each tile active in turn (side by side, the first one left): the first tile is drawn before
|
||||
// the second, so a bar drawn by every tile would end up on the second one both times.
|
||||
let mut centres = Vec::new();
|
||||
for idx in [0, 1] {
|
||||
assert!(h.state_mut().session.set_active(idx));
|
||||
h.run_steps(8);
|
||||
assert_eq!(h.state().session.active_index(), Some(idx));
|
||||
centres.push(bar(&h).unwrap_or_else(|| panic!("document {idx}: no bar")).center().x);
|
||||
}
|
||||
// The documents are the same size at the same zoom: the bars are one tile width apart.
|
||||
assert!(centres[1] - centres[0] > 200.0, "the bar follows the active tile: {centres:?}");
|
||||
// A click into the first tile activates its document while the frame is drawn: the second
|
||||
// tile, drawn after it as the active one, must not put the new document's bar on itself.
|
||||
let y = bar(&h).expect("bar").top() - 120.0;
|
||||
let at = pos2(centres[0], y);
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
h.run_steps(2);
|
||||
button(&mut h, at, true);
|
||||
assert_eq!(h.state().session.active_index(), Some(0), "the click activates the first tile");
|
||||
if let Some(b) = bar(&h) {
|
||||
assert!((b.center().x - centres[0]).abs() < 100.0, "the bar is on the first tile, not {} (the second)", b.center().x);
|
||||
}
|
||||
button(&mut h, at, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hide_bar_and_the_window_toggle() {
|
||||
let mut h = harness();
|
||||
assert_eq!(window_item_checked(&mut h), Some(true));
|
||||
menu(&mut h, "Hide bar");
|
||||
assert!(!h.state().ui.panels.context_task_bar);
|
||||
assert!(bar(&h).is_none());
|
||||
assert_eq!(window_item_checked(&mut h), Some(false), "Hide bar unticks Window › Contextual Task Bar");
|
||||
let ctx = h.ctx.clone();
|
||||
photocraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "window.panel.contextualTaskBar", json!({})).expect("toggle");
|
||||
h.run_steps(6);
|
||||
assert!(bar(&h).is_some(), "Window › Contextual Task Bar shows it again");
|
||||
assert_eq!(window_item_checked(&mut h), Some(true));
|
||||
control(&mut h, "ui.set", json!({"panels": {"context_task_bar": false}}));
|
||||
assert!(bar(&h).is_none(), "ui.set hides it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cancel_and_done_only_while_a_crop_is_pending() {
|
||||
let mut h = harness();
|
||||
assert!(!pending(h.state()));
|
||||
assert!(has(&h, "More options") && !has(&h, "Done") && !has(&h, "Cancel"), "the untouched frame offers no Cancel / Done");
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
assert!(pending(h.state()));
|
||||
assert!(has(&h, "Done") && has(&h, "Cancel"));
|
||||
let narrow = bar(&h).expect("bar");
|
||||
assert!(narrow.width() > 0.0);
|
||||
// Cancel: the frame goes, as with the options bar's cancel.
|
||||
let at = widget(&h, "Cancel");
|
||||
click_at(&mut h, at);
|
||||
assert!(!pending(h.state()));
|
||||
assert_eq!(h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)), Some((400, 300)));
|
||||
// Done commits the crop.
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
let at = widget(&h, "Done");
|
||||
click_at(&mut h, at);
|
||||
assert_eq!(h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)), Some((220, 170)), "Done crops");
|
||||
}
|
||||
|
||||
/// The active document's stored zoom.
|
||||
fn zoom(h: &Harness) -> f32 {
|
||||
let app = h.state();
|
||||
app.session.active_index().and_then(|i| app.ui.views.get(i)).map(|v| v.zoom).expect("a view")
|
||||
}
|
||||
|
||||
/// Done, like the options bar's commit, fits the cropped document on screen. Fit never zooms past
|
||||
/// 100 %, so the crop starts at 50 %: the 220 × 170 result fits at 100 %. The bar draws inside the
|
||||
/// canvas pass, whose write-back of its own camera used to drop that fit.
|
||||
#[test]
|
||||
fn done_fits_the_cropped_document() {
|
||||
let mut h = harness();
|
||||
control(&mut h, "ui.set", json!({"zoom": 0.5, "center": [200.0, 150.0]}));
|
||||
assert!((zoom(&h) - 0.5).abs() < 1e-4);
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
let at = widget(&h, "Done");
|
||||
click_at(&mut h, at);
|
||||
assert_eq!(h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)), Some((220, 170)), "Done crops");
|
||||
assert!((zoom(&h) - 1.0).abs() < 1e-4, "Done fits the cropped document: zoom {}", zoom(&h));
|
||||
let app = h.state();
|
||||
let v = app.session.active_index().and_then(|i| app.ui.views.get(i)).expect("a view");
|
||||
assert!(!v.fit_pending && (v.center[0] - 110.0).abs() < 0.5 && (v.center[1] - 85.0).abs() < 0.5, "fitted and centred: {:?}", v.center);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bar_grows_for_cancel_and_done() {
|
||||
let mut h = harness();
|
||||
let idle = bar(&h).expect("bar").width();
|
||||
draw_frame(&mut h, [40.0, 30.0], [260.0, 200.0]);
|
||||
h.run_steps(4);
|
||||
let busy = bar(&h).expect("bar").width();
|
||||
assert!(busy > idle + 40.0, "idle {idle}, pending {busy}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn straighten_is_the_options_bar_straighten() {
|
||||
let mut h = harness();
|
||||
assert!(!photocraft_ui_egui::crop_straighten::mode(h.state()));
|
||||
let at = widget(&h, "Straighten");
|
||||
click_at(&mut h, at);
|
||||
assert!(photocraft_ui_egui::crop_straighten::mode(h.state()), "armed, as by the options bar's button");
|
||||
assert_eq!(h.state().ui.crop_rect, Some([0.0, 0.0, 400.0, 300.0]), "the click didn't reach the canvas");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hide_and_place_are_kept_with_the_panel_layout() {
|
||||
let mut h = harness();
|
||||
// A layout saved before the bar existed: the bar is on and follows the frame.
|
||||
let mut old = serde_json::to_value(&h.state().ui.panels).expect("panels");
|
||||
old.as_object_mut().map(|o| (o.remove("context_task_bar"), o.remove("task_bar")));
|
||||
photocraft_ui_egui::dock::apply(h.state_mut(), &json!({"panels": old}));
|
||||
assert!(h.state().ui.panels.context_task_bar);
|
||||
assert_eq!(h.state().ui.panels.task_bar, Default::default());
|
||||
// What a restart restores.
|
||||
let saved = json!({"panels": {"context_task_bar": false, "task_bar": {"pinned": true, "at": [12.0, 34.0]}}});
|
||||
let mut panels = serde_json::to_value(&h.state().ui.panels).expect("panels");
|
||||
panels.as_object_mut().expect("object").extend(saved["panels"].as_object().expect("object").clone());
|
||||
photocraft_ui_egui::dock::apply(h.state_mut(), &json!({"panels": panels}));
|
||||
let p = &h.state().ui.panels;
|
||||
assert!(!p.context_task_bar);
|
||||
assert!(p.task_bar.pinned);
|
||||
assert_eq!(p.task_bar.at, Some([12.0, 34.0]));
|
||||
}
|
||||
@@ -17,6 +17,7 @@ mod crop_default_mode;
|
||||
mod crop_overlay_icons;
|
||||
mod crop_popup_keys;
|
||||
mod crop_shift_corner;
|
||||
mod crop_task_bar;
|
||||
mod crop_turn_grid;
|
||||
mod crop_turn_keeps_frame_inside;
|
||||
mod custom_print_paper;
|
||||
|
||||
@@ -65,6 +65,7 @@ The transport is `apps/photocraft/src/control_server.rs`, and the handlers are i
|
||||
- `ui.set` also accepts `cropFill` (`background`, the Fill dropdown's first entry, which reads Background (default), or Transparent (default) with Delete Cropped Pixels off, or `contentAware`), the Crop tool's Fill dropdown (#3823, #10872): with `contentAware`, committing a turned or extending frame passes `contentAware: true` to `image.crop`, which fills the area the image doesn't cover from its surroundings. `ui.inspect` reports it as `toolOptions.crop_content_aware`.
|
||||
Both gradient modes use the current preset, including its opacity stops. Select `Foreground to Transparent` through `gradient.presets.select`, or pass custom `stops` and `transparency: [[0,100],[1,0]]` (location 0..1, opacity 0..100). Use `applyToLayer: false` to edit only the tool preset. Classic gradient drags dispatch `paint.gradient` without overriding them.
|
||||
- `ui.set` also accepts the Crop tool's gear menu (#1919) as `cropShield`, an object patching any of `show_cropped_area` (Show Cropped Area; off hides everything outside the box behind the canvas colour, H in the app), `enabled` (Enable Crop Shield), `color` (`matchCanvas`, the pasteboard colour, or `custom`), `custom_color` (`[r, g, b]`, 0..255), `opacity` (0..100, default 75), `auto_adjust` (Auto Adjust Opacity: half the opacity while the box is dragged), `classic_mode` (Use Classic Mode, default off: the box turns and moves over the image; off is Photoshop's default mode, where the box stays upright and the view turns and pans the image behind it while the Crop tool shows a frame, P in the app; in both modes picking the tool turns a rotated view upright about its centre, Classic Mode keeping the camera upright with the frame drawn turned, and the view stays upright after a commit or cancel; Classic Mode greys out Show Cropped Area, which then acts as on, and Auto Center Preview) and `auto_center_preview` (default on: in default mode a box being resized keeps its centre where it is on screen, also after a pan, a drawn one moves to the middle of the canvas, and X re-centres it; a move never re-centres the box). `ui.inspect` reports it as `toolOptions.crop_shield`. The pending frame (`crop_rect`, `crop_angle`: its turn on the image) and the `image.crop` a commit runs are the same in both modes.
|
||||
- The contextual task bar (#10890) is the small floating bar under the Crop tool's frame: a grip, the crop preset dropdown (the options bar's), Straighten, a ⋯ menu (Hide bar, Reset bar position, Pin bar position) and, while a crop is pending, Cancel and Done (the options bar's cancel and commit). It sits centred under the frame with its top 11 points below the frame's bottom edge, follows the frame, and stays inside the canvas area; dragged by its grip or pinned, it stays where it is. `ui.inspect` › `taskBar` reports `enabled` (Window › Contextual Task Bar, `window.panel.contextualTaskBar`), `visible` (a bar shows now), `rect` (its screen rect `[x0, y0, x1, y1]` in points, `null` while hidden), `pinned` and `at` (its top-left in points from the canvas area's top-left once dragged or pinned, `null` while it follows the frame). `ui.set {"panels": {"context_task_bar": false}}` hides it (as Hide bar does) and `true` shows it; `ui.set {"panels": {"task_bar": {"pinned": true}}}` pins it where it is (`"at": null` with it first puts it back under the frame), `{"pinned": false, "at": null}` is Reset bar position, and `at: [x, y]` places it; a field left out keeps its value. Both are kept with the panel layout across restarts.
|
||||
- `ui.dialog.open {kind, fields?}` (kinds `newDocument`, `about`, `layerStyle {effect?}`, `colorPicker {target: foreground|background}`, `command {command}` (`layer.new.group` / `layer.new.groupFromLayers` open the New Group dialog: fields `name`, `color`, `mode`, `opacity`), `newCropPreset` / `deleteCropPreset`: the Crop tool's New / Delete Crop Preset… dialogs, fields `name` and `selected: [names]`; crop presets are `crop` tool presets, so `tool.presets.new/list/edit {"tool":"crop"}` drive them too) / `ui.dialog.set {dialog, field, value}` / `ui.dialog.confirm {dialog, wait?}` / `ui.dialog.cancel {dialog}`. Like `ui.menu.invoke`, `ui.dialog.confirm` waits for a background job its command starts (a filter dialog's OK) and replies with the result; `"wait": false` replies `{job, pending: true}` at once
|
||||
- A Layer Style color field opens the shared picker with `ui.dialog.open {"kind":"colorPicker","parent":12,"effect":"fx2","field":"color"}`. `parent` is the Layer Style dialog id; `effect` is its effect instance id. `field` must be one of that instance's color parameters (`color`, or `from`/`to` for Gradient Overlay). The picker previews over the pending style without changing the document. Picker OK changes only the parent parameter; Cancel discards the preview. Confirm the parent afterwards to apply the style. Parent confirmation is refused while its picker is open; parent cancellation closes both. The binding is exposed in `ui.inspect` as `__layerStyleColor`; changed/closed targets or a document switch invalidate it.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Generated by `cargo xtask parity` from `crates/ui-egui/src/menu_catalog.rs` (Photoshop's menu tree) and the live command registry. Do not edit by hand.
|
||||
|
||||
**660 of 660 menu items live (100.0%).**
|
||||
**661 of 661 menu items live (100.0%).**
|
||||
|
||||
| Menu | Live | Total | % |
|
||||
|---|---:|---:|---:|
|
||||
@@ -14,6 +14,6 @@ Generated by `cargo xtask parity` from `crates/ui-egui/src/menu_catalog.rs` (Pho
|
||||
| Select | 25 | 25 | 100% |
|
||||
| Filter | 75 | 75 | 100% |
|
||||
| View | 76 | 76 | 100% |
|
||||
| Window | 61 | 61 | 100% |
|
||||
| Window | 62 | 62 | 100% |
|
||||
|
||||
## Not yet implemented
|
||||
+2
-2
@@ -11,7 +11,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|
||||
| [Tools](#tools) | 36 | 9 | 0 | |
|
||||
| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 10 of 192 (target 0) |
|
||||
| [Type](#type) | 5 | 5 | 0 | |
|
||||
| [Automation](#automation) | 5 | 3 | 3 | 660 of 660 menu items live (100.0%) |
|
||||
| [Automation](#automation) | 5 | 3 | 3 | 661 of 661 menu items live (100.0%) |
|
||||
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present |
|
||||
| [Distribution](#distribution) | 5 | 5 | 1 | |
|
||||
| [Open bugs](#open-bugs) | 31 | 1 | 0 | |
|
||||
@@ -256,7 +256,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.
|
||||
|
||||
## Automation
|
||||
|
||||
Menu wiring (`docs/parity-checklist.md`): 660 of 660 menu items live (100.0%). This counts dispatch, not behaviour.
|
||||
Menu wiring (`docs/parity-checklist.md`): 661 of 661 menu items live (100.0%). This counts dispatch, not behaviour.
|
||||
|
||||
| Id | Target | Status | Issue | Note |
|
||||
|---|---|---|---|---|
|
||||
|
||||
Reference in new issue
Block a user