Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Object Finder: hovering with an empty active layer shows the status-bar hint (#6549)

MarekSpodBiedry4c730d3889cf
diff --git a/crates/engine/src/smartselect_cmds.rs b/crates/engine/src/smartselect_cmds.rs
index 380b6a720..a4152abfd 100644
--- a/crates/engine/src/smartselect_cmds.rs
+++ b/crates/engine/src/smartselect_cmds.rs
@@ -221,12 +221,20 @@ impl ObjectFinderCache {
/// `area`, say so instead of quietly finding nothing (#5246; scripts often add an empty layer
/// above the photo first).
fn check_sampled_pixels(doc: &Document, layer: Option<LayerId>, all_layers: bool, area: Rect) -> Result<()> {
- let Some(surf) = sampled_target(doc, layer, all_layers).and_then(|id| doc.layer(id)).and_then(Layer::surface) else { return Ok(()) };
- if surf.content_bounds().intersect(&area).is_empty() {
- let msg = if surf.content_bounds().is_empty() { "the active layer is empty" } else { "the active layer has no pixels in that area" };
- return Err(bad("select.object", &format!("{msg}; set \"sampleAllLayers\": true or select a layer with pixels")));
+ match empty_sampled_area(doc, layer, all_layers, area) {
+ Some(msg) => Err(bad("select.object", &format!("{msg}; set \"sampleAllLayers\": true or select a layer with pixels"))),
+ None => Ok(()),
}
- Ok(())
+}
+
+/// Why sampling `layer` (unless `all_layers`) can find nothing in `area`: the layer is empty, or has no pixels there.
+/// `None` = there is something to sample. The click path reports it as an error, the Object Finder hover as a hint.
+pub fn empty_sampled_area(doc: &Document, layer: Option<LayerId>, all_layers: bool, area: Rect) -> Option<&'static str> {
+ let surf = sampled_target(doc, layer, all_layers).and_then(|id| doc.layer(id)).and_then(Layer::surface)?;
+ if !surf.content_bounds().intersect(&area).is_empty() {
+ return None;
+ }
+ Some(if surf.content_bounds().is_empty() { "the active layer is empty" } else { "the active layer has no pixels in that area" })
}
/// `select.object` with `"point"`: the Object Finder's object under the point (cached).
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index f3fb8c8c4..ab954fdf5 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -3720,6 +3720,7 @@ navigator Zoom Zvětšení
Medium Blue Středně modrá
Object Finder Hledání objektů
No object found there — drag a rectangle around it Nebyl tam nalezen žádný objekt — přetáhněte kolem něj obdélník
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Aktivní vrstva tu nemá žádné pixely — zapněte Vzorkovat všechny vrstvy nebo vyberte vrstvu s pixely
Remove after each stroke Odstranit po každém tahu
Apply the removal ({key}) Použít odstranění ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Tahy k odstranění: {n} (Enter použije, Esc zruší)
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 48ebfba67..ff7028d50 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -3110,6 +3110,7 @@ curves Smooth Glätten
Fuzziness Toleranz
Object Finder Objektsucher
No object found there — drag a rectangle around it Dort wurde kein Objekt gefunden — ziehen Sie ein Rechteck darum
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Die aktive Ebene hat hier keine Pixel — aktivieren Sie „Alle Ebenen einbeziehen“ oder wählen Sie eine Ebene mit Pixeln
Remove after each stroke Nach jedem Strich entfernen
Apply the removal ({key}) Entfernen anwenden ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Striche zum Entfernen: {n} (Eingabe wendet an, Esc bricht ab)
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index f2c67c2c4..b5542f786 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3810,6 +3810,7 @@ curves Smooth Εξομάλυνση
Light Gray Ανοιχτό γκρι
Object Finder Εύρεση αντικειμένων
No object found there — drag a rectangle around it Δεν βρέθηκε αντικείμενο εκεί — σύρετε ένα ορθογώνιο γύρω του
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Το ενεργό επίπεδο δεν έχει εικονοστοιχεία εδώ — ενεργοποιήστε τη Δειγματοληψία όλων των επιπέδων ή επιλέξτε ένα επίπεδο με εικονοστοιχεία
Remove after each stroke Αφαίρεση μετά από κάθε πινελιά
Apply the removal ({key}) Εφαρμογή της αφαίρεσης ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Πινελιές προς αφαίρεση: {n} (Enter εφαρμόζει, Esc ακυρώνει)
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 45804fa2a..674e777ed 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2798,6 +2798,7 @@ curves Smooth Suavizar
Light Gray Gris claro
Object Finder Buscador de objetos
No object found there — drag a rectangle around it No se encontró ningún objeto ahí; arrastra un rectángulo a su alrededor
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels La capa activa no tiene píxeles aquí; activa Muestrear todas las capas o selecciona una capa con píxeles
Remove after each stroke Eliminar después de cada trazo
Apply the removal ({key}) Aplicar la eliminación ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Trazos por eliminar: {n} (Intro aplica, Esc cancela)
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 3e3451e09..080b15a7c 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -3115,6 +3115,7 @@ curves Smooth Lisser
Light Gray Gris clair
Object Finder Outil de recherche d’objets
No object found there — drag a rectangle around it Aucun objet trouvé ici — tracez un rectangle autour
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Le calque actif n’a pas de pixels ici — activez Échantillonner tous les calques ou sélectionnez un calque contenant des pixels
Remove after each stroke Supprimer après chaque trait
Apply the removal ({key}) Appliquer la suppression ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Traits à supprimer : {n} (Entrée applique, Échap annule)
diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv
index 9dc9a47fb..7a1bfdaa8 100644
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@ -4047,6 +4047,7 @@ cameraRaw Yellow Sárga
@plural {n} action|{n} actions {n} művelet
Object Finder Objektumkereső
No object found there — drag a rectangle around it Ott nem található objektum – húzz köré egy téglalapot
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Az aktív rétegnek itt nincsenek képpontjai – kapcsold be a Mintavétel minden rétegből beállítást, vagy válassz képpontokat tartalmazó réteget
Drag to pan · Scroll to zoom · Double-click to fit Húzás: mozgatás · Görgetés: nagyítás · Dupla kattintás: igazítás
Gradient Preset Options Színátmenet-előbeállítás beállításai
Import .GRD .GRD importálása
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 81e850f29..be7899aeb 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -3102,6 +3102,7 @@ curves Smooth Haluskan
Light Gray Abu-abu Muda
Object Finder Pencari Objek
No object found there — drag a rectangle around it Tidak ada objek ditemukan di sana — seret persegi panjang di sekelilingnya
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Layer aktif tidak memiliki piksel di sini — aktifkan Sampel Semua Layer atau pilih layer yang berisi piksel
Remove after each stroke Hapus setelah setiap goresan
Apply the removal ({key}) Terapkan penghapusan ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Goresan untuk dihapus: {n} (Enter menerapkan, Esc membatalkan)
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index c097ded29..a2b316e0a 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -4076,6 +4076,7 @@ navigator Zoom Zoom
{shortcut} is already in use by {commands} and will be removed from it when you click OK. {shortcut} è già usata da {commands} e verrà rimossa quando fai clic su OK.
Object Finder Ricerca oggetti
No object found there — drag a rectangle around it Nessun oggetto trovato lì: trascina un rettangolo intorno
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Il livello attivo non ha pixel qui: attiva Campiona tutti i livelli o seleziona un livello con pixel
Remove after each stroke Rimuovi dopo ogni tratto
Apply the removal ({key}) Applica la rimozione ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Tratti da rimuovere: {n} (Invio applica, Esc annulla)
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index b46096512..c17f887a0 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3723,6 +3723,7 @@ curves Smooth スムーズ
Light Gray ライトグレー
Object Finder オブジェクトファインダー
No object found there — drag a rectangle around it そこにオブジェクトが見つかりません — 周囲に矩形をドラッグしてください
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels アクティブなレイヤーのここにはピクセルがありません — 「すべてのレイヤーをサンプル」をオンにするか、ピクセルのあるレイヤーを選択してください
Remove after each stroke ストロークごとに削除
Apply the removal ({key}) 削除を適用 ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) 削除するストローク: {n}(Enter で適用、Esc で取り消し)
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 361cef2e9..94df2a9df 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3287,6 +3287,7 @@ curves Smooth 매끄럽게
Light Gray 연한 회색
Object Finder 개체 찾기
No object found there — drag a rectangle around it 그곳에서 개체를 찾지 못했습니다 — 주위에 사각형을 드래그하세요
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels 활성 레이어의 이 위치에는 픽셀이 없습니다 — 모든 레이어 샘플링을 켜거나 픽셀이 있는 레이어를 선택하세요
Remove after each stroke 획마다 제거
Apply the removal ({key}) 제거 적용 ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) 제거할 획: {n} (Enter 적용, Esc 취소)
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index f1ac67961..7bac8575c 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3872,6 +3872,7 @@ curves Smooth Vloeiend maken
Light Gray Lichtgrijs
Object Finder Objectzoeker
No object found there — drag a rectangle around it Daar is geen object gevonden — sleep er een rechthoek omheen
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels De actieve laag heeft hier geen pixels — zet Alle lagen samplen aan of selecteer een laag met pixels
Remove after each stroke Verwijderen na elke streek
Apply the removal ({key}) Verwijdering toepassen ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Streken om te verwijderen: {n} (Enter past toe, Esc annuleert)
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 04eb15609..2edeffd23 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3710,6 +3710,7 @@ curves Smooth Wygładź
Light Gray Jasnoszary
Object Finder Wyszukiwanie obiektów
No object found there — drag a rectangle around it Nie znaleziono tam obiektu — przeciągnij wokół niego prostokąt
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Aktywna warstwa nie ma tu pikseli — włącz Próbkuj wszystkie warstwy albo wybierz warstwę z pikselami
Remove after each stroke Usuwaj po każdym pociągnięciu
Apply the removal ({key}) Zastosuj usuwanie ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Pociągnięcia do usunięcia: {n} (Enter stosuje, Esc anuluje)
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 8d6b88fb5..d932d08e0 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -3902,6 +3902,7 @@ layerLabel No Color Sem cor
Light Gray Cinza-claro
Object Finder Localizador de objetos
No object found there — drag a rectangle around it Nenhum objeto encontrado ali — arraste um retângulo ao redor dele
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels A camada ativa não tem pixels aqui — ative Usar amostra de todas as camadas ou selecione uma camada com pixels
Remove after each stroke Remover após cada traço
Apply the removal ({key}) Aplicar a remoção ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Traços a remover: {n} (Enter aplica, Esc cancela)
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 9d733f11a..cfe75a9e3 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -3060,6 +3060,7 @@ curves Smooth Сгладить
Light Gray Светло-серый
Object Finder Поиск объектов
No object found there — drag a rectangle around it Объект не найден — обведите его прямоугольником
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels В активном слое здесь нет пикселей — включите «По всем слоям» или выберите слой с пикселями
Remove after each stroke Удалять после каждого штриха
Apply the removal ({key}) Применить удаление ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Штрихов к удалению: {n} (Enter применяет, Esc отменяет)
diff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsv
index d384c9bad..6cf369dee 100644
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@ -4181,6 +4181,7 @@ shape Appearance Izgled
Drag to pan · Scroll to zoom · Double-click to fit Prevucite za pomeranje · Skrolujte za zumiranje · Dvaput kliknite za uklapanje
Object Finder Pronalazač objekata
No object found there — drag a rectangle around it Tu nije pronađen nijedan objekat — prevucite pravougaonik oko njega
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Aktivni sloj ovde nema piksela — uključite Uzorkuj sve slojeve ili izaberite sloj sa pikselima
Clear Brush Controls Obriši kontrole četkice
Reset All Locked Settings Vrati sva zaključana podešavanja
Copy Texture to Other Tools Kopiraj teksturu u druge alatke
diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv
index 5c35aba71..05297f933 100644
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@ -3858,6 +3858,7 @@ cameraData Lens Lens
@plural {n} action|{n} actions {n} eylem
Object Finder Nesne Bulucu
No object found there — drag a rectangle around it Orada nesne bulunamadı — çevresine bir dikdörtgen sürükleyin
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Etkin katmanda burada piksel yok — Tüm Katmanları Örnekle seçeneğini açın veya piksel içeren bir katman seçin
Drag to pan · Scroll to zoom · Double-click to fit Kaydırmak için sürükleyin · Yakınlaştırmak için kaydırın · Sığdırmak için çift tıklayın
Gradient Preset Options Gradyan Ön Ayarı Seçenekleri
Import .GRD .GRD İçe Aktar
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index cb6f883eb..e42e6450e 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3811,6 +3811,7 @@ curves Smooth Згладити
Light Gray Світло-сірий
Object Finder Пошук об’єктів
No object found there — drag a rectangle around it Там не знайдено об’єкта — обведіть його прямокутником
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels В активному шарі тут немає пікселів — увімкніть «Зразок з усіх шарів» або виберіть шар із пікселями
Remove after each stroke Видаляти після кожного штриха
Apply the removal ({key}) Застосувати видалення ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Штрихів для видалення: {n} (Enter застосовує, Esc скасовує)
diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv
index e2e55ab1b..a0a1cd767 100644
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@ -3594,6 +3594,7 @@ curves Smooth Làm mượt
Response curve Đường cong phản hồi
Object Finder Trình tìm đối tượng
No object found there — drag a rectangle around it Không tìm thấy đối tượng ở đó — hãy kéo một hình chữ nhật quanh nó
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels Lớp đang hoạt động không có điểm ảnh ở đây — hãy bật Lấy mẫu mọi lớp hoặc chọn một lớp có điểm ảnh
Remove after each stroke Xóa sau mỗi nét vẽ
Apply the removal ({key}) Áp dụng việc xóa ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) Nét vẽ cần xóa: {n} (Enter áp dụng, Esc hủy)
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index eebeabaa6..3074fb862 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2723,6 +2723,7 @@ curves Smooth 平滑
Light Gray 浅灰色
Object Finder 对象查找程序
No object found there — drag a rectangle around it 那里未找到对象 — 请在其周围拖动矩形
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels 当前图层在此处没有像素 — 请打开“对所有图层采样”或选择有像素的图层
Remove after each stroke 每次描边后移除
Apply the removal ({key}) 应用移除 ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) 待移除的描边:{n}(Enter 应用,Esc 取消)
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index b35556b6f..5261e93b5 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2708,6 +2708,7 @@ curves Smooth 平滑
Light Gray 淺灰色
Object Finder 物件尋找器
No object found there — drag a rectangle around it 那裡找不到物件 — 請在其周圍拖曳矩形
+ The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels 作用中圖層在此處沒有像素 — 請開啟「取樣全部圖層」或選取有像素的圖層
Remove after each stroke 每次描邊後移除
Apply the removal ({key}) 套用移除 ({key})
Strokes to remove: {n} (Enter applies, Esc cancels) 待移除的描邊:{n}(Enter 套用,Esc 取消)
diff --git a/crates/ui-egui/src/object_finder.rs b/crates/ui-egui/src/object_finder.rs
index e219b0ddf..bc2b47048 100644
--- a/crates/ui-egui/src/object_finder.rs
+++ b/crates/ui-egui/src/object_finder.rs
@@ -16,7 +16,7 @@ use std::sync::Arc;
use egui::{Color32, TextureOptions, pos2};
use photocraft_algo::selection::Region;
use photocraft_doc::{DocId, Document, LayerId};
-use photocraft_engine::smartselect_cmds::{find_object, sampled_target};
+use photocraft_engine::smartselect_cmds::{empty_sampled_area, find_object, sampled_target};
use crate::PhotocraftApp;
use crate::canvas::ViewXform;
@@ -57,6 +57,13 @@ pub(crate) struct Update {
pub shown: Option<Arc<Region>>,
/// A lookup is pending or running: repaint soon to pick it up.
pub busy: bool,
+ /// Why nothing can be found here: [`empty_layer_hint`] when the sampled layer has no pixels under the pointer.
+ pub hint: Option<&'static str>,
+}
+
+/// The status-bar hint while hovering where the sampled layer has no pixels (the click reports the same as an error).
+fn empty_layer_hint() -> &'static str {
+ tl!("The active layer has no pixels here — turn on Sample All Layers or select a layer with pixels")
}
/// Whether the preview applies now (`pressed`: a pointer button is down).
@@ -87,6 +94,11 @@ pub(crate) fn update(app: &mut PhotocraftApp, at: Option<[f64; 2]>, pressed: boo
app.object_finder = Some(Finder { doc, revision, target, all_layers, at: px, since: now, job: None, misses: Vec::new(), shown: None, texture: None });
}
let doc_arc = Arc::clone(&st.doc);
+ // The click reports an empty sampled layer; the hover says so too instead of showing nothing.
+ let here = photocraft_geom::Rect::from_xywh(px[0], px[1], 1, 1);
+ if doc_arc.bounds().contains(px[0], px[1]) && empty_sampled_area(&doc_arc, layer, all_layers, here).is_some() {
+ return Update { shown: None, busy: false, hint: Some(empty_layer_hint()) };
+ }
let Some(f) = app.object_finder.as_mut() else { return Update::default() };
if f.at != px {
f.at = px;
@@ -121,7 +133,7 @@ pub(crate) fn update(app: &mut PhotocraftApp, at: Option<[f64; 2]>, pressed: boo
f.job = Some(spawn(Arc::clone(&doc_arc), layer, all_layers, px, at));
}
let busy = f.job.is_some() || (f.shown.is_none() && !missed && now - f.since < DEBOUNCE);
- Update { shown: f.shown.clone(), busy }
+ Update { shown: f.shown.clone(), busy, hint: None }
}
fn spawn(doc: Arc<Document>, layer: Option<LayerId>, all_layers: bool, px: [i32; 2], at: [f64; 2]) -> Job {
@@ -193,6 +205,15 @@ pub(crate) fn draw(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewXf
if up.busy {
ctx.request_repaint_after(std::time::Duration::from_millis(40));
}
+ match up.hint {
+ Some(h) if app.ui.status != h => {
+ app.ui.status = h.to_owned();
+ app.ui.status_error = false;
+ }
+ // The pointer moved on: drop our hint, never another message.
+ None if app.ui.status == empty_layer_hint() => app.ui.status.clear(),
+ _ => {}
+ }
let Some(r) = up.shown else { return };
let Some(f) = app.object_finder.as_mut() else { return };
let key = Arc::as_ptr(&r) as usize;
@@ -271,6 +292,19 @@ mod tests {
assert!(hover(&mut app, [4.0, 4.0]).shown.is_none());
}
+ #[test]
+ fn hovering_an_empty_active_layer_gives_a_hint_not_silence() {
+ let mut app = disc_app();
+ app.session.execute("layer.new.layer", json!({})).unwrap();
+ let u = update(&mut app, Some([100.0, 80.0]), false, 100.0);
+ assert!(u.shown.is_none() && !u.busy);
+ assert_eq!(u.hint, Some(empty_layer_hint()));
+ // Sample All Layers on: no hint, the object is looked up.
+ app.ui.tool_options.sample_all_layers = true;
+ assert!(update(&mut app, Some([100.0, 80.0]), false, 100.0).hint.is_none());
+ assert!(hover(&mut app, [100.0, 80.0]).shown.is_some());
+ }
+
#[test]
fn preview_clears_on_leave_tool_switch_button_option_and_edits() {
let mut app = disc_app();
diff --git a/docs/ui-parity.md b/docs/ui-parity.md
index 793f09840..ee51b1e45 100644
--- a/docs/ui-parity.md
+++ b/docs/ui-parity.md
@@ -29,7 +29,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme
| Move, artboard | Move, Artboard | |
| Marquee | Rectangular, Elliptical, Single Row, Single Column | |
| Lasso | Lasso, Polygonal, Magnetic | |
-| Selection | Object Selection, Quick Selection, Magic Wand | Object Selection's Object Finder (on by default in its options bar): resting the pointer highlights the object a click selects (`select.object` with `point`; ⇧ adds, ⌥ subtracts, ⇧⌥ intersects); dragging keeps the rectangle mode (#4087). Heuristic, not a learned segmenter (#2788). |
+| Selection | Object Selection, Quick Selection, Magic Wand | Object Selection's Object Finder (on by default in its options bar): resting the pointer highlights the object a click selects (`select.object` with `point`; ⇧ adds, ⌥ subtracts, ⇧⌥ intersects); dragging keeps the rectangle mode (#4087). Where the active layer has no pixels under the pointer (Sample All Layers off), the status bar says so instead of showing nothing (#6549). Heuristic, not a learned segmenter (#2788). |
| Crop and slice | Crop, Perspective Crop, Slice, Slice Select | |
| Frame | Frame (frames are groups clipped by a rectangular or elliptical mask) | |
| Eyedropper | Eyedropper, Color Sampler, Ruler, Note, Count | |