1/* GTK - The GIMP Toolkit
2 * Copyright (C) 2019 Benjamin Otte <otte@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GTK_CSS_BOXES_PRIVATE_H__
19#define __GTK_CSS_BOXES_PRIVATE_H__
20
21#include "gtkcsstypesprivate.h"
22#include "gtktypes.h"
23
24G_BEGIN_DECLS
25
26/*
27 * The idea behind this file is that it provides an on-stack representation
28 * for all the CSS boxes one can have to deal with in the CSS box model so that
29 * higher level code can use convenient and readable function calls instead of
30 * doing complicated math.
31 *
32 * However, because computing all those rectangles is prohibitively expensive,
33 * this struct does it lazily.
34 * And then we inline all the code, so that whenever we use this struct, the
35 * compiler can optimize out the parts we don't need in that particular use
36 * case.
37 */
38
39typedef struct _GtkCssBoxes GtkCssBoxes;
40
41/* ahem...
42 * Let's extend GtkCssArea a bit here. */
43#define GTK_CSS_AREA_MARGIN_BOX (3)
44#define GTK_CSS_AREA_OUTLINE_BOX (4)
45#define GTK_CSS_AREA_N_BOXES (5)
46
47
48struct _GtkCssBoxes
49{
50 GtkCssStyle *style;
51 GskRoundedRect box[GTK_CSS_AREA_N_BOXES];
52 gboolean has_rect[GTK_CSS_AREA_N_BOXES]; /* TRUE if we have initialized just the bounds rect */
53 gboolean has_box[GTK_CSS_AREA_N_BOXES]; /* TRUE if we have initialized the whole box */
54};
55
56static inline void gtk_css_boxes_init (GtkCssBoxes *boxes,
57 GtkWidget *widget);
58static inline void gtk_css_boxes_init_content_box (GtkCssBoxes *boxes,
59 GtkCssStyle *style,
60 double x,
61 double y,
62 double width,
63 double height);
64static inline void gtk_css_boxes_init_border_box (GtkCssBoxes *boxes,
65 GtkCssStyle *style,
66 double x,
67 double y,
68 double width,
69 double height);
70
71static inline const graphene_rect_t * gtk_css_boxes_get_rect (GtkCssBoxes *boxes,
72 GtkCssArea area);
73static inline const graphene_rect_t * gtk_css_boxes_get_margin_rect (GtkCssBoxes *boxes);
74static inline const graphene_rect_t * gtk_css_boxes_get_border_rect (GtkCssBoxes *boxes);
75static inline const graphene_rect_t * gtk_css_boxes_get_padding_rect (GtkCssBoxes *boxes);
76static inline const graphene_rect_t * gtk_css_boxes_get_content_rect (GtkCssBoxes *boxes);
77static inline const graphene_rect_t * gtk_css_boxes_get_outline_rect (GtkCssBoxes *boxes);
78
79static inline const GskRoundedRect * gtk_css_boxes_get_box (GtkCssBoxes *boxes,
80 GtkCssArea area);
81static inline const GskRoundedRect * gtk_css_boxes_get_border_box (GtkCssBoxes *boxes);
82static inline const GskRoundedRect * gtk_css_boxes_get_padding_box (GtkCssBoxes *boxes);
83static inline const GskRoundedRect * gtk_css_boxes_get_content_box (GtkCssBoxes *boxes);
84static inline const GskRoundedRect * gtk_css_boxes_get_outline_box (GtkCssBoxes *boxes);
85
86G_END_DECLS
87
88#endif /* __GTK_CSS_BOXES_PRIVATE_H__ */
89
90/* and finally include the actual code for the functions */
91#include "gtkcssboxesimplprivate.h"
92
93

source code of gtk/gtk/gtkcssboxesprivate.h