diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/button.c | 30 | ||||
-rw-r--r-- | test/gui/group.c | 39 | ||||
-rw-r--r-- | test/gui/pictureframe.c | 110 | ||||
-rw-r--r-- | test/gui/window.c | 15 | ||||
-rw-r--r-- | test/morpher/quadrilateral.c | 1 |
5 files changed, 195 insertions, 0 deletions
diff --git a/test/gui/button.c b/test/gui/button.c new file mode 100644 index 0000000..df3e04d --- /dev/null +++ b/test/gui/button.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <gui/group.h> | ||
2 | #include <gui/window.h> | ||
3 | #include <gui/button.h> | ||
4 | #include <gui/component.h> | ||
5 | #include "MLV/MLV_all.h" | ||
6 | |||
7 | |||
8 | static void test_button() { | ||
9 | /* Window window; | ||
10 | window_init(&window, 1000, 512, "Coucou"); | ||
11 | window_create(&window); | ||
12 | Button button1; | ||
13 | button_init(&button1, "OK", 10, 500, 256, button_click_test); | ||
14 | button1.component.print_method(&button1); | ||
15 | int mouse_x; | ||
16 | int mouse_y; | ||
17 | while (1) { | ||
18 | if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { | ||
19 | MLV_get_mouse_position(&mouse_x, &mouse_y); | ||
20 | button1.component.click_handler(mouse_x, mouse_y, &(button1.component)); | ||
21 | } | ||
22 | }*/ | ||
23 | /*MLV_wait_seconds(10); | ||
24 | window_free(&window);*/ | ||
25 | } | ||
26 | |||
27 | int main() { | ||
28 | test_button(); | ||
29 | return 0; | ||
30 | } \ No newline at end of file | ||
diff --git a/test/gui/group.c b/test/gui/group.c new file mode 100644 index 0000000..7dbf80c --- /dev/null +++ b/test/gui/group.c | |||
@@ -0,0 +1,39 @@ | |||
1 | #include <gui/group.h> | ||
2 | #include <gui/window.h> | ||
3 | #include "MLV/MLV_all.h" | ||
4 | |||
5 | |||
6 | static void test_group() { | ||
7 | /*Window window; | ||
8 | window_init(&window, 1000, 512, "Coucou"); | ||
9 | window_create(&window); | ||
10 | |||
11 | Button button1; | ||
12 | Button button2; | ||
13 | Button button3; | ||
14 | |||
15 | button_init(&button1, "OK", 10, 500, 256, button_click_test); | ||
16 | button_init(&button2,"Bouton magique",10, 500,290, button_click_test); | ||
17 | button_init(&button3,"Très lonnggggg boooouttttooooon",10,0,0,button_click_test); | ||
18 | |||
19 | window_add_button(&window,&button1); | ||
20 | window_add_button(&window,&button2); | ||
21 | window_add_button(&window,&button3); | ||
22 | |||
23 | window_print_buttons(&window); | ||
24 | int mouse_x; | ||
25 | int mouse_y; | ||
26 | while(1){ | ||
27 | if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { | ||
28 | MLV_get_mouse_position(&mouse_x, &mouse_y); | ||
29 | group_click_handler(mouse_x,mouse_y,&(window.group_buttons->component)); | ||
30 | } | ||
31 | } | ||
32 | MLV_wait_seconds(15); | ||
33 | window_free(&window);*/ | ||
34 | } | ||
35 | |||
36 | int main() { | ||
37 | test_group(); | ||
38 | return 0; | ||
39 | } \ No newline at end of file | ||
diff --git a/test/gui/pictureframe.c b/test/gui/pictureframe.c new file mode 100644 index 0000000..2dcbec6 --- /dev/null +++ b/test/gui/pictureframe.c | |||
@@ -0,0 +1,110 @@ | |||
1 | #include "gui/component.h" | ||
2 | #include <gui/group.h> | ||
3 | #include <gui/window.h> | ||
4 | #include <gui/button.h> | ||
5 | #include <gui/pictureframe.h> | ||
6 | #include <painter/rasterizer.h> | ||
7 | #include "MLV/MLV_all.h" | ||
8 | |||
9 | extern Mode mode; | ||
10 | |||
11 | static void test_pictureframe() { | ||
12 | Window window; | ||
13 | window_init(&window, 1005, 512, "Coucou"); | ||
14 | window_create(&window); | ||
15 | |||
16 | Button button1; | ||
17 | Button button2; | ||
18 | Button button3; | ||
19 | Button button4; | ||
20 | Button button5; | ||
21 | Button button6; | ||
22 | Button button7; | ||
23 | |||
24 | PictureFrame pictureFrame1; | ||
25 | PictureFrame pictureFrame2; | ||
26 | |||
27 | Morphing *morphing = morphing_create(500, 250); | ||
28 | Canvas *canvasSrc = canvas_create_from_image("/home/adam/Images/goku.png"); | ||
29 | Canvas *canvasTarget = canvas_create_from_image("/home/adam/Images/marty.jpg"); | ||
30 | |||
31 | int i; | ||
32 | |||
33 | sprintf(labelFrame, "%03d frames", frame); | ||
34 | button_init(&button1, "Add constraint point", 10, 0, 0, button_click_add_constraint); | ||
35 | button_init(&button2, "Show/Hide", 10, 0, 0, button_click_show_hide); | ||
36 | button_init(&button3, "Start rendering", 10, 0, 0, button_click_rendering); | ||
37 | button_init(&button4, "<<<", 10, 0, 0, button_click_less_frame); | ||
38 | button_init(&button5, labelFrame, 10, 0, 0, button_click_none); | ||
39 | button_init(&button6, ">>>", 10, 0, 0, button_click_more_frame); | ||
40 | button_init(&button7, "Exit", 10, 0, 0, button_click_exit); | ||
41 | |||
42 | |||
43 | pictureframe_init(&pictureFrame1, 500, 250, 0, 0, pictureframe_origin_split, morphing, canvasSrc, | ||
44 | pictureframe_click_handler_origin); | ||
45 | pictureframe_init(&pictureFrame2, 500, 250, 0, 0, pictureframe_target_split, morphing, canvasTarget, | ||
46 | pictureframe_click_handler_target); | ||
47 | |||
48 | window_add_pictureframe(&window, &pictureFrame1); | ||
49 | window_add_pictureframe(&window, &pictureFrame2); | ||
50 | |||
51 | window_add_button(&window, &button1); | ||
52 | window_add_button(&window, &button2); | ||
53 | window_add_button(&window, &button3); | ||
54 | window_add_button(&window, &button4); | ||
55 | window_add_button(&window, &button5); | ||
56 | window_add_button(&window, &button6); | ||
57 | window_add_button(&window, &button7); | ||
58 | |||
59 | |||
60 | window_print_buttons(&window); | ||
61 | window_print_pictureframes(&window); | ||
62 | int mouse_x; | ||
63 | int mouse_y; | ||
64 | while (mode != EXITING) { | ||
65 | MLV_wait_mouse(&mouse_x, &mouse_y); | ||
66 | group_click_handler(mouse_x, mouse_y, &(window.group_buttons->component)); | ||
67 | group_click_handler(mouse_x, mouse_y, &(window.group_pictureframe->component)); | ||
68 | |||
69 | switch (mode) { | ||
70 | case PRINTING: | ||
71 | window_print_pictureframes(&window); | ||
72 | mode = WAITING_BUTTON_SHOW; | ||
73 | break; | ||
74 | case WAITING_BUTTON_SHOW: | ||
75 | window_print_pictureframes(&window); | ||
76 | break; | ||
77 | case WAITING_BUTTON_HIDE: | ||
78 | window_print_pictureframes(&window); | ||
79 | break; | ||
80 | case PRINTING_BUTTONS: | ||
81 | button_init(&button5, labelFrame, 10, button5.component.x_pos, button5.component.y_pos, button_click_none); | ||
82 | window_print_buttons(&window); | ||
83 | mode = WAITING_BUTTON_SHOW; | ||
84 | break; | ||
85 | case RENDERING: | ||
86 | for (i = 1; i <= frame ; ++i) { | ||
87 | pictureFrame1.canvas = rasterize(canvasSrc,canvasTarget,morphing,(TimeVector)(i/(float)frame)); | ||
88 | pictureframe_draw_canvas(&pictureFrame1); | ||
89 | MLV_actualise_window(); | ||
90 | MLV_wait_seconds(1); | ||
91 | } | ||
92 | mode = EXITING; | ||
93 | MLV_wait_seconds(15); | ||
94 | break; | ||
95 | default: | ||
96 | break; | ||
97 | } | ||
98 | } | ||
99 | canvas_destroy(canvasSrc); | ||
100 | canvas_destroy(canvasTarget); | ||
101 | |||
102 | morphing_destroy(morphing); | ||
103 | |||
104 | window_free(&window); | ||
105 | } | ||
106 | |||
107 | int main() { | ||
108 | test_pictureframe(); | ||
109 | return 0; | ||
110 | } \ No newline at end of file | ||
diff --git a/test/gui/window.c b/test/gui/window.c new file mode 100644 index 0000000..b19300e --- /dev/null +++ b/test/gui/window.c | |||
@@ -0,0 +1,15 @@ | |||
1 | #include "gui/window.h" | ||
2 | #include "MLV/MLV_all.h" | ||
3 | |||
4 | static void test_window() { | ||
5 | /*Window window; | ||
6 | window_init(&window, 1000, 512, "Coucou"); | ||
7 | window_create(&window); | ||
8 | MLV_wait_seconds(150); | ||
9 | window_free(&window);*/ | ||
10 | } | ||
11 | |||
12 | int main() { | ||
13 | test_window(); | ||
14 | return 0; | ||
15 | } \ No newline at end of file | ||
diff --git a/test/morpher/quadrilateral.c b/test/morpher/quadrilateral.c index 31b22d6..c632b82 100644 --- a/test/morpher/quadrilateral.c +++ b/test/morpher/quadrilateral.c | |||
@@ -57,5 +57,6 @@ int main(int argc, char **argv) { | |||
57 | test_quadrilateral_flip_diagonal(); | 57 | test_quadrilateral_flip_diagonal(); |
58 | test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(2, 1), false); | 58 | test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(2, 1), false); |
59 | test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(4, -1), true); | 59 | test_quadrilateral_is_delaunay(m(0, 0), m(0, 3), m(3, 3), m(4, -1), true); |
60 | test_quadrilateral_is_delaunay(m(0, 0), m(0, 1), m(1, 1), m(1, 0), true); | ||
60 | return 0; | 61 | return 0; |
61 | } | 62 | } |