Mercurial > molko
changeset 625:20e9fd578b44
ui: improve documentation (align.h)
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 26 Aug 2023 09:34:27 +0200 |
parents | bbf30f167274 |
children | 2c5514927166 |
files | libmlk-ui/mlk/ui/align.c libmlk-ui/mlk/ui/align.h |
diffstat | 2 files changed, 75 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libmlk-ui/mlk/ui/align.c Wed Aug 23 21:20:16 2023 +0200 +++ b/libmlk-ui/mlk/ui/align.c Sat Aug 26 09:34:27 2023 +0200 @@ -1,5 +1,5 @@ /* - * align.h -- user interface alignment + * align.c -- user interface alignment helpers * * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr> * @@ -70,8 +70,8 @@ SET(x, px); break; default: - *x = px; - *y = py; + SET(x, px); + SET(y, py); break; } }
--- a/libmlk-ui/mlk/ui/align.h Wed Aug 23 21:20:16 2023 +0200 +++ b/libmlk-ui/mlk/ui/align.h Sat Aug 26 09:34:27 2023 +0200 @@ -1,5 +1,5 @@ /* - * align.h -- user interface alignment + * align.h -- user interface alignment helpers * * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr> * @@ -19,16 +19,64 @@ #ifndef MLK_UI_ALIGN_H #define MLK_UI_ALIGN_H +/** + * \file mlk/ui/align.h + * \brief User interface alignment helpers + */ + +/** + * \enum mlk_align + * \brief Alignment selector + */ enum mlk_align { + /** + * No alignment, set coordinates to the parent coordinates. + */ MLK_ALIGN_NONE, + + /** + * Align to the center. + */ MLK_ALIGN_CENTER, + + /** + * Top left corner. + */ MLK_ALIGN_TOP_LEFT, + + /** + * Top center. + */ MLK_ALIGN_TOP, + + /** + * Top right corner. + */ MLK_ALIGN_TOP_RIGHT, + + /** + * Right center (vertical). + */ MLK_ALIGN_RIGHT, + + /** + * Bottom right corner. + */ MLK_ALIGN_BOTTOM_RIGHT, + + /** + * Bottom center. + */ MLK_ALIGN_BOTTOM, + + /** + * Bottom left corner. + */ MLK_ALIGN_BOTTOM_LEFT, + + /** + * Left center (vertical). + */ MLK_ALIGN_LEFT }; @@ -36,16 +84,30 @@ extern "C" { #endif +/** + * Adjust x, y coordinates according to the object dimensions inside the + * bounding parent box. + * + * \param align alignment selector + * \param x x coordinate position to adjust (can be NULL) + * \param y y coordinate position to adjust (can be NULL) + * \param w the object width + * \param h the object height + * \param px the parent rectangle x coordinate + * \param py the parent rectangle y coordinate + * \param pw the parent rectangle width + * \param ph the parent rectangle height + */ void -mlk_align(enum mlk_align, - int *, - int *, - unsigned int, - unsigned int, - int, - int, - unsigned int, - unsigned int); +mlk_align(enum mlk_align align, + int *x, + int *y, + unsigned int w, + unsigned int h, + int px, + int py, + unsigned int pw, + unsigned int ph); #if defined(__cplusplus) }