/** * This function stops an ongoing drag operation. Do not call this unless * dragging has been started with wtk_start_drag() first. This function erases * the drag handles and frees any allocated memory. * * \param last_pos Last position, as for wtk_continue_drag(). */ static void wtk_stop_drag(struct win_point const *last_pos) { /* Don't do any graphics if we did not get memory when drag started. */ if (!wtk_drag_origin_pixmap || !wtk_drag_target_pixmap) { return; } /* Make sure we can draw on the entire screen, since dragging is not * necessarily limited to within one window. */ gfx_set_clipping(0, 0, gfx_get_width() - 1, gfx_get_height() - 1); /* Restore screen underneath drag origin symbol. */ gfx_put_pixmap(wtk_drag_origin_pixmap, WTK_DRAG_PIXMAP_SIZE, 0, 0, wtk_drag_origin.x - WTK_DRAG_HANDLE_RADIUS, wtk_drag_origin.y - WTK_DRAG_HANDLE_RADIUS, WTK_DRAG_PIXMAP_SIZE, WTK_DRAG_PIXMAP_SIZE); /* Restore screen underneath drag target symbol. */ gfx_put_pixmap(wtk_drag_target_pixmap, WTK_DRAG_PIXMAP_SIZE, 0, 0, last_pos->x - WTK_DRAG_HANDLE_RADIUS, last_pos->y - WTK_DRAG_HANDLE_RADIUS, WTK_DRAG_PIXMAP_SIZE, WTK_DRAG_PIXMAP_SIZE); /* Free memory when not dragging. */ membag_free(wtk_drag_origin_pixmap); membag_free(wtk_drag_target_pixmap); }
/** * This function updated the drag target handle graphics. Call this function * from the MOVE event handler of the dragging widget. This function needs * both the current position and the last used position. The last position will * be either the position handed to wtk_start_drag() or the "pos" parameter of * the last call to wtk_continue_drag(). The pointer event struct will keep this * value for you. No need to store it yourself. * * \param last_pos Last position. * \param pos Current position. */ static void wtk_continue_drag(struct win_point const *last_pos, struct win_point const *pos) { /* Don't do any graphics if we did not get memory when drag started. */ if (!wtk_drag_origin_pixmap || !wtk_drag_target_pixmap) { return; } /* Make sure we can draw on the entire screen, since dragging is not * necessarily limited to within one window. */ gfx_set_clipping(0, 0, gfx_get_width() - 1, gfx_get_height() - 1); /* Restore screen underneath drag target symbol. */ gfx_put_pixmap(wtk_drag_target_pixmap, WTK_DRAG_PIXMAP_SIZE, 0, 0, last_pos->x - WTK_DRAG_HANDLE_RADIUS, last_pos->y - WTK_DRAG_HANDLE_RADIUS, WTK_DRAG_PIXMAP_SIZE, WTK_DRAG_PIXMAP_SIZE); /* Store screen underneath and draw new drag target symbol. */ gfx_get_pixmap(wtk_drag_target_pixmap, WTK_DRAG_PIXMAP_SIZE, 0, 0, pos->x - WTK_DRAG_HANDLE_RADIUS, pos->y - WTK_DRAG_HANDLE_RADIUS, WTK_DRAG_PIXMAP_SIZE, WTK_DRAG_PIXMAP_SIZE); gfx_draw_filled_circle(pos->x, pos->y, WTK_DRAG_HANDLE_RADIUS, WTK_DRAG_TARGET_COLOR, GFX_WHOLE); }
/** * \brief Load file data directly to screen worker * * This worker function puts the data fetched from the file system directly to * the screen. * * \param task Pointer to the current work queue task */ static void load_to_screen_worker(struct workqueue_task *task) { struct file_loader *floader = &the_file_loader; enum status_code result; gfx_set_clipping(0, 0, gfx_get_width(), gfx_get_height()); gfx_put_pixmap((gfx_color_t *)floader->buffer, floader->load_size, 0, 0, floader->current_x + floader->offset_x, floader->current_y + floader->offset_y, floader->load_size, 1); floader->current_x += floader->load_size; if (floader->current_x >= floader->width) { floader->current_y++; floader->current_x = 0; } floader->load_size = min_u((floader->width - floader->current_x), MAX_LOAD_PIXELS); result = tsfs_read(&myfs, &floader->file, &floader->buffer, floader->load_size * sizeof(gfx_color_t), &floader->task); // If file we are done, run the image done task if ((result != STATUS_OK) || (floader->current_y > floader->height)) { floader->busy = false; if (floader->done_task) workqueue_add_task(&main_workqueue, floader->done_task); } }