From 92c999f56a86f221e6d3dc2182b5b7f7e0e08231 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Fri, 22 Dec 2017 19:15:56 +0100 Subject: Successful test for the group management and button handling. Buttons are placed in the right spots thanks to group position handling --- test/gui/button.c | 32 +++++++++++++++++++++++++++++--- test/gui/group.c | 27 ++++++++++++++++++++++++--- test/gui/window.c | 4 ++-- 3 files changed, 55 insertions(+), 8 deletions(-) (limited to 'test/gui') diff --git a/test/gui/button.c b/test/gui/button.c index 58270ef..df3e04d 100644 --- a/test/gui/button.c +++ b/test/gui/button.c @@ -1,4 +1,30 @@ -// -// Created by adam on 16/12/17. -// +#include +#include +#include +#include +#include "MLV/MLV_all.h" + +static void test_button() { + /* Window window; + window_init(&window, 1000, 512, "Coucou"); + window_create(&window); + Button button1; + button_init(&button1, "OK", 10, 500, 256, button_click_test); + button1.component.print_method(&button1); + int mouse_x; + int mouse_y; + while (1) { + if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { + MLV_get_mouse_position(&mouse_x, &mouse_y); + button1.component.click_handler(mouse_x, mouse_y, &(button1.component)); + } + }*/ + /*MLV_wait_seconds(10); + window_free(&window);*/ +} + +int main() { + test_button(); + return 0; +} \ No newline at end of file diff --git a/test/gui/group.c b/test/gui/group.c index e3d25f3..555c246 100644 --- a/test/gui/group.c +++ b/test/gui/group.c @@ -7,9 +7,30 @@ static void test_group() { Window window; window_init(&window, 1000, 512, "Coucou"); window_create(&window); - window.group_buttons->component.print_method(window.group_pictureframe); - MLV_wait_seconds(5); - window_free(&window); + + Button button1; + Button button2; + Button button3; + + button_init(&button1, "OK", 10, 500, 256, button_click_test); + button_init(&button2,"Bouton magique",10, 500,290, NULL); + button_init(&button3,"Très lonnggggg boooouttttooooon",10,0,0,button_click_test); + + window_add_button(&window,&button1); + window_add_button(&window,&button2); + window_add_button(&window,&button3); + + window_print_buttons(&window); + int mouse_x; + int mouse_y; + while(1){ + if (MLV_get_mouse_button_state(MLV_BUTTON_LEFT) == MLV_PRESSED) { + MLV_get_mouse_position(&mouse_x, &mouse_y); + group_click_handler(mouse_x,mouse_y,&(window.group_buttons->component)); + } + } + /*MLV_wait_seconds(15); + window_free(&window);*/ } int main() { diff --git a/test/gui/window.c b/test/gui/window.c index e3b062a..b19300e 100644 --- a/test/gui/window.c +++ b/test/gui/window.c @@ -2,11 +2,11 @@ #include "MLV/MLV_all.h" static void test_window() { - Window window; + /*Window window; window_init(&window, 1000, 512, "Coucou"); window_create(&window); MLV_wait_seconds(150); - window_free(&window); + window_free(&window);*/ } int main() { -- cgit v1.2.3