diff options
author | Adam NAILI | 2017-12-28 16:22:43 +0100 |
---|---|---|
committer | Adam NAILI | 2017-12-28 16:22:43 +0100 |
commit | aaf57e5ee1e0cf74afdbdf56293f1afd7e79e6b0 (patch) | |
tree | 6526fefe48549d97368aa882d862bbf468426c9e | |
parent | 46fecbfedfc61658caeb721565fd36f49c0d3db9 (diff) | |
download | morpher-aaf57e5ee1e0cf74afdbdf56293f1afd7e79e6b0.tar.gz |
Reworking signatures of pictureframe function, beginning of implementation, debug tests
-rw-r--r-- | include/gui/pictureframe.h | 5 | ||||
-rw-r--r-- | src/gui/pictureframe.c | 45 | ||||
-rw-r--r-- | test/gui/group.c | 2 | ||||
-rw-r--r-- | test/gui/pictureframe.c | 40 |
4 files changed, 90 insertions, 2 deletions
diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index de9ae1c..1f5407c 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <blender/canvas.h> | 4 | #include <blender/canvas.h> |
5 | #include <morpher/morphing.h> | 5 | #include <morpher/morphing.h> |
6 | #include "component.h" | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * File: pictureframe.h | 9 | * File: pictureframe.h |
@@ -12,6 +13,7 @@ | |||
12 | * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved | 13 | * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved |
13 | */ | 14 | */ |
14 | typedef CartesianVector (*CartesianMappingDivision)(const CartesianMapping *cartesianMapping); | 15 | typedef CartesianVector (*CartesianMappingDivision)(const CartesianMapping *cartesianMapping); |
16 | |||
15 | /** | 17 | /** |
16 | * Struct: PictureFrame | 18 | * Struct: PictureFrame |
17 | * Represents a component to print pictures. | 19 | * Represents a component to print pictures. |
@@ -47,7 +49,8 @@ CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMappi | |||
47 | */ | 49 | */ |
48 | CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); | 50 | CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); |
49 | 51 | ||
50 | void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, CartesianMappingDivision cartesianMappingDivision); | 52 | void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, |
53 | CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas); | ||
51 | 54 | ||
52 | void pictureframe_free(PictureFrame *pictureFrame); | 55 | void pictureframe_free(PictureFrame *pictureFrame); |
53 | 56 | ||
diff --git a/src/gui/pictureframe.c b/src/gui/pictureframe.c new file mode 100644 index 0000000..543ba4c --- /dev/null +++ b/src/gui/pictureframe.c | |||
@@ -0,0 +1,45 @@ | |||
1 | #include <assert.h> | ||
2 | #include <gui/pictureframe.h> | ||
3 | #include <MLV/MLV_all.h> | ||
4 | |||
5 | CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMapping) { | ||
6 | |||
7 | } | ||
8 | |||
9 | CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping) { | ||
10 | |||
11 | } | ||
12 | |||
13 | void pictureframe_print(Component *parameterSelf) { | ||
14 | PictureFrame *self = (PictureFrame *) parameterSelf; | ||
15 | /*DEBUG*/ | ||
16 | MLV_draw_filled_rectangle(self->component.x_pos, self->component.y_pos, self->component.width, self->component.height, | ||
17 | MLV_COLOR_RED); | ||
18 | /**/ | ||
19 | } | ||
20 | |||
21 | void pictureframe_click_handler(int x_pos, int y_pos, Component *parameterSelf) { | ||
22 | printf("ClickHandler pictureframe activated \n"); | ||
23 | } | ||
24 | |||
25 | void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, | ||
26 | CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas) { | ||
27 | assert(pictureFrame != NULL); | ||
28 | assert(width > 0); | ||
29 | assert(height > 0); | ||
30 | assert(x_pos >= 0); | ||
31 | assert(y_pos >= 0); | ||
32 | assert(cartesianMappingDivision != NULL); | ||
33 | assert(morphing != NULL); | ||
34 | assert(canvas != NULL); | ||
35 | pictureFrame->component.width = width; | ||
36 | pictureFrame->component.height = height; | ||
37 | pictureFrame->component.x_pos = x_pos; | ||
38 | pictureFrame->component.y_pos = y_pos; | ||
39 | pictureFrame->component.activated = true; | ||
40 | pictureFrame->component.print_method = pictureframe_print; | ||
41 | pictureFrame->component.click_handler = pictureframe_click_handler; | ||
42 | pictureFrame->morphing = morphing; | ||
43 | pictureFrame->canvas = canvas; | ||
44 | pictureFrame->cartesianMappingDivision = cartesianMappingDivision; | ||
45 | } \ No newline at end of file | ||
diff --git a/test/gui/group.c b/test/gui/group.c index 99a567e..5ec9194 100644 --- a/test/gui/group.c +++ b/test/gui/group.c | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | static void test_group() { | 6 | static void test_group() { |
7 | Window window; | 7 | /*Window window; |
8 | window_init(&window, 1000, 512, "Coucou"); | 8 | window_init(&window, 1000, 512, "Coucou"); |
9 | window_create(&window); | 9 | window_create(&window); |
10 | 10 | ||
diff --git a/test/gui/pictureframe.c b/test/gui/pictureframe.c new file mode 100644 index 0000000..a47eaa0 --- /dev/null +++ b/test/gui/pictureframe.c | |||
@@ -0,0 +1,40 @@ | |||
1 | #include <gui/group.h> | ||
2 | #include <gui/window.h> | ||
3 | #include "MLV/MLV_all.h" | ||
4 | |||
5 | |||
6 | static void test_pictureframe() { | ||
7 | Window window; | ||
8 | window_init(&window, 1000, 512, "Coucou"); | ||
9 | window_create(&window); | ||
10 | |||
11 | PictureFrame pictureFrame1; | ||
12 | PictureFrame pictureFrame2; | ||
13 | |||
14 | Morphing *morphing = morphing_create(500,250); | ||
15 | Canvas canvas; | ||
16 | canvas_init(&canvas,500,250); | ||
17 | |||
18 | pictureframe_init(&pictureFrame1,500,250,0,0,pictureframe_origin_split,morphing,&canvas); | ||
19 | pictureframe_init(&pictureFrame2,500,250,0,0,pictureframe_target_split,morphing,&canvas); | ||
20 | |||
21 | window_add_pictureframe(&window,&pictureFrame1); | ||
22 | window_add_pictureframe(&window,&pictureFrame2); | ||
23 | |||
24 | window_print_pictureframes(&window); | ||
25 | int mouse_x; | ||
26 | int mouse_y; | ||
27 | while(1){ | ||
28 | if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { | ||
29 | MLV_get_mouse_position(&mouse_x, &mouse_y); | ||
30 | group_click_handler(mouse_x,mouse_y,&(window.group_pictureframe->component)); | ||
31 | } | ||
32 | } | ||
33 | /*MLV_wait_seconds(15); | ||
34 | window_free(&window);*/ | ||
35 | } | ||
36 | |||
37 | int main() { | ||
38 | test_pictureframe(); | ||
39 | return 0; | ||
40 | } \ No newline at end of file | ||