mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 13:02:50 -05:00
Merge pull request #10765 from dotCooCoo/fix/print-dialog-title-print
Print: the File › Print dialog is titled Print
This commit is contained in:
3 files changed
+53
-5
No files matched your search
@@ -11,7 +11,7 @@ use craft::ui::docking::IconGroupSeparator;
|
||||
use craft::ui::list::{CommandHighlight, ThumbRows};
|
||||
use craft::ui::menu::{MenuTitleLook, MenuTitlePad};
|
||||
use craft::ui::patterns::form_dialogs::PresetCardLook;
|
||||
use craft::ui::runtime::env::{AltCodeKeys, RootEnv, Scale, ScrubDrags, WindowKey};
|
||||
use craft::ui::runtime::env::{AltCodeKeys, RootEnv, Scale, ScrubDrags, WindowKey, WordsOverride, with_env};
|
||||
use craft::ui::runtime::frame::{FrameInput, FrameOutput};
|
||||
use craft::ui::runtime::toast::{self, Toast};
|
||||
use craft::ui::runtime::windows::WindowHost;
|
||||
@@ -771,7 +771,7 @@ impl VectorcraftApp {
|
||||
let mut control_bar_place = chrome::control_bar_place(&self.ui);
|
||||
// PLAN: assumed `chrome::window_title(&VectorcraftApp) -> String` (shell-01 A1 names the call, no row gives its signature; shell-w9).
|
||||
let window_title = chrome::window_title(self);
|
||||
let shown = AppShell::new(WindowKey::main())
|
||||
let shell = AppShell::new(WindowKey::main())
|
||||
.title_bar_if(true, |_| None, chrome::app_bar)
|
||||
.options_bar(
|
||||
self.ui.control_bar,
|
||||
@@ -801,8 +801,11 @@ impl VectorcraftApp {
|
||||
.body(|ui, cx, app: &mut VectorcraftApp| {
|
||||
panel_docking::show(app, ui, cx.shell().is_some_and(|shell| shell.panels_hidden()));
|
||||
crate::place::window_files(app, ui);
|
||||
})
|
||||
.show(ui, self);
|
||||
});
|
||||
// The shell shows the window's dialogs under these words. Temporary: removed once the craft-libs pin includes
|
||||
// storytold/craft-libs#4891 (`dialogs::print::title_words`).
|
||||
let words = dialogs::print::title_words(self).map(WordsOverride::Overlay);
|
||||
let shown = with_env(ui, |env| env.words = words, |ui| shell.show(ui, self));
|
||||
chrome::set_control_bar_place(&mut self.ui, control_bar_place);
|
||||
if shown.screen_mode != given {
|
||||
self.ui.follow_screen_mode(shown.screen_mode);
|
||||
|
||||
@@ -33,7 +33,7 @@ use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamKi
|
||||
use craft::ui::patterns::presets::{NamedPresetEvent, PresetError, PresetRow};
|
||||
use craft::ui::pickers::{Anchor9, ReferencePoint, ReferencePointLook};
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::env::{LengthUnits, UnitKind};
|
||||
use craft::ui::runtime::env::{LengthUnits, UnitKind, WordRows};
|
||||
use craft::ui::shell::WindowDialogs;
|
||||
use craft::ui::text::{LinkMode, LinkedFields, NumberField, SelectableText};
|
||||
use serde_json::{Map, Value, json};
|
||||
@@ -518,6 +518,15 @@ pub(super) fn settings(fields: &DialogFields) -> Value {
|
||||
Value::Object(nested(p))
|
||||
}
|
||||
|
||||
/// The words that title File › Print "Print" while the Print dialog is open in Print mode, for the window's shell to
|
||||
/// show its dialogs under. The framework titles a dialog in sections "Print Settings". Temporary: this is removed, and
|
||||
/// the dialog is titled with `HostedPrint::title`, once the craft-libs pin includes storytold/craft-libs#4891.
|
||||
pub(crate) fn title_words(app: &VectorcraftApp) -> Option<WordRows> {
|
||||
app.print_dialog.open.as_ref().filter(|open| open.mode == PrintMode::Print)?;
|
||||
let title = craft::i18n::Word::keyed("printDialog.title", "Print Settings");
|
||||
Some(WordRows::new().row(title, tl!("Print")))
|
||||
}
|
||||
|
||||
/// The work of the open dialog, once per frame: the printer list, Setup…, the preview, the placement the preview was
|
||||
/// dragged to, the presets and OK.
|
||||
pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
|
||||
@@ -143,6 +143,42 @@ fn pages(pdf: &[u8]) -> usize {
|
||||
vectorcraft_pdf::info(pdf, None).unwrap().pages.len()
|
||||
}
|
||||
|
||||
/// The texts the whole window paints, with where each is drawn, once the open dialog has faded in (each frame is a
|
||||
/// quarter second on).
|
||||
fn window_texts(app: &mut VectorcraftApp) -> Vec<(String, egui::Rect)> {
|
||||
let ctx = ctx(app);
|
||||
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 1000.0));
|
||||
let mut texts = vec![];
|
||||
for k in 0..4 {
|
||||
let raw = egui::RawInput { screen_rect: Some(screen), time: Some(f64::from(k) * 0.25), ..Default::default() };
|
||||
let out = crate::testing::app_frame(app, &ctx, raw);
|
||||
texts = crate::tests_labels::text_shapes(&out)
|
||||
.into_iter()
|
||||
.map(|(t, transform)| (t.galley.text().to_string(), transform * t.galley.rect.translate(t.pos.to_vec2())))
|
||||
.collect();
|
||||
}
|
||||
texts
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_print_dialog_is_titled_print_and_the_preset_editor_keeps_its_title() {
|
||||
let (mut printing, _) = app();
|
||||
printing.run("file.print", json!({})).unwrap();
|
||||
let texts = window_texts(&mut printing);
|
||||
let painted = |texts: &[(String, egui::Rect)], text: &str| texts.iter().filter(|(t, _)| t == text).map(|(_, r)| *r).collect::<Vec<_>>();
|
||||
assert!(painted(&texts, "Print Settings").is_empty(), "the Print dialog is not titled Print Settings: {texts:?}");
|
||||
let preset_row = painted(&texts, "Print Preset");
|
||||
let preset_row = preset_row.first().expect("the Print Preset row is shown");
|
||||
// The title sits above the dialog's first row; the Print button sits below it.
|
||||
assert!(painted(&texts, "Print").iter().any(|title| title.bottom() <= preset_row.top()), "the dialog is titled Print: {texts:?}");
|
||||
|
||||
// The preset editor keeps the framework's title.
|
||||
let (mut editing, _) = app();
|
||||
editing.run("ui.printPresetDialog", json!({"preset": vectorcraft_engine::cmd::printpresets::DEFAULT_PRESET})).unwrap();
|
||||
let texts = window_texts(&mut editing);
|
||||
assert!(!painted(&texts, "Print Settings").is_empty(), "the preset editor is titled Print Settings: {texts:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_sends_every_page_to_the_chosen_printer_and_keeps_the_settings() {
|
||||
let (mut app, jobs) = app();
|
||||
|
||||
Reference in new issue
Block a user