Merge pull request #9683 from dotCooCoo/fix/east-asian-settings-live-field-binding

Keep current values in Warichu and Tate-chu-yoko Settings
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-26 21:35:01 -08:00
commit 5ed06405e5
2 files changed
+40 -2

No files matched your search

+15 -1
View File
@@ -10,6 +10,7 @@
//! Behavior reference (public documentation):
//! <https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/format-east-asian-characters-in-vertical-text.html>.
use craft::ui::contract::Bind;
use craft::ui::patterns::form_dialogs::{DialogFields, HostedParamDialog, Param, ParamDialog};
// PLAN: assumed path of `LengthUnits`
use craft::ui::runtime::env::LengthUnits;
@@ -47,7 +48,9 @@ pub fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
let initial = fields.clone();
let ctx = app.ui_ctx.clone().ok_or("no window")?;
let lengths = crate::canvas::rulers::type_lengths(app);
let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |_| ParamDialog::new(KIND, tl!("Tate-chu-yoko Settings"), rows(lengths)));
let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |fields| {
ParamDialog::new(KIND, tl!("Tate-chu-yoko Settings"), rows(lengths)).values(Bind::bound(fields))
});
super::host::open_held(app, dialog, move |app, result| {
let p = params(&result.fields, &initial);
if p.is_empty() {
@@ -99,6 +102,17 @@ mod tests {
}
}
#[test]
fn tate_chu_yoko_settings_step_the_opening_number_on_ok() {
let (mut app, id) = app();
app.run("text.setFormat", json!({"tcyUpDown": 3, "tcyLeftRight": -7})).unwrap();
let mut panel = crate::tests::panel_harness::Panel::new(app, crate::tests::picks::dialogs);
panel.app().run("ui.tateChuYokoSettings", json!({})).unwrap();
driver::step_number_and_ok(&mut panel, "Up/Down");
assert_eq!(offsets(&panel.app(), id), [(4.0, -7.0)]);
assert!(!driver::is_open(&panel.app()));
}
/// `ui.tateChuYokoSettings` opens on the characters' values; OK sets both in one undo step.
/// Automation sets the offsets in points, as a number row takes them.
#[test]
+25 -1
View File
@@ -11,6 +11,7 @@
//! Behavior reference (public documentation):
//! <https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html>.
use craft::ui::contract::Bind;
use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind};
// PLAN: assumed path of `UnitKind`
use craft::ui::runtime::env::UnitKind;
@@ -78,7 +79,9 @@ pub fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
let initial = fields.clone();
let ctx = app.ui_ctx.clone().ok_or("no window")?;
let lengths = crate::canvas::rulers::type_lengths(app);
let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |_| ParamDialog::new(KIND, tl!("Warichu Settings"), rows(lengths)));
let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |fields| {
ParamDialog::new(KIND, tl!("Warichu Settings"), rows(lengths)).values(Bind::bound(fields))
});
super::host::open_held(app, dialog, move |app, result| {
let p = params(&result.fields, &initial);
if p.is_empty() {
@@ -165,6 +168,16 @@ pub(super) mod driver {
app.dialogs().expect("window").with(|h| h.set_json_field(&ctx, id, key, value))
}
/// Steps a focused number field up once and clicks the dialog's OK button.
pub fn step_number_and_ok(panel: &mut crate::tests::panel_harness::Panel, label: &str) {
panel.frame();
let field = panel.rect_role(label, craft::ui::contract::Role::SPIN_BUTTON).center();
panel.click_at(field);
panel.key(egui::Key::ArrowUp, egui::Modifiers::NONE);
panel.key(egui::Key::Tab, egui::Modifiers::NONE);
panel.click("OK");
}
/// Runs the frame's pump.
pub fn pump(app: &mut VectorcraftApp) {
let ctx = ctx(app);
@@ -216,6 +229,17 @@ mod tests {
}
}
#[test]
fn warichu_settings_step_the_opening_number_on_ok() {
let (mut app, id) = app();
app.run("text.setFormat", json!({"warichuLines": 3, "warichuScale": 70})).unwrap();
let mut panel = crate::tests::panel_harness::Panel::new(app, crate::tests::picks::dialogs);
panel.app().run("ui.warichuSettings", json!({})).unwrap();
driver::step_number_and_ok(&mut panel, "Lines");
assert_eq!(settings(&panel.app(), id), [(false, 4, 0.0, 70.0, WarichuAlign::Auto)]);
assert!(!driver::is_open(&panel.app()));
}
/// `ui.warichuSettings` opens on the characters' values; OK sets the changed ones in one undo
/// step without turning Warichu on. A value past the ends is refused as it is set (the framework's
/// `FieldRefusal::Rejects`); OK keeps an unedited one to them (the test below). Automation sets the