From a05d3ad97d513c03d671059a5bae18487af23e24 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 18:31:33 +0100 Subject: Updating doc of button, implementing button_is_selected, button_print, button_click_test (debug click handling), button_init --- include/gui/button.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) (limited to 'include/gui') diff --git a/include/gui/button.h b/include/gui/button.h index fda83e9..6f91e37 100644 --- a/include/gui/button.h +++ b/include/gui/button.h @@ -5,17 +5,23 @@ * File: button.h * Buttons handling */ -#include "window.h" + +#include +#include "component.h" /** * Struct: Button * Component that can be triggered by click to execute a specific action. * * Fields: - * component - component that will acted as a button thanks to a rightful initialization. + * component - component that will acted as a button thanks to a rightful initialization + * *label - title on the button + * sizeInterligne - parameter that change padding of the button */ typedef struct { Component component; + char *label; + int sizeInterligne; } Button; /** @@ -25,8 +31,45 @@ typedef struct { * Parameters: * *button - pointer to the input button * text - label for the button + * sizeInterligne - parameter to initialize padding inside the button + * x_pos - position of the button on x axis + * y_pos - position of the button on y axis + * clickHandler - pointer of function that will be loaded inside our button to perform its purpose + */ +void button_init(Button *button, const char *text, int sizeInterligne, int x_pos, int y_pos, ClickHandler clickHandler); + +/** + * Function: button_print + * Prints the button. + * + * Parameters: + * *parameterSelf - pointer to the button + */ +void button_print(Component *parameterSelf); + +/** + * Function: button_click_test + * Debug function to test if the click is working on the current button. + * + * Parameters: + * x - position of the click on x axis + * y - position of the click on y axis + * *parameterSelf - pointer on the button that is clicked */ -void button_init(Button *button, char *text); +void button_click_test(int x, int y, Component *parameterSelf); +/** + * Function: button_is_selected + * Checks if the button is selected or not. + * + * Parameters: + * x - position in x for the check + * y - position in y for the check + * *button - pointer to the current button + * + * Returns: + * A bool from stdbool + */ +bool button_is_selected(int x, int y, Button *button); #endif -- cgit v1.2.3