Repository navigation
Expand file tree
/
Copy pathcontroller.c
More file actions
88 lines (81 loc) · 2.14 KB
/
Copy pathcontroller.c
File metadata and controls
88 lines (81 loc) · 2.14 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* controller.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fdeclerc <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/12 13:25:07 by fdeclerc #+# #+# */
/* Updated: 2017/01/22 15:39:21 by fdeclerc ### ########.fr */
/* */
/* ************************************************************************** */
#include "fdf.h"
int ft_init_expose(t_coord *e)
{
ft_init_pixel(e);
ft_init_x(e);
ft_init_y(e);
return (0);
}
int ft_arrow_key(int keycode, t_coord *e)
{
if (keycode == 126)
{
e->move_y = e->move_y - 30;
mlx_clear_window(e->mlx, e->win);
ft_init_expose(e);
}
if (keycode == 53)
exit(0);
return (0);
}
int ft_arrow_key_end(int keycode, t_coord *e)
{
int i;
i = e->length;
if (keycode == 123)
{
e->move_x = e->move_x - 30;
mlx_clear_window(e->mlx, e->win);
ft_init_expose(e);
}
if (keycode == 124)
{
e->move_x = e->move_x + 30;
mlx_clear_window(e->mlx, e->win);
ft_init_expose(e);
}
if (keycode == 125)
{
e->move_y = e->move_y + 30;
mlx_clear_window(e->mlx, e->win);
ft_init_expose(e);
}
ft_arrow_key(keycode, e);
return (0);
}
int ft_mouse_key(int button, int x, int y, t_coord *e)
{
int i;
i = e->length;
x = y;
if (button == 1)
{
e->zoom = e->zoom + 5;
if (e->zoom == 100)
e->zoom = 95;
mlx_clear_window(e->mlx, e->win);
e->value = ft_coord_base(e->t_value, e->length, e->width, e);
ft_init_expose(e);
}
if (button == 2)
{
e->zoom -= 5;
if (e->zoom == -35)
e->zoom = -30;
mlx_clear_window(e->mlx, e->win);
e->value = ft_coord_base(e->t_value, e->length, e->width, e);
ft_init_expose(e);
}
return (0);
}