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 /src/gui/window.c | |
parent | 54dac24c8f7be833124a90bafdca78810fc0d96a (diff) | |
download | morpher-2f3d8ebc9b5e10e56bed5da316f5ef098dda0997.tar.gz |
Updating documentation, cleaning includes, updating report
Diffstat (limited to 'src/gui/window.c')
-rw-r--r-- | src/gui/window.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/gui/window.c b/src/gui/window.c index 32aeb26..1859f58 100644 --- a/src/gui/window.c +++ b/src/gui/window.c | |||
@@ -1,22 +1,16 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <gui/window.h> | 2 | #include <assert.h> |
3 | #include <gui/button.h> | 3 | #include "gui/window.h" |
4 | #include <gui/pictureframe.h> | 4 | #include "MLV/MLV_all.h" |
5 | #include <gui/group.h> | 5 | #include "painter/rasterizer.h" |
6 | #include <MLV/MLV_keyboard.h> | ||
7 | #include <MLV/MLV_all.h> | ||
8 | #include <caca_conio.h> | ||
9 | #include <painter/rasterizer.h> | ||
10 | #include "common/mem.h" | 6 | #include "common/mem.h" |
11 | #include "string.h" | ||
12 | #include "assert.h" | ||
13 | #include "MLV/MLV_window.h" | ||
14 | 7 | ||
15 | void window_init(Window *window, int width, int height, char *title) { | 8 | |
16 | assert(window != NULL); | 9 | Window *window_create(int width, int height, char *title) { |
17 | assert(width > 0); | 10 | assert(width > 0); |
18 | assert(height > 0); | 11 | assert(height > 0); |
19 | assert(title != NULL); | 12 | assert(title != NULL); |
13 | Window *window = malloc_or_die(sizeof(Window)); | ||
20 | window->width = width; | 14 | window->width = width; |
21 | window->height = height; | 15 | window->height = height; |
22 | window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); | 16 | window->title = malloc_or_die(sizeof(char) * (strlen(title) + 1)); |
@@ -25,13 +19,16 @@ void window_init(Window *window, int width, int height, char *title) { | |||
25 | group_init(window->group_buttons, window->width, 100, 0, window->height - 100, 5); | 19 | group_init(window->group_buttons, window->width, 100, 0, window->height - 100, 5); |
26 | window->group_pictureframe = malloc_or_die(sizeof(Group)); | 20 | window->group_pictureframe = malloc_or_die(sizeof(Group)); |
27 | group_init(window->group_pictureframe, window->width, window->height - 100, 0, 0, 5); | 21 | group_init(window->group_pictureframe, window->width, window->height - 100, 0, 0, 5); |
22 | MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); | ||
23 | return window; | ||
28 | } | 24 | } |
29 | 25 | ||
30 | void window_free(Window *window) { | 26 | void window_destroy(Window *window) { |
31 | assert(window != NULL); | 27 | assert(window != NULL); |
32 | free(window->title); | 28 | free(window->title); |
33 | group_free(window->group_buttons); | 29 | group_free(window->group_buttons); |
34 | group_free(window->group_pictureframe); | 30 | group_free(window->group_pictureframe); |
31 | free(window); | ||
35 | } | 32 | } |
36 | 33 | ||
37 | void window_add_button(Window *window, Button *button) { | 34 | void window_add_button(Window *window, Button *button) { |
@@ -46,11 +43,6 @@ void window_add_pictureframe(Window *window, PictureFrame *pictureFrame) { | |||
46 | group_add_component(window->group_pictureframe, &(pictureFrame->component)); | 43 | group_add_component(window->group_pictureframe, &(pictureFrame->component)); |
47 | } | 44 | } |
48 | 45 | ||
49 | void window_create(Window *window) { | ||
50 | assert(window != NULL); | ||
51 | MLV_create_window(window->title, window->title, (unsigned int) window->width, (unsigned int) window->height); | ||
52 | } | ||
53 | |||
54 | void window_print_buttons(Window *window) { | 46 | void window_print_buttons(Window *window) { |
55 | assert(window != NULL); | 47 | assert(window != NULL); |
56 | window->group_buttons->component.print_method(&(window->group_buttons->component)); | 48 | window->group_buttons->component.print_method(&(window->group_buttons->component)); |
@@ -74,12 +66,13 @@ void window_wait_keyboard_or_mouse(MLV_Keyboard_button *keyboardButton, MLV_Keyb | |||
74 | void window_click_keyboard_handler(Window *window, MLV_Keyboard_button *keyboardButton, | 66 | void window_click_keyboard_handler(Window *window, MLV_Keyboard_button *keyboardButton, |
75 | MLV_Keyboard_modifier *keyboardModifier, | 67 | MLV_Keyboard_modifier *keyboardModifier, |
76 | int *unicode, int *mouse_x, int *mouse_y) { | 68 | int *unicode, int *mouse_x, int *mouse_y) { |
77 | window_wait_keyboard_or_mouse(keyboardButton,keyboardModifier,unicode,mouse_x,mouse_y); | 69 | window_wait_keyboard_or_mouse(keyboardButton, keyboardModifier, unicode, mouse_x, mouse_y); |
78 | group_click_handler(*mouse_x, *mouse_y, &(window->group_buttons->component)); | 70 | group_click_handler(*mouse_x, *mouse_y, &(window->group_buttons->component)); |
79 | group_click_handler(*mouse_x, *mouse_y, &(window->group_pictureframe->component)); | 71 | group_click_handler(*mouse_x, *mouse_y, &(window->group_pictureframe->component)); |
80 | } | 72 | } |
81 | 73 | ||
82 | void window_rendering(Window *window,PictureFrame *pictureFrame1,Canvas *canvasSrc, Canvas *canvasTarget, Morphing *morphing){ | 74 | void window_rendering(Window *window, PictureFrame *pictureFrame1, Canvas *canvasSrc, Canvas *canvasTarget, |
75 | Morphing *morphing) { | ||
83 | int i; | 76 | int i; |
84 | window_print_pictureframes(window); | 77 | window_print_pictureframes(window); |
85 | for (i = 1; i <= frame; ++i) { | 78 | for (i = 1; i <= frame; ++i) { |