summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gui/pictureframe.c83
1 files changed, 68 insertions, 15 deletions
diff --git a/test/gui/pictureframe.c b/test/gui/pictureframe.c
index 07e1236..9aa5639 100644
--- a/test/gui/pictureframe.c
+++ b/test/gui/pictureframe.c
@@ -1,6 +1,9 @@
1#include "gui/component.h" 1#include "gui/component.h"
2#include <gui/group.h> 2#include <gui/group.h>
3#include <gui/window.h> 3#include <gui/window.h>
4#include <gui/button.h>
5#include <gui/pictureframe.h>
6#include <painter/rasterizer.h>
4#include "MLV/MLV_all.h" 7#include "MLV/MLV_all.h"
5 8
6extern Mode mode; 9extern Mode mode;
@@ -11,42 +14,92 @@ static void test_pictureframe() {
11 window_create(&window); 14 window_create(&window);
12 15
13 Button button1; 16 Button button1;
17 Button button2;
18 Button button3;
19 Button button4;
20 Button button5;
21 Button button6;
22 Button button7;
14 23
15 PictureFrame pictureFrame1; 24 PictureFrame pictureFrame1;
16 PictureFrame pictureFrame2; 25 PictureFrame pictureFrame2;
17 26
18 Morphing *morphing = morphing_create(500, 250); 27 Morphing *morphing = morphing_create(500, 250);
19 Canvas *canvas1 = canvas_create_from_image("/home/adam/Images/goku.png"); 28 Canvas *canvasSrc = canvas_create_from_image("/home/adam/Images/goku.png");
20 Canvas *canvas2 = canvas_create_from_image("/home/adam/Images/marty.jpg"); 29 Canvas *canvasTarget = canvas_create_from_image("/home/adam/Images/marty.jpg");
21 30
31 int i;
32
33 sprintf(labelFrame, "%03d frames", frame);
22 button_init(&button1, "Add constraint point", 10, 0, 0, button_click_add_constraint); 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
23 42
24 pictureframe_init(&pictureFrame1, 500, 250, 0, 0, pictureframe_origin_split, morphing, canvas1, 43 pictureframe_init(&pictureFrame1, 500, 250, 0, 0, pictureframe_origin_split, morphing, canvasSrc,
25 pictureframe_click_handler_origin); 44 pictureframe_click_handler_origin);
26 pictureframe_init(&pictureFrame2, 500, 250, 0, 0, pictureframe_target_split, morphing, canvas2, 45 pictureframe_init(&pictureFrame2, 500, 250, 0, 0, pictureframe_target_split, morphing, canvasTarget,
27 pictureframe_click_handler_target); 46 pictureframe_click_handler_target);
28 47
29 window_add_pictureframe(&window, &pictureFrame1); 48 window_add_pictureframe(&window, &pictureFrame1);
30 window_add_pictureframe(&window, &pictureFrame2); 49 window_add_pictureframe(&window, &pictureFrame2);
31 50
32 window_add_button(&window, &button1); 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
33 window_print_buttons(&window); 60 window_print_buttons(&window);
34 window_print_pictureframes(&window); 61 window_print_pictureframes(&window);
35 int mouse_x; 62 int mouse_x;
36 int mouse_y; 63 int mouse_y;
37 while (1) { 64 while (mode != EXITING) {
38 if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { 65 MLV_wait_mouse(&mouse_x, &mouse_y);
39 MLV_get_mouse_position(&mouse_x, &mouse_y); 66 group_click_handler(mouse_x, mouse_y, &(window.group_buttons->component));
40 group_click_handler(mouse_x, mouse_y, &(window.group_buttons->component)); 67 group_click_handler(mouse_x, mouse_y, &(window.group_pictureframe->component));
41 group_click_handler(mouse_x, mouse_y, &(window.group_pictureframe->component)); 68
42 if(mode == PRINTING){ 69 switch (mode) {
43 window_print_pictureframes(&window); 70 case PRINTING:
44 mode = WAITING_BUTTON; 71 window_print_pictureframes(&window);
45 } 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 = 0; i < frame ; ++i) {
87 pictureFrame1.canvas = rasterize(canvasSrc,canvasTarget,morphing,(TimeVector)(TIME_UNIT/frame));
88 pictureframe_draw_canvas(&pictureFrame1);
89 MLV_actualise_window();
90 printf("Rendering\n");
91 }
92 break;
93 default:
94 break;
46 } 95 }
47 } 96 }
48 /*MLV_wait_seconds(15); 97 canvas_destroy(canvasSrc);
49 window_free(&window);*/ 98 canvas_destroy(canvasTarget);
99
100 morphing_destroy(morphing);
101
102 window_free(&window);
50} 103}
51 104
52int main() { 105int main() {