-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse.c
48 lines (44 loc) · 1.45 KB
/
mouse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* mouse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aelsayed <aelsayed@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/18 20:03:14 by aelsayed #+# #+# */
/* Updated: 2025/02/10 13:30:12 by aelsayed ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
int mouse_press(int button, int x, int y, t_all *var)
{
if (button == 1)
{
var->scale.x_ms = x;
var->scale.y_ms = y;
var->scale.mouse_pressed = 1;
}
return (0);
}
int mouse_release(int button, int x, int y, t_all *var)
{
if (button == 1)
{
(void)x;
(void)y;
var->scale.mouse_pressed = 0;
}
return (0);
}
int mouse_move(int x, int y, t_all *var)
{
if (var->scale.mouse_pressed)
{
var->scale.x_offset += x - var->scale.x_ms;
var->scale.y_offset += y - var->scale.y_ms;
var->scale.x_ms = x;
var->scale.y_ms = y;
draw(var);
}
return (0);
}