int key_hook(int keycode, t_all *all) { if (keycode == 65307) all->re = -1; if (keycode == 65362) move_down(all); if (keycode == 65364) move_up(all); if (keycode == 65361) move_right(all); if (keycode == 65363) move_left(all); if (keycode == 65451) alt_up(all); if (keycode == 65453) alt_down(all); if (keycode == 65465) adj_down(all); if (keycode == 65462) adj_up(all); if (keycode == 65421) ft_all_init(all); return (0); }
int PerspectiveCanvas::button_press_event() { if(is_event_win() && cursor_inside()) { // Set current point int x1, y1, x2, y2, x3, y3, x4, y4; int cursor_x = get_cursor_x(); int cursor_y = get_cursor_y(); plugin->thread->window->calculate_canvas_coords(x1, y1, x2, y2, x3, y3, x4, y4); float distance1 = DISTANCE(cursor_x, cursor_y, x1, y1); float distance2 = DISTANCE(cursor_x, cursor_y, x2, y2); float distance3 = DISTANCE(cursor_x, cursor_y, x3, y3); float distance4 = DISTANCE(cursor_x, cursor_y, x4, y4); // printf("PerspectiveCanvas::button_press_event %f %d %d %d %d\n", // distance3, // cursor_x, // cursor_y, // x3, // y3); float min = distance1; plugin->config.current_point = 0; if(distance2 < min) { min = distance2; plugin->config.current_point = 1; } if(distance3 < min) { min = distance3; plugin->config.current_point = 2; } if(distance4 < min) { min = distance4; plugin->config.current_point = 3; } if(plugin->config.mode == AffineEngine::SHEER) { if(plugin->config.current_point == 1) plugin->config.current_point = 0; else if(plugin->config.current_point == 2) plugin->config.current_point = 3; } start_cursor_x = cursor_x; start_cursor_y = cursor_y; if(alt_down() || shift_down()) { if(alt_down()) state = PerspectiveCanvas::DRAG_FULL; else state = PerspectiveCanvas::ZOOM; // Get starting positions start_x1 = plugin->config.x1; start_y1 = plugin->config.y1; start_x2 = plugin->config.x2; start_y2 = plugin->config.y2; start_x3 = plugin->config.x3; start_y3 = plugin->config.y3; start_x4 = plugin->config.x4; start_y4 = plugin->config.y4; } else { state = PerspectiveCanvas::DRAG; // Get starting positions start_x1 = plugin->get_current_x(); start_y1 = plugin->get_current_y(); } plugin->thread->window->update_coord(); plugin->thread->window->update_canvas(); return 1; } return 0; }