{
"id": "110",
"prompt": "A destructive action needs a confirm dialog: normally show a DELETE FILE button and a deleted counter. Clicking it opens a modal - darkened background, bordered centered panel asking ARE YOU SURE? with YES and NO buttons - and while the modal is open the underlying button must not be clickable (branch every hit-test on the modal flag kept in a state slot). YES increments the counter and closes, NO just closes. Edge-detect every click.",
"solution_rl": "fn frame(t: i32) {\n let w: i32 = host::display::width();\n let h: i32 = host::display::height();\n let down: i32 = host::display::pointer_down();\n let prev: i32 = host::display::state_get(2);\n let px: i32 = host::display::pointer_x();\n let py: i32 = host::display::pointer_y();\n let mut open: i32 = host::display::state_get(0);\n let mut count: i32 = host::display::state_get(1);\n let mx: i32 = w / 2 - 110;\n let my: i32 = h / 2 - 70;\n if down == 1 && prev == 0 {\n if open == 0 {\n if px >= 40 && px < 180 && py >= 60 && py < 104 {\n open = 1;\n }\n } else {\n if px >= mx + 20 && px < mx + 100 && py >= my + 80 && py < my + 116 {\n count = count + 1;\n host::display::state_set(1, count);\n open = 0;\n }\n if px >= mx + 120 && px < mx + 200 && py >= my + 80 && py < my + 116 {\n open = 0;\n }\n }\n host::display::state_set(0, open);\n }\n host::display::state_set(2, down);\n if open == 1 {\n host::display::clear(0x080808);\n host::display::fill_rect(mx - 3, my - 3, 226, 146, 0x606060);\n host::display::fill_rect(mx, my, 220, 140, 0x181820);\n host::display::draw_string(mx + 30, my + 30, \"ARE YOU SURE?\", 0xffffff, 2);\n host::display::fill_rect(mx + 20, my + 80, 80, 36, 0x882222);\n host::display::draw_string(mx + 40, my + 92, \"YES\", 0xffffff, 1);\n host::display::fill_rect(mx + 120, my + 80, 80, 36, 0x304050);\n host::display::draw_string(mx + 146, my + 92, \"NO\", 0xffffff, 1);\n } else {\n host::display::clear(0x101014);\n host::display::fill_rect(40, 60, 140, 44, 0x882222);\n host::display::draw_string(58, 76, \"DELETE FILE\", 0xffffff, 1);\n host::display::draw_string(40, 130, \"DELETED\", 0x808080, 1);\n host::display::draw_number(110, 130, count, 0xffffff, 2);\n }\n host::display::present();\n}\n",
"tags": [
"ui",
"pointer",
"state",
"modal"
]
}