mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-11 16:30:16 -06:00
Merge PR #893: Numbering & Section Options opens as New Section on a page without one
Conflicts: crates/ui-egui/src/dialogs/tests.rs: kept both tests (#1406 corner options, #893 new section) crates/ui-egui/src/i18n/*.rs (ar, cs, de, it, ja, ka, pl, pt_br, ru, uk): kept both sides' keys, plus #893's New Section
This commit is contained in:
@@ -466,6 +466,7 @@ Newest first.
|
||||
- **2026-10-21** · Properties › Align: the Align To button shows what the objects align to, one glyph each for the selection, the key object, the margins, the page and the spread, as InDesign's. Found in the Learn Skills Daily course, chapter 12. No readiness percentage change.
|
||||
- **2026-10-20** · Object › Corner Options opens a Corner Options dialog laid out as InDesign's: each corner's size and shape, the link button that makes all four the same, and Preview. The Corner link in Properties › Appearance opens it too (it opened a Rectangle size dialog). No readiness percentage change.
|
||||
- **2026-10-20** · The Object menu is in InDesign's order and groups; Paths has Join, Open Path and Close Path (Convert Shape lists only shapes, as InDesign's does) and a Convert Point submenu (Plain, Corner, Smooth, Symmetrical) is added. No readiness percentage change.
|
||||
- **2026-10-14** · Numbering & Section Options opened on a page that doesn't start a section is New Section, as in InDesign: Start Section on, 1 offered, and the start numbers stay editable (typing one chooses it). No readiness percentage change.
|
||||
- **2026-10-21** · Properties › Character and Paragraph: ••• (More Options) expands the section in place, as InDesign's: Character adds vertical and horizontal scale, baseline shift, skew, language and OpenType, and All Caps, Small Caps, Superscript, Subscript, Underline and Strikethrough; Paragraph adds the left, right, first line and last line indents, space before and after, the drop cap's lines and characters, Align to Baseline Grid and Hyphenate. It used to open the Character or Paragraph panel; the language field moved under ••• as in InDesign. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.
|
||||
- **2026-10-21** · The text Control panel has InDesign's two modes: A (Character Formatting Controls: font and style, size and leading, All Caps/Superscript/Underline and Small Caps/Subscript/Strikethrough, kerning and tracking, vertical and horizontal scale, baseline shift and skew, character style and language) and ¶ (Paragraph Formatting Controls: the nine alignments, left/first line and right/last line indents, space before and after, the drop cap's lines and characters, paragraph style, Hyphenate and Align to Baseline Grid). It used to show a fixed mix of both. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.
|
||||
- **2026-10-20** · With the Type tool, the Control panel's font size, leading and tracking fields have a spinner and a list of common values, as in InDesign (auto leading in parentheses). No readiness percentage change.
|
||||
|
||||
@@ -2217,6 +2217,8 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {
|
||||
"colorTheme" => crate::i18n::tr(&app.ui.language, "Color Theme"),
|
||||
"documentSetup" => crate::i18n::tr(&app.ui.language, "Document Setup"),
|
||||
"fileInfo" => crate::i18n::tr(&app.ui.language, "File Info"),
|
||||
// On a page that doesn't start a section yet, InDesign titles it New Section.
|
||||
"numberingSection" if d.b("newSection") => crate::i18n::tr(&app.ui.language, "New Section"),
|
||||
"numberingSection" => crate::i18n::tr(&app.ui.language, "Numbering & Section Options…").trim_end_matches('…'),
|
||||
"findChange" => crate::i18n::tr(&app.ui.language, "Find/Change"),
|
||||
"paragraphStyleOptions" => crate::i18n::tr(&app.ui.language, "Paragraph Style Options"),
|
||||
|
||||
@@ -3634,3 +3634,52 @@ fn corner_options_keep_each_objects_untouched_corners() {
|
||||
assert_eq!(ca, cb, "all four, on both");
|
||||
assert!(ca.iter().all(|c| c.shape == CornerShape::None && (c.size - 6.0).abs() < 1e-6), "{ca:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_a_page_without_a_section_the_window_is_new_section() {
|
||||
// Chris Nielsen's "Numbering Page Sections" (4:43): page 3 selected, the Pages panel menu's
|
||||
// Numbering & Section Options opens New Section with Start Section on and 1 offered.
|
||||
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"pages": 6, "facingPages": true})).unwrap();
|
||||
app.canvas_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1000.0, 800.0)));
|
||||
crate::canvas::go_to_page(&mut app, 2);
|
||||
crate::menus::activate(&mut app, "layout.section", &Value::Null);
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(
|
||||
(d.n("page"), d.b("newSection"), d.b("startSection"), d.b("automatic"), d.s("startNumber")),
|
||||
(Some(3.0), true, true, true, "1".into())
|
||||
);
|
||||
let ctx = dialog_context("en");
|
||||
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1178.0, 814.0));
|
||||
for _ in 0..3 {
|
||||
dialog_frame(&mut app, &ctx, screen, vec![]);
|
||||
}
|
||||
let labels = dialog_frame(&mut app, &ctx, screen, vec![]);
|
||||
visible_label(&labels, screen, "New Section");
|
||||
// Typing a number in the field chooses Start Page Numbering at; OK: page 3 is page 5 (odd,
|
||||
// so a facing page stays on the right).
|
||||
let field = visible_label(&labels, screen, "1");
|
||||
click_dialog(&mut app, &ctx, screen, field.center());
|
||||
dialog_frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
screen,
|
||||
vec![
|
||||
egui::Event::Key { key: egui::Key::End, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE },
|
||||
egui::Event::Key { key: egui::Key::Backspace, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE },
|
||||
egui::Event::Text("5".into()),
|
||||
],
|
||||
);
|
||||
assert!(!app.ui.dialog.as_ref().unwrap().b("automatic"), "typing chose Start Page Numbering at");
|
||||
let labels = dialog_frame(&mut app, &ctx, screen, vec![]);
|
||||
click_dialog(&mut app, &ctx, screen, visible_label(&labels, screen, "OK").center());
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert_eq!(app.session.active().unwrap().doc.page_name(2), "5");
|
||||
// Opened again on that page, it is Numbering & Section Options, showing the section.
|
||||
crate::menus::activate(&mut app, "layout.section", &Value::Null);
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!((d.b("newSection"), d.b("startSection"), d.b("automatic"), d.s("startNumber")), (false, true, false, "5".into()));
|
||||
let labels = (0..4).map(|_| dialog_frame(&mut app, &ctx, screen, vec![])).last().unwrap();
|
||||
visible_label(&labels, screen, "Numbering & Section Options");
|
||||
assert!(!labels.iter().any(|(t, _, _)| t == "New Section"));
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Corner Size and Shape:", "حجم الزوايا وشكلها:"),
|
||||
("Join", "وصل"),
|
||||
("Convert Point", "تحويل النقطة"),
|
||||
("New Section", "قسم جديد"),
|
||||
("Restart Numbering", "إعادة الترقيم"),
|
||||
("Continue Numbering", "متابعة الترقيم"),
|
||||
("Keep Options…", "خيارات الإبقاء…"),
|
||||
|
||||
@@ -39,6 +39,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Convert Point", "Převést bod"),
|
||||
("Plain", "Obyčejný"),
|
||||
("Symmetrical", "Symetrický"),
|
||||
("New Section", "Nový oddíl"),
|
||||
("Restart Numbering", "Začít číslování znovu"),
|
||||
("Continue Numbering", "Pokračovat v číslování"),
|
||||
("Keep Options…", "Volby zachování…"),
|
||||
|
||||
@@ -38,6 +38,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Convert Point", "Punkt konvertieren"),
|
||||
("Plain", "Einfach"),
|
||||
("Symmetrical", "Symmetrisch"),
|
||||
("New Section", "Neuer Abschnitt"),
|
||||
("Restart Numbering", "Nummerierung neu beginnen"),
|
||||
("Continue Numbering", "Nummerierung fortführen"),
|
||||
("Keep Options…", "Umbruchoptionen …"),
|
||||
|
||||
@@ -34,6 +34,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Corner Size and Shape:", "Dimensione e forma angoli:"),
|
||||
("Join", "Unisci"),
|
||||
("Convert Point", "Converti punto"),
|
||||
("New Section", "Nuova sezione"),
|
||||
("Restart Numbering", "Riavvia numerazione"),
|
||||
("Continue Numbering", "Continua numerazione"),
|
||||
("Keep Options…", "Opzioni di separazione…"),
|
||||
|
||||
@@ -35,6 +35,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Corner Size and Shape:", "角のサイズとシェイプ:"),
|
||||
("Join", "連結"),
|
||||
("Convert Point", "ポイントを切り換え"),
|
||||
("New Section", "新規セクション"),
|
||||
("Restart Numbering", "番号の振り直し"),
|
||||
("Continue Numbering", "番号の継続"),
|
||||
("Keep Options…", "段落分離禁止オプション…"),
|
||||
|
||||
@@ -35,6 +35,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Stroke Type", "კონტურის ტიპი"),
|
||||
("Corner Shape", "კუთხის ფორმა"),
|
||||
("Corner Size and Shape:", "კუთხეების ზომა და ფორმა:"),
|
||||
("New Section", "ახალი სექცია"),
|
||||
("Restart Numbering", "ნუმერაციის თავიდან დაწყება"),
|
||||
("Continue Numbering", "ნუმერაციის გაგრძელება"),
|
||||
("Keep Options…", "შენარჩუნების პარამეტრები…"),
|
||||
|
||||
@@ -37,6 +37,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Convert Point", "Konwertuj punkt"),
|
||||
("Plain", "Zwykły"),
|
||||
("Symmetrical", "Symetryczny"),
|
||||
("New Section", "Nowa sekcja"),
|
||||
("Restart Numbering", "Zacznij numerowanie od nowa"),
|
||||
("Continue Numbering", "Kontynuuj numerowanie"),
|
||||
("Keep Options…", "Opcje utrzymywania…"),
|
||||
|
||||
@@ -37,6 +37,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Corner Size and Shape:", "Tamanho e forma dos cantos:"),
|
||||
("Join", "Unir"),
|
||||
("Convert Point", "Converter ponto"),
|
||||
("New Section", "Nova seção"),
|
||||
("Restart Numbering", "Reiniciar numeração"),
|
||||
("Continue Numbering", "Continuar numeração"),
|
||||
("Keep Options…", "Opções de manutenção…"),
|
||||
|
||||
@@ -41,6 +41,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Convert Point", "Преобразовать точку"),
|
||||
("Plain", "Простая"),
|
||||
("Symmetrical", "Симметричная"),
|
||||
("New Section", "Новый раздел"),
|
||||
("Restart Numbering", "Начать нумерацию заново"),
|
||||
("Continue Numbering", "Продолжить нумерацию"),
|
||||
("Keep Options…", "Параметры удержания…"),
|
||||
|
||||
@@ -1136,6 +1136,7 @@ pub(super) const TABLE: &[(&str, [&str; 5])] = &[
|
||||
],
|
||||
),
|
||||
("Load Styles", ["Formate laden", "Charger les styles", "Cargar estilos", "スタイルを読み込み", "加载样式"]),
|
||||
("New Section", ["Neuer Abschnitt", "Nouvelle section", "Nueva sección", "新規セクション", "新建章节"]),
|
||||
("Restart Numbering", ["Nummerierung neu beginnen", "Recommencer la numérotation", "Reiniciar numeración", "番号の振り直し", "重新开始编号"]),
|
||||
("Continue Numbering", ["Nummerierung fortführen", "Poursuivre la numérotation", "Continuar numeración", "番号の継続", "继续编号"]),
|
||||
("Keep Options…", ["Umbruchoptionen …", "Options d'enchaînement…", "Opciones de separación…", "段落分離禁止オプション…", "保持选项…"]),
|
||||
|
||||
@@ -35,6 +35,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[
|
||||
("Corner Size and Shape:", "Розмір і форма кутів:"),
|
||||
("Join", "Зʼєднати"),
|
||||
("Convert Point", "Перетворити точку"),
|
||||
("New Section", "Новий розділ"),
|
||||
("Restart Numbering", "Почати нумерацію знову"),
|
||||
("Continue Numbering", "Продовжити нумерацію"),
|
||||
("Keep Options…", "Параметри утримання…"),
|
||||
|
||||
@@ -36,13 +36,17 @@ pub(crate) fn open(app: &mut DesignApp) {
|
||||
let doc = &st.doc;
|
||||
let page = current.min(doc.page_count().saturating_sub(1));
|
||||
let own = doc.sections.iter().find(|s| s.start == page);
|
||||
// A new section starts from the one the page is in.
|
||||
// A new section starts from the one the page is in. As in InDesign, the window opened on a
|
||||
// page that doesn't start a section is New Section: Start Section checked, Start Page
|
||||
// Numbering at offering 1, Automatic Page Numbering chosen.
|
||||
let base = own.or_else(|| doc.section_of(page));
|
||||
let new = page != 0 && own.is_none();
|
||||
let fields = json!({
|
||||
"page": page + 1,
|
||||
"startSection": page == 0 || own.is_some(),
|
||||
"newSection": new,
|
||||
"startSection": true,
|
||||
"automatic": own.is_none_or(|s| s.start_number.is_none()),
|
||||
"startNumber": doc.page_number(page).to_string(),
|
||||
"startNumber": if new { "1".to_string() } else { doc.page_number(page).to_string() },
|
||||
"prefix": base.map(|s| s.prefix.clone()).unwrap_or_default(),
|
||||
"style": base.map(|s| s.style).unwrap_or_default(),
|
||||
"marker": base.map(|s| s.marker.clone()).unwrap_or_default(),
|
||||
@@ -160,7 +164,12 @@ pub(crate) fn body(app: &DesignApp, ui: &mut Ui, d: &mut Dialog) {
|
||||
if ui.radio(!automatic, crate::rtl::widget(ui, tr("Start Page Numbering at:"))).clicked() {
|
||||
d.fields.insert("automatic".into(), json!(false));
|
||||
}
|
||||
ui.add_enabled_ui(!automatic, |ui| text(ui, d, "startNumber", FIELD_W));
|
||||
// As in InDesign, the number stays editable; typing one chooses Start Page Numbering at.
|
||||
let mut n = d.s("startNumber");
|
||||
if ui.add(egui::TextEdit::singleline(&mut n).desired_width(FIELD_W)).changed() {
|
||||
d.fields.insert("startNumber".into(), Value::String(n));
|
||||
d.fields.insert("automatic".into(), json!(false));
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
group(ui, rtl, tr("Page Numbering"), |ui| {
|
||||
@@ -200,7 +209,12 @@ pub(crate) fn body(app: &DesignApp, ui: &mut Ui, d: &mut Dialog) {
|
||||
}
|
||||
});
|
||||
if value == ChapterSource::UserDefined {
|
||||
ui.add_enabled_ui(source == value, |ui| text(ui, d, "chapterStart", FIELD_W));
|
||||
// Editable whichever is chosen, as in InDesign; typing a number chooses it.
|
||||
let mut n = d.s("chapterStart");
|
||||
if ui.add(egui::TextEdit::singleline(&mut n).desired_width(FIELD_W)).changed() {
|
||||
d.fields.insert("chapterStart".into(), Value::String(n));
|
||||
d.fields.insert("chapterSource".into(), json!(value));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user