mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 08:53:33 +00:00
Merge pull request #8121 from dotCooCoo/feat/type-size-other
Type: Size › Other… gives the Character panel's Font Size field the focus
This commit is contained in:
@@ -381,6 +381,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"Cmd+Alt+Shift+F",
|
||||
"{} show the Character panel if it is hidden and open its font family menu, whose search field takes the keyboard focus: type to search, Enter applies the highlighted font → {field: \"fontName\"}. Without selected type (or text the Type tool edits) the panel shows, and the error says to select type first",
|
||||
),
|
||||
(
|
||||
"type.highlightFontSize",
|
||||
"Highlight Font Size",
|
||||
"",
|
||||
"{} (Type › Size › Other…) show the Character panel if it is hidden and give its Font Size field the keyboard focus with its value selected (blank where the selected sizes differ): type a size and press Enter → {field: \"fontSize\"}. Without selected type (or text the Type tool edits) the panel shows, and the error says to select type first",
|
||||
),
|
||||
(
|
||||
"type.highlightKerning",
|
||||
"Highlight Kerning",
|
||||
|
||||
@@ -6097,6 +6097,8 @@ theme Appearance Външен вид
|
||||
Reset Tracking and Kerning Нулиране на разредката и кернинга
|
||||
Reset Horizontal Scale Нулиране на хоризонталния мащаб
|
||||
Highlight Font Name Маркиране на името на шрифта
|
||||
Highlight Font Size Маркиране на размера на шрифта
|
||||
Other… Друг…
|
||||
Highlight Kerning Маркиране на кернинга
|
||||
Highlight Tracking Маркиране на разредката
|
||||
@msg span must be "object" or "selection", got {v} span трябва да е "object" или "selection", а не {v}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4293,6 +4293,8 @@ axis Both Obje
|
||||
Reset Tracking and Kerning Vrati razmak slova i podrezivanje na početno
|
||||
Reset Horizontal Scale Vrati vodoravnu skalu na početno
|
||||
Highlight Font Name Istakni naziv fonta
|
||||
Highlight Font Size Istakni veličinu fonta
|
||||
Other… Druga…
|
||||
Highlight Kerning Istakni podrezivanje
|
||||
Highlight Tracking Istakni razmak slova
|
||||
Step Type Vrsta koraka
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1823,6 +1823,8 @@ digits Malayalam Malaiàlam
|
||||
Fonts added in the last 30 days Tipus de lletra afegits en els darrers 30 dies
|
||||
Font Preview Size Mida de previsualització del tipus de lletra
|
||||
Font Size Mida del tipus de lletra
|
||||
Highlight Font Size Ressalta la mida del tipus de lletra
|
||||
Other… Una altra…
|
||||
Font Style: Estil de tipus de lletra:
|
||||
Font Technology Tecnologia del tipus de lletra
|
||||
Font: Tipus de lletra:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4395,6 +4395,8 @@ axis Both Obě
|
||||
Reset Tracking and Kerning Obnovit prostrkání a vyrovnání párů
|
||||
Reset Horizontal Scale Obnovit vodorovnou změnu velikosti
|
||||
Highlight Font Name Zvýraznit název písma
|
||||
Highlight Font Size Zvýraznit velikost písma
|
||||
Other… Jiná…
|
||||
Highlight Kerning Zvýraznit vyrovnání párů
|
||||
Highlight Tracking Zvýraznit prostrkání
|
||||
Step Type Krokovat text
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8603,6 +8603,8 @@ mark-style Japanese Japansk
|
||||
Reset Tracking and Kerning Nulstil sporing og kerning
|
||||
Reset Horizontal Scale Nulstil vandret skalering
|
||||
Highlight Font Name Fremhæv skrifttypenavn
|
||||
Highlight Font Size Fremhæv skriftstørrelse
|
||||
Other… Anden…
|
||||
Highlight Kerning Fremhæv kerning
|
||||
Highlight Tracking Fremhæv sporing
|
||||
@msg span must be "object" or "selection", got {v} span skal være "object" eller "selection", fik {v}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1284,6 +1284,8 @@ font-technology Variable Variabel
|
||||
Reset Tracking and Kerning Laufweite und Kerning zurücksetzen
|
||||
Reset Horizontal Scale Horizontale Skalierung zurücksetzen
|
||||
Highlight Font Name Schriftname hervorheben
|
||||
Highlight Font Size Schriftgrad hervorheben
|
||||
Other… Andere…
|
||||
Highlight Kerning Kerning hervorheben
|
||||
Highlight Tracking Laufweite hervorheben
|
||||
Spacing Abstand
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6499,6 +6499,8 @@ effect Points Σημεία
|
||||
Reset Horizontal Scale Επαναφορά οριζόντιας κλίμακας
|
||||
Reset Tracking and Kerning Επαναφορά απόστασης χαρακτήρων και διαγραμμάτωσης
|
||||
Highlight Font Name Επισήμανση ονόματος γραμματοσειράς
|
||||
Highlight Font Size Επισήμανση μεγέθους γραμματοσειράς
|
||||
Other… Άλλο…
|
||||
Highlight Kerning Επισήμανση διαγραμμάτωσης
|
||||
Highlight Tracking Επισήμανση απόστασης χαρακτήρων
|
||||
Sample Color from Screen Δειγματοληψία χρώματος από την οθόνη
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1309,6 +1309,8 @@ font-technology Variable Variables
|
||||
Reset Tracking and Kerning Restablecer espaciado e interletraje
|
||||
Reset Horizontal Scale Restablecer escala horizontal
|
||||
Highlight Font Name Resaltar nombre de fuente
|
||||
Highlight Font Size Resaltar tamaño de fuente
|
||||
Other… Otro…
|
||||
Highlight Kerning Resaltar interletraje
|
||||
Highlight Tracking Resaltar espaciado
|
||||
Spacing Espaciado
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -6509,6 +6509,8 @@ mark-style Japanese Japanilainen
|
||||
Reset Horizontal Scale Palauta vaakaskaalaus
|
||||
Reset Tracking and Kerning Palauta merkkiväli ja parivälistys
|
||||
Highlight Font Name Korosta fontin nimi
|
||||
Highlight Font Size Korosta fonttikoko
|
||||
Other… Muu…
|
||||
Highlight Kerning Korosta parivälistys
|
||||
Highlight Tracking Korosta merkkiväli
|
||||
Sample Color from Screen Poimi väri näytöltä
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1299,6 +1299,8 @@ font-technology Variable Variables
|
||||
Reset Tracking and Kerning Réinitialiser l’approche et le crénage
|
||||
Reset Horizontal Scale Réinitialiser la mise à l’échelle horizontale
|
||||
Highlight Font Name Surligner le nom de la police
|
||||
Highlight Font Size Surligner la taille de police
|
||||
Other… Autre…
|
||||
Highlight Kerning Surligner le crénage
|
||||
Highlight Tracking Surligner l’approche
|
||||
Spacing Espacement
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1714,6 +1714,8 @@
|
||||
Highlight Alternate Glyphs વૈકલ્પિક ગ્લિફ હાઇલાઇટ કરો
|
||||
Highlight Area વિસ્તાર હાઇલાઇટ કરો
|
||||
Highlight Font Name ફોન્ટનું નામ હાઇલાઇટ કરો
|
||||
Highlight Font Size ફોન્ટ સાઇઝ હાઇલાઇટ કરો
|
||||
Other… અન્ય…
|
||||
Highlight Intensity હાઇલાઇટ તીવ્રતા
|
||||
Highlight Kerning કર્નિંગ હાઇલાઇટ કરો
|
||||
Highlight Rows પંક્તિઓ હાઇલાઇટ કરો
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -2344,6 +2344,8 @@ antiAlias Sharp शार्प
|
||||
Highlight anchors on mouse over माउस ओवर पर हाइलाइट एंकर
|
||||
Highlight Area हाइलाइट क्षेत्र
|
||||
Highlight Font Name हाइलाइट फ़ॉन्ट नाम
|
||||
Highlight Font Size हाइलाइट फ़ॉन्ट साइज़
|
||||
Other… अन्य…
|
||||
Highlight Kerning हाइलाइट कर्निंग
|
||||
Highlight Rows हाइलाइट पंक्तियाँ
|
||||
Highlight Substituted Fonts हाईलाइट सबस्टिट्यूटेड फ़ॉन्ट
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3649,6 +3649,8 @@ mark-style Japanese Japán
|
||||
Reset Tracing Tracing visszaállítása
|
||||
Reset Tracking and Kerning Betűköz és alávágás visszaállítása
|
||||
Highlight Font Name Betűtípusnév kiemelése
|
||||
Highlight Font Size Betűméret kiemelése
|
||||
Other… Egyéb…
|
||||
Highlight Kerning Alávágás kiemelése
|
||||
Highlight Tracking Betűköz kiemelése
|
||||
Reset Typography Typography visszaállítása
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5842,6 +5842,8 @@ mark-style Japanese Jepang
|
||||
Reset Tracking and Kerning Atur ulang tracking dan kerning
|
||||
Reset Horizontal Scale Atur ulang skala horizontal
|
||||
Highlight Font Name Sorot nama font
|
||||
Highlight Font Size Sorot ukuran font
|
||||
Other… Lainnya…
|
||||
Highlight Kerning Sorot kerning
|
||||
Highlight Tracking Sorot tracking
|
||||
@msg span must be "object" or "selection", got {v} span harus "object" atau "selection", diterima {v}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2516 and column 5.
|
@@ -1318,6 +1318,8 @@ font-technology Variable Variabili
|
||||
Reset Tracking and Kerning Reimposta spaziatura caratteri e crenatura
|
||||
Reset Horizontal Scale Reimposta scala orizzontale
|
||||
Highlight Font Name Evidenzia nome del font
|
||||
Highlight Font Size Evidenzia dimensione font
|
||||
Other… Altro…
|
||||
Highlight Kerning Evidenzia crenatura
|
||||
Highlight Tracking Evidenzia spaziatura caratteri
|
||||
Spacing Spaziatura
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -466,6 +466,8 @@ digits Malayalam マラヤーラム数字
|
||||
Reset Tracking and Kerning トラッキングとカーニングをリセット
|
||||
Reset Horizontal Scale 水平比率をリセット
|
||||
Highlight Font Name フォント名をハイライト
|
||||
Highlight Font Size フォントサイズをハイライト
|
||||
Other… その他…
|
||||
Highlight Kerning カーニングをハイライト
|
||||
Highlight Tracking トラッキングをハイライト
|
||||
Step Type 文字を段階的に調整
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8284,6 +8284,8 @@ liquify-list-end {0}, {1} {0} და {1}
|
||||
Keep selected მონიშნულად დატოვება
|
||||
Reset Tracking and Kerning ტრეკინგისა და კერნინგის ჩამოყრა
|
||||
Highlight Font Name შრიფტის სახელის გამოკვეთა
|
||||
Highlight Font Size შრიფტის ზომის გამოკვეთა
|
||||
Other… სხვა…
|
||||
Highlight Kerning კერნინგის გამოკვეთა
|
||||
Highlight Tracking ტრეკინგის გამოკვეთა
|
||||
Legacy (version 7) ძველი (ვერსია 7)
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -459,6 +459,8 @@ digits Malayalam 말라얄람어
|
||||
Reset Tracking and Kerning 자간 및 커닝 재설정
|
||||
Reset Horizontal Scale 가로 비율 재설정
|
||||
Highlight Font Name 글꼴 이름 강조 표시
|
||||
Highlight Font Size 글꼴 크기 강조 표시
|
||||
Other… 기타…
|
||||
Highlight Kerning 커닝 강조 표시
|
||||
Highlight Tracking 자간 강조 표시
|
||||
Step Type 단계별 문자
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -8389,6 +8389,8 @@ mark-style Japanese Japans
|
||||
Reset Tracking and Kerning Tracking en kerning herstellen
|
||||
Reset Horizontal Scale Horizontale schaal herstellen
|
||||
Highlight Font Name Lettertypenaam markeren
|
||||
Highlight Font Size Lettertypegrootte markeren
|
||||
Other… Andere…
|
||||
Highlight Kerning Kerning markeren
|
||||
Highlight Tracking Tracking markeren
|
||||
@msg span must be "object" or "selection", got {v} span moet "object" of "selection" zijn, maar is {v}
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4237,6 +4237,8 @@ axis Both Obie
|
||||
Reset Tracking and Kerning Resetuj światło i kerning
|
||||
Reset Horizontal Scale Resetuj skalę poziomą
|
||||
Highlight Font Name Wyróżnij nazwę czcionki
|
||||
Highlight Font Size Wyróżnij rozmiar czcionki
|
||||
Other… Inny…
|
||||
Highlight Kerning Wyróżnij kerning
|
||||
Highlight Tracking Wyróżnij światło
|
||||
Step Type Krok tekstu
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1189,6 +1189,8 @@ antiAlias Sharp Nítido
|
||||
Reset Tracking and Kerning Redefinir Rastreamento e Kerning
|
||||
Reset Horizontal Scale Redefinir Escala Horizontal
|
||||
Highlight Font Name Destacar Nome da Fonte
|
||||
Highlight Font Size Destacar Tamanho da Fonte
|
||||
Other… Outro…
|
||||
Highlight Kerning Destacar Kerning
|
||||
Highlight Tracking Destacar Rastreamento
|
||||
Step Type Ajustar Texto em Incrementos
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1307,6 +1307,8 @@ font-technology Variable Вариативные
|
||||
Reset Tracking and Kerning Сбросить трекинг и кернинг
|
||||
Reset Horizontal Scale Сбросить масштаб по горизонтали
|
||||
Highlight Font Name Выделить имя шрифта
|
||||
Highlight Font Size Выделить размер шрифта
|
||||
Other… Другой…
|
||||
Highlight Kerning Выделить кернинг
|
||||
Highlight Tracking Выделить трекинг
|
||||
Spacing Интервал
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6489,6 +6489,8 @@ theme Appearance Utseende
|
||||
Reset Horizontal Scale Återställ horisontell skala
|
||||
Reset Tracking and Kerning Återställ spärrning och kerning
|
||||
Highlight Font Name Framhäv typsnittsnamn
|
||||
Highlight Font Size Framhäv teckenstorlek
|
||||
Other… Annan…
|
||||
Highlight Kerning Framhäv kerning
|
||||
Highlight Tracking Framhäv spärrning
|
||||
Sample Color from Screen Hämta färg från skärmen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1258,6 +1258,8 @@ font-technology Variable Değişken
|
||||
Reset Tracking and Kerning Takip ve Karakter Aralığını Sıfırla
|
||||
Reset Horizontal Scale Yatay Ölçeği Sıfırla
|
||||
Highlight Font Name Yazı Tipi Adını Vurgula
|
||||
Highlight Font Size Yazı Tipi Boyutunu Vurgula
|
||||
Other… Diğer…
|
||||
Highlight Kerning Karakter Aralığını Vurgula
|
||||
Highlight Tracking Takibi Vurgula
|
||||
Spacing Aralık
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1312,6 +1312,8 @@ font-technology Variable Варіативні
|
||||
Reset Tracking and Kerning Скинути трекінг і кернінг
|
||||
Reset Horizontal Scale Скинути масштаб по горизонталі
|
||||
Highlight Font Name Виділити назву шрифту
|
||||
Highlight Font Size Виділити розмір шрифту
|
||||
Other… Інший…
|
||||
Highlight Kerning Виділити кернінг
|
||||
Highlight Tracking Виділити трекінг
|
||||
Spacing Інтервал
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3420,6 +3420,8 @@ mark-style Japanese Kiểu Nhật
|
||||
Reset to White, Black Đặt lại về Trắng, Đen
|
||||
Reset Tracking and Kerning Đặt lại giãn chữ và kerning
|
||||
Highlight Font Name Đánh dấu tên phông
|
||||
Highlight Font Size Đánh dấu cỡ chữ
|
||||
Other… Khác…
|
||||
Highlight Kerning Đánh dấu kerning
|
||||
Highlight Tracking Đánh dấu giãn chữ
|
||||
Reset with Mesh Đặt lại với lưới
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 206 and column 5.
|
@@ -1249,6 +1249,8 @@ antiAlias Sharp 锐利
|
||||
Reset Tracking and Kerning 重置字距和字偶距
|
||||
Reset Horizontal Scale 重置水平缩放
|
||||
Highlight Font Name 突出显示字体名称
|
||||
Highlight Font Size 突出显示字号
|
||||
Other… 其他…
|
||||
Highlight Kerning 突出显示字偶距
|
||||
Highlight Tracking 突出显示字距
|
||||
Spacing 间距
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1283,6 +1283,8 @@ font-technology Variable 可變
|
||||
Reset Tracking and Kerning 重設字距與字距微調
|
||||
Reset Horizontal Scale 重設水平縮放
|
||||
Highlight Font Name 反白顯示字體名稱
|
||||
Highlight Font Size 反白顯示字體大小
|
||||
Other… 其他…
|
||||
Highlight Kerning 反白顯示字距微調
|
||||
Highlight Tracking 反白顯示字距
|
||||
Spacing 間距
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -322,6 +322,7 @@ fn run_ui_part3(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
"type.bold" => crate::panels::character::toggle_face(app, Face::Bold),
|
||||
"type.italic" => crate::panels::character::toggle_face(app, Face::Italic),
|
||||
"type.highlightFontName" => crate::panels::character::highlight(app, crate::panels::character::Field::FontName),
|
||||
"type.highlightFontSize" => crate::panels::character::highlight(app, crate::panels::character::Field::FontSize),
|
||||
"type.highlightKerning" => crate::panels::character::highlight(app, crate::panels::character::Field::Kerning),
|
||||
"type.highlightTracking" => crate::panels::character::highlight(app, crate::panels::character::Field::Tracking),
|
||||
"type.underline" => crate::panels::character::toggle_underline(app),
|
||||
|
||||
@@ -219,7 +219,7 @@ pub fn enabled(app: &VectorcraftApp, id: &str) -> bool {
|
||||
match id {
|
||||
// Save is off for a clean document that already has its own file.
|
||||
"file.save" => app.session.active().is_some_and(|d| d.path.is_none() || d.converted || d.is_dirty()),
|
||||
"type.bold" | "type.italic" | "type.underline" | "type.lineComposer" | "type.hyphenate" => {
|
||||
"type.bold" | "type.italic" | "type.underline" | "type.lineComposer" | "type.hyphenate" | "type.highlightFontSize" => {
|
||||
crate::panels::character::text_style(app).is_some()
|
||||
}
|
||||
id if crate::panels::paragraph::ALIGN_COMMANDS.iter().any(|c| c.0 == id) => crate::panels::character::text_style(app).is_some(),
|
||||
|
||||
@@ -442,6 +442,39 @@ fn center_on_top_and_bottom_are_type_on_a_path_items() {
|
||||
assert!((start - 0.625).abs() < 1e-6, "{start}");
|
||||
}
|
||||
|
||||
/// Type › Size ends with a separator and Other…, which runs `type.highlightFontSize`: dimmed
|
||||
/// without selected type, enabled with it, and never checked.
|
||||
#[test]
|
||||
fn type_size_ends_with_other() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
|
||||
let id = "type.highlightFontSize";
|
||||
assert!(!enabled(&app, id), "no document");
|
||||
app.run("file.new", json!({})).unwrap();
|
||||
let items: Vec<Item> = menu_tree()
|
||||
.into_iter()
|
||||
.filter(|(menu, _)| *menu == "Type")
|
||||
.flat_map(|(_, items)| items)
|
||||
.filter_map(|item| match item {
|
||||
Item::Sub("Size", children) => Some(children),
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
let n = items.len();
|
||||
assert!(n > 2, "{n} items");
|
||||
assert!(matches!(items[n - 2], Item::Sep), "a separator comes before Other…");
|
||||
assert!(matches!(&items[n - 1], Item::Cmd("Other…", c, p) if *c == id && p.is_null()), "Other… comes last");
|
||||
assert!(items[..n - 2].iter().all(|i| matches!(i, Item::Cmd(_, "text.setStyle", _))), "the sizes come first");
|
||||
assert!(!enabled(&app, id), "nothing selected");
|
||||
let path = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap()["id"].clone();
|
||||
app.run("select.set", json!({"ids": [path]})).unwrap();
|
||||
assert!(!enabled(&app, id), "a path selected");
|
||||
let text = app.run("text.create", json!({"x": 10, "y": 100, "text": "Size"})).unwrap()["id"].clone();
|
||||
app.run("select.set", json!({"ids": [text]})).unwrap();
|
||||
assert!(enabled(&app, id), "type selected");
|
||||
assert_eq!(checked(&app, id, &Value::Null), None);
|
||||
}
|
||||
|
||||
/// Type › Dynamic Text Presets › Circle, Arch and Bow run `type.dynamicTextPreset` with their
|
||||
/// preset, enabled for point type and type on a path but not for area type alone.
|
||||
#[test]
|
||||
|
||||
@@ -397,7 +397,14 @@ pub fn menu_tree_named(english_names: bool) -> Vec<(&'static str, Vec<Item>)> {
|
||||
vec![
|
||||
sub("Font", font_items(english_names)),
|
||||
sub("Recent Fonts", RECENT_FONT_IDS.iter().map(|id| c("Recent Font", id)).collect()),
|
||||
sub("Size", TYPE_SIZES.iter().map(|(l, n)| cp(l, "text.setStyle", json!({ "size": n }))).collect()),
|
||||
sub(
|
||||
"Size",
|
||||
TYPE_SIZES
|
||||
.iter()
|
||||
.map(|(l, n)| cp(l, "text.setStyle", json!({ "size": n })))
|
||||
.chain([Sep, c("Other…", "type.highlightFontSize")])
|
||||
.collect(),
|
||||
),
|
||||
c("Bold", "type.bold"),
|
||||
c("Italic", "type.italic"),
|
||||
Sep,
|
||||
|
||||
@@ -382,6 +382,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"Cmd+Alt+Shift+F",
|
||||
"{} show the Character panel if it is hidden and open its font family menu, whose search field takes the keyboard focus: type to search, Enter applies the highlighted font → {field: \"fontName\"}. Without selected type (or text the Type tool edits) the panel shows, and the error says to select type first",
|
||||
),
|
||||
(
|
||||
"type.highlightFontSize",
|
||||
"Highlight Font Size",
|
||||
"",
|
||||
"{} (Type › Size › Other…) show the Character panel if it is hidden and give its Font Size field the keyboard focus with its value selected (blank where the selected sizes differ): type a size and press Enter → {field: \"fontSize\"}. Without selected type (or text the Type tool edits) the panel shows, and the error says to select type first",
|
||||
),
|
||||
(
|
||||
"type.highlightKerning",
|
||||
"Highlight Kerning",
|
||||
|
||||
@@ -408,7 +408,7 @@ fn a_character_field_shortcut_brings_the_floating_character_panel_forward() {
|
||||
h.frame(vec![]);
|
||||
assert!(showing(&h.app.ui, "character"));
|
||||
assert_eq!(h.app.dock_rt.raise, None);
|
||||
for command in ["type.highlightKerning", "type.highlightTracking", "type.highlightFontName"] {
|
||||
for command in ["type.highlightKerning", "type.highlightTracking", "type.highlightFontName", "type.highlightFontSize"] {
|
||||
h.app.run(command, json!({})).unwrap();
|
||||
assert_eq!(h.app.dock_rt.raise.as_deref(), Some("character"), "{command}");
|
||||
h.frame(vec![]);
|
||||
|
||||
@@ -483,12 +483,14 @@ pub(crate) fn toggle_face(app: &mut VectorcraftApp, face: Face) -> Result<Value,
|
||||
Ok(json!({ "style": name }))
|
||||
}
|
||||
|
||||
/// The Character panel fields that the Highlight Font Name, Highlight Kerning and Highlight
|
||||
/// Tracking commands give the keyboard focus ([`highlight`]).
|
||||
/// The Character panel fields that the Highlight Font Name, Highlight Font Size (Type › Size ›
|
||||
/// Other…), Highlight Kerning and Highlight Tracking commands give the keyboard focus
|
||||
/// ([`highlight`]).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum Field {
|
||||
/// The font family menu: it opens, and its search field takes the focus.
|
||||
FontName,
|
||||
FontSize,
|
||||
Kerning,
|
||||
Tracking,
|
||||
}
|
||||
@@ -498,6 +500,7 @@ impl Field {
|
||||
fn salt(self) -> &'static str {
|
||||
match self {
|
||||
Field::FontName => "ch-font",
|
||||
Field::FontSize => "ch-size",
|
||||
Field::Kerning => "ch-kern",
|
||||
Field::Tracking => "ch-track",
|
||||
}
|
||||
@@ -506,17 +509,19 @@ impl Field {
|
||||
fn name(self) -> &'static str {
|
||||
match self {
|
||||
Field::FontName => "fontName",
|
||||
Field::FontSize => "fontSize",
|
||||
Field::Kerning => "kerning",
|
||||
Field::Tracking => "tracking",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `type.highlightFontName`, `type.highlightKerning` and `type.highlightTracking`: show the
|
||||
/// Character panel if it is hidden (a shown one is activated, so its floating window comes
|
||||
/// forward), and give `field` the keyboard focus when the panel next draws it, a number field with
|
||||
/// its value selected (typing replaces it, Enter applies it). Without selected type or text the
|
||||
/// Type tool edits, the panel shows, nothing takes the focus and the command fails. → `{field}`.
|
||||
/// `type.highlightFontName`, `type.highlightFontSize`, `type.highlightKerning` and
|
||||
/// `type.highlightTracking`: show the Character panel if it is hidden (a shown one is activated,
|
||||
/// so its floating window comes forward), and give `field` the keyboard focus when the panel next
|
||||
/// draws it, a number field with its value selected (typing replaces it, Enter applies it).
|
||||
/// Without selected type or text the Type tool edits, the panel shows, nothing takes the focus and
|
||||
/// the command fails. → `{field}`.
|
||||
pub(crate) fn highlight(app: &mut VectorcraftApp, field: Field) -> Result<Value, String> {
|
||||
// `window.panel` would hide a floating panel in front of its window, or an open flyout.
|
||||
if crate::panel_docking::visible(&app.ui, "character") {
|
||||
|
||||
@@ -343,6 +343,57 @@ fn highlight_commands_focus_the_font_kerning_and_tracking_fields() {
|
||||
assert_eq!(app.character_focus, None);
|
||||
}
|
||||
|
||||
/// Type › Size › Other… (Highlight Font Size) shows the Character panel and gives its Font Size
|
||||
/// field the keyboard focus with the value selected: what is typed replaces it, Enter applies it
|
||||
/// as one undo step, and a selection of different sizes takes the one size typed into the blank
|
||||
/// field. Without selected type the panel shows, the command fails and nothing takes the focus.
|
||||
#[test]
|
||||
fn highlight_font_size_focuses_the_font_size_field() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let a = app.run("text.create", json!({"x": 20, "y": 50, "text": "AVAX", "size": 12})).unwrap()["id"].clone();
|
||||
let b = app.run("text.create", json!({"x": 20, "y": 120, "text": "Wave", "size": 20})).unwrap()["id"].clone();
|
||||
let ctx = egui::Context::default();
|
||||
let frame = |app: &mut VectorcraftApp, events: Vec<egui::Event>| {
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| show(app, ui));
|
||||
out.textures_delta.clear();
|
||||
};
|
||||
let typed = |text: &str| {
|
||||
let enter = egui::Event::Key { key: egui::Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() };
|
||||
vec![egui::Event::Text(text.into()), enter]
|
||||
};
|
||||
let size = |app: &VectorcraftApp| shared(app, |s| s.size);
|
||||
app.run("select.set", json!({"ids": [a.clone()]})).unwrap();
|
||||
assert_eq!(app.run("type.highlightFontSize", json!({})).unwrap(), json!({"field": "fontSize"}));
|
||||
assert!(crate::panel_docking::showing(&app.ui, "character"), "the panel shows");
|
||||
frame(&mut app, vec![]);
|
||||
assert_eq!(app.character_focus, None, "the Font Size field took the focus");
|
||||
frame(&mut app, typed("33"));
|
||||
assert_eq!(size(&app), Some(33.0), "typing replaced the size");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(size(&app), Some(12.0), "one undo step restores the size");
|
||||
// Choosing Other again while the field holds typed text that is not applied selects all of it.
|
||||
app.run("type.highlightFontSize", json!({})).unwrap();
|
||||
frame(&mut app, vec![]);
|
||||
frame(&mut app, vec![egui::Event::Text("999".into())]);
|
||||
app.run("type.highlightFontSize", json!({})).unwrap();
|
||||
frame(&mut app, vec![]);
|
||||
frame(&mut app, typed("18"));
|
||||
assert_eq!(size(&app), Some(18.0), "typing replaced the text typed before");
|
||||
ctx.memory_mut(|m| m.stop_text_input());
|
||||
// Different sizes: the field is blank, and the size typed applies to every selected object.
|
||||
app.run("select.set", json!({"ids": [a, b]})).unwrap();
|
||||
assert_eq!(size(&app), None);
|
||||
app.run("type.highlightFontSize", json!({})).unwrap();
|
||||
frame(&mut app, vec![]);
|
||||
frame(&mut app, typed("16"));
|
||||
assert_eq!(size(&app), Some(16.0), "both objects take the size typed");
|
||||
// No type selected: the panel shows, the command fails and nothing is armed.
|
||||
app.run("select.none", json!({})).unwrap();
|
||||
assert!(app.run("type.highlightFontSize", json!({})).is_err());
|
||||
assert_eq!(app.character_focus, None);
|
||||
}
|
||||
|
||||
/// A variable font gets the Variable Font button, which opens one slider per axis named as the
|
||||
/// font names it; a drag along one sets that axis of the selected type in one undo step.
|
||||
#[test]
|
||||
|
||||
@@ -120,7 +120,8 @@ fn unit_field(
|
||||
|
||||
/// [`unit_field`] whose blank field (`value` is `None`) steps from `blank_from` (points) with
|
||||
/// ↑/↓ and the wheel instead of doing nothing. With `refuse_outside`, a value typed outside
|
||||
/// `bounds` is refused as text that doesn't read is, rather than kept at the nearer end.
|
||||
/// `bounds` is refused as text that doesn't read is, rather than kept at the nearer end. Armed
|
||||
/// with id salt `id` ([`arm_field_focus`]), it takes the keyboard focus with its value selected.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn unit_field_from(
|
||||
ui: &mut Ui,
|
||||
@@ -138,10 +139,18 @@ fn unit_field_from(
|
||||
empty: &str,
|
||||
refuse_outside: bool,
|
||||
) -> Option<f64> {
|
||||
let armed = take_armed_focus(ui, &id);
|
||||
let id = id_with(ui.scope_id(), id);
|
||||
let shown = value.map(|v| unit.format(v)).unwrap_or_else(|| empty.to_string());
|
||||
take_dialog_focus(ui, id, &shown);
|
||||
if armed {
|
||||
focus_field(ui, id, &shown);
|
||||
}
|
||||
let (mut buf, commit, resp, rect) = recessed_text(ui, id, &shown, width, 1, label, name);
|
||||
if armed {
|
||||
// A field armed while it has focus keeps the text typed into it: select all of that text.
|
||||
select_all(ui, id, &buf);
|
||||
}
|
||||
select_all_on_focus(ui, &resp, &buf);
|
||||
// ↑/↓ and the wheel step in the field's unit; a drag on its label scrubs it.
|
||||
let typed = typed_unit(ui.ctx(), unit);
|
||||
|
||||
Reference in New Issue
Block a user