mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-18 08:07:26 +00:00
Present mode: a click on the draft's own pin keeps the typed draft (#2209)
The pin isn't interactable, so the click fell through and started a new draft. Review item on #2211. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Model-Effort: Opus 5.5 drove and wrote (review fix, no brief)
This commit is contained in:
1 parent
fba314a340
commit
205fb12075
2 files changed
+16
-1
No files matched your search
@@ -1241,8 +1241,11 @@ pub fn presenter(app: &mut FigApp, ctx: &egui::Context, frame: NodeId, place: cr
|
||||
// presented point back to the frame as designed.
|
||||
let frame_rect = place.rect(fb).intersect(clip);
|
||||
let click = ctx.input(|i| if i.pointer.primary_clicked() { i.pointer.interact_pos() } else { None });
|
||||
// The draft's own pin isn't interactable, so a click on it would start a new draft and lose
|
||||
// the typed text: it is left alone.
|
||||
let draft_pin = app.ui.comments.draft.as_ref().map(|(x, y, _)| pin_rect(to_screen((*x, *y))));
|
||||
if clicked.is_none()
|
||||
&& let Some(q) = click.filter(|q| frame_rect.contains(*q))
|
||||
&& let Some(q) = click.filter(|q| frame_rect.contains(*q) && !draft_pin.is_some_and(|r| r.contains(*q)))
|
||||
&& ctx.layer_id_at(q).is_none_or(|l| l.order == egui::Order::Background)
|
||||
{
|
||||
let pt = place.page(q);
|
||||
|
||||
@@ -307,6 +307,18 @@ fn a_click_in_the_presenters_comment_mode_adds_a_comment_on_the_frame() {
|
||||
assert!(u.app.ui.present.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_click_on_the_presenters_draft_pin_keeps_the_typed_draft() {
|
||||
let (mut u, _, _, frame_min) = present_comment_mode();
|
||||
let at = frame_min + vec2(120.0, 90.0);
|
||||
click(&mut u, at);
|
||||
u.frame(vec![Event::Text("typed".into())]);
|
||||
// The pin's body sits above and right of the point it marks.
|
||||
click(&mut u, at + vec2(6.0, -6.0));
|
||||
let draft = u.app.ui.comments.draft.clone();
|
||||
assert_eq!(draft.as_ref().map(|d| d.2.as_str()), Some("typed"), "the draft stays open with its text: {draft:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_click_off_the_frame_in_the_presenters_comment_mode_adds_no_draft() {
|
||||
let (mut u, _, _, frame_min) = present_comment_mode();
|
||||
|
||||
Reference in new issue
Block a user