Mercurial > molko
changeset 564:e91f37da2992
core: doxygenize window
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 08 Mar 2023 20:09:21 +0100 |
parents | 4e6d3b00f514 |
children | 97af110e9e4d |
files | libmlk-core/mlk/core/window.c libmlk-core/mlk/core/window.h |
diffstat | 2 files changed, 96 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmlk-core/mlk/core/window.c Wed Mar 08 19:57:23 2023 +0100 +++ b/libmlk-core/mlk/core/window.c Wed Mar 08 20:09:21 2023 +0100 @@ -82,6 +82,8 @@ mlk_window_open(const char *title, unsigned int w, unsigned int h) { assert(title); + assert(w); + assert(h); if (!load_window(title, w, h) || !load_renderer()) return mlk_errf("%s", SDL_GetError());
--- a/libmlk-core/mlk/core/window.h Wed Mar 08 19:57:23 2023 +0100 +++ b/libmlk-core/mlk/core/window.h Wed Mar 08 20:09:21 2023 +0100 @@ -19,36 +19,128 @@ #ifndef MLK_CORE_WINDOW_H #define MLK_CORE_WINDOW_H +/** + * \file window.h + * \brief Basic window management + * + * Main window module. + * + * In Molko's Engine, only one window can be opened at a time and is provided + * read-only with the ::mlk_window global variable. + */ + +/** + * \struct mlk_window + * \brief Window structure + */ struct mlk_window { + /** + * (read-only) + * + * Window width. + */ unsigned int w; + + /** + * (read-only) + * + * Window height. + */ unsigned int h; + + /** + * (read-only) + * + * Display preferred framerate. May be set to 0 if not supported. + */ unsigned int framerate; + + /** \cond MLK_PRIVATE_DECLS */ void *handle; + /** \endcond MLK_PRIVATE_DECLS */ }; +/** + * \enum mlk_window_cursor + * \brief Window mouse cursor + * \note Not all cursors are supported. + */ enum mlk_window_cursor { + /** + * Standard arrow. + */ MLK_WINDOW_CURSOR_ARROW, + + /** + * Text edit cursor like "I". + */ MLK_WINDOW_CURSOR_EDIT, + + /** + * Busy cursor. + */ MLK_WINDOW_CURSOR_WAIT, + + /** + * Cross-hair for selection. + */ MLK_WINDOW_CURSOR_CROSSHAIR, + + /** + * Resizing or moving cursor. + */ MLK_WINDOW_CURSOR_SIZE, + + /** + * Forbidden action. + */ MLK_WINDOW_CURSOR_NO, + + /** + * Hand, usually for hyper links. + */ MLK_WINDOW_CURSOR_HAND, + + /** + * Unused sentinel value. + */ MLK_WINDOW_CURSOR_LAST }; +/** + * Global readonly window info. + */ extern struct mlk_window mlk_window; #if defined(__cplusplus) extern "C" { #endif +/** + * Open the window. + * + * \pre title != NULL + * \pre w > 0 + * \pre h > 0 + * \param title the window title + * \param w the window width + * \param h the window height + * \return 0 on success or -1 on error + */ int -mlk_window_open(const char *, unsigned int, unsigned int); +mlk_window_open(const char *title, unsigned int w, unsigned int h); +/** + * Change the window mouse cursor. + * + * \param cursor the new cursor + */ void -mlk_window_set_cursor(enum mlk_window_cursor); +mlk_window_set_cursor(enum mlk_window_cursor cursor); +/** + * Destroy the window. + */ void mlk_window_finish(void);