int mouse_hook(int button, int x, int y, t_env *env) { double x_calc; double y_calc; if (button == 1) { env->zoom += 1 * env->ratio; x_calc = (double)(SCREEN_X / 2 - x) / 12.5; y_calc = (double)(SCREEN_Y / 2 - y) / 25; env->move_x += (double)-(x_calc / env->zoom / 10); env->move_y += (double)-(y_calc / env->zoom / 10); } else if (button == 3) { env->zoom -= 1 * env->ratio; if (env->zoom <= 0) env->zoom = 1; x_calc = (double)(SCREEN_X / 2 - x) / 12.5; y_calc = (double)(SCREEN_Y / 2 - y) / 25; env->move_x += (double)-(x_calc / env->zoom / 10); env->move_y += (double)-(y_calc / env->zoom / 10); } else mouse_hook_bis(button, x, y, env); expose_hook(env); return (0); }
int mouse_hook(int button, int x, int y, void *data) { if (button == M_PLUS) key_zoom_in((t_data *)data); else if (button == M_MINUS) key_zoom_out((t_data *)data); else if (button == M_RETURN) key_return((t_data *)data); else if (button == L_CLICK && x < W_WIDTH / 3 && y > W_HEIGHT / 3 && y < W_HEIGHT * 2 / 3) key_trans(LARROW, (t_data *)data); else if (button == L_CLICK && x > W_WIDTH * 2 / 3 && y > W_HEIGHT / 3 && y < W_HEIGHT * 2 / 3) key_trans(RARROW, (t_data *)data); else if (button == L_CLICK && y < W_HEIGHT / 3 && x > W_WIDTH / 3 && x < W_WIDTH * 2 / 3) key_trans(UARROW, (t_data *)data); else if (button == L_CLICK && y > W_HEIGHT * 2 / 3 && x > W_WIDTH / 3 && x < W_WIDTH * 2 / 3) key_trans(DARROW, (t_data *)data); else mouse_hook_bis(button, x, y, data); return (1); }