mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 12:16:39 +00:00
Merge pull request #8516 from dotCooCoo/feat/control-bar-link-label-opens-links
Control bar: the Linked File or Embedded label opens the Links panel
This commit is contained in:
@@ -1011,6 +1011,19 @@ pub fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Control bar's object label, `label`, while the bar has room for it. For one selected image
|
||||
/// (`image`: Linked File or Embedded) it is an underlined link, and a click opens the Links panel on
|
||||
/// the image with its Link Info.
|
||||
fn object_label(app: &mut VectorcraftApp, ui: &mut Ui, label: egui::RichText, image: bool) {
|
||||
if ui.available_width() < widgets::text_width(ui, label.clone()) {
|
||||
left_out(ui);
|
||||
} else if !image {
|
||||
ui.label(label);
|
||||
} else if ui.link(label.underline()).clicked() {
|
||||
crate::panels::links::show_selected_image(app, ui.ctx());
|
||||
}
|
||||
}
|
||||
|
||||
/// The Control bar's gripper, controls and panel menu, in the bar `bar`. A `floating` bar clips its
|
||||
/// controls to the room left of the panel menu button, and always shows the button.
|
||||
fn contents(app: &mut VectorcraftApp, ui: &mut Ui, t: &Tokens, bar: egui::Rect, dock_room: egui::Rect, floating: bool) {
|
||||
@@ -1043,30 +1056,22 @@ fn contents(app: &mut VectorcraftApp, ui: &mut Ui, t: &Tokens, bar: egui::Rect,
|
||||
let units = app.session.general_unit();
|
||||
let first = st.selection.objects.first().and_then(|id| st.doc.node(*id));
|
||||
let anchors = anchor_controls(app);
|
||||
let label = match first {
|
||||
_ if app.session.tool_id() == "artboard" => tl!("Artboard"),
|
||||
Some(_) if count == 1 && anchors != AnchorControls::None => {
|
||||
tl!("Anchor Point")
|
||||
}
|
||||
// The label, and whether it names one selected image.
|
||||
let (label, image) = match first {
|
||||
_ if app.session.tool_id() == "artboard" => (tl!("Artboard"), false),
|
||||
Some(_) if count == 1 && anchors != AnchorControls::None => (tl!("Anchor Point"), false),
|
||||
Some(vectorcraft_doc::Node { kind: NodeKind::Image(im), .. }) if count == 1 => {
|
||||
if im.link.is_some() {
|
||||
tl!("Linked File")
|
||||
(tl!("Linked File"), true)
|
||||
} else {
|
||||
tl!("Embedded")
|
||||
(tl!("Embedded"), true)
|
||||
}
|
||||
}
|
||||
Some(n) if count == 1 && crate::panels::image_trace::is_trace(n) => {
|
||||
tl!("Image Tracing")
|
||||
}
|
||||
_ => tl!(crate::panels::appearance::summary(app, ui.ctx()).map_or("No Selection", |s| s.label)),
|
||||
Some(n) if count == 1 && crate::panels::image_trace::is_trace(n) => (tl!("Image Tracing"), false),
|
||||
_ => (tl!(crate::panels::appearance::summary(app, ui.ctx()).map_or("No Selection", |s| s.label)), false),
|
||||
};
|
||||
let has_first = first.is_some();
|
||||
let label = egui::RichText::new(label).font(theme::semibold(12.0)).color(t.text);
|
||||
if ui.available_width() >= widgets::text_width(ui, label.clone()) {
|
||||
ui.label(label);
|
||||
} else {
|
||||
left_out(ui);
|
||||
}
|
||||
object_label(app, ui, egui::RichText::new(label).font(theme::semibold(12.0)).color(t.text), image);
|
||||
// With the Artboard tool in use, the bar shows the active artboard's controls in place
|
||||
// of the object controls.
|
||||
let (artboard_options, transform) = (group_on(app, "artboardOptions"), group_on(app, "transform"));
|
||||
|
||||
@@ -4304,6 +4304,58 @@ fn select_similar_stays_out_while_an_image_control_is_left_out() {
|
||||
assert!(seen, "a wide bar shows the button after the image's controls");
|
||||
}
|
||||
|
||||
/// A click on the Control bar's Linked File or Embedded label shows the Links panel, in an expanded
|
||||
/// dock and in one collapsed to icons; the label of any other object stays plain text.
|
||||
#[test]
|
||||
fn the_linked_file_and_embedded_labels_open_the_links_panel() {
|
||||
crate::i18n::set_current(crate::i18n::Lang::EN);
|
||||
let mut app = crate::VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 200})).unwrap();
|
||||
let img = image::RgbaImage::from_pixel(20, 20, image::Rgba([0, 0, 0, 255]));
|
||||
let mut png = vec![];
|
||||
img.write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap();
|
||||
let dir = vectorcraft_testkit::temp_dir("control-bar-image-label");
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("square.png");
|
||||
std::fs::write(&path, &png).unwrap();
|
||||
use crate::tests_removeanchors::{at, click_control, control_frame};
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let links = crate::panels::links::ID;
|
||||
// Closes the Links panel, clicks `name` on the bar and answers whether the panel shows.
|
||||
let click = |app: &mut crate::VectorcraftApp, name: &str| {
|
||||
app.run("window.panel.close", json!({"panel": links})).ok();
|
||||
app.ui.open_panel = None;
|
||||
assert!(!crate::panel_docking::visible(&app.ui, links), "{name}: the panel is closed first");
|
||||
let pos = at(&control_frame(app, &ctx, vec![]), name);
|
||||
click_control(app, &ctx, pos);
|
||||
crate::panel_docking::visible(&app.ui, links)
|
||||
};
|
||||
let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 20})).unwrap()["id"].clone();
|
||||
let linked = app.run("file.place", json!({"path": path, "link": true})).unwrap()["ids"].clone();
|
||||
let embedded = app.run("file.place", json!({"path": path, "link": false})).unwrap()["ids"].clone();
|
||||
// The default layout floats Links: dock it beside Layers so that both passes reach a docked panel.
|
||||
app.run("window.panel", json!({"panel": links})).unwrap();
|
||||
app.run("window.panel.dock", json!({"panel": links, "onto": "layers"})).unwrap();
|
||||
// Whether Links floats, and whether its dock column is collapsed to icons.
|
||||
let placed = |app: &crate::VectorcraftApp| {
|
||||
let layout = crate::panel_docking::layout_of(&app.ui);
|
||||
(layout.floating.iter().any(|w| w.panels().any(|p| p == links)), crate::panel_docking::in_iconic_column(&layout, links))
|
||||
};
|
||||
for collapsed in [false, true] {
|
||||
app.run("window.collapseDock", json!({ "collapsed": collapsed })).unwrap();
|
||||
app.run("select.set", json!({ "ids": linked })).unwrap();
|
||||
assert!(click(&mut app, "Linked File"), "collapsed {collapsed}, status: {}", app.ui.status);
|
||||
assert_eq!(placed(&app), (false, collapsed), "Links opened in its dock, collapsed {collapsed}");
|
||||
app.run("select.set", json!({ "ids": embedded })).unwrap();
|
||||
assert!(click(&mut app, "Embedded"), "collapsed {collapsed}, status: {}", app.ui.status);
|
||||
assert_eq!(placed(&app), (false, collapsed), "Links opened in its dock, collapsed {collapsed}");
|
||||
app.run("select.set", json!({ "ids": [id] })).unwrap();
|
||||
let name = crate::panels::appearance::object_label(&app);
|
||||
assert!(!click(&mut app, name), "collapsed {collapsed}: a rectangle's label opens nothing");
|
||||
}
|
||||
}
|
||||
|
||||
/// The Anchor Points group holds Convert and Anchors for direct-selected anchors; off, the bar keeps
|
||||
/// its Anchor Point label.
|
||||
#[test]
|
||||
|
||||
@@ -429,11 +429,27 @@ fn restore_hidden_group(app: &mut VectorcraftApp, panel: &str) -> Result<Value,
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// The tab in front of the group that holds `panel` in a dock column collapsed to icons.
|
||||
fn flyout_tab(layout: &Layout<String>, panel: &str) -> Option<String> {
|
||||
dock_columns(layout)
|
||||
.into_iter()
|
||||
.filter(|column| column.iconic)
|
||||
.flat_map(|column| &column.groups)
|
||||
.find(|group| group.panels.iter().any(|p| p == panel))
|
||||
.and_then(|group| group.active_panel())
|
||||
.map(|front| front.to_string())
|
||||
}
|
||||
|
||||
/// Show `panel` as `window.panel` does, but leave it be when it can be seen already ([`visible`]):
|
||||
/// a command that opens a panel to work in (Edit › Color Settings…) never puts it away. In
|
||||
/// Presentation Mode the panel comes to the front of its group and shows when the mode ends.
|
||||
/// a command that opens a panel to work in (Edit › Color Settings…) never puts it away. A flyout
|
||||
/// keeps the name of the icon that opened it after another of its tabs is clicked, so a panel whose
|
||||
/// flyout is open with another tab in front comes to the front of it. In Presentation Mode the
|
||||
/// panel comes to the front of its group and shows when the mode ends.
|
||||
pub(crate) fn reveal_panel(app: &mut VectorcraftApp, panel: &str) -> Result<Value, String> {
|
||||
if visible(&app.ui, panel) {
|
||||
if app.ui.docking.is_some() && flyout_tab(&layout_of(&app.ui), panel).is_some_and(|front| front != panel) {
|
||||
gesture(app, Action::Activate { panel: panel.to_string() })?;
|
||||
}
|
||||
return Ok(json!({"open": panel}));
|
||||
}
|
||||
let id = normalize(panel).ok_or_else(|| format!("unknown panel `{panel}`"))?;
|
||||
|
||||
@@ -397,6 +397,28 @@ fn a_collapsed_dock_uses_the_flyouts_active_tab_for_thumbnail_work() {
|
||||
assert!(!thumbnail_panel_showing(&h.app.ui, &h.ctx), "a Properties tab under the Layers icon does not need thumbnails");
|
||||
}
|
||||
|
||||
/// Revealing a panel whose flyout is open with another tab of its group in front brings that panel
|
||||
/// to the front and keeps the flyout open.
|
||||
#[test]
|
||||
fn reveal_brings_the_panel_to_the_front_of_its_open_flyout() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("window.collapseDock", json!({"collapsed": true})).unwrap();
|
||||
h.app.ui.docking = Some(layout_of(&h.app.ui));
|
||||
h.app.run("window.panel", json!({"panel": "properties"})).unwrap();
|
||||
h.frame(vec![]);
|
||||
gesture(&mut h.app, Action::Activate { panel: "layers".into() }).unwrap();
|
||||
h.frame(vec![]);
|
||||
assert_eq!(h.app.ui.open_panel.as_deref(), Some("properties"), "the flyout is still named for its opening icon");
|
||||
assert_eq!(flyout_tab(&layout_of(&h.app.ui), "properties").as_deref(), Some("layers"), "Layers is in front");
|
||||
reveal_panel(&mut h.app, "properties").unwrap();
|
||||
h.frame(vec![]);
|
||||
assert_eq!(h.app.ui.open_panel.as_deref(), Some("properties"), "the flyout stays open");
|
||||
assert_eq!(flyout_tab(&layout_of(&h.app.ui), "properties").as_deref(), Some("properties"), "Properties is in front");
|
||||
// Revealed again while in front, the panel stays as it is.
|
||||
reveal_panel(&mut h.app, "properties").unwrap();
|
||||
assert_eq!(h.app.ui.open_panel.as_deref(), Some("properties"));
|
||||
}
|
||||
|
||||
/// A Character field shortcut with the Character panel in front of its floating window brings
|
||||
/// that window forward and leaves the panel showing.
|
||||
#[test]
|
||||
|
||||
@@ -82,6 +82,26 @@ fn set_options(ctx: &egui::Context, f: impl FnOnce(&mut Options)) {
|
||||
set_pstate(ctx, "links-options", o);
|
||||
}
|
||||
|
||||
/// Show the Links panel on the selected image (the Control bar's Linked File or Embedded label),
|
||||
/// wherever the panel is docked or floats; a panel that is already shown stays where it is. The
|
||||
/// Link Info section opens, and when the panel next draws the list, a Show filter that leaves out
|
||||
/// the image's row goes back to Show All and the list scrolls to the row ([`show`]). The sort,
|
||||
/// thumbnail size and DCS option keep their settings.
|
||||
pub(crate) fn show_selected_image(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
let first = selected_images(app).first().copied();
|
||||
let request = app.session.active().map(|st| st.uid).zip(first);
|
||||
set_pstate(ctx, "links-scroll-to", request);
|
||||
// The list drawn next is read after this request, so a row a file change has just brought
|
||||
// into the Show filter is there to scroll to.
|
||||
let mut c: std::sync::Arc<Cache> = pstate(ctx, "links-cache");
|
||||
std::sync::Arc::make_mut(&mut c).at = f64::NEG_INFINITY;
|
||||
set_pstate(ctx, "links-cache", c);
|
||||
set_options(ctx, |o| o.info = true);
|
||||
if let Err(e) = crate::panel_docking::reveal_panel(app, ID) {
|
||||
app.status(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// The rows to show (cached per document revision, the files looked at again every [`RECHECK`]
|
||||
/// seconds) and the Link Info of the first selected image when the section is open. A frame that
|
||||
/// fetches nothing returns the stored cache without copying it and stores nothing.
|
||||
@@ -577,12 +597,28 @@ fn click(app: &mut VectorcraftApp, ctx: &egui::Context, rows: &[Value], id: u64,
|
||||
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let o = options(ui.ctx());
|
||||
let mut o = options(ui.ctx());
|
||||
super::layers::show_thumbs_of(app.session.active().map(|st| st.uid));
|
||||
let Some(cache) = cached(app, ui.ctx(), &o) else {
|
||||
let Some(mut cache) = cached(app, ui.ctx(), &o) else {
|
||||
widgets::dim_label(ui, tl!("No document"));
|
||||
return;
|
||||
};
|
||||
// The row that `show_selected_image` asks for, used by this draw only and only in the document
|
||||
// it was asked in. A Show filter that leaves the row out goes back to Show All, decided from the
|
||||
// rows this frame draws and scrolls through.
|
||||
let request: Option<(u64, u64)> = pstate(ui.ctx(), "links-scroll-to");
|
||||
if request.is_some() {
|
||||
set_pstate::<Option<(u64, u64)>>(ui.ctx(), "links-scroll-to", None);
|
||||
}
|
||||
let uid = app.session.active().map(|st| st.uid);
|
||||
let scroll_to = request.filter(|(doc, _)| Some(*doc) == uid).map(|(_, id)| id);
|
||||
let listed = |cache: &Cache, id: u64| cache.list["links"].as_array().is_some_and(|rows| rows.iter().any(|r| r["id"].as_u64() == Some(id)));
|
||||
if scroll_to.filter(|id| o.show != "all" && !listed(&cache, *id)).is_some() {
|
||||
set_options(ui.ctx(), |o| o.show = "all");
|
||||
o = options(ui.ctx());
|
||||
let Some(all) = cached(app, ui.ctx(), &o) else { return };
|
||||
cache = all;
|
||||
}
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let doc = st.doc.clone();
|
||||
let thumbs = super::layers::ThumbSource::of(app, st, &doc);
|
||||
@@ -606,6 +642,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
for r in rows {
|
||||
let Some(id) = r["id"].as_u64() else { continue };
|
||||
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), h), Sense::click());
|
||||
if scroll_to == Some(id) {
|
||||
ui.scroll_to_rect(rect, Some(egui::Align::Center));
|
||||
}
|
||||
if !ui.is_rect_visible(rect) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,158 @@ fn the_panel_lists_the_images_with_link_info_for_the_selected_one() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Click the flyout item `name`, checked or not (frames at `time` and just after).
|
||||
fn click_menu_item(app: &mut VectorcraftApp, ctx: &egui::Context, name: &str, time: f64) {
|
||||
let frame = |app: &mut VectorcraftApp, events: Vec<egui::Event>, time: f64| {
|
||||
super::tests_appearance::frame_raw(ctx, app, egui::RawInput { events, time: Some(time), ..Default::default() }, super::links::menu)
|
||||
};
|
||||
let texts = frame(app, vec![], time);
|
||||
let item = texts.iter().find(|(t, _)| t.trim_start_matches('✓').trim() == name);
|
||||
let at = item.unwrap_or_else(|| panic!("`{name}` not drawn: {texts:?}")).1.center();
|
||||
let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
for (i, e) in [egui::Event::PointerMoved(at), button(true), button(false)].into_iter().enumerate() {
|
||||
frame(app, vec![e], time + 0.01 * (i + 1) as f64);
|
||||
}
|
||||
}
|
||||
|
||||
/// Opening the panel on the selected image (the Control bar's Linked File or Embedded label) opens
|
||||
/// Link Info when it was closed, and sets a Show filter that leaves out the image's row back to
|
||||
/// Show All; a filter that lists the row stays.
|
||||
#[test]
|
||||
fn opening_the_panel_on_the_selected_image_shows_its_row_and_link_info() {
|
||||
let dir = Folder::new("show-selected");
|
||||
let (mut app, linked, embedded) = app(&dir);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let text = |app: &mut VectorcraftApp, time: f64| {
|
||||
let raw = egui::RawInput { time: Some(time), ..Default::default() };
|
||||
let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show);
|
||||
texts.into_iter().map(|(t, _)| t).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
app.run("select.set", json!({"ids": [linked]})).unwrap();
|
||||
click_menu_item(&mut app, &ctx, "Show Link Info", 1.0);
|
||||
click_menu_item(&mut app, &ctx, "Show Embedded", 2.0);
|
||||
let before = text(&mut app, 3.0);
|
||||
assert!(!before.contains("linked.png") && !before.contains("Location"), "the filter hides the row, Link Info is closed: {before}");
|
||||
app.run("window.panel.close", json!({"panel": super::links::ID})).ok();
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
assert!(crate::panel_docking::visible(&app.ui, super::links::ID), "status: {}", app.ui.status);
|
||||
let after = text(&mut app, 4.0);
|
||||
assert!(after.contains("linked.png") && after.contains("embedded.png"), "Show All lists every row: {after}");
|
||||
assert!(after.contains("Location") && after.contains("300 × 200 px"), "Link Info shows the linked image: {after}");
|
||||
// An embedded image under Show Embedded keeps the filter.
|
||||
app.run("select.set", json!({"ids": [embedded]})).unwrap();
|
||||
click_menu_item(&mut app, &ctx, "Show Link Info", 5.0);
|
||||
click_menu_item(&mut app, &ctx, "Show Embedded", 6.0);
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
assert!(crate::panel_docking::visible(&app.ui, super::links::ID), "an open panel stays open");
|
||||
let embedded_only = text(&mut app, 7.0);
|
||||
assert!(embedded_only.contains("embedded.png") && !embedded_only.contains("linked.png"), "Show Embedded stays: {embedded_only}");
|
||||
assert!(embedded_only.contains("Effective PPI"), "Link Info shows the embedded image: {embedded_only}");
|
||||
}
|
||||
|
||||
/// Opening the panel on the selected image scrolls the list to the image's row when it is out of
|
||||
/// view.
|
||||
#[test]
|
||||
fn opening_the_panel_on_the_selected_image_scrolls_to_its_row() {
|
||||
let dir = Folder::new("show-selected-scroll");
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
// The panel lists the image placed first last, below the list's view.
|
||||
let mut first = None;
|
||||
for i in 0..20 {
|
||||
let path = dir.file(&format!("img{i:02}.png"), &png(10, 10));
|
||||
let id = app.run("file.place", json!({"path": path, "at": [10 + 15 * i, 100]})).unwrap()["ids"][0].as_u64().unwrap();
|
||||
first.get_or_insert(id);
|
||||
}
|
||||
app.run("select.set", json!({"ids": [first]})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
// How many times the first image's name is drawn: its row while in view, and Link Info.
|
||||
let drawn = |app: &mut VectorcraftApp, time: f64| {
|
||||
let raw = egui::RawInput { time: Some(time), ..Default::default() };
|
||||
let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show);
|
||||
texts.iter().filter(|(t, _)| t == "img00.png").count()
|
||||
};
|
||||
let before = drawn(&mut app, 1.0);
|
||||
assert_eq!(drawn(&mut app, 2.0), before, "the list stays at the top");
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
// The list scrolls over the frames after the one that asks.
|
||||
for time in [3.0, 4.0, 5.0] {
|
||||
drawn(&mut app, time);
|
||||
}
|
||||
assert_eq!(drawn(&mut app, 6.0), before + 1, "the row scrolled into view");
|
||||
}
|
||||
|
||||
/// Opening the panel on the selected image draws a list read after the request, so a row that a
|
||||
/// file change brought into the Show filter since the list was last read is there to scroll to.
|
||||
#[test]
|
||||
fn opening_the_panel_on_the_selected_image_reads_the_list_again() {
|
||||
let dir = Folder::new("show-selected-fresh");
|
||||
let (mut app, linked, _) = app(&dir);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
// How many times the linked image's name is drawn: its row, and Link Info.
|
||||
let drawn = |app: &mut VectorcraftApp, time: f64| {
|
||||
let raw = egui::RawInput { time: Some(time), ..Default::default() };
|
||||
let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show);
|
||||
texts.iter().filter(|(t, _)| t == "linked.png").count()
|
||||
};
|
||||
app.run("select.set", json!({"ids": [linked]})).unwrap();
|
||||
click_menu_item(&mut app, &ctx, "Show Missing", 1.0);
|
||||
assert_eq!(drawn(&mut app, 2.0), 1, "Link Info only: nothing is missing yet");
|
||||
std::fs::remove_file(dir.0.join("linked.png")).unwrap();
|
||||
// Within the time the panel keeps its list before it looks at the files again.
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
assert_eq!(drawn(&mut app, 2.1), 2, "the missing image's row and its Link Info are drawn");
|
||||
}
|
||||
|
||||
/// The Show filter is set back to Show All from the rows the panel draws, not from the files as
|
||||
/// they were when the panel was asked to open: a missing image restored before the list is drawn
|
||||
/// still gets its row.
|
||||
#[test]
|
||||
fn opening_the_panel_on_the_selected_image_decides_the_filter_from_the_drawn_rows() {
|
||||
let dir = Folder::new("show-selected-drawn");
|
||||
let (mut app, linked, _) = app(&dir);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let drawn = |app: &mut VectorcraftApp, time: f64| {
|
||||
let raw = egui::RawInput { time: Some(time), ..Default::default() };
|
||||
let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show);
|
||||
texts.iter().filter(|(t, _)| t == "linked.png").count()
|
||||
};
|
||||
app.run("select.set", json!({"ids": [linked]})).unwrap();
|
||||
click_menu_item(&mut app, &ctx, "Show Missing", 1.0);
|
||||
let bytes = std::fs::read(dir.0.join("linked.png")).unwrap();
|
||||
std::fs::remove_file(dir.0.join("linked.png")).unwrap();
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
std::fs::write(dir.0.join("linked.png"), bytes).unwrap();
|
||||
assert_eq!(drawn(&mut app, 2.0), 2, "the restored image's row and its Link Info are drawn");
|
||||
assert_eq!(super::pstate::<Option<(u64, u64)>>(&ctx, "links-scroll-to"), None, "the scroll request is used on the row");
|
||||
}
|
||||
|
||||
/// A request to show the selected image applies only in the document it was made in: drawn for
|
||||
/// another document, the panel keeps its Show filter and drops the request.
|
||||
#[test]
|
||||
fn opening_the_panel_on_the_selected_image_leaves_another_document_alone() {
|
||||
let dir = Folder::new("show-selected-other-doc");
|
||||
let (mut app, linked, _) = app(&dir);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let text = |app: &mut VectorcraftApp, time: f64| {
|
||||
let raw = egui::RawInput { time: Some(time), ..Default::default() };
|
||||
let texts = super::tests_appearance::frame_raw(&ctx, app, raw, super::links::show);
|
||||
texts.into_iter().map(|(t, _)| t).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
app.run("select.set", json!({"ids": [linked]})).unwrap();
|
||||
click_menu_item(&mut app, &ctx, "Show Missing", 1.0);
|
||||
super::links::show_selected_image(&mut app, &ctx);
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
let other = text(&mut app, 2.0);
|
||||
assert!(other.contains("Nothing matches the Show filter."), "the other document keeps Show Missing: {other}");
|
||||
assert_eq!(super::pstate::<Option<(u64, u64)>>(&ctx, "links-scroll-to"), None, "the request is dropped");
|
||||
}
|
||||
|
||||
/// A frame that fetches nothing keeps the stored rows and Link Info as they are, without a copy; the
|
||||
/// two-second recheck, another first selected image and an edit each store a new cache.
|
||||
#[test]
|
||||
|
||||
@@ -2365,6 +2365,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Missing linked files can be looked for in a folder and its subfolders: Find in Folder… in the Linked File Not Found dialog and in the Links panel menu lists the files with each one's name, those with the size and contents saved with the link first, and relinks the files chosen, copying an image's file into the document's folder when asked, without replacing a file there (`links.findFiles`, `links.relink {copy}`). In the Links panel it looks for the selected linked files when any are selected.
|
||||
- The Links panel's Relink… opens a Relink dialog whose Replace menu picks which links take the new file: Selected Instances (the selected images, as before), All Instances (every image linked to the same file), Missing Links from This Folder (then every other missing link whose file name is in the new file's folder) and Each Link Separately (a file for each selected link in turn). Each relinks as one undo step (`links.relink {scope}`, `ui.relinkDialog`). Relink to Folder… stays as it is.
|
||||
- The Links panel menu's Copy Info ([Links panel](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-from-other-apps/links-panel-in-illustrator.html)) copies the selected link's file name to the clipboard (`links.copyInfo`). VectorCraft's own rules: with several rows selected it copies one name per line in the order the panel shows them, an embedded image gives the name its row shows, and the item is off with no row selected.
|
||||
- With one image selected, the Control bar's object label, Linked File or Embedded, is an underlined link, and a click on it opens the Links panel wherever it is docked, scrolls the list to the image's row, which shows selected, and shows the image's details in Link Info. The help page (<https://helpx.adobe.com/illustrator/using/links-info.html>) describes clicking this label for a selected linked object as a way to open the Links panel. VectorCraft's own rules: the Embedded label opens the panel too, the click opens Link Info when it was closed and scrolls the list to the row, and a Show filter that leaves out the image's row goes back to Show All; the panel's sort, thumbnail size and other options stay as they were (`the_linked_file_and_embedded_labels_open_the_links_panel`, `opening_the_panel_on_the_selected_image_shows_its_row_and_link_info`, `opening_the_panel_on_the_selected_image_scrolls_to_its_row`).
|
||||
- The Links panel menu's Unembed… works on several selected embedded images at once and writes them all to one chosen folder ([Embed and unembed images and files](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/manage-linked-and-embedded-files/embed-images-and-files.html)): it asks for a folder once, writes a file for each image there and links each image to its file in one undo step (`links.unembed {ids, folder}`). VectorCraft's own rules: each file keeps the format its image is stored in (or PNG when that format is not one of VectorCraft's raster file formats) and is named after the image, a taken name gets a number (`Name 2`) and a file already in the folder is never replaced, linked rows in the selection are left as they are, and when one image can't be written the files already written are removed and nothing is unembedded. On the web each image is downloaded instead. Evidence: `unembed_to_a_folder_writes_each_image_and_links_it_in_one_undo_step`, `unembed_to_a_folder_that_fails_leaves_no_file_and_no_change`, `unembed_writes_several_images_to_one_picked_folder`.
|
||||
- Linked files inside symbols, graph designs, patterns and opacity masks are saved with their paths relative to the document, as linked files in the layers are, so they are found after the document and its files move to another folder together; on open each of those links takes the path where its file was found. Update Links, and opening with Update Links: Automatically, read a modified file again for that art too, and saving a document refreshes its placed copies inside symbols and patterns of the other open documents. Evidence: `links_outside_the_layers_find_their_files_after_the_folder_moves`, `update_links_reads_files_again_inside_symbols_patterns_and_masks`, `saving_a_document_refreshes_its_placed_copies_inside_symbols_and_patterns`.
|
||||
- A linked file that is missing when a moved document is saved keeps the folder its relative path names, instead of a relative path worked out from the out-of-date absolute path, also for a `.ai` file another app wrote (such as `src/`), so the file is found once it is back in that folder. Evidence: `a_missing_link_keeps_its_relative_path_when_the_moved_document_is_saved`, `links_of_an_imported_file_are_found_by_their_relative_folder`, `a_missing_link_of_a_moved_document_keeps_its_relative_place`.
|
||||
|
||||
Reference in New Issue
Block a user