Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge raycast and master #1

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"request": "launch",
"program": "${workspaceFolder}/guimp",
"args": [],
"stopAtEntry": false,
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"externalConsole": false,
"MIMode": "lldb"
}
]
Expand Down
8 changes: 6 additions & 2 deletions libui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: sbednar <sbednar@student.42.fr> +#+ +:+ +#+ #
# By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/03/07 16:14:32 by sbednar #+# #+# #
# Updated: 2019/04/15 05:51:18 by sbednar ### ########.fr #
# Updated: 2019/04/15 10:24:19 by edraugr- ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -34,6 +34,10 @@ SRC_UI_EL = ui_el_add_child.c \
ui_el_add_texture.c \
ui_el_create_texture_from_surface.c \
ui_el_get_current_texture.c \
ui_el_set_abs_size.c \
ui_el_set_rel_size.c \
ui_el_set_abs_pos.c \
ui_el_set_rel_pos.c \
ui_el_default_pointer_enter.c \
ui_el_default_pointer_exit.c \
ui_el_setup_default.c
Expand Down
4 changes: 2 additions & 2 deletions libui/include/libui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* libui.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbednar <sbednar@student.42.fr> +#+ +:+ +#+ */
/* By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/10 19:09:04 by sbednar #+# #+# */
/* Updated: 2019/04/15 05:51:11 by sbednar ### ########.fr */
/* Updated: 2019/04/15 10:19:18 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
5 changes: 3 additions & 2 deletions libui/src/ui_el/ui_el_add_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ui_el_add_child.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbednar <sbednar@student.42.fr> +#+ +:+ +#+ */
/* By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/28 14:55:52 by edraugr- #+# #+# */
/* Updated: 2019/04/04 05:25:29 by sbednar ### ########.fr */
/* Updated: 2019/04/15 06:40:12 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -18,6 +18,7 @@ int ui_el_add_child(t_ui_el *el, t_ui_el *child)

if ((node = ft_lstnew(NULL, 0)) == NULL)
return (FUNCTION_FAILURE);
child->parent = el;
node->content = (void *)child;
ft_lstadd_back(&(el->children), node);
return (FUNCTION_SUCCESS);
Expand Down
6 changes: 3 additions & 3 deletions libui/src/ui_el/ui_el_set_abs_pos.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: edraugr- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/10 13:35:28 by edraugr- #+# #+# */
/* Updated: 2019/04/10 14:00:57 by edraugr- ### ########.fr */
/* Updated: 2019/04/15 06:16:15 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -20,6 +20,6 @@ void ui_el_set_abs_pos(t_ui_el *el, int x, int y)
return ;
el->rect.x = x;
el->rect.y = y;
el->frect.x = (float)((float)p->rect.x / (float)x);
el->frect.y = (float)((float)p->rect.y / (float)y);
el->frect.x = (float)((float)x / (float)p->rect.w);
el->frect.y = (float)((float)y / (float)p->rect.h);
}
8 changes: 4 additions & 4 deletions libui/src/ui_el/ui_el_set_abs_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: edraugr- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/10 13:33:27 by edraugr- #+# #+# */
/* Updated: 2019/04/10 13:47:08 by edraugr- ### ########.fr */
/* Updated: 2019/04/12 20:43:52 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,14 +16,14 @@ void ui_el_set_abs_size(t_ui_el *el, int w, int h)
{
t_ui_el *p;

if (!el || !(p = el->parent))
if (!el || !(p = el->parent) || w == 0 || h == 0)
return ;
// if (x > p->rect.x || x < 0)
// x > 0 ? x = p->p->rect.x : x = 0;
// if (y > p->p->rect.y || y < 0)
// y > 0 ? y = p->p->rect.y : y = 0;
el->rect.w = w;
el->rect.h = h;
el->frect.w = (float)((float)p->rect.w / (float)w);
el->frect.h = (float)((float)p->rect.h / (float)h);
el->frect.w = (float)((float)w / (float)p->rect.w);
el->frect.h = (float)((float)h / (float)p->rect.h);
}
4 changes: 2 additions & 2 deletions libui/src/ui_el/ui_el_set_rel_pos.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
/* By: edraugr- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/10 13:35:52 by edraugr- #+# #+# */
/* Updated: 2019/04/10 14:06:17 by edraugr- ### ########.fr */
/* Updated: 2019/04/11 23:34:42 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

#include "libui.h"

void ui_el_set_rel_size(t_ui_el *el, float x, float y)
void ui_el_set_rel_pos(t_ui_el *el, float x, float y)
{
t_ui_el *p;

Expand Down
4 changes: 2 additions & 2 deletions libui/src/ui_el/ui_el_set_rel_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: edraugr- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/10 13:35:05 by edraugr- #+# #+# */
/* Updated: 2019/04/10 14:06:00 by edraugr- ### ########.fr */
/* Updated: 2019/04/12 20:19:05 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,7 +16,7 @@ void ui_el_set_rel_size(t_ui_el *el, float w, float h)
{
t_ui_el *p;

if (!el || !(p = el->parent))
if (!el || !(p = el->parent) || w == 0.0 || h == 0.0)
return ;
el->frect.w = w;
el->frect.h = h;
Expand Down
20 changes: 17 additions & 3 deletions libui/src/ui_log/ui_log_window_closed.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
/* ::: :::::::: */
/* ui_log_window_closed.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbednar <sbednar@student.42.fr> +#+ +:+ +#+ */
/* By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/04 00:51:02 by sbednar #+# #+# */
/* Updated: 2019/04/06 18:43:54 by sbednar ### ########.fr */
/* Updated: 2019/04/15 10:33:25 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

#include "libui.h"

void ui_log_window_closed(void *a1, void *a2)
static void close_notmain(t_ui_main *m, Uint32 windowID)
{
ui_main_remove_window_by_id(m, windowID);
}

static void close_main()
{
ui_sdl_deinit(EXIT_SUCCESS);
}

void ui_log_window_closed(void *a1, void *a2)
{
t_ui_main *m;
t_ui_win *w;
Expand All @@ -24,5 +34,9 @@ void ui_log_window_closed(void *a1, void *a2)
if (w != NULL)
{
SDL_Log("Window with ID=%d closed\n", windowID);
if (w->params & WIN_MAIN)
close_main();
else
close_notmain(m, windowID);
}
}
9 changes: 6 additions & 3 deletions libui/src/ui_main/ui_main_add_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ui_main_add_window.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbednar <sbednar@student.42.fr> +#+ +:+ +#+ */
/* By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/30 22:02:32 by sbednar #+# #+# */
/* Updated: 2019/04/04 00:06:08 by sbednar ### ########.fr */
/* Updated: 2019/04/15 09:05:07 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,8 +16,11 @@ int ui_main_add_window(t_ui_main *m, t_ui_win *w)
{
t_list *node;

if (!(node = ft_lstnew((void *)w, sizeof(t_ui_win))))
// if (!(node = ft_lstnew((void *)w, sizeof(t_ui_win))))
// return (FUNCTION_FAILURE);
if (!(node = ft_lstnew(NULL, 0)))
return (FUNCTION_FAILURE);
node->content = (void *)w;
if (m->windows == NULL)
m->windows = node;
else
Expand Down
14 changes: 11 additions & 3 deletions libui/src/ui_main/ui_main_remove_window_by_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
/* ::: :::::::: */
/* ui_main_remove_window_by_id.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sbednar <sbednar@student.fr.42> +#+ +:+ +#+ */
/* By: edraugr- <edraugr-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/30 23:34:51 by sbednar #+# #+# */
/* Updated: 2019/03/31 02:46:33 by sbednar ### ########.fr */
/* Updated: 2019/04/15 09:55:47 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

#include "libui.h"

static void ft_lstdelones_without_cont(t_list **alst)
{
if (!alst)
return ;
free(*alst);
*alst = NULL;
}

void ui_main_remove_window_by_id(t_ui_main *m, Uint32 windowID)
{
t_list *prev;
Expand All @@ -30,7 +38,7 @@ void ui_main_remove_window_by_id(t_ui_main *m, Uint32 windowID)
else
prev->next = cur->next;
ui_win_close(win);
ft_lstdelones(&cur);
ft_lstdelones_without_cont(&cur);
return ;
}
prev = cur;
Expand Down
4 changes: 1 addition & 3 deletions libui/src/ui_win/ui_win_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: edraugr- <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/29 21:00:14 by sbednar #+# #+# */
/* Updated: 2019/04/10 02:17:17 by edraugr- ### ########.fr */
/* Updated: 2019/04/15 10:50:13 by edraugr- ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,8 +21,6 @@ void ui_win_create(t_ui_win *w)
;
w->sdl_renderer = SDL_CreateRenderer(w->sdl_window, -1, 0);
w->sdl_windowID = SDL_GetWindowID(w->sdl_window);
// w->canvas.rect.x = w->size.x;
// w->canvas.rect.y = w->size.y;
SDL_SetWindowResizable(w->sdl_window, (w->params) & WIN_RESIZABLE ? SDL_TRUE : SDL_FALSE);
SDL_RaiseWindow(w->sdl_window);
}
Loading