mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 07:17:00 +00:00
Stroke: custom arrowheads from an arrowheads file join the arrowhead menus
The Stroke panel menu's Edit Arrowheads… (stroke.arrowheads.edit) opens
Arrowheads.vectorcraft next to the preferences, creating it with one
example head when it is missing. Each symbol in the file is one head,
listed by name after the built-in heads in both arrowhead menus: it
points right, its registration point is the tip, and its height is drawn
as wide as the built-in heads. The file is read at startup and again
each time VectorCraft saves it; stroke.arrowheads.reload and
stroke.arrowheads.list read and list it.
Arrowhead gets a Custom variant, appended after the built-in names, that
carries the head's name and outline, so a document that uses one draws,
saves, reopens and exports it without the arrowheads file. stroke.set
takes {"custom": name} or the {"Custom": {name, path}} form that
document.inspect reports.
Part of #5421.
This commit is contained in:
@@ -2759,6 +2759,10 @@ digits Malayalam Малаялам
|
||||
Search Preferences Търсене в настройките
|
||||
No settings found Няма намерени настройки
|
||||
Reset Profiles Нулиране на профилите
|
||||
Arrowheads Върхове на стрелки
|
||||
Edit Arrowheads Редактиране на върхове на стрелки
|
||||
Edit Arrowheads… Редактиране на върхове на стрелки…
|
||||
Reload Arrowheads Презареждане на върхове на стрелки
|
||||
Reset Rotate View Нулиране на изгледа на завъртане
|
||||
Rotate View to Selection Завъртане на изгледа спрямо селекцията
|
||||
Reset the rows to the artwork's colors Нулиране на редовете към цветовете на илюстрацията
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3819,6 +3819,10 @@ theme Appearance Izgled
|
||||
Add to Profiles Dodaj u profile
|
||||
Delete Profile Izbriši profil
|
||||
Reset Profiles Vrati profile na početno
|
||||
Arrowheads Vrhovi strelica
|
||||
Edit Arrowheads Uredi vrhove strelica
|
||||
Edit Arrowheads… Uredi vrhove strelica…
|
||||
Reload Arrowheads Ponovo učitaj vrhove strelica
|
||||
Stroke Options Opcije poteza
|
||||
Width Profiles Profili širine
|
||||
Apply Graphic Style Primijeni grafički stil
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3507,6 +3507,10 @@ digits Malayalam Malaiàlam
|
||||
No settings found No s'ha trobat cap paràmetre
|
||||
Reset Printing and Proofing Restableix impressió i prova
|
||||
Reset Profiles Restableix els perfils
|
||||
Arrowheads Puntes de fletxa
|
||||
Edit Arrowheads Edita les puntes de fletxa
|
||||
Edit Arrowheads… Edita les puntes de fletxa…
|
||||
Reload Arrowheads Torna a carregar les puntes de fletxa
|
||||
Reset Rotate View Restableix la rotació de la vista
|
||||
Reset Ruler Origin Restableix l’origen de les regles
|
||||
Reset the rows to the artwork's colors Restableix les files als colors de l’obra
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3870,6 +3870,10 @@ theme Appearance Motiv
|
||||
Add to Profiles Přidat do profilů
|
||||
Delete Profile Odstranit profil
|
||||
Reset Profiles Obnovit profily
|
||||
Arrowheads Šipky
|
||||
Edit Arrowheads Upravit šipky
|
||||
Edit Arrowheads… Upravit šipky…
|
||||
Reload Arrowheads Znovu načíst šipky
|
||||
Stroke Options Možnosti tahu
|
||||
Width Profiles Profily šířky
|
||||
Apply Graphic Style Použít grafický styl
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3594,6 +3594,10 @@ theme Appearance Udseende
|
||||
Add to Profiles Føj til profiler
|
||||
Delete Profile Slet profil
|
||||
Reset Profiles Nulstil profiler
|
||||
Arrowheads Pilespidser
|
||||
Edit Arrowheads Redigér pilespidser
|
||||
Edit Arrowheads… Redigér pilespidser…
|
||||
Reload Arrowheads Genindlæs pilespidser
|
||||
Stroke Options Konturindstillinger
|
||||
Width Profiles Breddeprofiler
|
||||
Apply Graphic Style Anvend grafikstil
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2791,6 +2791,10 @@ digits Malayalam Malayalam
|
||||
Search Preferences Voreinstellungen durchsuchen
|
||||
No settings found Keine Einstellungen gefunden
|
||||
Reset Profiles Profile zurücksetzen
|
||||
Arrowheads Pfeilspitzen
|
||||
Edit Arrowheads Pfeilspitzen bearbeiten
|
||||
Edit Arrowheads… Pfeilspitzen bearbeiten…
|
||||
Reload Arrowheads Pfeilspitzen neu laden
|
||||
Rotate View Ansicht drehen
|
||||
Reset Rotate View Ansichtsdrehung zurücksetzen
|
||||
Rotate View to Selection Ansicht nach Auswahl drehen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3423,6 +3423,10 @@ digits Malayalam Μαλαγιάλαμ
|
||||
Reset OpenType Features Επαναφορά χαρακτηριστικών OpenType
|
||||
Reset Panel Επαναφορά πίνακα
|
||||
Reset Profiles Επαναφορά προφίλ
|
||||
Arrowheads Αιχμές βελών
|
||||
Edit Arrowheads Επεξεργασία αιχμών βελών
|
||||
Edit Arrowheads… Επεξεργασία αιχμών βελών…
|
||||
Reload Arrowheads Επαναφόρτωση αιχμών βελών
|
||||
Reset Rotate View Επαναφορά περιστροφής προβολής
|
||||
Rotate View to Selection Περιστροφή προβολής ως προς την επιλογή
|
||||
Reset the rows to the artwork's colors Επαναφορά γραμμών στα χρώματα του σχεδίου
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2833,6 +2833,10 @@ digits Malayalam Malayálam
|
||||
Search Preferences Buscar en preferencias
|
||||
No settings found No se encontraron ajustes
|
||||
Reset Profiles Restablecer perfiles
|
||||
Arrowheads Puntas de flecha
|
||||
Edit Arrowheads Editar puntas de flecha
|
||||
Edit Arrowheads… Editar puntas de flecha…
|
||||
Reload Arrowheads Volver a cargar puntas de flecha
|
||||
Reset Rotate View Restablecer rotación de vista
|
||||
Rotate View to Selection Rotar vista según la selección
|
||||
Reset the rows to the artwork's colors Restablecer las filas a los colores de la ilustración
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3794,6 +3794,10 @@ theme Appearance Ulkoasu
|
||||
Add to Profiles Lisää profiileihin
|
||||
Delete Profile Poista profiili
|
||||
Reset Profiles Palauta profiilit
|
||||
Arrowheads Nuolenkärjet
|
||||
Edit Arrowheads Muokkaa nuolenkärkiä
|
||||
Edit Arrowheads… Muokkaa nuolenkärkiä…
|
||||
Reload Arrowheads Lataa nuolenkärjet uudelleen
|
||||
Stroke Options Viivan asetukset
|
||||
Width Profiles Leveysprofiilit
|
||||
Apply Graphic Style Käytä grafiikkatyyliä
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2825,6 +2825,10 @@ digits Malayalam Malayalam
|
||||
Search Preferences Rechercher dans les préférences
|
||||
No settings found Aucun réglage trouvé
|
||||
Reset Profiles Réinitialiser les profils
|
||||
Arrowheads Pointes de flèche
|
||||
Edit Arrowheads Modifier les pointes de flèche
|
||||
Edit Arrowheads… Modifier les pointes de flèche…
|
||||
Reload Arrowheads Recharger les pointes de flèche
|
||||
Reset Rotate View Réinitialiser la rotation de l’affichage
|
||||
Rotate View to Selection Faire pivoter l’affichage selon la sélection
|
||||
Reset the rows to the artwork's colors Réinitialiser les lignes avec les couleurs de l’illustration
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3811,6 +3811,10 @@ antiAlias Sharp शार्प
|
||||
No settings found कोई सेटिंग नहीं मिली
|
||||
Reset Printing and Proofing मुद्रण और प्रूफिंग रीसेट करें
|
||||
Reset Profiles प्रोफ़ाइल रीसेट करें
|
||||
Arrowheads एरोहेड्स
|
||||
Edit Arrowheads एरोहेड्स संपादित करें
|
||||
Edit Arrowheads… एरोहेड्स संपादित करें…
|
||||
Reload Arrowheads एरोहेड्स फिर से लोड करें
|
||||
Reset Rotate View व्यू घुमाएँ रीसेट करें
|
||||
Reset Ruler Origin शासकीय उत्पत्ति रीसेट करें
|
||||
Reset Symbol Instance सिंबल इंस्टेंस रीसेट करें
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3377,6 +3377,10 @@ mark-style Japanese Japán
|
||||
No settings found Nincs ilyen beállítás
|
||||
Reset Printing and Proofing Printing and Proofing visszaállítása
|
||||
Reset Profiles Profilok visszaállítása
|
||||
Arrowheads Nyílhegyek
|
||||
Edit Arrowheads Nyílhegyek szerkesztése
|
||||
Edit Arrowheads… Nyílhegyek szerkesztése…
|
||||
Reload Arrowheads Nyílhegyek újratöltése
|
||||
Reset Rotate View Nézetforgatás visszaállítása
|
||||
Rotate View to Selection Nézet elforgatása a kijelöléshez
|
||||
Reset the rows to the artwork's colors Sorok visszaállítása a grafika színeire
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3594,6 +3594,10 @@ theme Appearance Tampilan
|
||||
Add to Profiles Tambahkan ke profil
|
||||
Delete Profile Hapus profil
|
||||
Reset Profiles Atur ulang profil
|
||||
Arrowheads Mata panah
|
||||
Edit Arrowheads Edit mata panah
|
||||
Edit Arrowheads… Edit mata panah…
|
||||
Reload Arrowheads Muat ulang mata panah
|
||||
Stroke Options Opsi goresan
|
||||
Width Profiles Profil lebar
|
||||
Apply Graphic Style Terapkan gaya grafis
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2328 and column 5.
|
@@ -2867,6 +2867,10 @@ digits Malayalam Malayalam
|
||||
Search Preferences Cerca nelle preferenze
|
||||
No settings found Nessuna impostazione trovata
|
||||
Reset Profiles Reimposta profili
|
||||
Arrowheads Punte di freccia
|
||||
Edit Arrowheads Modifica punte di freccia
|
||||
Edit Arrowheads… Modifica punte di freccia…
|
||||
Reload Arrowheads Ricarica punte di freccia
|
||||
Rotate View Ruota vista
|
||||
Reset Rotate View Reimposta rotazione vista
|
||||
Rotate View to Selection Ruota vista in base alla selezione
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2864,6 +2864,10 @@ mark-style Japanese 日本式
|
||||
Search Preferences 環境設定を検索
|
||||
No settings found 設定が見つかりません
|
||||
Reset Profiles プロファイルをリセット
|
||||
Arrowheads 矢印
|
||||
Edit Arrowheads 矢印を編集
|
||||
Edit Arrowheads… 矢印を編集…
|
||||
Reload Arrowheads 矢印を再読み込み
|
||||
Reset the rows to the artwork's colors 行をアートワークのカラーにリセット
|
||||
Reset to Default 初期設定に戻す
|
||||
Reset to White, Black 白、黒にリセット
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3433,6 +3433,10 @@ theme Appearance იერსახე
|
||||
Add to Profiles პროფილებში დამატება
|
||||
Delete Profile პროფილის წაშლა
|
||||
Reset Profiles პროფილების ჩამოყრა
|
||||
Arrowheads ისრის წვერები
|
||||
Edit Arrowheads ისრის წვერების რედაქტირება
|
||||
Edit Arrowheads… ისრის წვერების რედაქტირება…
|
||||
Reload Arrowheads ისრის წვერების ხელახლა ჩატვირთვა
|
||||
Stroke Options კონტურის პარამეტრები
|
||||
Width Profiles სიგანის პროფილები
|
||||
Apply Graphic Style გრაფიკული სტილის გამოყენება
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2853,6 +2853,10 @@ mark-style Japanese 일본식
|
||||
Search Preferences 환경 설정 검색
|
||||
No settings found 설정을 찾을 수 없음
|
||||
Reset Profiles 프로필 재설정
|
||||
Arrowheads 화살촉
|
||||
Edit Arrowheads 화살촉 편집
|
||||
Edit Arrowheads… 화살촉 편집…
|
||||
Reload Arrowheads 화살촉 다시 불러오기
|
||||
Reset the rows to the artwork's colors 행을 아트웍 색상으로 재설정
|
||||
Reset to Default 기본값으로 재설정
|
||||
Reset to White, Black 흰색, 검정으로 재설정
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3608,6 +3608,10 @@ theme Appearance Vormgeving
|
||||
Add to Profiles Aan profielen toevoegen
|
||||
Delete Profile Profiel verwijderen
|
||||
Reset Profiles Profielen opnieuw instellen
|
||||
Arrowheads Pijlpunten
|
||||
Edit Arrowheads Pijlpunten bewerken
|
||||
Edit Arrowheads… Pijlpunten bewerken…
|
||||
Reload Arrowheads Pijlpunten opnieuw laden
|
||||
Stroke Options Lijnopties
|
||||
Width Profiles Breedteprofielen
|
||||
Apply Graphic Style Grafische stijl toepassen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3733,6 +3733,10 @@ theme Appearance Wygląd
|
||||
Add to Profiles Dodaj do profili
|
||||
Delete Profile Usuń profil
|
||||
Reset Profiles Resetuj profile
|
||||
Arrowheads Groty strzałek
|
||||
Edit Arrowheads Edytuj groty strzałek
|
||||
Edit Arrowheads… Edytuj groty strzałek…
|
||||
Reload Arrowheads Wczytaj ponownie groty strzałek
|
||||
Stroke Options Opcje obrysu
|
||||
Width Profiles Profile szerokości
|
||||
Apply Graphic Style Zastosuj styl graficzny
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2370,6 +2370,10 @@ digits Malayalam Malaiala
|
||||
Search Preferences Pesquisar nas Preferências
|
||||
No settings found Nenhuma configuração encontrada
|
||||
Reset Profiles Redefinir Perfis
|
||||
Arrowheads Pontas de Seta
|
||||
Edit Arrowheads Editar Pontas de Seta
|
||||
Edit Arrowheads… Editar Pontas de Seta…
|
||||
Reload Arrowheads Recarregar Pontas de Seta
|
||||
Rotate View Girar Visualização
|
||||
Reset Rotate View Redefinir Visualização Girada
|
||||
Rotate View to Selection Girar Visualização para a Seleção
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2862,6 +2862,10 @@ digits Malayalam Малаялам
|
||||
Search Preferences Поиск в настройках
|
||||
No settings found Настройки не найдены
|
||||
Reset Profiles Сбросить профили
|
||||
Arrowheads Стрелки
|
||||
Edit Arrowheads Редактировать стрелки
|
||||
Edit Arrowheads… Редактировать стрелки…
|
||||
Reload Arrowheads Перезагрузить стрелки
|
||||
Rotate View Повернуть вид
|
||||
Reset Rotate View Сбросить поворот вида
|
||||
Rotate View to Selection Повернуть вид по выделению
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2769,6 +2769,10 @@ digits Malayalam Malayalam
|
||||
Search Preferences Sök i inställningar
|
||||
No settings found Inga inställningar hittades
|
||||
Reset Profiles Återställ profiler
|
||||
Arrowheads Pilspetsar
|
||||
Edit Arrowheads Redigera pilspetsar
|
||||
Edit Arrowheads… Redigera pilspetsar…
|
||||
Reload Arrowheads Läs in pilspetsar igen
|
||||
Reset Rotate View Återställ Rotera vy
|
||||
Rotate View to Selection Rotera vyn efter markeringen
|
||||
Reset the rows to the artwork's colors Återställ raderna till teckningens färger
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -2638,6 +2638,10 @@ digits Malayalam Malayalam
|
||||
Search Preferences Tercihlerde Ara
|
||||
No settings found Ayar bulunamadı
|
||||
Reset Profiles Profilleri Sıfırla
|
||||
Arrowheads Ok Uçları
|
||||
Edit Arrowheads Ok Uçlarını Düzenle
|
||||
Edit Arrowheads… Ok Uçlarını Düzenle…
|
||||
Reload Arrowheads Ok Uçlarını Yeniden Yükle
|
||||
Reset Rotate View Döndürme Görünümünü Sıfırla
|
||||
Rotate View to Selection Görünümü Seçime Döndür
|
||||
Reset the rows to the artwork's colors Satırları resmin renklerine göre sıfırlayın
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -2859,6 +2859,10 @@ digits Malayalam Малаялам
|
||||
Search Preferences Пошук у налаштуваннях
|
||||
No settings found Налаштування не знайдено
|
||||
Reset Profiles Скинути профілі
|
||||
Arrowheads Стрілки
|
||||
Edit Arrowheads Редагувати стрілки
|
||||
Edit Arrowheads… Редагувати стрілки…
|
||||
Reload Arrowheads Перезавантажити стрілки
|
||||
Rotate View Повернути вид
|
||||
Reset Rotate View Скинути поворот виду
|
||||
Rotate View to Selection Повернути вид за виділенням
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 182 and column 5.
|
@@ -3140,6 +3140,10 @@ mark-style Japanese Kiểu Nhật
|
||||
Search Preferences Tìm trong tùy chọn
|
||||
No settings found Không tìm thấy cài đặt
|
||||
Reset Profiles Đặt lại hồ sơ màu
|
||||
Arrowheads Đầu mũi tên
|
||||
Edit Arrowheads Chỉnh sửa đầu mũi tên
|
||||
Edit Arrowheads… Chỉnh sửa đầu mũi tên…
|
||||
Reload Arrowheads Tải lại đầu mũi tên
|
||||
Rotate View Xoay chế độ xem
|
||||
Reset Rotate View Đặt lại xoay chế độ xem
|
||||
Rotate View to Selection Xoay chế độ xem theo vùng chọn
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 204 and column 5.
|
@@ -2733,6 +2733,10 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Search Preferences 搜索首选项
|
||||
No settings found 未找到设置
|
||||
Reset Profiles 重置配置文件
|
||||
Arrowheads 箭头
|
||||
Edit Arrowheads 编辑箭头
|
||||
Edit Arrowheads… 编辑箭头…
|
||||
Reload Arrowheads 重新载入箭头
|
||||
Reset Rotate View 重置旋转视图
|
||||
Rotate View to Selection 按所选对象旋转视图
|
||||
Reset the rows to the artwork's colors 将各行重置为图稿的颜色
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3811,6 +3811,10 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Search Preferences 搜尋偏好設定
|
||||
No settings found 找不到設定
|
||||
Reset Profiles 重設描述檔
|
||||
Arrowheads 箭頭
|
||||
Edit Arrowheads 編輯箭頭
|
||||
Edit Arrowheads… 編輯箭頭…
|
||||
Reload Arrowheads 重新載入箭頭
|
||||
Rotate View 旋轉檢視
|
||||
Reset Rotate View 重設旋轉檢視
|
||||
Rotate View to Selection 依選取範圍旋轉檢視
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -100,10 +100,37 @@ pub(crate) fn edited_dash_pattern(fields: &[Option<f64>; 6], previous: &[f64]) -
|
||||
out
|
||||
}
|
||||
|
||||
fn arrow_label(a: Option<Arrowhead>) -> &'static str {
|
||||
fn arrow_label(a: Option<&Arrowhead>) -> &'static str {
|
||||
a.map_or("None", Arrowhead::label)
|
||||
}
|
||||
|
||||
/// The name an arrowhead menu shows for `a`: a built-in head's in the interface language, a
|
||||
/// custom head's own.
|
||||
fn arrow_name(a: Option<&Arrowhead>) -> String {
|
||||
match a {
|
||||
Some(Arrowhead::Custom(c)) => c.name.clone(),
|
||||
_ => tl!(arrow_label(a)).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The preview cache key of `a`: its name, and for a custom head its art.
|
||||
fn arrow_key(a: Option<&Arrowhead>) -> String {
|
||||
match a {
|
||||
Some(Arrowhead::Custom(c)) => {
|
||||
use std::hash::{Hash, Hasher};
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
for s in &c.path.subpaths {
|
||||
(s.anchors.len(), s.closed).hash(&mut h);
|
||||
for p in s.anchors.iter().flat_map(|a| [a.p, a.h_in, a.h_out]) {
|
||||
(p.x.to_bits(), p.y.to_bits()).hash(&mut h);
|
||||
}
|
||||
}
|
||||
format!("custom:{}:{:x}", c.name, h.finish())
|
||||
}
|
||||
_ => format!("{a:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply Stroke panel options (`stroke.set` params): while the Type tool edits text, to the
|
||||
/// selected characters' stroke.
|
||||
fn set(app: &mut VectorcraftApp, p: Value) {
|
||||
@@ -272,14 +299,17 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
widgets::divider(ui);
|
||||
// Arrowheads.
|
||||
let (sa, ea) = (st.as_ref().and_then(|s| s.start_arrow), st.as_ref().and_then(|s| s.end_arrow));
|
||||
let (sa, ea) = (st.as_ref().and_then(|s| s.start_arrow.clone()), st.as_ref().and_then(|s| s.end_arrow.clone()));
|
||||
// The custom heads of the arrowheads file follow the built-in ones.
|
||||
let custom: Vec<Arrowhead> = app.session.arrowheads.heads().iter().cloned().map(Arrowhead::Custom).collect();
|
||||
ui.horizontal(|ui| {
|
||||
row_label(ui, tl!("Arrowheads:"));
|
||||
if let Some(a) = arrow_dropdown(ui, "arrow-start", sa, true) {
|
||||
set(app, json!({"startArrow": a.map(|a| format!("{a:?}"))}));
|
||||
// A custom head goes with its art, as document.inspect reports it.
|
||||
if let Some(a) = arrow_dropdown(ui, "arrow-start", sa.as_ref(), &custom, true) {
|
||||
set(app, json!({ "startArrow": a }));
|
||||
}
|
||||
if let Some(a) = arrow_dropdown(ui, "arrow-end", ea, false) {
|
||||
set(app, json!({"endArrow": a.map(|a| format!("{a:?}"))}));
|
||||
if let Some(a) = arrow_dropdown(ui, "arrow-end", ea.as_ref(), &custom, false) {
|
||||
set(app, json!({ "endArrow": a }));
|
||||
}
|
||||
if widgets::icon_button_enabled(ui, "arrow-left-right", tl!("Swap start and end arrowheads"), false, st.is_some(), 22.0).clicked() {
|
||||
app.run("stroke.setAdvanced", json!({"swapArrows": true})).ok();
|
||||
@@ -360,14 +390,15 @@ pub(super) fn arrow_doc(a: Option<Arrowhead>, start: bool, w: f64, h: f64) -> Op
|
||||
|
||||
/// Draw an arrowhead preview (the head as the canvas draws it) in `r`: a line with the head at the
|
||||
/// left (`start`) or right end.
|
||||
fn paint_arrow(ui: &Ui, r: Rect, a: Option<Arrowhead>, start: bool, color: Color32) {
|
||||
if let Some(tex) = widgets::doc_preview(ui, &format!("arrow:{a:?}:{start}"), r.size(), |w, h| arrow_doc(a, start, w, h)) {
|
||||
fn paint_arrow(ui: &Ui, r: Rect, a: Option<&Arrowhead>, start: bool, color: Color32) {
|
||||
if let Some(tex) = widgets::doc_preview(ui, &format!("arrow:{}:{start}", arrow_key(a)), r.size(), |w, h| arrow_doc(a.cloned(), start, w, h)) {
|
||||
ui.painter().image(tex.id(), r, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), color);
|
||||
}
|
||||
}
|
||||
|
||||
/// Dropdown whose button and items show drawn arrowhead previews. Returns Some(choice).
|
||||
fn arrow_dropdown(ui: &mut Ui, id: &str, cur: Option<Arrowhead>, start: bool) -> Option<Option<Arrowhead>> {
|
||||
/// Dropdown whose button and items show drawn arrowhead previews: None, the built-in heads, then
|
||||
/// the `custom` ones. Returns Some(choice).
|
||||
fn arrow_dropdown(ui: &mut Ui, id: &str, cur: Option<&Arrowhead>, custom: &[Arrowhead], start: bool) -> Option<Option<Arrowhead>> {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (r, resp) = ui.allocate_exact_size(vec2(64.0, 24.0), Sense::click());
|
||||
ui.painter().rect_filled(r, 2, t.input);
|
||||
@@ -380,7 +411,8 @@ fn arrow_dropdown(ui: &mut Ui, id: &str, cur: Option<Arrowhead>, start: bool) ->
|
||||
egui::Popup::menu(&resp).id(egui::Id::unique(("arrow-pop", id))).show(|ui| {
|
||||
ui.set_min_width(170.0);
|
||||
egui::ScrollArea::vertical().max_height(360.0).show(ui, |ui| {
|
||||
for a in std::iter::once(None).chain(Arrowhead::ALL.map(Some)) {
|
||||
let built_in = Arrowhead::ALL;
|
||||
for a in std::iter::once(None).chain(built_in.iter().map(Some)).chain(custom.iter().map(Some)) {
|
||||
let (row, rr) = ui.allocate_exact_size(vec2(170.0, 22.0), Sense::click());
|
||||
if a == cur {
|
||||
ui.painter().rect_filled(row, 0.0, t.row_selected);
|
||||
@@ -391,12 +423,12 @@ fn arrow_dropdown(ui: &mut Ui, id: &str, cur: Option<Arrowhead>, start: bool) ->
|
||||
ui.painter().text(
|
||||
row.left_center() + vec2(66.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
tl!(arrow_label(a)),
|
||||
arrow_name(a),
|
||||
egui::FontId::proportional(11.5),
|
||||
t.text,
|
||||
);
|
||||
if rr.clicked() {
|
||||
out = Some(a);
|
||||
out = Some(a.cloned());
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
@@ -500,6 +532,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if menu_item(ui, tl!("Reset Profiles"), crate::menus::enabled(app, "stroke.widthProfile.reset"), false) {
|
||||
app.run("stroke.widthProfile.reset", json!({})).ok();
|
||||
}
|
||||
ui.separator();
|
||||
// Opens the arrowheads file, whose symbols are the custom heads; saving it reloads them.
|
||||
if menu_item(ui, tl!("Edit Arrowheads…"), crate::menus::enabled(app, "stroke.arrowheads.edit"), false) {
|
||||
app.run("stroke.arrowheads.edit", json!({})).ok();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -647,7 +684,7 @@ mod tests {
|
||||
assert!(silhouette(WidthProfile::PRESETS[0].points).is_none(), "uniform draws the plain bar");
|
||||
let lens = WidthProfile::lens();
|
||||
assert_eq!(silhouette(&lens.points), Some(lens.points.as_slice()));
|
||||
assert_eq!(arrow_label(Some(Arrowhead::CircleOpen)), "Circle (open)");
|
||||
assert_eq!(arrow_label(Some(&Arrowhead::CircleOpen)), "Circle (open)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -100,9 +100,15 @@ fn every_arrowhead_preview_draws_its_head() {
|
||||
};
|
||||
let plain = (ink(None, false), ink(None, true));
|
||||
for a in Arrowhead::ALL {
|
||||
assert!(ink(Some(a), false) > plain.0 + 20, "{a:?} at the end");
|
||||
assert!(ink(Some(a), true) > plain.1 + 20, "{a:?} at the start");
|
||||
assert!(ink(Some(a.clone()), false) > plain.0 + 20, "{a:?} at the end");
|
||||
assert!(ink(Some(a.clone()), true) > plain.1 + 20, "{a:?} at the start");
|
||||
}
|
||||
// So does a custom head: a 4 × 4 square behind its tip.
|
||||
let pts = [(0.0, -2.0), (4.0, -2.0), (4.0, 2.0), (0.0, 2.0)].map(|(x, y)| vectorcraft_geom::Point::new(x, y));
|
||||
let square = vectorcraft_geom::PathData::single(vectorcraft_geom::SubPath::polyline(&pts, true));
|
||||
let custom = Arrowhead::Custom(std::sync::Arc::new(vectorcraft_doc::CustomArrowhead::new("Square".into(), square)));
|
||||
assert!(ink(Some(custom.clone()), false) > plain.0 + 20);
|
||||
assert!(ink(Some(custom), true) > plain.1 + 20);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user