diff --git a/includes/mlx_functions.h b/includes/mlx_functions.h index 772a6ee..85d15b8 100644 --- a/includes/mlx_functions.h +++ b/includes/mlx_functions.h @@ -6,7 +6,7 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/08 21:54:56 by bgoulard #+# #+# */ -/* Updated: 2024/11/11 21:36:06 by rparodi ### ########.fr */ +/* Updated: 2024/11/11 21:54:26 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,9 +58,8 @@ int mlx_clear_window(t_xvar *mlx_ptr, t_win_list *win_ptr); * @param color Color of the pixel. * @return 0 on success, non-zero on error. */ -int mlx_pixel_put(\ - t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y, int color); - +int mlx_pixel_put(t_xvar *mlx_ptr, t_win_list *win_ptr, \ + int x, int y, int color); /** * @brief Creates a new image. @@ -79,7 +78,8 @@ t_img *mlx_new_image(t_xvar *mlx_ptr, int width, int height); * @param endian Endian of the image (0 for little-endian, 1 for big-endian). * @return Pointer to the image data. */ -char *mlx_get_data_addr(t_img *img_ptr, int *bits_per_pixel, int *size_line, int *endian); +char *mlx_get_data_addr(t_img *img_ptr, int *bits_per_pixel, \ + int *size_line, int *endian); /** * @brief Puts an image into a window. @@ -90,7 +90,8 @@ char *mlx_get_data_addr(t_img *img_ptr, int *bits_per_pixel, int *size_line, int * @param y Y coordinate in the window. * @return 0 on success, non-zero on error. */ -int mlx_put_image_to_window(t_xvar *mlx_ptr, t_win_list *win_ptr, t_img *img_ptr, int x, int y); +int mlx_put_image_to_window(t_xvar *mlx_ptr, t_win_list *win_ptr, \ + t_img *img_ptr, int x, int y); /** * @brief Gets the color value for the specified color. @@ -98,7 +99,7 @@ int mlx_put_image_to_window(t_xvar *mlx_ptr, t_win_list *win_ptr, t_img *img_ptr * @param color The color to retrieve the value for. * @return The color value. */ -int mlx_get_color_value(t_xvar *mlx_ptr, int color); +int mlx_get_color_value(t_xvar *mlx_ptr, int color); /** * @brief Sets a mouse hook on the window. @@ -107,7 +108,8 @@ int mlx_get_color_value(t_xvar *mlx_ptr, int color); * @param param Parameter passed to the hook function. * @return 0 on success, non-zero on error. */ -int mlx_mouse_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); +int mlx_mouse_hook(t_win_list *win_ptr, int (*funct_ptr)(), \ + void *param); /** * @brief Sets a keyboard hook on the window. @@ -116,7 +118,7 @@ int mlx_mouse_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); * @param param Parameter passed to the hook function. * @return 0 on success, non-zero on error. */ -int mlx_key_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); +int mlx_key_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); /** * @brief Sets an expose hook on the window. @@ -125,7 +127,8 @@ int mlx_key_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); * @param param Parameter passed to the hook function. * @return 0 on success, non-zero on error. */ -int mlx_expose_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); +int mlx_expose_hook(t_win_list *win_ptr, int (*funct_ptr)(), \ + void *param); /** * @brief Sets a loop hook for repeated execution. @@ -134,21 +137,21 @@ int mlx_expose_hook(t_win_list *win_ptr, int (*funct_ptr)(), void *param); * @param param Parameter passed to the hook function. * @return 0 on success, non-zero on error. */ -int mlx_loop_hook(t_xvar *mlx_ptr, int (*funct_ptr)(), void *param); +int mlx_loop_hook(t_xvar *mlx_ptr, int (*funct_ptr)(), void *param); /** * @brief Starts the main loop for MLX. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_loop(t_xvar *mlx_ptr); +int mlx_loop(t_xvar *mlx_ptr); /** * @brief Ends the main loop for MLX. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_loop_end(t_xvar *mlx_ptr); +int mlx_loop_end(t_xvar *mlx_ptr); /** * @brief Draws a string in the specified window. @@ -160,7 +163,8 @@ int mlx_loop_end(t_xvar *mlx_ptr); * @param string The string to display. * @return 0 on success, non-zero on error. */ -int mlx_string_put(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y, int color, char *string); +int mlx_string_put(t_xvar *mlx_ptr, t_win_list *win_ptr, \ + int x, int y, int color, char *string); /** * @brief Sets the font for the window. @@ -168,7 +172,7 @@ int mlx_string_put(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y, int color * @param win_ptr Pointer to the window. * @param name The font name. */ -void mlx_set_font(t_xvar *mlx_ptr, t_win_list *win_ptr, char *name); +void mlx_set_font(t_xvar *mlx_ptr, t_win_list *win_ptr, char *name); /** * @brief Converts XPM data to an image. @@ -178,7 +182,8 @@ void mlx_set_font(t_xvar *mlx_ptr, t_win_list *win_ptr, char *name); * @param height Output parameter for the height of the image. * @return Pointer to the created image. */ -t_img *mlx_xpm_to_image(t_xvar *mlx_ptr, char **xpm_data, int *width, int *height); +t_img *mlx_xpm_to_image(t_xvar *mlx_ptr, char **xpm_data, int *width, \ + int *height); /** * @brief Converts an XPM file to an image. @@ -188,7 +193,8 @@ t_img *mlx_xpm_to_image(t_xvar *mlx_ptr, char **xpm_data, int *width, int *heigh * @param height Output parameter for the height of the image. * @return Pointer to the created image. */ -t_img *mlx_xpm_file_to_image(t_xvar *mlx_ptr, char *filename, int *width, int *height); +t_img *mlx_xpm_file_to_image(t_xvar *mlx_ptr, char *filename, \ + int *width, int *height); /** * @brief Destroys a window. @@ -196,7 +202,7 @@ t_img *mlx_xpm_file_to_image(t_xvar *mlx_ptr, char *filename, int *width, int *h * @param win_ptr Pointer to the window. * @return 0 on success, non-zero on error. */ -int mlx_destroy_window(t_xvar *mlx_ptr, t_win_list *win_ptr); +int mlx_destroy_window(t_xvar *mlx_ptr, t_win_list *win_ptr); /** * @brief Destroys an image. @@ -204,14 +210,14 @@ int mlx_destroy_window(t_xvar *mlx_ptr, t_win_list *win_ptr); * @param img_ptr Pointer to the image. * @return 0 on success, non-zero on error. */ -int mlx_destroy_image(t_xvar *mlx_ptr, t_img *img_ptr); +int mlx_destroy_image(t_xvar *mlx_ptr, t_img *img_ptr); /** * @brief Destroys the MLX display. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_destroy_display(t_xvar *mlx_ptr); +int mlx_destroy_display(t_xvar *mlx_ptr); /** * @brief Sets an event hook for a specific event. @@ -222,28 +228,29 @@ int mlx_destroy_display(t_xvar *mlx_ptr); * @param param Parameter passed to the hook function. * @return 0 on success, non-zero on error. */ -int mlx_hook(t_win_list *win_ptr, int x_event, int x_mask, int (*funct)(), void *param); +int mlx_hook(t_win_list *win_ptr, int x_event, int x_mask, \ + int (*funct)(), void *param); /** * @brief Disables key auto-repeat. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_do_key_autorepeatoff(t_xvar *mlx_ptr); +int mlx_do_key_autorepeatoff(t_xvar *mlx_ptr); /** * @brief Enables key auto-repeat. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_do_key_autorepeaton(t_xvar *mlx_ptr); +int mlx_do_key_autorepeaton(t_xvar *mlx_ptr); /** * @brief Synchronizes the MLX display. * @param mlx_ptr Pointer to the MLX instance. * @return 0 on success, non-zero on error. */ -int mlx_do_sync(t_xvar *mlx_ptr); +int mlx_do_sync(t_xvar *mlx_ptr); /** * @brief Retrieves the current mouse position. @@ -253,7 +260,8 @@ int mlx_do_sync(t_xvar *mlx_ptr); * @param y Output parameter for the Y coordinate. * @return 0 on success, non-zero on error. */ -int mlx_mouse_get_pos(t_xvar *mlx_ptr, t_win_list *win_ptr, int *x, int *y); +int mlx_mouse_get_pos(t_xvar *mlx_ptr, t_win_list *win_ptr, \ + int *x, int *y); /** * @brief Moves the mouse to a specified position. @@ -263,7 +271,7 @@ int mlx_mouse_get_pos(t_xvar *mlx_ptr, t_win_list *win_ptr, int *x, int *y); * @param y Y coordinate to move to. * @return 0 on success, non-zero on error. */ -int mlx_mouse_move(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y); +int mlx_mouse_move(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y); /** * @brief Hides the mouse cursor. @@ -271,7 +279,7 @@ int mlx_mouse_move(t_xvar *mlx_ptr, t_win_list *win_ptr, int x, int y); * @param win_ptr Pointer to the window. * @return 0 on success, non-zero on error. */ -int mlx_mouse_hide(t_xvar *mlx_ptr, t_win_list *win_ptr); +int mlx_mouse_hide(t_xvar *mlx_ptr, t_win_list *win_ptr); /** * @brief Shows the mouse cursor. @@ -279,7 +287,6 @@ int mlx_mouse_hide(t_xvar *mlx_ptr, t_win_list *win_ptr); * @param win_ptr Pointer to the window. * @return 0 on success, non-zero on error. */ -int mlx_mouse_show(t_xvar *mlx_ptr, t_win_list *win_ptr); - +int mlx_mouse_show(t_xvar *mlx_ptr, t_win_list *win_ptr); #endif /* FIXED_MLX_H */ diff --git a/includes/mlx_structs.h b/includes/mlx_structs.h index 954de86..4a3b522 100644 --- a/includes/mlx_structs.h +++ b/includes/mlx_structs.h @@ -6,12 +6,12 @@ /* By: bgoulard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/10 05:33:08 by bgoulard #+# #+# */ -/* Updated: 2024/11/10 05:38:28 by bgoulard ### ########.fr */ +/* Updated: 2024/11/11 21:45:35 by bgoulard ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef MLX_STRUCT_H -# define MLX_STRUCT_H +#ifndef MLX_STRUCTS_H +# define MLX_STRUCTS_H # include # include @@ -25,31 +25,28 @@ # define ENV_DISPLAY "DISPLAY" # define LOCALHOST "localhost" -# define ERR_NO_TRUECOLOR "MinilibX Error : No TrueColor Visual available.\n" -# define WARN_SHM_ATTACH "MinilibX Warning : X server can't attach shared memory.\n" -typedef struct s_xpm_col +typedef struct s_xpm_col { int name; int col; -} t_xpm_col; +} t_xpm_col; - -struct s_col_name +struct s_col_name { char *name; int color; }; -typedef struct s_event_list +typedef struct s_event_list { int mask; int (*hook)(); void *param; -} t_event_list; +} t_event_list; /// @brief window pointer from mlx -typedef struct s_win_list +typedef struct s_win_list { Window window; GC gc; @@ -61,9 +58,9 @@ typedef struct s_win_list void *key_param; void *expose_param; t_event_list hooks[MLX_MAX_EVENT]; -} t_win_list; +} t_win_list; -typedef struct s_img +typedef struct s_img { XImage *image; Pixmap pix; @@ -76,10 +73,10 @@ typedef struct s_img int format; char *data; XShmSegmentInfo shm; -} t_img; +} t_img; /// @brief mlx pointer -typedef struct s_xvar +typedef struct s_xvar { Display *display; Window root; @@ -97,7 +94,7 @@ typedef struct s_xvar int decrgb[6]; Atom wm_delete_window; Atom wm_protocols; - int end_loop; + int end_loop; } t_xvar; -#endif /* MLX_STRUCT_H */ +#endif /* MLX_STRUCTS_H */