comparison libmlk-ui/ui/align.h @ 243:71b3b7036de7

misc: lot of cleanups, - prefix libraries with libmlk, - move assets from source directories closes #2520, - prefix header guards closes #2519
author David Demelier <markand@malikania.fr>
date Sat, 28 Nov 2020 22:37:30 +0100
parents libui/ui/align.h@9733d379be89
children 08ab73b32832
comparison
equal deleted inserted replaced
242:4c24604efcab 243:71b3b7036de7
1 /*
2 * align.h -- user interface alignment
3 *
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MOLKO_UI_ALIGN_H
20 #define MOLKO_UI_ALIGN_H
21
22 /**
23 * \file align.h
24 * \brief User interface alignment.
25 */
26
27 /**
28 * \brief Label alignment in bounding box.
29 *
30 * The alignment is described as following:
31 *
32 * ```
33 * +---------------------+
34 * | 2 3 4 |
35 * | |
36 * | 9 1 5 |
37 * | |
38 * | 8 7 6 |
39 * +---------------------+
40 * ```
41 *
42 * The default value of 0 (LABEL_ALIGN_NONE) means the alignment isn't used.
43 */
44 enum align {
45 ALIGN_NONE, /*!< No alignment. */
46 ALIGN_CENTER, /*!< Align to the center. */
47 ALIGN_TOP_LEFT, /*!< Top left. */
48 ALIGN_TOP, /*!< Top center (aligned horizontally). */
49 ALIGN_TOP_RIGHT, /*!< Top right. */
50 ALIGN_RIGHT, /*!< Right (aligned vertically). */
51 ALIGN_BOTTOM_RIGHT, /*!< Bottom right. */
52 ALIGN_BOTTOM, /*!< Bottom (aligned horizontally). */
53 ALIGN_BOTTOM_LEFT, /*!< Bottom left. */
54 ALIGN_LEFT /*!< Left (aligned vertically). */
55 };
56
57 /**
58 * Align the given object relative to its parent region.
59 *
60 * The arguments are described as following:
61 *
62 * ```
63 * Example of ALIGN_LEFT (centered vertically but placed on the left.)
64 *
65 * px, py
66 * +----------pw----------+
67 * | |
68 * | x, y |
69 * | +---w---+ |
70 * ph h | |
71 * | +-------+ |
72 * | |
73 * | |
74 * +----------------------+
75 * ```
76 *
77 * As a convenience, x and y are left untouched if align is ALIGN_NONE which
78 * means you can set the coordinates to default values and still call the align
79 * function without need to check.
80 *
81 * \param align the desired alignment
82 * \param x the pointer to x coordinate to modify (may be NULL)
83 * \param y the pointer yo y coordinate to modify (may be NULL)
84 * \param w the object width
85 * \param h the object height
86 * \param px the parent region start
87 * \param py the parent region start
88 * \param pw the parent region width
89 * \param ph the parent region height
90 */
91 void
92 align(enum align align,
93 int *x,
94 int *y,
95 unsigned int w,
96 unsigned int h,
97 int px,
98 int py,
99 unsigned int pw,
100 unsigned int ph);
101
102 #endif /* !MOLKO_UI_ALIGN_H */