mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-19 00:27:49 +00:00
Merge remote-tracking branch 'origin/main' into fix/present-hidpi-detail-2127
Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
This commit is contained in:
commit
4eb45a3239
8 files changed
+192
-3
No files matched your search
@@ -121,3 +121,7 @@ sync_github_name = true
|
||||
|
||||
[people.gmrmad1]
|
||||
real_name = "Madhav Agarwal"
|
||||
|
||||
[people.Aathish-D]
|
||||
real_name = "Aathish Duraiswamy"
|
||||
sync_github_name = true
|
||||
@@ -360,6 +360,7 @@ name = "English"
|
||||
"Copy fill" = "Copy fill"
|
||||
"Copy for AI" = "Copy for AI"
|
||||
"Copy link" = "Copy link"
|
||||
"Copy link to page" = "Copy link to page"
|
||||
"Copy stroke" = "Copy stroke"
|
||||
"Copy the {label}" = "Copy the {label}"
|
||||
"Copy {value}" = "Copy {value}"
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//! A text field that isn't being edited ends a value too long for it with an ellipsis, shows the
|
||||
//! whole value on hover, and keeps it whole for screen readers (#2368: the variant value "Down
|
||||
//! left" showed as "Down lef" in a 62 px chip).
|
||||
|
||||
use egui::accesskit::Node;
|
||||
use egui::epaint::{ClippedShape, Shape};
|
||||
use egui::{Event, Pos2, pos2};
|
||||
use figcraft_doc::NodeId;
|
||||
use figcraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::component_swap_default_tests::tree;
|
||||
use crate::layers_drag_tests::Ui;
|
||||
|
||||
fn id(v: serde_json::Value) -> NodeId {
|
||||
NodeId(v["id"].as_u64().unwrap())
|
||||
}
|
||||
|
||||
/// A selected component set with a "Looking" property of `values`.
|
||||
fn set_with(values: &[&str]) -> Ui {
|
||||
let mut s = Session::new();
|
||||
let mut variants = Vec::new();
|
||||
for (k, v) in values.iter().enumerate() {
|
||||
let f = id(s.execute("frame.create", &json!({"x": 0, "y": k * 60, "width": 80, "height": 40, "name": format!("Looking={v}")})).unwrap());
|
||||
variants.push(id(s.execute("component.create", &json!({"ids": [f]})).unwrap()));
|
||||
}
|
||||
let set = id(s.execute("component.combineVariants", &json!({"ids": variants})).unwrap());
|
||||
s.execute("select.set", &json!({"ids": [set]})).unwrap();
|
||||
let u = Ui::new(s);
|
||||
u.ctx.enable_accesskit();
|
||||
u
|
||||
}
|
||||
|
||||
/// How many painted texts read `text`.
|
||||
fn count(shapes: &[String], text: &str) -> usize {
|
||||
shapes.iter().filter(|t| *t == text).count()
|
||||
}
|
||||
|
||||
/// Frames with a still pointer on `at`, long enough for egui's tooltip delay; the last one's texts.
|
||||
fn hover(u: &mut Ui, at: Pos2) -> Vec<String> {
|
||||
let mut shown = Vec::new();
|
||||
u.frame(vec![Event::PointerMoved(at)]);
|
||||
for _ in 0..90 {
|
||||
shown = texts(&u.frame_output(vec![]).shapes);
|
||||
}
|
||||
shown
|
||||
}
|
||||
|
||||
fn texts(shapes: &[ClippedShape]) -> Vec<String> {
|
||||
fn walk(s: &Shape, out: &mut Vec<String>) {
|
||||
match s {
|
||||
Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),
|
||||
Shape::Text(t) => out.push(t.galley.text().to_owned()),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
shapes.iter().for_each(|c| walk(&c.shape, &mut out));
|
||||
out
|
||||
}
|
||||
|
||||
/// The accesskit node of the value chip showing `value`.
|
||||
fn chip(nodes: &[Node], value: &str) -> Pos2 {
|
||||
let n = nodes.iter().find(|n| n.value() == Some(value) && n.bounds().is_some()).unwrap_or_else(|| panic!("a chip for {value}"));
|
||||
let b = n.bounds().unwrap();
|
||||
pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_variant_value_too_long_for_its_chip_ends_with_an_ellipsis() {
|
||||
let mut u = set_with(&["Top right", "Down left"]);
|
||||
let shown = texts(&u.frame_output(vec![]).shapes);
|
||||
let cut: Vec<&String> = shown.iter().filter(|t| t.starts_with("Down l")).collect();
|
||||
assert!(!cut.is_empty(), "the value is painted: {shown:?}");
|
||||
assert!(cut.iter().all(|t| t.ends_with('…')), "ends with an ellipsis: {cut:?}");
|
||||
assert!(!shown.iter().any(|t| t == "Down lef"), "not cut mid-letter: {shown:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_shortened_value_shows_whole_on_hover() {
|
||||
let mut u = set_with(&["Top right", "Down left"]);
|
||||
let at = chip(&tree(&mut u), "Down left");
|
||||
let before = count(&texts(&u.frame_output(vec![]).shapes), "Down left");
|
||||
let shown = hover(&mut u, at);
|
||||
assert_eq!(count(&shown, "Down left"), before + 1, "the whole value is painted again, in a tooltip: {shown:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_value_that_fits_is_shown_whole_without_a_tooltip() {
|
||||
let mut u = set_with(&["Top", "Down left"]);
|
||||
let nodes = tree(&mut u);
|
||||
let shown = texts(&u.frame_output(vec![]).shapes);
|
||||
let before = count(&shown, "Top");
|
||||
assert!(before > 0, "Top is painted as it is: {shown:?}");
|
||||
let after = hover(&mut u, chip(&nodes, "Top"));
|
||||
assert_eq!(count(&after, "Top"), before, "no tooltip repeats it: {after:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn screen_readers_keep_the_whole_value() {
|
||||
let mut u = set_with(&["Top right", "Down left"]);
|
||||
let nodes = tree(&mut u);
|
||||
assert!(nodes.iter().any(|n| n.value() == Some("Down left")), "the chip's value is the whole text");
|
||||
assert!(!nodes.iter().any(|n| n.value().is_some_and(|v| v.ends_with('…'))), "no node announces a shortened value");
|
||||
}
|
||||
@@ -4,11 +4,14 @@
|
||||
//! list (dragging pages, dividers). Rows the documentation is silent on say so and pin today's
|
||||
//! behaviour. What the gestures do to the document is in the engine's `panels_behaviour_tests`.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use egui::{Event, Id, Modifiers, Pos2};
|
||||
use figcraft_doc::NodeId;
|
||||
use figcraft_engine::Session;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Services;
|
||||
use crate::layers_drag_tests::Ui;
|
||||
|
||||
fn id(v: serde_json::Value) -> NodeId {
|
||||
@@ -687,6 +690,68 @@ fn the_page_menu_sets_the_opening_page_and_not_on_dividers() {
|
||||
assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error);
|
||||
}
|
||||
|
||||
/// Right-clicks `at` in the pages list and returns the menu's "Copy link to page" item, if shown.
|
||||
fn copy_link_item(u: &mut Ui, at: Pos2) -> Option<Pos2> {
|
||||
u.frame(vec![
|
||||
Event::PointerMoved(at),
|
||||
Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed: true, modifiers: Modifiers::NONE },
|
||||
]);
|
||||
u.frame(vec![Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed: false, modifiers: Modifiers::NONE }]);
|
||||
let shapes: Vec<egui::Shape> = u.frame_output(vec![]).shapes.into_iter().map(|c| c.shape).collect();
|
||||
crate::live_tests::has_text(&shapes, "Copy link to page").then(|| crate::live_tests::text_center(&shapes, "Copy link to page"))
|
||||
}
|
||||
|
||||
/// The pages list's menu offers "Copy link to page" on a page and not on a divider, and using it
|
||||
/// copies the page's node link to the clipboard and shows a toast without moving the viewer's page (#2379).
|
||||
#[test]
|
||||
fn the_page_menu_copies_link_to_page_and_not_on_dividers() {
|
||||
let mut s = Session::new();
|
||||
let p1 = s.page().unwrap();
|
||||
let p2 = id(s.execute("page.add", &json!({})).unwrap());
|
||||
let div = id(s.execute("page.add", &json!({"name": "-"})).unwrap());
|
||||
s.execute("page.move", &json!({"id": div, "index": 1})).unwrap();
|
||||
s.execute("page.select", &json!({"id": p1})).unwrap();
|
||||
let mut u = Ui::new(s);
|
||||
let copied = Arc::new(Mutex::new(Vec::new()));
|
||||
struct Clip(Arc<Mutex<Vec<String>>>);
|
||||
impl Services for Clip {
|
||||
fn clipboard_set_text(&mut self, s: &str) {
|
||||
self.0.lock().unwrap().push(s.to_string());
|
||||
}
|
||||
}
|
||||
u.app.services = Box::new(Clip(copied.clone()));
|
||||
let (r1, r2) = (page_row(&mut u, p1, p2), page_row(&mut u, p2, p1));
|
||||
let mid = Pos2::new(r1.x, (r1.y + r2.y) / 2.0);
|
||||
u.app.session.execute("page.select", &json!({"id": p1})).unwrap();
|
||||
u.frame(vec![]);
|
||||
|
||||
// A divider has no "Copy link to page" menu item.
|
||||
assert_eq!(copy_link_item(&mut u, mid), None, "a divider has no such item");
|
||||
u.frame(vec![Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }]);
|
||||
for _ in 0..5 {
|
||||
u.frame(vec![]);
|
||||
}
|
||||
|
||||
// A normal page has "Copy link to page".
|
||||
let item = copy_link_item(&mut u, r2).expect("a page has the item (and its menu is open)");
|
||||
u.frame(vec![Event::PointerMoved(item)]);
|
||||
u.button(item, true);
|
||||
u.button(item, false);
|
||||
for _ in 0..3 {
|
||||
u.frame(vec![]);
|
||||
}
|
||||
|
||||
// Checks:
|
||||
// 1. Link format is `figcraft://node/<p2_id>`
|
||||
assert_eq!(*copied.lock().unwrap(), vec![format!("figcraft://node/{}", p2.0)]);
|
||||
// 2. Toast "Link copied" is shown
|
||||
assert_eq!(u.app.ui.toast.as_ref().map(|t| t.0.as_str()), Some("Link copied"));
|
||||
// 3. Document opening page and viewer's current page are unaffected
|
||||
assert_ne!(u.app.session.doc().unwrap().current_page, Some(p2));
|
||||
assert_eq!(u.app.session.page().unwrap(), p1);
|
||||
assert!(u.app.ui.last_error.is_none(), "{:?}", u.app.ui.last_error);
|
||||
}
|
||||
|
||||
/// The y of the line between the pages and the layers, above the layers' row at `layer` (found by
|
||||
/// the resize cursor it shows when hovered).
|
||||
fn pages_edge_at(u: &mut Ui, layer: f32) -> f32 {
|
||||
|
||||
@@ -110,6 +110,8 @@ mod export_name_tests;
|
||||
#[cfg(test)]
|
||||
mod export_preview_tests;
|
||||
#[cfg(test)]
|
||||
mod field_ellipsis_tests;
|
||||
#[cfg(test)]
|
||||
mod field_tests;
|
||||
#[cfg(test)]
|
||||
mod font_menu_regrow_tests;
|
||||
|
||||
@@ -333,6 +333,12 @@ fn pages(app: &mut FigApp, ui: &mut Ui) {
|
||||
}
|
||||
ui.close();
|
||||
}
|
||||
// Copy link to page (#2379); a divider can't be linked.
|
||||
if !divider && ui.button(tr("Copy link to page")).clicked() {
|
||||
app.clipboard_set_text(&format!("figcraft://node/{}", id.0));
|
||||
app.toast(tr("Link copied"));
|
||||
ui.close();
|
||||
}
|
||||
// The page the file opens on, for everyone (#1817); a divider can't be one.
|
||||
if !divider && ui.button(tr("Set as opening page")).clicked() {
|
||||
if !crate::menus::dev_mode_refuses(app, "page.setOpening") {
|
||||
|
||||
@@ -718,9 +718,14 @@ fn text_field_in(ui: &mut Ui, id: Id, value: &str, rect: Rect, placeholder: &str
|
||||
}
|
||||
None => {
|
||||
let (s, col) = if value.is_empty() { (placeholder, t.text_tertiary) } else { (&*shown, t.text) };
|
||||
// Long text stays inside the field.
|
||||
// Long text ends in an ellipsis inside the field; hovering shows the whole value (not
|
||||
// of a secret one: that is a key).
|
||||
let fitted = elide(ui, s, rect.width() - 16.0);
|
||||
let painter = ui.painter().with_clip_rect(rect.shrink2(vec2(8.0, 0.0)));
|
||||
painter.text(pos2(rect.min.x + 8.0, rect.center().y), Align2::LEFT_CENTER, s, regular(11.0), col);
|
||||
painter.text(pos2(rect.min.x + 8.0, rect.center().y), Align2::LEFT_CENTER, &fitted, regular(11.0), col);
|
||||
if fitted != s && !secret && !value.is_empty() {
|
||||
resp.on_hover_text(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
|
||||
@@ -22,7 +22,7 @@ accounts).
|
||||
| A component can't contain its own instance, directly or through other components | done | refused with the loop named (creating, placing, swapping, switching variants, moving, pasting, an instance-swap value); each variant counts as its own component, so a variant may hold a sibling variant's instance unless that one leads back to it; a dropped instance lands on the page; a file holding a loop opens with one instance detached and a note, any other file unchanged; a loop merged in a live session stops expanding where an instance would show itself again (#1084) |
|
||||
| Switching variants keeps overrides where names match and both variants had the same value; text layers keep theirs | done | |
|
||||
| Default variant: the top-left one (new instances, Assets thumbnail, generated code) | done | |
|
||||
| Variant property order (names rewritten), duplicate combinations reported | done | drag a property in the Properties section to reorder it, one undo step (#679), or `component.editProperty {index}` |
|
||||
| Variant property order (names rewritten), duplicate combinations reported | done | drag a property in the Properties section to reorder it, one undo step (#679), or `component.editProperty {index}`; a variant value too long for its field ends with an ellipsis and shows whole on hover (#2368) |
|
||||
| Properties: boolean, text, instance swap (preferred values), variant | done | listed in the order they were made, a rename keeping the place (#1536; the shared ones don't reorder by drag yet); every component menu scrolls past 320 pt, the default of an instance-swap property's too (#1338); the instance-swap menus (an instance's property and swap menus, a property's default, the playground) open with a search field that filters by name as you type, with Up, Down and Enter to pick and Escape to clear then close; the slot and preferred components menus have no search yet; an instance lists the properties its variant's layers use, so a set with one text property per variant shows one text field per instance (#2022; measured in Figma's web app, 2026-11-11); long names are cut to one line, the full name on hover |
|
||||
| Slots (preferred components, fill menu, kept across updates) | done | Figma 2025 feature; Make slot asks for the name first (a field under the frame's Slot row), and slots are renamed in the component's Properties list (#1537); no rename with only the slot's frame selected yet |
|
||||
| Exposed nested instances | done | hidden ones hide their properties |
|
||||
@@ -80,6 +80,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-18 | patch | M3, #2368: a text field that isn't being edited ends a value too long for it with an ellipsis and shows the whole value on hover (a secret field shows none), so the variant value "Down left" no longer reads "Down lef"; screen readers and editing keep the whole value (`field_ellipsis_tests`). Grade unchanged. |
|
||||
| 2026-11-14 | patch | M3, #2354: the Local variables window resizes from its edges and corners, width and height (minimum 600 x 240), and keeps its size and place while the app runs. |
|
||||
| 2026-11-07 | patch | M3, #2090: an instance's own resizing follows its main's unless its size is overridden. Measured in Figma: a plain instance turns Fixed when its main's width does (a child set to Fill along it) and back to Hug with it; an instance whose width was typed keeps it; Fill in its own auto layout parent is kept. Tests: `components_behaviour_tests::a_plain_instances_resizing_follows_the_mains_root_both_ways` and the instance resizing tests beside it. |
|
||||
| 2026-11-13 | patch | Rows that recent merges had duplicated or garbled are merged back into one row each (no behaviour change): Create component, instances, detach, reset, go to main, restore main, push changes. |
|
||||
|
||||
Reference in new issue
Block a user