mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 08:11:41 +00:00
3D: Bevel Shape labels an effect's own custom bevel apart from a file bevel of the same name
When the bevels file lists a bevel with the name of the effect's own custom bevel but other points, the effect's entry is now shown as "<name> (document)", and the menu marks the current entry by its position instead of its label, so two entries are no longer both shown as selected.
This commit is contained in:
@@ -244,7 +244,7 @@ pub(crate) type BevelChoice = (String, Value, Option<(String, Value)>);
|
||||
/// The entries of [`bevel_choice`]'s menu for form `fields`, and how many are built in. The
|
||||
/// built-in labels are translated; custom bevels show their names as they are. The effect's own
|
||||
/// custom bevel, the panel's [`OWN_BEVEL`] else the form's, is listed unless the file lists it by
|
||||
/// name with the same points.
|
||||
/// name with the same points; while another entry has its label, " (document)" is added to it.
|
||||
pub(crate) fn bevel_options(app: &VectorcraftApp, fields: &serde_json::Map<String, Value>, effect: &str) -> (Vec<BevelChoice>, usize) {
|
||||
let mut options: Vec<BevelChoice> = super::effect::own_choices(effect, "bevel", false)
|
||||
.unwrap_or_default()
|
||||
@@ -266,7 +266,11 @@ pub(crate) fn bevel_options(app: &VectorcraftApp, fields: &serde_json::Map<Strin
|
||||
if let Some((n, p)) = own
|
||||
&& !options[builtin..].iter().any(|(_, _, c)| c.as_ref().is_some_and(|(cn, cp)| *cn == n && *cp == p))
|
||||
{
|
||||
let shown = if n.is_empty() { tl!("Custom").to_string() } else { n.clone() };
|
||||
let mut shown = if n.is_empty() { tl!("Custom").to_string() } else { n.clone() };
|
||||
// Each pass makes the label longer, so this ends once no entry has it.
|
||||
while options.iter().any(|(l, _, _)| *l == shown) {
|
||||
shown = crate::i18n::fmt(tl!("{name} (document)"), &[("name", &shown)]);
|
||||
}
|
||||
options.push((shown, json!("custom"), Some((n, p))));
|
||||
}
|
||||
(options, builtin)
|
||||
@@ -302,7 +306,17 @@ pub(super) fn bevel_choice(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dial
|
||||
let labels: Vec<&str> = options.iter().map(|(l, _, _)| l.as_str()).collect();
|
||||
let shown = current.and_then(|i| labels.get(i)).copied().unwrap_or("");
|
||||
let width = VALUE_W + rail_width(ui) + 6.0;
|
||||
if let Some(k) = widgets::dropdown_names(ui, ("three-d-choice", KEY), shown, &labels, width)
|
||||
// Marked by index, not label: a custom bevel's name can match another entry's label.
|
||||
let picked = widgets::combo(ui, ("three-d-choice", KEY), shown, width, |ui| {
|
||||
let mut chosen = None;
|
||||
for (i, l) in labels.iter().enumerate() {
|
||||
if ui.add(egui::Button::selectable(current == Some(i), *l)).clicked() {
|
||||
chosen = Some(i);
|
||||
}
|
||||
}
|
||||
chosen
|
||||
});
|
||||
if let Some(k) = picked
|
||||
&& let Some((_, v, c)) = options.get(k)
|
||||
{
|
||||
d.fields.insert(KEY.into(), v.clone());
|
||||
|
||||
@@ -2863,6 +2863,7 @@ digits Malayalam Малаялам
|
||||
Bevels Фаски
|
||||
Edit Bevels Редактиране на фаски
|
||||
Edit Bevels… Редактиране на фаски…
|
||||
{name} (document) {name} (документ)
|
||||
Reload Bevels Презареждане на фаски
|
||||
Reset Rotate View Нулиране на изгледа на завъртане
|
||||
Rotate View to Selection Завъртане на изгледа спрямо селекцията
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3969,6 +3969,7 @@ theme Appearance Izgled
|
||||
Bevels Zakošenja
|
||||
Edit Bevels Uredi zakošenja
|
||||
Edit Bevels… Uredi zakošenja…
|
||||
{name} (document) {name} (dokument)
|
||||
Reload Bevels Ponovo učitaj zakošenja
|
||||
Stroke Options Opcije poteza
|
||||
Width Profiles Profili širine
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3653,6 +3653,7 @@ digits Malayalam Malaiàlam
|
||||
Bevels Bisells
|
||||
Edit Bevels Edita els bisells
|
||||
Edit Bevels… Edita els bisells…
|
||||
{name} (document) {name} (document)
|
||||
Reload Bevels Torna a carregar els bisells
|
||||
Reset Rotate View Restableix la rotació de la vista
|
||||
Reset Ruler Origin Restableix l’origen de les regles
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4025,6 +4025,7 @@ theme Appearance Motiv
|
||||
Bevels Zkosení
|
||||
Edit Bevels Upravit zkosení
|
||||
Edit Bevels… Upravit zkosení…
|
||||
{name} (document) {name} (dokument)
|
||||
Reload Bevels Znovu načíst zkosení
|
||||
Stroke Options Možnosti tahu
|
||||
Width Profiles Profily šířky
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3742,6 +3742,7 @@ theme Appearance Udseende
|
||||
Bevels Facetter
|
||||
Edit Bevels Redigér facetter
|
||||
Edit Bevels… Redigér facetter…
|
||||
{name} (document) {name} (dokument)
|
||||
Reload Bevels Genindlæs facetter
|
||||
Stroke Options Konturindstillinger
|
||||
Width Profiles Breddeprofiler
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2908,6 +2908,7 @@ digits Malayalam Malayalam
|
||||
Bevels Abgeflachte Kanten
|
||||
Edit Bevels Abgeflachte Kanten bearbeiten
|
||||
Edit Bevels… Abgeflachte Kanten bearbeiten…
|
||||
{name} (document) {name} (Dokument)
|
||||
Reload Bevels Abgeflachte Kanten neu laden
|
||||
Rotate View Ansicht drehen
|
||||
Reset Rotate View Ansichtsdrehung zurücksetzen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3645,6 +3645,7 @@ digits Malayalam Μαλαγιάλαμ
|
||||
Bevels Λοξοτμήσεις
|
||||
Edit Bevels Επεξεργασία λοξοτμήσεων
|
||||
Edit Bevels… Επεξεργασία λοξοτμήσεων…
|
||||
{name} (document) {name} (έγγραφο)
|
||||
Reload Bevels Επαναφόρτωση λοξοτμήσεων
|
||||
Reset Rotate View Επαναφορά περιστροφής προβολής
|
||||
Rotate View to Selection Περιστροφή προβολής ως προς την επιλογή
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2942,6 +2942,7 @@ digits Malayalam Malayálam
|
||||
Bevels Biseles
|
||||
Edit Bevels Editar biseles
|
||||
Edit Bevels… Editar biseles…
|
||||
{name} (document) {name} (documento)
|
||||
Reload Bevels Volver a cargar biseles
|
||||
Reset Rotate View Restablecer rotación de vista
|
||||
Rotate View to Selection Rotar vista según la selección
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3949,6 +3949,7 @@ theme Appearance Ulkoasu
|
||||
Bevels Viisteet
|
||||
Edit Bevels Muokkaa viisteitä
|
||||
Edit Bevels… Muokkaa viisteitä…
|
||||
{name} (document) {name} (asiakirja)
|
||||
Reload Bevels Lataa viisteet uudelleen
|
||||
Stroke Options Viivan asetukset
|
||||
Width Profiles Leveysprofiilit
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2934,6 +2934,7 @@ digits Malayalam Malayalam
|
||||
Bevels Biseaux
|
||||
Edit Bevels Modifier les biseaux
|
||||
Edit Bevels… Modifier les biseaux…
|
||||
{name} (document) {name} (document)
|
||||
Reload Bevels Recharger les biseaux
|
||||
Reset Rotate View Réinitialiser la rotation de l’affichage
|
||||
Rotate View to Selection Faire pivoter l’affichage selon la sélection
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4016,6 +4016,7 @@ antiAlias Sharp शार्प
|
||||
Bevels बेवल्स
|
||||
Edit Bevels बेवल्स संपादित करें
|
||||
Edit Bevels… बेवल्स संपादित करें…
|
||||
{name} (document) {name} (दस्तावेज़)
|
||||
Reload Bevels बेवल्स फिर से लोड करें
|
||||
Reset Rotate View व्यू घुमाएँ रीसेट करें
|
||||
Reset Ruler Origin शासकीय उत्पत्ति रीसेट करें
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3500,6 +3500,7 @@ mark-style Japanese Japán
|
||||
Bevels Élletörések
|
||||
Edit Bevels Élletörések szerkesztése
|
||||
Edit Bevels… Élletörések szerkesztése…
|
||||
{name} (document) {name} (dokumentum)
|
||||
Reload Bevels Élletörések ú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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3742,6 +3742,7 @@ theme Appearance Tampilan
|
||||
Bevels Bentuk bevel
|
||||
Edit Bevels Edit bentuk bevel
|
||||
Edit Bevels… Edit bentuk bevel…
|
||||
{name} (document) {name} (dokumen)
|
||||
Reload Bevels Muat ulang bentuk bevel
|
||||
Stroke Options Opsi goresan
|
||||
Width Profiles Profil lebar
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2429 and column 5.
|
@@ -2984,6 +2984,7 @@ digits Malayalam Malayalam
|
||||
Bevels Smussi
|
||||
Edit Bevels Modifica smussi
|
||||
Edit Bevels… Modifica smussi…
|
||||
{name} (document) {name} (documento)
|
||||
Reload Bevels Ricarica smussi
|
||||
Rotate View Ruota vista
|
||||
Reset Rotate View Reimposta rotazione vista
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2992,6 +2992,7 @@ mark-style Japanese 日本式
|
||||
Bevels ベベル一覧
|
||||
Edit Bevels ベベルを編集
|
||||
Edit Bevels… ベベルを編集…
|
||||
{name} (document) {name} (ドキュメント)
|
||||
Reload Bevels ベベルを再読み込み
|
||||
Reset the rows to the artwork's colors 行をアートワークのカラーにリセット
|
||||
Color Theme Picker カラーテーマピッカー
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3585,6 +3585,7 @@ theme Appearance იერსახე
|
||||
Bevels წაკვეთები
|
||||
Edit Bevels წაკვეთების რედაქტირება
|
||||
Edit Bevels… წაკვეთების რედაქტირება…
|
||||
{name} (document) {name} (დოკუმენტი)
|
||||
Reload Bevels წაკვეთების ხელახლა ჩატვირთვა
|
||||
Stroke Options კონტურის პარამეტრები
|
||||
Width Profiles სიგანის პროფილები
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2981,6 +2981,7 @@ mark-style Japanese 일본식
|
||||
Bevels 베벨 목록
|
||||
Edit Bevels 베벨 편집
|
||||
Edit Bevels… 베벨 편집…
|
||||
{name} (document) {name}(문서)
|
||||
Reload Bevels 베벨 다시 불러오기
|
||||
Reset the rows to the artwork's colors 행을 아트웍 색상으로 재설정
|
||||
Color Theme Picker 색상 테마 피커
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4259,6 +4259,7 @@ theme Appearance Vormgeving
|
||||
Bevels Afschuiningen
|
||||
Edit Bevels Afschuiningen bewerken
|
||||
Edit Bevels… Afschuiningen bewerken…
|
||||
{name} (document) {name} (document)
|
||||
Reload Bevels Afschuiningen opnieuw laden
|
||||
Stroke Options Lijnopties
|
||||
Width Profiles Breedteprofielen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3888,6 +3888,7 @@ theme Appearance Wygląd
|
||||
Bevels Fazy
|
||||
Edit Bevels Edytuj fazy
|
||||
Edit Bevels… Edytuj fazy…
|
||||
{name} (document) {name} (dokument)
|
||||
Reload Bevels Wczytaj ponownie fazy
|
||||
Stroke Options Opcje obrysu
|
||||
Width Profiles Profile szerokości
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2475,6 +2475,7 @@ digits Malayalam Malaiala
|
||||
Bevels Chanfros
|
||||
Edit Bevels Editar Chanfros
|
||||
Edit Bevels… Editar Chanfros…
|
||||
{name} (document) {name} (documento)
|
||||
Reload Bevels Recarregar Chanfros
|
||||
Rotate View Girar Visualização
|
||||
Reset Rotate View Redefinir Visualização Girada
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2971,6 +2971,7 @@ digits Malayalam Малаялам
|
||||
Bevels Фаски
|
||||
Edit Bevels Редактировать фаски
|
||||
Edit Bevels… Редактировать фаски…
|
||||
{name} (document) {name} (документ)
|
||||
Reload Bevels Перезагрузить фаски
|
||||
Rotate View Повернуть вид
|
||||
Reset Rotate View Сбросить поворот вида
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2878,6 +2878,7 @@ digits Malayalam Malayalam
|
||||
Bevels Fasningar
|
||||
Edit Bevels Redigera fasningar
|
||||
Edit Bevels… Redigera fasningar…
|
||||
{name} (document) {name} (dokument)
|
||||
Reload Bevels Läs in fasningar igen
|
||||
Reset Rotate View Återställ Rotera vy
|
||||
Rotate View to Selection Rotera vyn efter markeringen
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2721,6 +2721,7 @@ digits Malayalam Malayalam
|
||||
Bevels Eğimler
|
||||
Edit Bevels Eğimleri Düzenle
|
||||
Edit Bevels… Eğimleri Düzenle…
|
||||
{name} (document) {name} (belge)
|
||||
Reload Bevels Eğimleri 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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -2976,6 +2976,7 @@ digits Malayalam Малаялам
|
||||
Bevels Фаски
|
||||
Edit Bevels Редагувати фаски
|
||||
Edit Bevels… Редагувати фаски…
|
||||
{name} (document) {name} (документ)
|
||||
Reload Bevels Перезавантажити фаски
|
||||
Rotate View Повернути вид
|
||||
Reset Rotate View Скинути поворот виду
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3269,6 +3269,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Bevels Các kiểu vát
|
||||
Edit Bevels Chỉnh sửa kiểu vát
|
||||
Edit Bevels… Chỉnh sửa kiểu vát…
|
||||
{name} (document) {name} (tài liệu)
|
||||
Reload Bevels Tải lại kiểu vát
|
||||
Rotate View Xoay chế độ xem
|
||||
Reset Rotate View Đặt lại xoay chế độ xem
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 204 and column 5.
|
@@ -2838,6 +2838,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Bevels 斜角列表
|
||||
Edit Bevels 编辑斜角
|
||||
Edit Bevels… 编辑斜角…
|
||||
{name} (document) {name} (文档)
|
||||
Reload Bevels 重新载入斜角
|
||||
Reset Rotate View 重置旋转视图
|
||||
Rotate View to Selection 按所选对象旋转视图
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4055,6 +4055,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Bevels 斜角清單
|
||||
Edit Bevels 編輯斜角
|
||||
Edit Bevels… 編輯斜角…
|
||||
{name} (document) {name} (文件)
|
||||
Reload Bevels 重新載入斜角
|
||||
Rotate View 旋轉檢視
|
||||
Reset Rotate View 重設旋轉檢視
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -311,6 +311,28 @@ fn a_mixed_selection_still_lists_the_first_effects_own_custom_bevel() {
|
||||
}
|
||||
}
|
||||
|
||||
/// An effect's own custom bevel named like a bevel of the bevels file with other points is listed
|
||||
/// under its own label, so Bevel Shape does not show two entries of one name.
|
||||
#[test]
|
||||
fn an_own_custom_bevel_named_like_a_file_bevel_gets_its_own_label() {
|
||||
use crate::dialogs::revolve::bevel_options;
|
||||
let dir = std::env::temp_dir().join(format!("vectorcraft-ui-bevels-own-label-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let mut app = app();
|
||||
app.session.attach_bevels_file(dir.join(vectorcraft_engine::cmd::bevels::FILE_NAME).to_string_lossy().to_string());
|
||||
app.run("threeD.bevels.edit", json!({})).unwrap();
|
||||
let file = app.session.bevels.get("Example Bevel").unwrap().profile_json();
|
||||
let other = json!([[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]);
|
||||
assert_ne!(file, other);
|
||||
let fields = json!({"bevel": "custom", "bevelName": "Example Bevel", "bevelProfile": other}).as_object().cloned().unwrap();
|
||||
let (options, builtin) = bevel_options(&app, &fields, "threeD.extrude");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
let labels: Vec<&str> = options[builtin..].iter().map(|(l, _, _)| l.as_str()).collect();
|
||||
assert_eq!(labels, ["Example Bevel", "Example Bevel (document)"]);
|
||||
assert_eq!(options[builtin + 1].2, Some(("Example Bevel".to_string(), other)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_panel_finds_a_3d_effect_on_a_fill() {
|
||||
let mut app = app();
|
||||
|
||||
Reference in New Issue
Block a user