; ; @ANO_SCRIPT_NAME gui_draw_block ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Simple thread drawing moving block ; ; @ANO_FLAGS_USE_PROTOS [ ] ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2026, Jani Salonen ; All rights reserved. ; ; Example to draw a block to window which follows mouse movement. Nothing ; really interesting here. ; main { ; Global pre-initialized variables. ; mov color ("cyanwhite") mov pos_x ([int] 0) mov pos_y ([int] 0) mov set_w ([int] 64) mov set_h ([int] 64) ; Initialize windowing system... ; gui_enabled { window_init ; ...and open main window. ; window_open (\ title_name: "Drawing window", \ title_charset: NULL, \ flags: 0, \ parent_handle: NOPARENT, \ widget_stack_id: NOWIDGET, \ widget_set: 0, \ window_refresh_divider: ACTIVE_REFRESH, \ position_x: POS_CENTERED, \ position_y: POS_CENTERED, \ size_width: 600, \ size_height: 300, \ cb_main_loop: "cb_mainloop", \ cb_expose: NULL, \ cb_key_press: NULL, \ cb_key_release: NULL, \ cb_button_press: NULL, \ cb_button_release: NULL, \ cb_client_message: NULL, \ cb_save_yourself: NULL, \ cb_configure_notify: NULL, \ cb_destroy_notify: "cb_destroy", \ cb_motion_notify: "cb_motion", \ cb_map_notify: NULL, \ cb_unmap_notify: NULL, \ cb_open_notify: "cb_open") } ; No exit here as callbacks are taking over when main process is done. } _WINCB_MAINLOOP_ callback cb_mainloop (_hnd) { ; Clear window... ; draw_wipe (_hnd) ; ...and draw simple block where the pointer is. ; draw_set (_hnd, \ pos_x, pos_y, pos_x + set_w, pos_y + set_h, color) } _WINCB_OPEN_ callback cb_open (_hnd) { _hnd.map() } _WINCB_DESTROY_ callback cb_destroy (_hnd) { _hnd.destroy() exit } _WINCB_MOTION_ callback cb_motion (_hnd, \ _x, _y, _x_root, _y_root, _state, _detail) { ; Update block coordinates. ; mov pos_x (_x - (set_w / 2)) mov pos_y (_y - (set_h / 2)) }