diff options
author | Adam NAILI | 2018-01-03 19:40:51 +0100 |
---|---|---|
committer | Adam NAILI | 2018-01-03 19:40:51 +0100 |
commit | 2f3d8ebc9b5e10e56bed5da316f5ef098dda0997 (patch) | |
tree | e2df4b6eaf81cb72f6fef75f6cf7324b0e671f23 /test/gui/pictureframe.c | |
parent | 54dac24c8f7be833124a90bafdca78810fc0d96a (diff) | |
download | morpher-2f3d8ebc9b5e10e56bed5da316f5ef098dda0997.tar.gz |
Updating documentation, cleaning includes, updating report
Diffstat (limited to 'test/gui/pictureframe.c')
-rw-r--r-- | test/gui/pictureframe.c | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/test/gui/pictureframe.c b/test/gui/pictureframe.c index 13926b4..f1d90df 100644 --- a/test/gui/pictureframe.c +++ b/test/gui/pictureframe.c | |||
@@ -1,92 +1,78 @@ | |||
1 | #include "gui/component.h" | 1 | #include "gui/component.h" |
2 | #include <gui/group.h> | 2 | #include "gui/window.h" |
3 | #include <gui/window.h> | 3 | #include "common/mem.h" |
4 | #include <gui/button.h> | ||
5 | #include <gui/pictureframe.h> | ||
6 | #include <painter/rasterizer.h> | ||
7 | #include "MLV/MLV_all.h" | ||
8 | 4 | ||
9 | extern Mode mode; | 5 | extern Mode mode; |
10 | 6 | ||
11 | static void test_pictureframe() { | 7 | static void test_pictureframe() { |
12 | Window window; | 8 | Window *window = window_create(1005, 512, "Coucou"); |
13 | window_init(&window, 1005, 512, "Coucou"); | ||
14 | window_create(&window); | ||
15 | 9 | ||
16 | Button button1; | 10 | sprintf(labelFrame, "%03d frames", frame); |
17 | Button button2; | 11 | Button *button1 = button_create("Add constraint point", 10, 0, 0, button_click_add_constraint); |
18 | Button button3; | 12 | Button *button2 = button_create("Show/Hide", 10, 0, 0, button_click_show_hide); |
19 | Button button4; | 13 | Button *button3 = button_create("Start rendering", 10, 0, 0, button_click_rendering); |
20 | Button button5; | 14 | Button *button4 = button_create("<<<", 10, 0, 0, button_click_less_frame); |
21 | Button button6; | 15 | Button *button5 = button_create(labelFrame, 10, 0, 0, button_click_none); |
22 | Button button7; | 16 | Button *button6 = button_create(">>>", 10, 0, 0, button_click_more_frame); |
17 | Button *button7 = button_create("Exit", 10, 0, 0, button_click_exit); | ||
23 | 18 | ||
24 | PictureFrame pictureFrame1; | ||
25 | PictureFrame pictureFrame2; | ||
26 | 19 | ||
27 | Morphing *morphing = morphing_create(500, 250); | 20 | Morphing *morphing = morphing_create(500, 250); |
28 | Canvas *canvasSrc = canvas_create_from_image("/home/adam/Images/goku.png"); | 21 | Canvas *canvasSrc = canvas_create_from_image("/home/adam/Images/goku.png"); |
29 | Canvas *canvasTarget = canvas_create_from_image("/home/adam/Images/marty.jpg"); | 22 | Canvas *canvasTarget = canvas_create_from_image("/home/adam/Images/marty.jpg"); |
30 | 23 | ||
31 | sprintf(labelFrame, "%03d frames", frame); | 24 | PictureFrame *pictureFrame1 = pictureframe_create(500, 250, 0, 0, pictureframe_origin_split, morphing, canvasSrc, |
32 | button_init(&button1, "Add constraint point", 10, 0, 0, button_click_add_constraint); | 25 | pictureframe_click_handler_origin); |
33 | button_init(&button2, "Show/Hide", 10, 0, 0, button_click_show_hide); | 26 | PictureFrame *pictureFrame2 = pictureframe_create(500, 250, 0, 0, pictureframe_target_split, morphing, canvasTarget, |
34 | button_init(&button3, "Start rendering", 10, 0, 0, button_click_rendering); | 27 | pictureframe_click_handler_target); |
35 | button_init(&button4, "<<<", 10, 0, 0, button_click_less_frame); | ||
36 | button_init(&button5, labelFrame, 10, 0, 0, button_click_none); | ||
37 | button_init(&button6, ">>>", 10, 0, 0, button_click_more_frame); | ||
38 | button_init(&button7, "Exit", 10, 0, 0, button_click_exit); | ||
39 | |||
40 | 28 | ||
41 | pictureframe_init(&pictureFrame1, 500, 250, 0, 0, pictureframe_origin_split, morphing, canvasSrc, | 29 | window_add_pictureframe(window, pictureFrame1); |
42 | pictureframe_click_handler_origin); | 30 | window_add_pictureframe(window, pictureFrame2); |
43 | pictureframe_init(&pictureFrame2, 500, 250, 0, 0, pictureframe_target_split, morphing, canvasTarget, | ||
44 | pictureframe_click_handler_target); | ||
45 | 31 | ||
46 | window_add_pictureframe(&window, &pictureFrame1); | 32 | window_add_button(window, button1); |
47 | window_add_pictureframe(&window, &pictureFrame2); | 33 | window_add_button(window, button2); |
34 | window_add_button(window, button3); | ||
35 | window_add_button(window, button4); | ||
36 | window_add_button(window, button5); | ||
37 | window_add_button(window, button6); | ||
38 | window_add_button(window, button7); | ||
48 | 39 | ||
49 | window_add_button(&window, &button1); | ||
50 | window_add_button(&window, &button2); | ||
51 | window_add_button(&window, &button3); | ||
52 | window_add_button(&window, &button4); | ||
53 | window_add_button(&window, &button5); | ||
54 | window_add_button(&window, &button6); | ||
55 | window_add_button(&window, &button7); | ||
56 | 40 | ||
57 | 41 | window_print_buttons(window); | |
58 | window_print_buttons(&window); | 42 | window_print_pictureframes(window); |
59 | window_print_pictureframes(&window); | ||
60 | 43 | ||
61 | MLV_Keyboard_button keyboardButton; | 44 | MLV_Keyboard_button keyboardButton; |
62 | MLV_Keyboard_modifier keyboardModifier; | 45 | MLV_Keyboard_modifier keyboardModifier; |
63 | int unicode; | 46 | int unicode; |
64 | int mouse_x; | 47 | int mouse_x; |
65 | int mouse_y; | 48 | int mouse_y; |
49 | |||
66 | while (mode != EXITING) { | 50 | while (mode != EXITING) { |
67 | window_click_keyboard_handler(&window, &keyboardButton, &keyboardModifier, &unicode, &mouse_x, &mouse_y); | 51 | window_click_keyboard_handler(window, &keyboardButton, &keyboardModifier, &unicode, &mouse_x, &mouse_y); |
68 | switch (mode) { | 52 | switch (mode) { |
69 | case PRINTING: | 53 | case PRINTING: |
70 | window_print_pictureframes(&window); | 54 | window_print_pictureframes(window); |
71 | mode = WAITING_BUTTON_SHOW; | 55 | mode = WAITING_BUTTON_SHOW; |
72 | break; | 56 | break; |
73 | case WAITING_BUTTON_SHOW: | 57 | case WAITING_BUTTON_SHOW: |
74 | window_print_pictureframes(&window); | 58 | window_print_pictureframes(window); |
75 | break; | 59 | break; |
76 | case WAITING_BUTTON_HIDE: | 60 | case WAITING_BUTTON_HIDE: |
77 | window_print_pictureframes(&window); | 61 | window_print_pictureframes(window); |
78 | break; | 62 | break; |
79 | case PRINTING_BUTTONS: | 63 | case PRINTING_BUTTONS: |
80 | button_init(&button5, labelFrame, 10, button5.component.x_pos, button5.component.y_pos, button_click_none); | 64 | free(button5->label); |
81 | window_print_buttons(&window); | 65 | button5->label = malloc_or_die(sizeof(char) * (strlen(labelFrame) + 1)); |
66 | strcpy(button5->label, labelFrame); | ||
67 | window_print_buttons(window); | ||
82 | mode = WAITING_BUTTON_SHOW; | 68 | mode = WAITING_BUTTON_SHOW; |
83 | break; | 69 | break; |
84 | case RENDERING: | 70 | case RENDERING: |
85 | window_rendering(&window,&pictureFrame1,canvasSrc,canvasTarget,morphing); | 71 | window_rendering(window, pictureFrame1, canvasSrc, canvasTarget, morphing); |
86 | break; | 72 | break; |
87 | case INSERT_TARGET: | 73 | case INSERT_TARGET: |
88 | if (keyboardButton == MLV_KEYBOARD_ESCAPE) { | 74 | if (keyboardButton == MLV_KEYBOARD_ESCAPE) { |
89 | window_print_pictureframes(&window); | 75 | window_print_pictureframes(window); |
90 | mode = WAITING_BUTTON_SHOW; | 76 | mode = WAITING_BUTTON_SHOW; |
91 | } | 77 | } |
92 | break; | 78 | break; |
@@ -94,12 +80,23 @@ static void test_pictureframe() { | |||
94 | break; | 80 | break; |
95 | } | 81 | } |
96 | } | 82 | } |
83 | |||
84 | button_destroy(button1); | ||
85 | button_destroy(button2); | ||
86 | button_destroy(button3); | ||
87 | button_destroy(button4); | ||
88 | button_destroy(button5); | ||
89 | button_destroy(button6); | ||
90 | button_destroy(button7); | ||
91 | |||
92 | pictureframe_destroy(pictureFrame1); | ||
93 | pictureframe_destroy(pictureFrame2); | ||
94 | |||
97 | canvas_destroy(canvasSrc); | 95 | canvas_destroy(canvasSrc); |
98 | canvas_destroy(canvasTarget); | 96 | canvas_destroy(canvasTarget); |
99 | |||
100 | morphing_destroy(morphing); | 97 | morphing_destroy(morphing); |
101 | 98 | ||
102 | window_free(&window); | 99 | window_destroy(window); |
103 | } | 100 | } |
104 | 101 | ||
105 | int main() { | 102 | int main() { |