DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge remote-tracking branch 'upstream/main' into docking-trial
aionggbc1ccfa48129
diff --cc Cargo.tomlindex d696e54fa,8a83e0463..d8521ba47--- a/Cargo.toml+++ b/Cargo.toml@@@ -116,14 -122,9 +122,13 @@@ debug =# Opt-in cancelable macOS termination on the pinned winit 0.30 line.[patch.crates-io]- winit = { git = "https://github.com/skylartaylor/winit.git", rev = "3d51077fd1a966f84df9ef287839dc84fd5b4ca7" }- krilla = { git = "https://github.com/storytold/craft-libs", rev = "c3487320b2d1de657b860b3c8abb44e1f2b32bd8", version = "=0.8.2" }- # The hayro crates from pdfcraft's vendor/ directory, with the patches its README lists.- hayro = { git = "https://github.com/storytold/pdfcraft", rev = "b5467d93a0ffaa5e5e6658bccdf8655a3ba689c9" }- hayro-interpret = { git = "https://github.com/storytold/pdfcraft", rev = "b5467d93a0ffaa5e5e6658bccdf8655a3ba689c9" }- hayro-syntax = { git = "https://github.com/storytold/pdfcraft", rev = "b5467d93a0ffaa5e5e6658bccdf8655a3ba689c9" }- hayro-jbig2 = { git = "https://github.com/storytold/pdfcraft", rev = "b5467d93a0ffaa5e5e6658bccdf8655a3ba689c9" }+ krilla = { git = "https://github.com/storytold/craft-libs", rev = "89dcbb3060377a26c99a6d80caa16084366704c4", version = "=0.8.2" }+ winit = { git = "https://github.com/storytold/winit.git", rev = "3d51077fd1a966f84df9ef287839dc84fd5b4ca7" }+ hayro = { git = "https://github.com/storytold/craft-libs", rev = "89dcbb3060377a26c99a6d80caa16084366704c4", version = "=0.7.1" }+ hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "89dcbb3060377a26c99a6d80caa16084366704c4", version = "=0.7.0" }+ hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "89dcbb3060377a26c99a6d80caa16084366704c4", version = "=0.7.2" }+ hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "89dcbb3060377a26c99a6d80caa16084366704c4", version = "=0.3.0" }++# Docking trial: craft-ui from the craft-libs `docking` branch.+[patch."https://github.com/storytold/craft-libs"]+craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "2fa4ad79d7dcde5e6ad671d36083dee367a1b788" }diff --cc crates/ui-egui/src/i18n.rsindex 86cd07e27,6057abc97..7ed31d191--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@@ -5055,6 -4846,6 +4951,8 @@@ mod testskeys.extend(crate::about::SIBLINGS.iter().map(|(_, _, what)| *what));keys.extend(crate::credits::NameMode::ALL.iter().map(|mode| mode.label()));keys.extend(crate::credits::SortKey::ALL.iter().flat_map(|key| [key.label().0, key.label().1]));++ // Docking chrome labels reach `tr` through craft-ui's localizer.++ keys.extend(crate::panel_docking::DOCK_LABELS.iter().map(|(_, english)| *english));// UI labels passed to `tr` that no other catalog has yet.keys.extend(["(any)",@@@ -5068,14 -4861,14 +4968,11 @@@"Email Address:","Email:","Find fill:",-- "Group with","H:","Message:","Organization:","Phone:","W:",-- "Resize panel window",-- "Resize panels","Subject:","Text:","Unsaved Changes",diff --cc crates/ui-egui/src/i18n/fr.rsindex 69fe4863e,681230d84..3341a408b--- a/crates/ui-egui/src/i18n/fr.rs+++ b/crates/ui-egui/src/i18n/fr.rs@@@ -64,15 -132,28 +132,27 @@@ pub(super) const TABLE: &[(&str, &str)("Figure Space", "Espace chiffre"),("File/Export", "Fichier/Exporter"),("Find What", "Rechercher"),+ ("Find fill:", "Rechercher le fond :"),+ ("First commit", "Premier commit"),("Flush Space", "Espace sans alinéa"),("Forced Line Break", "Saut de ligne forcé"),+ ("Formatting Affects Text", "La mise en forme agit sur le texte"),+ ("Found", "Trouvé"),("Frame Break", "Saut de bloc"),+ ("Free Transform Tool", "Outil Transformation manuelle"),("GREP", "GREP"),+ ("Gap Tool", "Outil Espace"),("Generate Index", "Générer l'index"),("Generate Live Caption", "Générer une légende dynamique"),+ ("Get Cell Stroke", "Obtenir le contour de cellule"),+ ("Get Tabs", "Obtenir les tabulations"),("Global Light", "Lumière globale"),+ ("Grab bag", "Liste"),+ ("Gradient Feather Tool", "Outil Contour progressif dégradé"),+ ("Gradient Swatch Tool", "Outil Dégradé de nuance"),("Graphic", "Graphique"),- ("Group with", "Grouper avec"),("Hair Space", "Espace ultrafine"),+ ("Hand Tool", "Outil Main"),("Hide Guides", "Masquer les repères"),("High Contrast", "Contraste élevé"),("High Resolution", "Haute résolution"),@@@ -132,15 -249,33 +248,32 @@@("Object/Transform", "Objet/Transformation"),("Object/Transform Again", "Objet/Répéter la transformation"),("On", "Activé"),+ ("Organization:", "Organisation :"),("Orientation", "Orientation"),+ ("PDF import cancelled: the originating document has closed", "Importation PDF annulée : le document d'origine a été fermé"),+ ("PRs", "PR"),("Package", "Assemblage"),+ ("Packaged {count} files into {dir}", "{count} fichiers assemblés dans {dir}"),("Page Break", "Saut de page"),+ ("Page Options", "Options de page"),+ ("Page Tool", "Outil Page"),- ("Panels", "Panneaux"),("Paragraph Return", "Retour de paragraphe"),+ ("Paragraph Style", "Style de paragraphe"),("Paragraph Symbol", "Symbole de paragraphe"),+ ("Parent Options…", "Options de gabarit…"),+ ("Pen Tool", "Outil Plume"),+ ("Pencil Tool", "Outil Crayon"),+ ("Phone:", "Téléphone :"),("Picas", "Picas"),+ ("Pin Bar Position", "Épingler la position de la barre"),("Place with Import Options", "Importer avec les options d'importation"),+ ("Polygon Frame Tool", "Outil Bloc polygonal"),+ ("Polygon Tool", "Outil Polygone"),("Preflight", "Contrôle en amont"),("Preflight Panel…", "Panneau Contrôle en amont…"),+ ("Press keys…", "Appuyez sur des touches…"),+ ("Preview Change", "Prévisualiser la modification"),+ ("Preview Record", "Aperçu de l'enregistrement"),("Previous Page Number", "Numéro de la page précédente"),("Print Booklet", "Imprimer le cahier"),("Punctuation Space", "Espace de ponctuation"),@@@ -150,9 -292,24 +290,22 @@@("Registered Trademark Symbol", "Symbole de marque déposée"),("Relink", "Rééditer le lien"),("Relink to Folder", "Rééditer le lien au dossier"),+ ("Relinked {count}", "Liens rétablis : {count}"),+ ("Reload Fonts", "Recharger les polices"),+ ("Remove Data Source", "Supprimer la source de données"),+ ("Remove Field", "Supprimer le champ"),+ ("Remove Frame from Thread", "Retirer le bloc du chaînage"),+ ("Reorder Objects", "Réorganiser les objets"),("Report an Issue", "Signaler un problème"),+ ("Report an issue", "Signaler un problème"),+ ("Reset Bar Position", "Réinitialiser la position de la barre"),+ ("Resize Row or Column", "Redimensionner la ligne ou la colonne"),+ ("Resize Window", "Redimensionner la fenêtre"),- ("Resize panel window", "Redimensionner la fenêtre du panneau"),- ("Resize panels", "Redimensionner les panneaux"),+ ("Reverse the order", "Inverser l'ordre"),("Right Indent Tab", "Tabulation de retrait à droite"),+ ("Rotate Tool", "Outil Rotation"),("Rotation", "Rotation"),+ ("Ruler Zero Point", "Point zéro des règles"),("Save As", "Enregistrer sous"),("Save Swatches for Exchange", "Enregistrer les nuances pour échange"),("Save a Copy", "Enregistrer une copie"),diff --cc crates/ui-egui/src/panel_docking.rsindex dd9a294e4,bec168ea1..ab52a8017--- a/crates/ui-egui/src/panel_docking.rs+++ b/crates/ui-egui/src/panel_docking.rs@@@ -919,79 -533,75 +919,79 @@@ pub(crate) fn show(app: &mut DesignAppapp.ui.status = error;}}- icon_rail(app, ui);- true+ if let Some(panel) = focused.filter(|panel| panel == CANVAS || layout_of(app).contains(panel)) {+ app.ui.docking_focused = Some(panel);+ }}-fn icon_rail(app: &mut DesignApp, ui: &mut egui::Ui) {- let t = crate::theme::Tokens::get(ui.ctx());- let column = egui::Panel::right("shared-panel-icons")- .exact_size(38.0)- .resizable(false)- .frame(egui::Frame::NONE.fill(t.panel))- .show(ui, |ui| {- egui::ScrollArea::vertical().id_salt("shared-panel-icons-scroll").show(ui, |ui| {- ui.spacing_mut().item_spacing.y = 2.0;- for &(id, label, icon) in crate::dock::DOCK_TABS.iter().chain(crate::dock::ICON_PANELS) {- if app.ui.docking.as_ref().is_some_and(|layout| {- layout.contains(&id.to_string()) && (app.ui.dock_expanded || layout.floating.iter().any(|g| g.panels.iter().any(|p| p == id)))- }) {- continue;- }+/// What the control channel reports: the layout in use (craft-ui's serialized `Layout`),+/// whether it is the workspace's default, the panel (or `canvas`) last clicked or selected, the+/// panels closed with a remembered place, the panel whose flyout is open, and where each+/// docking gesture starts in the last frame (`hitRects`).+pub(crate) fn inspect(app: &DesignApp, ctx: &egui::Context) -> Value {+ let hits = craft_ui::docking::DockArea::<String>::hit_rects(ctx, area_id());+ let hit_rects: Vec<Value> = hits.iter().map(|(hit, r)| json!({"hit": hit, "rect": [r.left(), r.top(), r.width(), r.height()]})).collect();+ json!({+ "layout": layout_of(app),+ "customized": app.ui.docking.is_some(),+ "focused": app.ui.docking_focused,+ "flyout": app.ui.docking_flyout,+ "autoCollapse": app.ui.dock_auto_collapse,+ "rightToLeft": crate::i18n::is_rtl(&app.ui.language),+ "hidden": app.ui.docking_hidden.keys().collect::<Vec<_>>(),+ "hitRects": hit_rects,+ })+}- let response =- crate::icons::button(ui, icon, 28.0, false, crate::i18n::tr(&app.ui.language, label)).interact(egui::Sense::click_and_drag());- if response.clicked() {- let _ = app.run("window.panel.activate", json!({"panel":id}));- }- legacy_tab(app, ui, id, &response);- }- });- })- .response- .rect;- let _ = column;+fn dock_style(ui: &egui::Ui, language: &str) -> craft_ui::docking::DockStyle {+ let t = crate::theme::Tokens::get(ui.ctx());+ let mut style = craft_ui::docking::DockStyle::from_ui(ui);+ style.tab_height = 27.0;+ style.background = t.panel;+ style.tab_background = t.tab_strip;+ style.active_background = t.panel;+ style.text = t.text_strong;+ style.inactive_text = t.text_dim;+ style.border = egui::Stroke::new(1.0, t.border);+ style.accent = t.accent;+ style.right_to_left = crate::i18n::is_rtl(language);+ style.localized(|key| DOCK_LABELS.iter().find(|(k, _)| *k == key).map(|(_, english)| crate::i18n::tr(language, english).to_owned()))}-pub(crate) fn legacy_tab(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str, response: &egui::Response) {- let Some(panel) = normalize(panel) else { return };- response.context_menu(|ui| panel_menu(app, ui, panel));- if response.drag_started()- && let Some(id) = normalize(panel)- {- let mut layout = app.ui.docking.clone().unwrap_or_else(|| legacy(app));- let bounds = ui.max_rect();- let source = egui::Rect::from_min_size(- egui::pos2(bounds.left(), response.rect.top()),- egui::vec2(bounds.width().clamp(240.0, 600.0), bounds.height().clamp(200.0, 600.0)),- );- if ensure(&mut layout, id).is_ok()- && craft_ui::docking::begin_drag(ui.ctx(), egui::Id::new("designcraft-panel-docking"), id.to_string(), source)- {- ui.ctx().data_mut(|data| {- data.insert_temp(- egui::Id::new("designcraft-panel-docking").with("legacy-origin"),- LegacyDrag {- layout: app.ui.docking.clone(),- open_panel: app.ui.open_panel.clone(),- floating: app.ui.floating.clone(),- generation: app.ui.docking_generation,- },- )- });- app.ui.docking = Some(layout);- app.ui.open_panel = None;- }- }-}--/// The menu behind a panel's three-line button, in either dock: the panel's own commands, then-/// its docking commands.-pub(crate) fn three_line_menu(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str) {+/// DesignCraft's wording of craft-ui's docking labels, translated through `i18n::tr`.- const DOCK_LABELS: &[(&str, &str)] = &[++pub(crate) const DOCK_LABELS: &[(&str, &str)] = &[+ ("dock.float", "Float Panel"),+ ("dock.close", "Close"),+ ("dock.movePanelTo", "Group with"),+ ("dock.panels", "Panels"),+ ("dock.resize", "Resize panels"),+ ("dock.resizeWindow", "Resize panel window"),+ ("dock.moveGroup", "Move tab group"),+ ("dock.closeGroup", "Close Tab Group"),+ ("dock.minimize", "Minimize"),+ ("dock.expand", "Expand"),+ ("dock.floatGroup", "Float Tab Group"),+ ("dock.moveGroupTo", "Group Tab Group with"),+ ("dock.moveColumn", "Move panel column"),+ ("dock.collapseToIcons", "Collapse to Icons"),+ ("dock.expandPanels", "Expand Panels"),+ ("dock.collapseColumn", "Collapse to Icons"),+ ("dock.expandColumn", "Expand Panels"),+ ("dock.moveWindow", "Move panel window"),+ ("dock.closeWindow", "Close panel window"),+ ("dock.undock", "Undock Panel"),+ ("dock.undockGroup", "Undock Panel Group"),+ ("dock.closePanelGroup", "Close Panel Group"),+ ("dock.closeOthers", "Close Other Panels in Group"),+ ("dock.maximize", "Maximize Frame"),+ ("dock.restoreFrame", "Restore Frame Size"),+ ("dock.newWindow", "Move Panel to New Window"),+ ("dock.autoCollapse", "Auto-Collapse Iconic Panels"),+];++/// The menu behind a panel's three-line button: the panel's own commands, then its docking+/// commands.+fn three_line_menu(app: &mut DesignApp, ui: &mut egui::Ui, panel: &str) {if panel == "pages" {crate::panels::pages::panel_menu(app, ui);ui.separator();