mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-27 21:29:46 +00:00
M4: the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable (#1674)
* M4: the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks * M4: the Create from color window's collection picker is its own function
This commit is contained in:
+2
-1
File diff suppressed because one or more lines are too long
@@ -334,6 +334,10 @@ impl Session {
|
||||
let sel = ds.selection.clone();
|
||||
if self.tool.pick_only {
|
||||
self.tool.picked = Some(c);
|
||||
} else if ev.cmd && ev.shift {
|
||||
// Cmd/Ctrl+Shift: make a colour style or variable of it instead (the UI asks which
|
||||
// and what to call it; nothing is applied).
|
||||
self.request_ui("dialog.createFromColor", json!({"color": c.to_css_hex()}));
|
||||
} else if !sel.is_empty() {
|
||||
self.execute("node.set", &json!({"ids": sel, "props": {"fill": c.to_css_hex()}}))?;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//! The eyedropper with Cmd/Ctrl+Shift held makes a colour style or variable of what it picks (as
|
||||
//! the reference app's eyedropper does): it asks the UI which (`dialog.createFromColor`) and leaves the
|
||||
//! selection's fills alone; a plain pick still fills the selection.
|
||||
|
||||
use figcraft_doc::NodeId;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Session;
|
||||
use crate::tools::{PointerEvent, PointerKind, ToolId};
|
||||
|
||||
/// A white page with a red square at (0, 0) and a green one selected at (200, 0).
|
||||
fn scene() -> (Session, NodeId) {
|
||||
let mut s = Session::new();
|
||||
s.execute("page.setBackground", &json!({"color": "#FFFFFF"})).unwrap();
|
||||
let rect = |s: &mut Session, x: f64, fill: &str| {
|
||||
let r = s.execute("shape.rectangle", &json!({"x": x, "y": 0, "width": 100, "height": 100})).unwrap();
|
||||
let id = crate::params::id_of(&r["id"]).unwrap();
|
||||
s.execute("node.set", &json!({"id": id, "props": {"fills": [fill]}})).unwrap();
|
||||
id
|
||||
};
|
||||
rect(&mut s, 0.0, "#FF0000");
|
||||
let green = rect(&mut s, 200.0, "#00FF00");
|
||||
s.execute("select.set", &json!({"ids": [green]})).unwrap();
|
||||
s.ui_requests.clear();
|
||||
(s, green)
|
||||
}
|
||||
|
||||
fn pick(s: &mut Session, cmd: bool, shift: bool) {
|
||||
s.execute("edit.pickColor", &json!({})).unwrap();
|
||||
s.pointer(&PointerEvent { cmd, shift, ..PointerEvent::at(PointerKind::Down, 50.0, 50.0, 1.0) }).unwrap();
|
||||
}
|
||||
|
||||
fn fill(s: &Session, id: NodeId) -> Option<String> {
|
||||
s.doc().unwrap().node(id).unwrap().fills.first().and_then(|p| p.solid_color()).map(|c| c.to_hex())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_shift_asks_to_make_a_style_or_variable_of_the_pick() {
|
||||
let (mut s, green) = scene();
|
||||
let undo = s.undo_depth().0;
|
||||
pick(&mut s, true, true);
|
||||
let asks: Vec<_> = s.ui_requests.iter().filter(|r| r.kind == "dialog.createFromColor").collect();
|
||||
assert_eq!(asks.len(), 1, "{:?}", s.ui_requests);
|
||||
assert_eq!(asks[0].data["color"], "#FF0000", "the colour under the pointer");
|
||||
assert_eq!(fill(&s, green), Some("00FF00".into()), "the selection keeps its fill");
|
||||
assert_eq!(s.undo_depth().0, undo, "nothing to undo");
|
||||
assert_eq!(s.tool.tool, ToolId::Move, "picking ends the eyedropper");
|
||||
assert_eq!(s.recent_colors.first().map(|c| c.to_hex()), Some("FF0000".into()), "a recent colour as any pick");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_picks_fill_the_selection_as_before() {
|
||||
for (cmd, shift) in [(false, false), (true, false), (false, true)] {
|
||||
let (mut s, green) = scene();
|
||||
pick(&mut s, cmd, shift);
|
||||
assert!(!s.ui_requests.iter().any(|r| r.kind == "dialog.createFromColor"), "cmd {cmd} shift {shift}");
|
||||
assert_eq!(fill(&s, green), Some("FF0000".into()), "cmd {cmd} shift {shift}");
|
||||
}
|
||||
// The colour picker's eyedropper only samples, whatever is held.
|
||||
let (mut s, green) = scene();
|
||||
s.execute("edit.pickColor", &json!({"apply": false})).unwrap();
|
||||
s.pointer(&PointerEvent { cmd: true, shift: true, ..PointerEvent::at(PointerKind::Down, 50.0, 50.0, 1.0) }).unwrap();
|
||||
assert!(s.ui_requests.is_empty());
|
||||
assert_eq!(s.tool.picked.map(|c| c.to_hex()), Some("FF0000".into()));
|
||||
assert_eq!(fill(&s, green), Some("00FF00".into()));
|
||||
}
|
||||
@@ -309,6 +309,8 @@ mod export_depth_tests;
|
||||
#[cfg(test)]
|
||||
mod extended_chain_tests;
|
||||
#[cfg(test)]
|
||||
mod eyedropper_create_tests;
|
||||
#[cfg(test)]
|
||||
mod facilitate_tests;
|
||||
#[cfg(test)]
|
||||
mod fig_export_assets_tests;
|
||||
|
||||
@@ -243,6 +243,7 @@ status = "draft — needs native review"
|
||||
"Convert to frame" = "تحويل إلى إطار"
|
||||
"Convert to section" = "تحويل إلى قسم"
|
||||
"CSS custom properties…" = "خصائص CSS المخصصة…"
|
||||
"Create from color" = "إنشاء من اللون"
|
||||
"Dart constants for Flutter…" = "ثوابت Dart لـ Flutter…"
|
||||
"Can edit" = "يمكنه التحرير"
|
||||
"Can't read this library: {e}" = "تعذرت قراءة هذه المكتبة: {e}"
|
||||
@@ -814,6 +815,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "القائمة الرئيسية"
|
||||
"Make a component" = "إنشاء مكوّن"
|
||||
"Make slot" = "إنشاء خانة محتوى"
|
||||
"New collection" = "مجموعة جديدة"
|
||||
"Pasted design layers" = "طبقات تصميم ملصقة"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "لُصقت طبقات التصميم؛ لم تحمل الحافظة صور: {layers}"
|
||||
"Remove these results from the file" = "احذف هذه النتائج من الملف"
|
||||
|
||||
@@ -353,6 +353,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "কম্পোনেন্ট তৈরি করুন"
|
||||
"Create component property" = "কম্পোনেন্ট প্রপার্টি তৈরি করুন"
|
||||
"Create components, styles or variables to publish them as a library." = "লাইব্রেরি হিসেবে প্রকাশ করতে কম্পোনেন্ট, স্টাইল বা ভেরিয়েবল তৈরি করুন।"
|
||||
"Create from color" = "রং থেকে তৈরি করুন"
|
||||
"Create property…" = "প্রপার্টি তৈরি করুন..."
|
||||
"Create style" = "স্টাইল তৈরি করুন"
|
||||
"Create style from the selected text" = "নির্বাচিত টেক্সট থেকে স্টাইল তৈরি করুন"
|
||||
@@ -782,6 +783,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "প্রধান মেনু"
|
||||
"Make a component" = "একটি কম্পোনেন্ট তৈরি করুন"
|
||||
"Make slot" = "স্লট তৈরি করুন"
|
||||
"New collection" = "নতুন সংগ্রহ"
|
||||
"Pasted design layers" = "পেস্ট করা ডিজাইন লেয়ার"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "ডিজাইন লেয়ার পেস্ট হয়েছে; ক্লিপবোর্ডে এগুলোর ছবি ছিল না: {layers}"
|
||||
"Remove these results from the file" = "এই ফলাফল ফাইল থেকে মুছুন"
|
||||
|
||||
@@ -243,6 +243,7 @@ status = "draft — needs native review"
|
||||
"Convert to frame" = "Pretvori u okvir"
|
||||
"Convert to section" = "Pretvori u sekciju"
|
||||
"CSS custom properties…" = "Prilagođena CSS svojstva…"
|
||||
"Create from color" = "Napravi iz boje"
|
||||
"Dart constants for Flutter…" = "Dart konstante za Flutter…"
|
||||
"Can edit" = "Može uređivati"
|
||||
"Can't read this library: {e}" = "Nije moguće pročitati ovu biblioteku: {e}"
|
||||
@@ -823,6 +824,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Glavni meni"
|
||||
"Make a component" = "Napravi komponentu"
|
||||
"Make slot" = "Napravi slot"
|
||||
"New collection" = "Nova kolekcija"
|
||||
"Pasted design layers" = "Zalijepljeni slojevi dizajna"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Zalijepljeni slojevi dizajna; međuspremnik nije prenio slike za: {layers}"
|
||||
"Scroll wheel zoom" = "Zumiranje kotačićem miša"
|
||||
|
||||
@@ -343,6 +343,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Vytvořit komponentu"
|
||||
"Create component property" = "Vytvořit vlastnost komponenty"
|
||||
"Create components, styles or variables to publish them as a library." = "Vytvořte komponenty, styly nebo proměnné a publikujte je jako knihovnu."
|
||||
"Create from color" = "Vytvořit z barvy"
|
||||
"Create property…" = "Vytvořit vlastnost…"
|
||||
"Create style" = "Vytvořit styl"
|
||||
"Create style from the selected text" = "Vytvořit styl z vybraného textu"
|
||||
@@ -767,6 +768,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Hlavní nabídka"
|
||||
"Make a component" = "Vytvořit komponentu"
|
||||
"Make slot" = "Vytvořit slot"
|
||||
"New collection" = "Nová kolekce"
|
||||
"Pasted design layers" = "Vložené návrhové vrstvy"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Návrhové vrstvy vloženy; schránka neobsahovala obrázky těchto vrstev: {layers}"
|
||||
"Remove these results from the file" = "Odebrat tyto výsledky ze souboru"
|
||||
|
||||
@@ -344,6 +344,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Komponente erstellen"
|
||||
"Create component property" = "Komponenteneigenschaft erstellen"
|
||||
"Create components, styles or variables to publish them as a library." = "Erstellen Sie Komponenten, Stile oder Variablen, um sie als Bibliothek zu veröffentlichen."
|
||||
"Create from color" = "Aus Farbe erstellen"
|
||||
"Create property…" = "Eigenschaft erstellen…"
|
||||
"Create style" = "Stil erstellen"
|
||||
"Create style from the selected text" = "Stil aus dem ausgewählten Text erstellen"
|
||||
@@ -752,6 +753,7 @@ status = "draft — needs native review"
|
||||
"Main component deleted" = "Hauptkomponente gelöscht"
|
||||
"Main menu" = "Hauptmenü"
|
||||
"Make slot" = "Slot erstellen"
|
||||
"New collection" = "Neue Sammlung"
|
||||
"Nobody shares a file there now." = "Dort teilt gerade niemand eine Datei."
|
||||
"Pasted design layers" = "Eingefügte Designebenen"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Designebenen eingefügt; die Zwischenablage enthielt die Bilder von {layers} nicht"
|
||||
|
||||
@@ -244,6 +244,7 @@ name = "English"
|
||||
"Copy browser link" = "Copy browser link"
|
||||
"Couldn't reach {server} for its team list." = "Couldn't reach {server} for its team list."
|
||||
"CSS custom properties…" = "CSS custom properties…"
|
||||
"Create from color" = "Create from color"
|
||||
"Dart constants for Flutter…" = "Dart constants for Flutter…"
|
||||
"Calculated from other variables; it follows them" = "Calculated from other variables; it follows them"
|
||||
"Can edit" = "Can edit"
|
||||
@@ -829,6 +830,7 @@ name = "English"
|
||||
"Main menu" = "Main menu"
|
||||
"Make a component" = "Make a component"
|
||||
"Make slot" = "Make slot"
|
||||
"New collection" = "New collection"
|
||||
"Nobody shares a file there now." = "Nobody shares a file there now."
|
||||
"Pasted design layers" = "Pasted design layers"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Pasted design layers; the clipboard didn't carry the images of: {layers}"
|
||||
|
||||
@@ -34,6 +34,8 @@ status = "draft — needs native review"
|
||||
"Connector" = "Conector"
|
||||
"Couldn't download the variables" = "No se pudieron descargar las variables"
|
||||
"Couldn't download {name}" = "No se pudo descargar {name}"
|
||||
"Create from color" = "Crear a partir del color"
|
||||
"New collection" = "Nueva colección"
|
||||
"Delete results" = "Eliminar resultados"
|
||||
"Pasted design layers" = "Capas de diseño pegadas"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Capas de diseño pegadas; el portapapeles no traía las imágenes de: {layers}"
|
||||
|
||||
@@ -355,6 +355,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Luo komponentti"
|
||||
"Create component property" = "Luo komponentin ominaisuus"
|
||||
"Create components, styles or variables to publish them as a library." = "Luo komponentteja, tyylejä tai muuttujia, jotta voit julkaista ne kirjastona."
|
||||
"Create from color" = "Luo väristä"
|
||||
"Create property…" = "Luo ominaisuus…"
|
||||
"Create style" = "Luo tyyli"
|
||||
"Create style from the selected text" = "Luo tyyli valitusta tekstistä"
|
||||
@@ -784,6 +785,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Päävalikko"
|
||||
"Make a component" = "Luo komponentti"
|
||||
"Make slot" = "Luo sisältöpaikka"
|
||||
"New collection" = "Uusi kokoelma"
|
||||
"Pasted design layers" = "Liitetyt suunnittelutasot"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Suunnittelutasot liitetty; leikepöydällä ei ollut näiden kuvia: {layers}"
|
||||
"Remove these results from the file" = "Poista nämä tulokset tiedostosta"
|
||||
|
||||
@@ -353,6 +353,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Créer un composant"
|
||||
"Create component property" = "Créer une propriété de composant"
|
||||
"Create components, styles or variables to publish them as a library." = "Créez des composants, des styles ou des variables pour les publier en tant que bibliothèque."
|
||||
"Create from color" = "Créer à partir de la couleur"
|
||||
"Create property…" = "Créer une propriété…"
|
||||
"Create style" = "Créer un style"
|
||||
"Create style from the selected text" = "Créer un style à partir du texte sélectionné"
|
||||
@@ -784,6 +785,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Menu principal"
|
||||
"Make a component" = "Créer un composant"
|
||||
"Make slot" = "Créer un emplacement"
|
||||
"New collection" = "Nouvelle collection"
|
||||
"Pasted design layers" = "Calques de design collés"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Calques de design collés ; le presse-papiers ne contenait pas les images de : {layers}"
|
||||
"Remove these results from the file" = "Retirer ces résultats du fichier"
|
||||
|
||||
@@ -11,6 +11,8 @@ status = "draft — needs native review"
|
||||
"A later vote" = "Pemungutan suara yang lebih baru"
|
||||
"A table takes at most {rows} rows and {columns} columns: the rest wasn't pasted" = "Tabel memuat paling banyak {rows} baris dan {columns} kolom: sisanya tidak ditempel"
|
||||
"Add a connected shape" = "Tambahkan bentuk yang terhubung"
|
||||
"Create from color" = "Buat dari warna"
|
||||
"New collection" = "Koleksi baru"
|
||||
"An earlier vote" = "Pemungutan suara yang lebih lama"
|
||||
"Delete results" = "Hapus hasil"
|
||||
"Pasted design layers" = "Lapisan desain yang ditempel"
|
||||
|
||||
@@ -337,6 +337,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Crea componente"
|
||||
"Create component property" = "Crea proprietà del componente"
|
||||
"Create components, styles or variables to publish them as a library." = "Crea componenti, stili o variabili per pubblicarli come libreria."
|
||||
"Create from color" = "Crea dal colore"
|
||||
"Create property…" = "Crea proprietà…"
|
||||
"Create style" = "Crea stile"
|
||||
"Create style from the selected text" = "Crea stile dal testo selezionato"
|
||||
@@ -758,6 +759,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Menu principale"
|
||||
"Make a component" = "Crea un componente"
|
||||
"Make slot" = "Crea slot"
|
||||
"New collection" = "Nuova collezione"
|
||||
"Pasted design layers" = "Livelli di design incollati"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Livelli di design incollati; gli appunti non contenevano le immagini di: {layers}"
|
||||
"Remove these results from the file" = "Rimuovi questi risultati dal file"
|
||||
|
||||
@@ -351,6 +351,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "コンポーネントを作成"
|
||||
"Create component property" = "コンポーネントプロパティを作成"
|
||||
"Create components, styles or variables to publish them as a library." = "コンポーネント、スタイル、変数を作成すると、ライブラリとして公開できる。"
|
||||
"Create from color" = "色から作成"
|
||||
"Create property…" = "プロパティを作成…"
|
||||
"Create style" = "スタイルを作成"
|
||||
"Create style from the selected text" = "選択したテキストからスタイルを作成"
|
||||
@@ -778,6 +779,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "メインメニュー"
|
||||
"Make a component" = "コンポーネントを作成"
|
||||
"Make slot" = "スロットにする"
|
||||
"New collection" = "新しいコレクション"
|
||||
"Pasted design layers" = "貼り付けたデザインレイヤー"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "デザインレイヤーを貼り付けました。クリップボードに次の画像がありませんでした: {layers}"
|
||||
"Remove these results from the file" = "この結果をファイルから削除します"
|
||||
|
||||
@@ -358,6 +358,7 @@ status = "draft — reviewed by a native speaker, awaiting a maintainer's approv
|
||||
"Create component" = "კომპონენტის შექმნა"
|
||||
"Create component property" = "კომპონენტის თვისების შექმნა"
|
||||
"Create components, styles or variables to publish them as a library." = "შექმენით კომპონენტები, სტილები ან ცვლადები, რომ ბიბლიოთეკად გამოაქვეყნოთ."
|
||||
"Create from color" = "ფერიდან შექმნა"
|
||||
"Create property…" = "თვისების შექმნა…"
|
||||
"Create style" = "სტილის შექმნა"
|
||||
"Create style from the selected text" = "სტილის შექმნა მონიშნული ტექსტიდან"
|
||||
@@ -791,6 +792,7 @@ status = "draft — reviewed by a native speaker, awaiting a maintainer's approv
|
||||
"Main menu" = "მთავარი მენიუ"
|
||||
"Make a component" = "შექმენით კომპონენტი"
|
||||
"Make slot" = "სლოტად გადაქცევა"
|
||||
"New collection" = "ახალი კოლექცია"
|
||||
"Pasted design layers" = "ჩასმული დიზაინის ფენები"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "დიზაინის ფენები ჩაისვა; ბუფერში არ იყო შემდეგის სურათები: {layers}"
|
||||
"Remove these results from the file" = "ამ შედეგების ფაილიდან წაშლა"
|
||||
|
||||
@@ -340,6 +340,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "컴포넌트 만들기"
|
||||
"Create component property" = "컴포넌트 속성 만들기"
|
||||
"Create components, styles or variables to publish them as a library." = "컴포넌트, 스타일 또는 변수를 만들어 라이브러리로 게시하세요."
|
||||
"Create from color" = "색상으로 만들기"
|
||||
"Create property…" = "속성 만들기…"
|
||||
"Create style" = "스타일 만들기"
|
||||
"Create style from the selected text" = "선택한 텍스트로 스타일 만들기"
|
||||
@@ -742,6 +743,7 @@ status = "draft — needs native review"
|
||||
"Main component deleted" = "메인 컴포넌트가 삭제됨"
|
||||
"Main menu" = "메인 메뉴"
|
||||
"Make slot" = "슬롯으로 만들기"
|
||||
"New collection" = "새 컬렉션"
|
||||
"Pasted design layers" = "붙여넣은 디자인 레이어"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "디자인 레이어를 붙여넣었습니다. 클립보드에 다음 이미지가 없었습니다: {layers}"
|
||||
"Remove these results from the file" = "이 결과를 파일에서 삭제합니다"
|
||||
|
||||
@@ -355,6 +355,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Component maken"
|
||||
"Create component property" = "Componenteigenschap maken"
|
||||
"Create components, styles or variables to publish them as a library." = "Maak componenten, stijlen of variabelen om ze als bibliotheek te publiceren."
|
||||
"Create from color" = "Maken van kleur"
|
||||
"Create property…" = "Eigenschap maken…"
|
||||
"Create style" = "Stijl maken"
|
||||
"Create style from the selected text" = "Stijl maken van de geselecteerde tekst"
|
||||
@@ -784,6 +785,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Hoofdmenu"
|
||||
"Make a component" = "Maak een component"
|
||||
"Make slot" = "Slot maken"
|
||||
"New collection" = "Nieuwe verzameling"
|
||||
"Pasted design layers" = "Geplakte ontwerplagen"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Ontwerplagen geplakt; het klembord bevatte de afbeeldingen van {layers} niet"
|
||||
"Remove these results from the file" = "Deze resultaten uit het bestand verwijderen"
|
||||
|
||||
@@ -354,6 +354,7 @@ name = "Polski"
|
||||
"Create component" = "Utwórz komponent"
|
||||
"Create component property" = "Utwórz właściwość komponentu"
|
||||
"Create components, styles or variables to publish them as a library." = "Twórz komponenty, style lub zmienne, aby opublikować je jako bibliotekę."
|
||||
"Create from color" = "Utwórz z koloru"
|
||||
"Create property…" = "Utwórz właściwość…"
|
||||
"Create style" = "Utwórz styl"
|
||||
"Create style from the selected text" = "Utwórz styl z zaznaczonego tekstu"
|
||||
@@ -786,6 +787,7 @@ name = "Polski"
|
||||
"Main menu" = "Menu główne"
|
||||
"Make a component" = "Utwórz komponent"
|
||||
"Make slot" = "Utwórz gniazdo (slot)"
|
||||
"New collection" = "Nowa kolekcja"
|
||||
"Pasted design layers" = "Wklejone warstwy projektu"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Wklejono warstwy projektu; schowek nie zawierał obrazów warstw: {layers}"
|
||||
"Remove these results from the file" = "Usuń te wyniki z pliku"
|
||||
|
||||
@@ -339,6 +339,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Criar componente"
|
||||
"Create component property" = "Criar propriedade de componente"
|
||||
"Create components, styles or variables to publish them as a library." = "Crie componentes, estilos ou variáveis para publicá-los como biblioteca."
|
||||
"Create from color" = "Criar a partir da cor"
|
||||
"Create property…" = "Criar propriedade…"
|
||||
"Create style" = "Criar estilo"
|
||||
"Create style from the selected text" = "Criar estilo a partir do texto selecionado"
|
||||
@@ -741,6 +742,7 @@ status = "draft — needs native review"
|
||||
"Main component deleted" = "Componente principal excluído"
|
||||
"Main menu" = "Menu principal"
|
||||
"Make slot" = "Transformar em slot"
|
||||
"New collection" = "Nova coleção"
|
||||
"Pasted design layers" = "Camadas de design coladas"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Camadas de design coladas; a área de transferência não trouxe as imagens de: {layers}"
|
||||
"Remove these results from the file" = "Remover estes resultados do arquivo"
|
||||
|
||||
@@ -354,6 +354,7 @@ name = "Русский"
|
||||
"Create component" = "Создать компонент"
|
||||
"Create component property" = "Создать свойство компонента"
|
||||
"Create components, styles or variables to publish them as a library." = "Создайте компоненты, стили или переменные, чтобы опубликовать их как библиотеку."
|
||||
"Create from color" = "Создать из цвета"
|
||||
"Create property…" = "Создать свойство…"
|
||||
"Create style" = "Создать стиль"
|
||||
"Create style from the selected text" = "Создать стиль из выделенного текста"
|
||||
@@ -786,6 +787,7 @@ name = "Русский"
|
||||
"Main menu" = "Главное меню"
|
||||
"Make a component" = "Создать компонент"
|
||||
"Make slot" = "Сделать слотом"
|
||||
"New collection" = "Новая коллекция"
|
||||
"Pasted design layers" = "Вставленные слои дизайна"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Слои дизайна вставлены; в буфере обмена не было изображений слоёв: {layers}"
|
||||
"Remove these results from the file" = "Удалить эти результаты из файла"
|
||||
|
||||
@@ -241,6 +241,7 @@ name = "Svenska"
|
||||
"Convert to frame" = "Konvertera till frame"
|
||||
"Convert to section" = "Konvertera till avsnitt"
|
||||
"CSS custom properties…" = "Anpassade CSS-egenskaper…"
|
||||
"Create from color" = "Skapa från färg"
|
||||
"Dart constants for Flutter…" = "Dart-konstanter för Flutter…"
|
||||
"Can edit" = "Kan redigera"
|
||||
"Can't read this library: {e}" = "Det går inte att läsa det här biblioteket: {e}"
|
||||
@@ -821,6 +822,7 @@ name = "Svenska"
|
||||
"Main menu" = "Huvudmeny"
|
||||
"Make a component" = "Skapa en komponent"
|
||||
"Make slot" = "Gör till plats"
|
||||
"New collection" = "Ny samling"
|
||||
"Pasted design layers" = "Inklistrade designlager"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Designlager inklistrade; urklippet innehöll inte bilderna för: {layers}"
|
||||
"Remove these results from the file" = "Ta bort de här resultaten från filen"
|
||||
|
||||
@@ -352,6 +352,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "สร้างคอมโพเนนต์"
|
||||
"Create component property" = "สร้างพร็อพเพอร์ตีของคอมโพเนนต์"
|
||||
"Create components, styles or variables to publish them as a library." = "สร้างคอมโพเนนต์ สไตล์ หรือตัวแปรเพื่อเผยแพร่เป็นไลบรารี"
|
||||
"Create from color" = "สร้างจากสี"
|
||||
"Create property…" = "สร้างพร็อพเพอร์ตี…"
|
||||
"Create style" = "สร้างสไตล์"
|
||||
"Create style from the selected text" = "สร้างสไตล์จากข้อความที่เลือก"
|
||||
@@ -780,6 +781,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "เมนูหลัก"
|
||||
"Make a component" = "สร้างคอมโพเนนต์"
|
||||
"Make slot" = "สร้างสล็อต"
|
||||
"New collection" = "คอลเลกชันใหม่"
|
||||
"Pasted design layers" = "เลเยอร์ดีไซน์ที่วาง"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "วางเลเยอร์ดีไซน์แล้ว คลิปบอร์ดไม่มีภาพของ: {layers}"
|
||||
"Remove these results from the file" = "ลบผลลัพธ์นี้ออกจากไฟล์"
|
||||
|
||||
@@ -347,6 +347,7 @@ name = "Türkçe"
|
||||
"Create component" = "Bileşen oluştur"
|
||||
"Create component property" = "Bileşen özelliği oluştur"
|
||||
"Create components, styles or variables to publish them as a library." = "Kitaplık olarak yayımlamak için bileşen, stil veya değişken oluşturun."
|
||||
"Create from color" = "Renkten oluştur"
|
||||
"Create property…" = "Özellik oluştur…"
|
||||
"Create style" = "Stil oluştur"
|
||||
"Create style from the selected text" = "Seçili metinden stil oluştur"
|
||||
@@ -771,6 +772,7 @@ name = "Türkçe"
|
||||
"Main menu" = "Ana menü"
|
||||
"Make a component" = "Bileşen yap"
|
||||
"Make slot" = "Yuva yap"
|
||||
"New collection" = "Yeni koleksiyon"
|
||||
"Pasted design layers" = "Yapıştırılan tasarım katmanları"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Tasarım katmanları yapıştırıldı; pano şunların görsellerini taşımıyordu: {layers}"
|
||||
"Remove these results from the file" = "Bu sonuçları dosyadan kaldır"
|
||||
|
||||
@@ -338,6 +338,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "Tạo thành phần"
|
||||
"Create component property" = "Tạo thuộc tính thành phần"
|
||||
"Create components, styles or variables to publish them as a library." = "Hãy tạo các thành phần, kiểu hoặc biến để xuất bản thành thư viện."
|
||||
"Create from color" = "Tạo từ màu"
|
||||
"Create property…" = "Tạo thuộc tính…"
|
||||
"Create style" = "Tạo kiểu"
|
||||
"Create style from the selected text" = "Tạo kiểu từ văn bản đã chọn"
|
||||
@@ -759,6 +760,7 @@ status = "draft — needs native review"
|
||||
"Main menu" = "Trình đơn chính"
|
||||
"Make a component" = "Tạo thành phần"
|
||||
"Make slot" = "Tạo ô chứa"
|
||||
"New collection" = "Bộ sưu tập mới"
|
||||
"Pasted design layers" = "Các lớp thiết kế đã dán"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "Đã dán các lớp thiết kế; bộ nhớ tạm không có hình ảnh của: {layers}"
|
||||
"Remove these results from the file" = "Xóa kết quả này khỏi tệp"
|
||||
|
||||
@@ -344,6 +344,7 @@ status = "draft — needs native review"
|
||||
"Create component" = "创建组件"
|
||||
"Create component property" = "创建组件属性"
|
||||
"Create components, styles or variables to publish them as a library." = "创建组件、样式或变量,即可将其发布为库。"
|
||||
"Create from color" = "从颜色创建"
|
||||
"Create property…" = "创建属性…"
|
||||
"Create style" = "创建样式"
|
||||
"Create style from the selected text" = "从所选文本创建样式"
|
||||
@@ -747,6 +748,7 @@ status = "draft — needs native review"
|
||||
"Main component deleted" = "主组件已删除"
|
||||
"Main menu" = "主菜单"
|
||||
"Make slot" = "设为插槽"
|
||||
"New collection" = "新建集合"
|
||||
"Pasted design layers" = "粘贴的设计图层"
|
||||
"Pasted design layers; the clipboard didn't carry the images of: {layers}" = "已粘贴设计图层;剪贴板未包含以下图层的图像:{layers}"
|
||||
"Remove these results from the file" = "从文件中删除这些结果"
|
||||
|
||||
@@ -126,6 +126,7 @@ impl FigApp {
|
||||
}
|
||||
"dialog.preferences" => self.ui.preferences = true,
|
||||
"dialog.missingFonts" => missing_fonts::request(self),
|
||||
"dialog.createFromColor" => crate::sampled_color::request(self, &r.data),
|
||||
"panel.shortcuts" => self.ui.shortcuts_panel = !self.ui.shortcuts_panel,
|
||||
"palette.actions" => menus::toggle_palette(&mut self.ui),
|
||||
"panel.design" if self.session.doc().is_ok_and(figcraft_engine::board::is_board) => self.ui.board_panel = !self.ui.board_panel,
|
||||
|
||||
@@ -34,6 +34,7 @@ pub mod credits;
|
||||
pub mod import_report;
|
||||
pub mod missing_fonts;
|
||||
pub mod plugins_ui;
|
||||
pub mod sampled_color;
|
||||
pub mod updates_ui;
|
||||
pub mod variables_panel;
|
||||
|
||||
@@ -209,6 +210,7 @@ pub fn show(app: &mut FigApp, ctx: &Context) {
|
||||
crate::pending_open::pending_opens(app, ctx);
|
||||
crate::import_report::show(app, ctx);
|
||||
crate::missing_fonts::show(app, ctx);
|
||||
crate::sampled_color::show(app, ctx);
|
||||
let t = Tokens::get(ctx);
|
||||
if app.ui.about {
|
||||
let mut open = true;
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
//! A colour picked with the eyedropper while holding Cmd/Ctrl+Shift becomes a colour style or a
|
||||
//! colour variable, as in the reference app: the eyedropper asks for this window
|
||||
//! (`dialog.createFromColor`), which asks which to make, what to call it and (a variable) in which
|
||||
//! collection, then runs `style.create` or `variable.create`.
|
||||
|
||||
use egui::{Context, RichText};
|
||||
use figcraft_color::{Color, Paint};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::window;
|
||||
use crate::FigApp;
|
||||
use crate::i18n::tr;
|
||||
use crate::theme::Tokens;
|
||||
use crate::widgets;
|
||||
|
||||
/// The window's state: the colour, what to make of it and its name.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct SampledColor {
|
||||
/// The document it was picked in: the window goes when another is in front.
|
||||
pub uid: u64,
|
||||
/// `#rrggbb`.
|
||||
pub color: String,
|
||||
/// A variable (else a style).
|
||||
pub variable: bool,
|
||||
pub name: String,
|
||||
/// The local collection a variable goes in (`None`: a new one).
|
||||
pub collection: Option<String>,
|
||||
}
|
||||
|
||||
/// `dialog.createFromColor {color}` from the eyedropper: the window for the document in front, with
|
||||
/// the next free style name ("Color 1"…) and its first collection.
|
||||
pub fn request(app: &mut FigApp, data: &Value) {
|
||||
let Some(color) = data.get("color").and_then(Value::as_str).and_then(Color::from_hex) else { return };
|
||||
let Ok(ds) = app.session.ds() else { return };
|
||||
let collection = figcraft_engine::library::local_collections(&ds.doc).next().map(|c| c.id.clone());
|
||||
app.ui.sampled_color = Some(SampledColor {
|
||||
uid: ds.uid,
|
||||
color: color.to_css_hex(),
|
||||
variable: false,
|
||||
name: crate::style_picker::next_name(&ds.doc, "Color"),
|
||||
collection,
|
||||
});
|
||||
}
|
||||
|
||||
/// The command that makes what `s` asks for: a paint style, a colour variable in its collection,
|
||||
/// or (no collection) a new collection and the variable in it, one undo step.
|
||||
pub fn create_params(app: &FigApp, s: &SampledColor) -> (&'static str, Value) {
|
||||
let name = s.name.trim();
|
||||
if !s.variable {
|
||||
return ("style.create", json!({"type": "paint", "name": name, "value": s.color}));
|
||||
}
|
||||
let variable = |collection: Value| json!({"collection": collection, "name": name, "type": "color", "value": s.color});
|
||||
match &s.collection {
|
||||
Some(c) => ("variable.create", variable(json!(c))),
|
||||
None => {
|
||||
let taken = |n: &str| app.session.doc().is_ok_and(|d| d.variables.collections.iter().any(|c| c.name == n));
|
||||
let collection = crate::variables_panel::unique("Collection", taken);
|
||||
let new = json!({"command": "variable.createCollection", "params": {"name": collection, "modes": ["Mode 1"]}, "as": "collection"});
|
||||
let add = json!({"command": "variable.create", "params": variable(json!({"$ref": "collection"}))});
|
||||
("command.batch", json!({"label": "Create variable", "commands": [new, add]}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A variable's collection: one of the file's, or a new one.
|
||||
fn collection_picker(ui: &mut egui::Ui, s: &mut SampledColor, collections: &[(String, String)]) {
|
||||
let shown = s.collection.as_ref().and_then(|id| collections.iter().find(|c| &c.0 == id)).map_or(tr("New collection"), |c| c.1.as_str());
|
||||
let resp = widgets::dropdown(ui, shown, 260.0, None);
|
||||
crate::right::menu_popup(&resp).show(|ui| {
|
||||
for (id, label) in collections {
|
||||
if crate::right::menu_item(ui, label, "") {
|
||||
s.collection = Some(id.clone());
|
||||
}
|
||||
}
|
||||
if crate::right::menu_item(ui, tr("New collection"), "") {
|
||||
s.collection = None;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// The window: a swatch of the colour, Style or Variable, its name, a variable's collection,
|
||||
/// Cancel and Create (Enter creates).
|
||||
pub fn show(app: &mut FigApp, ctx: &Context) {
|
||||
let Some(mut s) = app.ui.sampled_color.clone() else { return };
|
||||
if app.session.ds().map(|d| d.uid).ok() != Some(s.uid) {
|
||||
app.ui.sampled_color = None;
|
||||
return;
|
||||
}
|
||||
let t = Tokens::get(ctx);
|
||||
let collections: Vec<(String, String)> = app
|
||||
.session
|
||||
.doc()
|
||||
.map(|d| figcraft_engine::library::local_collections(d).map(|c| (c.id.clone(), c.name.clone())).collect())
|
||||
.unwrap_or_default();
|
||||
let (mut open, mut cancel, mut create) = (true, false, false);
|
||||
window(tr("Create from color"), ctx).id(egui::Id::unique("Create from color")).open(&mut open).show(ctx, |ui| {
|
||||
ui.set_width(280.0);
|
||||
ui.horizontal(|ui| {
|
||||
let paint = Color::from_hex(&s.color).map(Paint::solid);
|
||||
if let Some(p) = &paint {
|
||||
widgets::swatch(ui, p, 24.0);
|
||||
}
|
||||
ui.label(RichText::new(s.color.trim_start_matches('#').to_uppercase()).color(t.text));
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
if widgets::radio(ui, !s.variable, tr("Style")) {
|
||||
s.variable = false;
|
||||
}
|
||||
if widgets::radio(ui, s.variable, tr("Variable")) {
|
||||
s.variable = true;
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
let name = ui.add(egui::TextEdit::singleline(&mut s.name).hint_text(tr("Name")).desired_width(260.0));
|
||||
widgets::select_all_on_focus(ui, &name, &s.name);
|
||||
if ui.memory(|m| m.focused().is_none()) {
|
||||
name.request_focus();
|
||||
}
|
||||
if s.variable {
|
||||
ui.add_space(6.0);
|
||||
collection_picker(ui, &mut s, &collections);
|
||||
}
|
||||
ui.add_space(10.0);
|
||||
let ready = !s.name.trim().is_empty();
|
||||
ui.horizontal(|ui| {
|
||||
cancel = widgets::button(ui, tr("Cancel"), false, true).clicked() || ui.input(|i| i.key_pressed(egui::Key::Escape));
|
||||
let enter = name.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
|
||||
create = (widgets::button(ui, tr("Create"), true, ready).clicked() || enter) && ready;
|
||||
});
|
||||
});
|
||||
let made = create && {
|
||||
let (cmd, params) = create_params(app, &s);
|
||||
app.run(cmd, params).is_some()
|
||||
};
|
||||
// A name already taken leaves the window open to change it (the error says why).
|
||||
app.ui.sampled_color = (open && !cancel && !made).then_some(s);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ fn rename_field(ui: &mut Ui, st: &mut Editor, target: &Rename, value: &str, rect
|
||||
}
|
||||
|
||||
/// The first of `base`, `base 2`, `base 3`… that `taken` doesn't hold.
|
||||
fn unique(base: &str, taken: impl Fn(&str) -> bool) -> String {
|
||||
pub(crate) fn unique(base: &str, taken: impl Fn(&str) -> bool) -> String {
|
||||
(1..10_000).map(|k| if k == 1 { base.to_string() } else { format!("{base} {k}") }).find(|n| !taken(n)).unwrap_or_else(|| base.to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +221,8 @@ mod proto_responsive_tests;
|
||||
#[cfg(test)]
|
||||
mod resources_tests;
|
||||
#[cfg(test)]
|
||||
mod sampled_color_tests;
|
||||
#[cfg(test)]
|
||||
mod save_as_tests;
|
||||
#[cfg(test)]
|
||||
mod select_all_tests;
|
||||
@@ -288,6 +290,7 @@ pub use dialogs::credits;
|
||||
pub use dialogs::import_report;
|
||||
pub use dialogs::missing_fonts;
|
||||
pub use dialogs::plugins_ui;
|
||||
pub use dialogs::sampled_color;
|
||||
pub use dialogs::updates_ui;
|
||||
pub use dialogs::variables_panel;
|
||||
pub use home::home_recents;
|
||||
@@ -502,6 +505,8 @@ pub struct UiState {
|
||||
/// Files the user opened whose fonts are yet to be checked (by document uid).
|
||||
pub font_checks: Vec<u64>,
|
||||
pub missing_fonts: Option<missing_fonts::Shown>,
|
||||
/// The eyedropper's Cmd/Ctrl+Shift pick, to make a colour style or variable of.
|
||||
pub sampled_color: Option<sampled_color::SampledColor>,
|
||||
pub screenshot_requests: Vec<(u64, String)>,
|
||||
pub frame_ms: f64,
|
||||
pub render_ms: f64,
|
||||
@@ -669,6 +674,7 @@ impl Default for UiState {
|
||||
import_report: None,
|
||||
font_checks: Vec::new(),
|
||||
missing_fonts: None,
|
||||
sampled_color: None,
|
||||
screenshot_requests: Vec::new(),
|
||||
frame_ms: 0.0,
|
||||
render_ms: 0.0,
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//! The window that makes a colour the eyedropper picked (with Cmd/Ctrl+Shift) into a colour style
|
||||
//! or variable: it opens from the eyedropper's request, Create makes what it says, and a variable
|
||||
//! goes into the chosen collection or, with none, a new one, in one undo step.
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
use crate::export_preview_tests::{click, labelled};
|
||||
use crate::layers_drag_tests::Ui;
|
||||
use crate::sampled_color::{SampledColor, create_params};
|
||||
|
||||
fn opened(s: figcraft_engine::Session) -> Ui {
|
||||
let mut u = Ui::new(s);
|
||||
u.app.session.request_ui("dialog.createFromColor", json!({"color": "#ff8800"}));
|
||||
u.app.handle_ui_requests();
|
||||
u.frame(vec![]);
|
||||
u.frame(vec![]);
|
||||
u
|
||||
}
|
||||
|
||||
fn press(u: &mut Ui, text: &str) {
|
||||
let shown = labelled(u);
|
||||
let at = shown.iter().find(|(t, _)| t == text).map(|x| x.1).unwrap_or_else(|| panic!("{text:?} in {shown:?}"));
|
||||
click(u, at);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_eyedroppers_request_opens_the_window_and_create_makes_a_style() {
|
||||
let mut u = opened(figcraft_engine::Session::new());
|
||||
let s = u.app.ui.sampled_color.clone().expect("the window is open");
|
||||
assert_eq!((s.color.as_str(), s.variable, s.name.as_str()), ("#FF8800", false, "Color 1"));
|
||||
let texts: Vec<String> = labelled(&mut u).into_iter().map(|(t, _)| t).collect();
|
||||
assert!(texts.iter().any(|t| t == "Create from color") && texts.iter().any(|t| t == "FF8800"), "{texts:?}");
|
||||
press(&mut u, "Create");
|
||||
let doc = u.app.session.doc().unwrap();
|
||||
let style = doc.styles.iter().find(|s| s.name == "Color 1").expect("a style");
|
||||
let colour = match &style.kind {
|
||||
figcraft_doc::StyleKind::Paint { paints } => paints.first().and_then(|p| p.solid_color()).map(|c| c.to_hex()),
|
||||
_ => None,
|
||||
};
|
||||
assert_eq!(colour.as_deref(), Some("FF8800"), "a paint style of the colour: {style:?}");
|
||||
assert!(u.app.ui.sampled_color.is_none(), "it closes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_variable_goes_into_a_new_or_the_chosen_collection() {
|
||||
// No collection yet: one is made with it, one undo step.
|
||||
let mut u = opened(figcraft_engine::Session::new());
|
||||
let undo = u.app.session.undo_depth().0;
|
||||
if let Some(s) = u.app.ui.sampled_color.as_mut() {
|
||||
s.variable = true;
|
||||
s.name = "Accent".into();
|
||||
}
|
||||
u.frame(vec![]);
|
||||
press(&mut u, "Create");
|
||||
let doc = u.app.session.doc().unwrap();
|
||||
let v = doc.variables.variables.iter().find(|v| v.name == "Accent").expect("a variable");
|
||||
let c = doc.variables.collection(&v.collection).expect("its collection");
|
||||
assert_eq!(c.name, "Collection");
|
||||
assert_eq!(u.app.session.undo_depth().0, undo + 1, "one step");
|
||||
// With collections: the first is chosen, and the variable goes there.
|
||||
let mut s = figcraft_engine::Session::new();
|
||||
s.execute("variable.createCollection", &json!({"name": "Brand"})).unwrap();
|
||||
let u = opened(s);
|
||||
let state = u.app.ui.sampled_color.clone().unwrap();
|
||||
let brand = u.app.session.doc().unwrap().variables.collections[0].id.clone();
|
||||
assert_eq!(state.collection.as_deref(), Some(brand.as_str()));
|
||||
let (cmd, params) = create_params(&u.app, &SampledColor { variable: true, name: "Accent".into(), ..state });
|
||||
assert_eq!((cmd, params["collection"].as_str()), ("variable.create", Some(brand.as_str())));
|
||||
assert_eq!((params["type"].as_str(), params["value"].as_str()), (Some("color"), Some("#FF8800")));
|
||||
}
|
||||
@@ -333,7 +333,7 @@ fn leaf(name: &str) -> &str {
|
||||
}
|
||||
|
||||
/// `base N` with the smallest N no style of the document is named.
|
||||
fn next_name(doc: &Document, base: &str) -> String {
|
||||
pub(crate) fn next_name(doc: &Document, base: &str) -> String {
|
||||
(1..).map(|n| format!("{base} {n}")).find(|n| doc.styles.iter().all(|s| &s.name != n)).unwrap_or_else(|| base.to_string())
|
||||
}
|
||||
|
||||
|
||||
+2
-1
File diff suppressed because one or more lines are too long
+3
-2
@@ -1,6 +1,6 @@
|
||||
# UI and interaction parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7)
|
||||
|
||||
Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys,
|
||||
drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status:
|
||||
@@ -89,7 +89,7 @@ interaction feel not yet compared.
|
||||
| Shape builder (Shift+M) on fills, strokes and open paths; variable width (Shift+W), one side with Alt | done | |
|
||||
| Boolean groups: clicked where the result is, double-click or Cmd/Ctrl-click into operands, live results while dragging or editing points, per-operand operations | done | a group past the path operations' caps (250 000 segments, 2 million possible crossings, 4 million segments swept over a fold) draws without its result, with a warning, and Flatten refuses it (#1104) |
|
||||
| Text: point, auto height, fixed; caret, words, lines, IME | done | the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; no spell check |
|
||||
| Eyedropper (I) | done | picks the colour seen under the pointer (opaque) into the selection's fill and the recent colours, one undo step (`fx_behaviour_tests`) |
|
||||
| Eyedropper (I) | done | picks the colour seen under the pointer (opaque) into the selection's fill and the recent colours, one undo step (`fx_behaviour_tests`); with Cmd/Ctrl+Shift held it makes a colour style or variable of it instead, as the reference app's eyedropper does: a Create from color window asks which, its name (the next free "Color n") and a variable's collection (the file's first, or a new one made with it in the same undo step), and leaves the selection's fills alone (`eyedropper_create_tests`, `sampled_color_tests`) |
|
||||
| Comment (C), Shift+C to show/hide | done | local only |
|
||||
| Text on a path (Figma Draw) | done | the Text on a path tool in the Text flyout (`tool.textOnPath`) shows the I-beam over a shape's or vector's path, and a click there puts new text on the path, starting at the click, with the path's effects and its fill when one shows; the path layer is removed, and the path comes back if nothing is typed. Also from the Design panel or `text.onPath`; the path is edited by resizing only |
|
||||
| Stretch and scatter brushes (Figma Draw) | done | eight presets drawn in code; the Pencil's brush is set by `tool.pencilBrush`, not from the toolbar |
|
||||
@@ -175,6 +175,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-30 | minor | M4, gap 4: the eyedropper with Cmd/Ctrl+Shift held makes a colour style or variable of the colour it picks, as the reference app's eyedropper does, instead of filling the selection. It asks the UI for a Create from color window (`dialog.createFromColor`; the control channel never opens it). The window shows the colour and offers Style or Variable, a name (the next free "Color n") and, for a variable, a collection: the file's first, or a new one made with it in the same undo step. Create runs `style.create` or `variable.create`. Tests: `eyedropper_create_tests`, `sampled_color_tests`. |
|
||||
| 2026-10-30 | minor | M1: sidebar number and text fields keep their text vertically centered when focused, including typography spacing. Editors use the full 24 pt field height instead of adding a 4 pt top inset to an editor already at least 24 pt tall. Regression: `field_tests::sidebar_field_text_stays_in_place_on_focus` compares painted text positions before and after focus. Readiness estimates unchanged. |
|
||||
| 2026-10-30 | minor | Pen into vector edit mode (#1430): Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on; Escape keeps the pen. Numbers unchanged. |
|
||||
| 2026-10-30 | minor | M8, #1574: the Actions palette (Ctrl+K) offered engine commands that need parameters it can't give, such as `image.place` ("Place image", needing the image's `data` or `path`), which failed with "Invalid parameters" and sat above the menu's Place image… row with the same label. A search now leaves out a command no menu lists when its params doc names a parameter without `?` (`figcraft_engine::cmd::needs_params`), and a row no menu item gives whose label reads like a menu item's (any case, without the ellipsis). Place image runs File ▸ Place image…, which opens the file dialog. Tests: `palette_tests.rs` (no row needs parameters unless a menu item runs it, no duplicate label across several searches), `unknown_params_tests.rs`. |
|
||||
|
||||
Reference in New Issue
Block a user