From 9ed3c28a0335137d34e51d5fd49be6e523f65a89 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Thu, 28 Dec 2017 22:52:28 +0100 Subject: Implementing the add constraint feature, need to be fixed --- include/gui/button.h | 3 ++- include/gui/component.h | 6 ++++-- include/gui/pictureframe.h | 38 +++++++++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'include/gui') diff --git a/include/gui/button.h b/include/gui/button.h index 6f91e37..26d7970 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -1,6 +1,5 @@ #ifndef UPEM_MORPHING_BUTTON #define UPEM_MORPHING_BUTTON - /** * File: button.h * Buttons handling @@ -58,6 +57,7 @@ void button_print(Component *parameterSelf); */ void button_click_test(int x, int y, Component *parameterSelf); +void button_click_add_constraint(int x, int y, Component *parameterSelf); /** * Function: button_is_selected * Checks if the button is selected or not. @@ -70,6 +70,7 @@ void button_click_test(int x, int y, Component *parameterSelf); * Returns: * A bool from stdbool */ + bool button_is_selected(int x, int y, Button *button); #endif diff --git a/include/gui/component.h b/include/gui/component.h index dd101dc..0e8f437 100644 --- a/include/gui/component.h +++ b/include/gui/component.h @@ -1,7 +1,10 @@ #ifndef UPEM_C_COMPONENT_H #define UPEM_C_COMPONENT_H +typedef enum { + WAITING_BUTTON, INSERT_ORIGIN, INSERT_TARGET,PRINTING +} Mode; -#include +extern Mode mode; /** * File: component.h * Windows and components handling. @@ -38,7 +41,6 @@ typedef void (*PrintMethod)(struct Component *); typedef struct Component { int width, height; int x_pos, y_pos; - bool activated; ClickHandler click_handler; PrintMethod print_method; } Component; diff --git a/include/gui/pictureframe.h b/include/gui/pictureframe.h index 1f5407c..f06a530 100644 --- a/include/gui/pictureframe.h +++ b/include/gui/pictureframe.h @@ -1,13 +1,14 @@ #ifndef UPEM_MORPHING_PITUREFRAME #define UPEM_MORPHING_PITUREFRAME -#include #include +#include #include "component.h" - /** * File: pictureframe.h */ + +CartesianVector savedPoint; /** * Type: CartesianMappingDivision * Type of functions needed to split CartesianMapping and keep only the CartesianVector needed, related to the type of PictureFrame involved @@ -49,8 +50,24 @@ CartesianVector pictureframe_origin_split(const CartesianMapping *cartesianMappi */ CartesianVector pictureframe_target_split(const CartesianMapping *cartesianMapping); +bool pictureframe_is_selected(int x, int y, PictureFrame *pictureFrame); + +/** + * Function: pictureframe_conversion_to_origin + * Returns the relative coordinate on the picture corresponding to the input values + * + * Parameters: + * x - value on x axis from the origin of the window to convert + * y - value on y axis from the origin of the window to convert + * *pictureFrame - pointer to the reference pictureframe that will give his relative coordinates + */ +CartesianVector pictureframe_conversion_to_origin(int x, int y, PictureFrame *pictureFrame); + +CartesianVector pictureframe_conversion_to_picture(int x, int y, PictureFrame *pictureFrame); + void pictureframe_init(PictureFrame *pictureFrame, int width, int height, int x_pos, int y_pos, - CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas); + CartesianMappingDivision cartesianMappingDivision, Morphing *morphing, Canvas *canvas, + ClickHandler clickHandler); void pictureframe_free(PictureFrame *pictureFrame); @@ -73,7 +90,18 @@ void pictureframe_draw_canvas(PictureFrame *pictureFrame); void pictureframe_print(Component *parameterSelf); /** - * Function: pictureframe_click_handler + * Function: pictureframe_click_handler_origin + * Adds a point on the coordinate of the picture that the mouse is pointing. + * + * Parameters: + * x_pos - coordinate on x axis of the mouse + * y_pos - coordinate on y axis of the mouse + * *parameterSelf - pointer that will be casted into a PictureFrame + */ +void pictureframe_click_handler_origin(int x_pos, int y_pos, Component *parameterSelf); + +/** + * Function: pictureframe_click_handler_target * Adds a point on the coordinate of the picture that the mouse is pointing. * * Parameters: @@ -81,7 +109,7 @@ void pictureframe_print(Component *parameterSelf); * y_pos - coordinate on y axis of the mouse * *parameterSelf - pointer that will be casted into a PictureFrame */ -void pictureframe_click_handler(int x_pos, int y_pos, Component *parameterSelf); +void pictureframe_click_handler_target(int x_pos, int y_pos, Component *parameterSelf); #endif -- cgit v1.2.3