mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 20:16:29 -05:00
Merge pull request #19037
Co-authored-by: autocraft-bot[bot] <354215646+autocraft-bot[bot]@users.noreply.github.com>
This commit is contained in:
commit
f49b5b105a
2 files changed
+85
-4
No files matched your search
@@ -266,10 +266,11 @@ pub(crate) fn tab_title_at(app: &PhotocraftApp, i: usize, zoom: f32) -> String {
|
||||
};
|
||||
let layer = active_layer.map(|l| format!("{}, ", l.name)).unwrap_or_default();
|
||||
// An Indexed or Bitmap document names only its mode, with no bit depth: "(Index)",
|
||||
// "(Bitmap)" (#17607). A mask target and every other mode keep "RGB/8" and so on.
|
||||
let mode = match (mask || quick_mask, st.doc.mode) {
|
||||
(false, photocraft_doc::ColorMode::Indexed) => "Index".to_string(),
|
||||
(false, photocraft_doc::ColorMode::Bitmap) => "Bitmap".to_string(),
|
||||
// "(Bitmap)" (#17607). Indexed Quick Mask also omits the bit depth (#19009).
|
||||
let mode = match (mask, quick_mask, st.doc.mode) {
|
||||
(_, true, photocraft_doc::ColorMode::Indexed) => model,
|
||||
(false, false, photocraft_doc::ColorMode::Indexed) => "Index".to_string(),
|
||||
(false, false, photocraft_doc::ColorMode::Bitmap) => "Bitmap".to_string(),
|
||||
_ => format!("{model}/{}", st.doc.depth.bits()),
|
||||
};
|
||||
// A save in progress: "name @ 100% (Layer 1, RGB/16) - Saving 45%", as Photoshop does (#3389).
|
||||
@@ -314,6 +315,10 @@ pub(super) fn move_target_after_filter(visible: &[usize], from: usize, to: usize
|
||||
#[path = "../file_info_copyright_title_tests.rs"]
|
||||
mod file_info_copyright_title_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../quick_mask_indexed_tab_title_tests.rs"]
|
||||
mod quick_mask_indexed_tab_title_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tab_indexed_bitmap_label_tests.rs"]
|
||||
mod tab_indexed_bitmap_label_tests;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
use serde_json::json;
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
|
||||
use super::tab_title_at;
|
||||
|
||||
fn app(depth: u8) -> Box<PhotocraftApp> {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 40, "height": 30, "name": "oracle", "depth": depth})).unwrap();
|
||||
app
|
||||
}
|
||||
|
||||
fn indexed(app: &mut PhotocraftApp) {
|
||||
app.run("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "dither": "none", "transparency": false})).unwrap();
|
||||
}
|
||||
|
||||
fn quick_mask(app: &mut PhotocraftApp, on: bool) {
|
||||
app.run("select.editInQuickMaskMode", json!({"on": on})).unwrap();
|
||||
}
|
||||
|
||||
fn title(app: &PhotocraftApp) -> String {
|
||||
tab_title_at(app, 0, 100.0)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn indexed_quick_mask_omits_the_depth_and_restores_index_on_exit() {
|
||||
let mut app = app(8);
|
||||
indexed(&mut app);
|
||||
assert_eq!(title(&app), "oracle @ 100% (Index)");
|
||||
quick_mask(&mut app, true);
|
||||
assert_eq!(title(&app), "oracle @ 100% (Quick Mask)");
|
||||
quick_mask(&mut app, false);
|
||||
assert_eq!(title(&app), "oracle @ 100% (Index)");
|
||||
|
||||
app.run("layer.new.layer", json!({"name": "Top"})).unwrap();
|
||||
quick_mask(&mut app, true);
|
||||
assert_eq!(title(&app), "oracle @ 100% (Top, Quick Mask)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rgb_quick_mask_displays_the_document_depth() {
|
||||
for depth in [8, 16, 32] {
|
||||
let mut app = app(depth);
|
||||
quick_mask(&mut app, true);
|
||||
assert_eq!(title(&app), format!("oracle @ 100% (Quick Mask/{depth})"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn other_measured_modes_keep_the_depth_in_quick_mask() {
|
||||
for command in ["image.mode.grayscale", "image.mode.cmyk", "image.mode.lab", "image.mode.multichannel"] {
|
||||
let mut app = app(8);
|
||||
app.run(command, json!({})).unwrap();
|
||||
quick_mask(&mut app, true);
|
||||
assert_eq!(title(&app), "oracle @ 100% (Quick Mask/8)", "{command}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bitmap_outside_quick_mask_omits_the_depth() {
|
||||
let mut app = app(8);
|
||||
app.run("image.mode.grayscale", json!({})).unwrap();
|
||||
app.run("image.mode.bitmap", json!({"method": "threshold"})).unwrap();
|
||||
assert_eq!(title(&app), "oracle @ 100% (Bitmap)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn indexed_layer_mask_keeps_its_depth() {
|
||||
let mut app = app(8);
|
||||
indexed(&mut app);
|
||||
app.run("layer.new.layer", json!({"name": "Top"})).unwrap();
|
||||
let layer = app.session.active().unwrap().active_layer.unwrap();
|
||||
app.run("layer.layerMask.revealAll", json!({"layer": layer.0})).unwrap();
|
||||
app.run("channel.target", json!({"channel": "mask"})).unwrap();
|
||||
assert_eq!(title(&app), "oracle @ 100% (Top, Layer Mask/8)");
|
||||
}
|
||||
Reference in new issue
Block a user