summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2018-01-01 23:36:39 +0100
committerAdam NAILI2018-01-01 23:36:39 +0100
commitff2d78256b6b2288e9a5954a49fe4babaf6400cb (patch)
treeed10145f7f49c949a57a19597251c576ef0ac5c1
parent8565b20b86a489b09f611ed1cd3b0ba7ac23a94a (diff)
downloadmorpher-ff2d78256b6b2288e9a5954a49fe4babaf6400cb.tar.gz
Implementing rendering
-rw-r--r--include/gui/pictureframe.h6
-rw-r--r--include/gui/window.h6
-rw-r--r--src/gui/button.c18
-rw-r--r--src/gui/gui.c4
-rw-r--r--src/gui/pictureframe.c18
-rw-r--r--src/gui/window.c33
6 files changed, 53 insertions, 32 deletions
diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h
index f06a530..7b9644e 100644
--- a/include/gui/pictureframe.h
+++ b/include/gui/pictureframe.h
@@ -61,16 +61,14 @@ bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame);
61 * y - value on y axis from the origin of the window to convert 61 * y - value on y axis from the origin of the window to convert
62 * *pictureFrame - pointer to the reference pictureframe that will give his relative coordinates 62 * *pictureFrame - pointer to the reference pictureframe that will give his relative coordinates
63 */ 63 */
64CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame); 64CartesianVector pictureframe_conversion_to_pic(int x, int y, PictureFrame *pictureFrame);
65 65
66CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *pictureFrame); 66CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame);
67 67
68void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, 68void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos,
69 CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas, 69 CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas,
70 ClickHandler clickHandler); 70 ClickHandler clickHandler);
71 71
72void pictureframe_free(PictureFrame *pictureFrame);
73
74/** 72/**
75 * Function: pictureframe_draw_canvas 73 * Function: pictureframe_draw_canvas
76 * Draws the contained Canvas of the PictureFrame. 74 * Draws the contained Canvas of the PictureFrame.
diff --git a/include/gui/window.h b/include/gui/window.h
index 329997b..10f0e74 100644
--- a/include/gui/window.h
+++ b/include/gui/window.h
@@ -9,6 +9,7 @@
9 * The famous OS 9 * The famous OS
10 */ 10 */
11 11
12#include <MLV/MLV_keyboard.h>
12#include "group.h" 13#include "group.h"
13#include "component.h" 14#include "component.h"
14#include "button.h" 15#include "button.h"
@@ -100,4 +101,9 @@ void window_print_buttons(Window *window);
100 */ 101 */
101void window_print_pictureframes(Window *window); 102void window_print_pictureframes(Window *window);
102 103
104void window_click_keyboard_handler(Window *window, MLV_Keyboard_button *keyboardButton,
105 MLV_Keyboard_modifier *keyboardModifier,
106 int *unicode, int *mouse_x, int *mouse_y);
107void window_rendering(Window *window,PictureFrame *pictureFrame1,Canvas *canvasSrc, Canvas *canvasTarget, Morphing *morphing);
108
103#endif 109#endif
diff --git a/src/gui/button.c b/src/gui/button.c
index 03addf8..a55796d 100644
--- a/src/gui/button.c
+++ b/src/gui/button.c
@@ -7,8 +7,6 @@
7#include <gui/component.h> 7#include <gui/component.h>
8 8
9bool button_is_selected(int x, int y, Button *button) { 9bool button_is_selected(int x, int y, Button *button) {
10 assert(x >= 0);
11 assert(y >= 0);
12 assert(button != NULL); 10 assert(button != NULL);
13 int x1 = button->component.x_pos; 11 int x1 = button->component.x_pos;
14 int y1 = button->component.y_pos; 12 int y1 = button->component.y_pos;
@@ -28,8 +26,6 @@ void button_print(Component *parameterSelf) {
28} 26}
29 27
30void button_click_test(int x, int y, Component *parameterSelf) { 28void button_click_test(int x, int y, Component *parameterSelf) {
31 assert(x >= 0);
32 assert(y >= 0);
33 assert(parameterSelf != NULL); 29 assert(parameterSelf != NULL);
34 Button *self = (Button *) parameterSelf; 30 Button *self = (Button *) parameterSelf;
35 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 31 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -37,8 +33,6 @@ void button_click_test(int x, int y, Component *parameterSelf) {
37} 33}
38 34
39void button_click_add_constraint(int x, int y, Component *parameterSelf) { 35void button_click_add_constraint(int x, int y, Component *parameterSelf) {
40 assert(x >= 0);
41 assert(y >= 0);
42 assert(parameterSelf != NULL); 36 assert(parameterSelf != NULL);
43 Button *self = (Button *) parameterSelf; 37 Button *self = (Button *) parameterSelf;
44 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 38 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -47,8 +41,6 @@ void button_click_add_constraint(int x, int y, Component *parameterSelf) {
47} 41}
48 42
49void button_click_show_hide(int x, int y, Component *parameterSelf) { 43void button_click_show_hide(int x, int y, Component *parameterSelf) {
50 assert(x >= 0);
51 assert(y >= 0);
52 assert(parameterSelf != NULL); 44 assert(parameterSelf != NULL);
53 Button *self = (Button *) parameterSelf; 45 Button *self = (Button *) parameterSelf;
54 if (button_is_selected(x, y, self)) { 46 if (button_is_selected(x, y, self)) {
@@ -61,8 +53,6 @@ void button_click_show_hide(int x, int y, Component *parameterSelf) {
61} 53}
62 54
63void button_click_exit(int x, int y, Component *parameterSelf) { 55void button_click_exit(int x, int y, Component *parameterSelf) {
64 assert(x >= 0);
65 assert(y >= 0);
66 assert(parameterSelf != NULL); 56 assert(parameterSelf != NULL);
67 Button *self = (Button *) parameterSelf; 57 Button *self = (Button *) parameterSelf;
68 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 58 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -71,8 +61,6 @@ void button_click_exit(int x, int y, Component *parameterSelf) {
71} 61}
72 62
73void button_click_less_frame(int x, int y, Component *parameterSelf) { 63void button_click_less_frame(int x, int y, Component *parameterSelf) {
74 assert(x >= 0);
75 assert(y >= 0);
76 assert(parameterSelf != NULL); 64 assert(parameterSelf != NULL);
77 Button *self = (Button *) parameterSelf; 65 Button *self = (Button *) parameterSelf;
78 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 66 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -85,8 +73,6 @@ void button_click_less_frame(int x, int y, Component *parameterSelf) {
85} 73}
86 74
87void button_click_more_frame(int x, int y, Component *parameterSelf) { 75void button_click_more_frame(int x, int y, Component *parameterSelf) {
88 assert(x >= 0);
89 assert(y >= 0);
90 assert(parameterSelf != NULL); 76 assert(parameterSelf != NULL);
91 Button *self = (Button *) parameterSelf; 77 Button *self = (Button *) parameterSelf;
92 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 78 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -99,8 +85,6 @@ void button_click_more_frame(int x, int y, Component *parameterSelf) {
99} 85}
100 86
101void button_click_rendering(int x,int y, Component *parameterSelf) { 87void button_click_rendering(int x,int y, Component *parameterSelf) {
102 assert(x >= 0);
103 assert(y >= 0);
104 assert(parameterSelf != NULL); 88 assert(parameterSelf != NULL);
105 Button *self = (Button *) parameterSelf; 89 Button *self = (Button *) parameterSelf;
106 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) { 90 if (button_is_selected(x, y, self) && (mode == WAITING_BUTTON_SHOW || mode == WAITING_BUTTON_HIDE)) {
@@ -109,8 +93,6 @@ void button_click_rendering(int x,int y, Component *parameterSelf) {
109} 93}
110 94
111void button_click_none(int x, int y, Component *parameterSelf) { 95void button_click_none(int x, int y, Component *parameterSelf) {
112 assert(x >= 0);
113 assert(y >= 0);
114 assert(parameterSelf != NULL); 96 assert(parameterSelf != NULL);
115} 97}
116 98
diff --git a/src/gui/gui.c b/src/gui/gui.c
new file mode 100644
index 0000000..2a3d018
--- /dev/null
+++ b/src/gui/gui.c
@@ -0,0 +1,4 @@
1//
2// Created by adam on 01/01/18.
3//
4
diff --git a/src/gui/pictureframe.c b/src/gui/pictureframe.c
index 4126f59..a6a94bf 100644
--- a/src/gui/pictureframe.c
+++ b/src/gui/pictureframe.c
@@ -17,7 +17,7 @@ void pictureframe_draw_canvas(PictureFrame *pictureFrame){
17void pictureframe_print(Component *parameterSelf) { 17void pictureframe_print(Component *parameterSelf) {
18 PictureFrame *self = (PictureFrame *) parameterSelf; 18 PictureFrame *self = (PictureFrame *) parameterSelf;
19 pictureframe_draw_canvas(self); 19 pictureframe_draw_canvas(self);
20 if (mode != WAITING_BUTTON_HIDE) { 20 if (mode != WAITING_BUTTON_HIDE && mode != RENDERING) {
21 TriangleMap *p = self->morphing->first; 21 TriangleMap *p = self->morphing->first;
22 CartesianVector p1; 22 CartesianVector p1;
23 CartesianVector p2; 23 CartesianVector p2;
@@ -30,9 +30,9 @@ void pictureframe_print(Component *parameterSelf) {
30 p2 = self->cartesianMappingDivision(&(p->vertices[1])); 30 p2 = self->cartesianMappingDivision(&(p->vertices[1]));
31 p3 = self->cartesianMappingDivision(&(p->vertices[2])); 31 p3 = self->cartesianMappingDivision(&(p->vertices[2]));
32 32
33 pointToPrint1 = pictureframe_conversion_to_picture(p1.x, p1.y, self); 33 pointToPrint1 = pictureframe_conversion_to_origin(p1.x, p1.y, self);
34 pointToPrint2 = pictureframe_conversion_to_picture(p2.x, p2.y, self); 34 pointToPrint2 = pictureframe_conversion_to_origin(p2.x, p2.y, self);
35 pointToPrint3 = pictureframe_conversion_to_picture(p3.x, p3.y, self); 35 pointToPrint3 = pictureframe_conversion_to_origin(p3.x, p3.y, self);
36 36
37 MLV_draw_filled_circle(pointToPrint1.x, pointToPrint1.y, 2, MLV_COLOR_RED); 37 MLV_draw_filled_circle(pointToPrint1.x, pointToPrint1.y, 2, MLV_COLOR_RED);
38 MLV_draw_filled_circle(pointToPrint2.x, pointToPrint2.y, 2, MLV_COLOR_RED); 38 MLV_draw_filled_circle(pointToPrint2.x, pointToPrint2.y, 2, MLV_COLOR_RED);
@@ -47,8 +47,6 @@ void pictureframe_print(Component *parameterSelf) {
47} 47}
48 48
49bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) { 49bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) {
50 assert(x >= 0);
51 assert(y >= 0);
52 assert(pictureFrame != NULL); 50 assert(pictureFrame != NULL);
53 int x1 = pictureFrame->component.x_pos; 51 int x1 = pictureFrame->component.x_pos;
54 int y1 = pictureFrame->component.y_pos; 52 int y1 = pictureFrame->component.y_pos;
@@ -60,14 +58,14 @@ bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame) {
60 return false; 58 return false;
61} 59}
62 60
63CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame) { 61CartesianVector pictureframe_conversion_to_pic(int x, int y, PictureFrame *pictureFrame) {
64 CartesianVector vector; 62 CartesianVector vector;
65 vector.x = x - pictureFrame->component.x_pos; 63 vector.x = x - pictureFrame->component.x_pos;
66 vector.y = y - pictureFrame->component.y_pos; 64 vector.y = y - pictureFrame->component.y_pos;
67 return vector; 65 return vector;
68} 66}
69 67
70CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *pictureFrame) { 68CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame) {
71 CartesianVector vector; 69 CartesianVector vector;
72 vector.x = x + pictureFrame->component.x_pos; 70 vector.x = x + pictureFrame->component.x_pos;
73 vector.y = y + pictureFrame->component.y_pos; 71 vector.y = y + pictureFrame->component.y_pos;
@@ -77,7 +75,7 @@ CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *p
77void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf) { 75void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf) {
78 PictureFrame *self = (PictureFrame *) parameterSelf; 76 PictureFrame *self = (PictureFrame *) parameterSelf;
79 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_ORIGIN) { 77 if (pictureframe_is_selected(x_pos, y_pos, self) && mode == INSERT_ORIGIN) {
80 CartesianVector vector = pictureframe_conversion_to_origin(x_pos, y_pos, self); 78 CartesianVector vector = pictureframe_conversion_to_pic(x_pos, y_pos, self);
81 MLV_draw_filled_circle(x_pos, y_pos, 2, MLV_COLOR_BLUE); 79 MLV_draw_filled_circle(x_pos, y_pos, 2, MLV_COLOR_BLUE);
82 savedPoint = vector; 80 savedPoint = vector;
83 MLV_ac