{
"id": "166",
"prompt": "Two-panel dashboard hosting OTHER subdomains' published cartridges side by side: spawn_module(\"clock\", ...) and spawn_module(\"ticker\", ...) into two rects, both handles latched in state slots (spawning every frame would blow the compose budget). A click inside a panel gives that child focus with focus_module so it receives pointer input; a click anywhere else hands focus back with focus_module(-1). Read focused() each frame to paint the focused panel's border green, show per-panel LOADING/FAILED from status(), and print module_count().",
"solution_rl": "fn frame(t: i32) {\n host::display::clear(0x0c0c0c);\n host::display::draw_string(8, 8, \"DASHBOARD\", 0xffffff, 2);\n if host::display::state_get(0) == 0 {\n host::display::state_set(0, 1);\n host::display::state_set(1, host::compose::spawn_module(\"clock\", 16, 60, 224, 168));\n host::display::state_set(2, host::compose::spawn_module(\"ticker\", 272, 60, 224, 168));\n }\n let a: i32 = host::display::state_get(1);\n let b: i32 = host::display::state_get(2);\n if host::display::pointer_down() == 1 {\n let px: i32 = host::display::pointer_x();\n let py: i32 = host::display::pointer_y();\n if py >= 60 && py < 228 && px >= 16 && px < 240 {\n host::compose::focus_module(a);\n } else {\n if py >= 60 && py < 228 && px >= 272 && px < 496 {\n host::compose::focus_module(b);\n } else {\n host::compose::focus_module(-1);\n }\n }\n }\n let f: i32 = host::compose::focused();\n let mut ca: i32 = 0x303030;\n if f == a { ca = 0x00ff66; }\n let mut cb: i32 = 0x303030;\n if f == b { cb = 0x00ff66; }\n host::display::fill_rect(12, 56, 232, 2, ca);\n host::display::fill_rect(12, 230, 232, 2, ca);\n host::display::fill_rect(12, 56, 2, 176, ca);\n host::display::fill_rect(242, 56, 2, 176, ca);\n host::display::fill_rect(268, 56, 232, 2, cb);\n host::display::fill_rect(268, 230, 232, 2, cb);\n host::display::fill_rect(268, 56, 2, 176, cb);\n host::display::fill_rect(498, 56, 2, 176, cb);\n if host::compose::status(a) == 0 { host::display::draw_string(24, 130, \"LOADING\", 0xffff00, 1); }\n if host::compose::status(a) == 2 { host::display::draw_string(24, 130, \"FAILED\", 0xff0000, 1); }\n if host::compose::status(b) == 0 { host::display::draw_string(280, 130, \"LOADING\", 0xffff00, 1); }\n if host::compose::status(b) == 2 { host::display::draw_string(280, 130, \"FAILED\", 0xff0000, 1); }\n host::display::draw_number(8, 40, host::compose::module_count(), 0x808080, 1);\n host::display::present();\n}\n",
"tags": [
"compose",
"state",
"pointer"
]
}