gtkcssnodeprivate.h 11.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* GTK - The GIMP Toolkit
 * Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __GTK_CSS_NODE_PRIVATE_H__
#define __GTK_CSS_NODE_PRIVATE_H__

#include "gtkcssnodedeclarationprivate.h"
22
#include "gtkcssnodestylecacheprivate.h"
23
#include "gtkcssstylechangeprivate.h"
24 25
#include "gtkbitmaskprivate.h"
#include "gtkcsstypesprivate.h"
26 27 28

G_BEGIN_DECLS

29 30 31 32 33 34 35
#define GTK_TYPE_CSS_NODE           (gtk_css_node_get_type ())
#define GTK_CSS_NODE(obj)           (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_NODE, GtkCssNode))
#define GTK_CSS_NODE_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_NODE, GtkCssNodeClass))
#define GTK_IS_CSS_NODE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_NODE))
#define GTK_IS_CSS_NODE_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_NODE))
#define GTK_CSS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_NODE, GtkCssNodeClass))

36
typedef struct _GtkCssNodeClass         GtkCssNodeClass;
37 38 39 40 41

struct _GtkCssNode
{
  GObject object;

42 43 44 45 46 47
  GtkCssNode *parent;
  GtkCssNode *previous_sibling;
  GtkCssNode *next_sibling;
  GtkCssNode *first_child;
  GtkCssNode *last_child;

48 49
  GtkCssNodeDeclaration *decl;
  GtkCssStyle           *style;
50
  GtkCssNodeStyleCache  *cache;                 /* cache for children to look up styles */
51

52 53
  GtkCssChange           pending_changes;       /* changes that accumulated since the style was last computed */

54
  guint                  visible :1;            /* node will be skipped when validating or computing styles */
55
  guint                  invalid :1;            /* node or a child needs to be validated (even if just for animation) */
56
  guint                  needs_propagation :1;  /* children have state changes that need to be propagated to their siblings */
57 58 59 60 61 62
  /* Two invariants hold for this variable:
   * style_is_invalid == TRUE  =>  next_sibling->style_is_invalid == TRUE
   * style_is_invalid == FALSE =>  first_child->style_is_invalid == TRUE
   * So if a valid style is computed, one has to previously ensure that the parent's and the previous sibling's style
   * are valid. This allows both validation and invalidation to run in O(nodes-in-tree) */
  guint                  style_is_invalid :1;   /* the style needs to be recomputed */
63 64 65 66 67
};

struct _GtkCssNodeClass
{
  GObjectClass object_class;
68

69 70 71 72 73 74
  void                  (* node_added)                  (GtkCssNode            *cssnode,
                                                         GtkCssNode            *child,
                                                         GtkCssNode            *previous);
  void                  (* node_removed)                (GtkCssNode            *cssnode,
                                                         GtkCssNode            *child,
                                                         GtkCssNode            *previous);
75
  void                  (* style_changed)               (GtkCssNode            *cssnode,
76
                                                         GtkCssStyleChange     *style_change);
77

78
  gboolean              (* init_matcher)                (GtkCssNode            *cssnode,
79
                                                         GtkCssMatcher         *matcher);
80 81
  GtkWidgetPath *       (* create_widget_path)          (GtkCssNode            *cssnode);
  const GtkWidgetPath * (* get_widget_path)             (GtkCssNode            *cssnode);
82
  /* get style provider to use or NULL to use parent's */
83
  GtkStyleProviderPrivate *(* get_style_provider)       (GtkCssNode            *cssnode);
84 85
  /* get frame clock or NULL (only relevant for root node) */
  GdkFrameClock *       (* get_frame_clock)             (GtkCssNode            *cssnode);
86 87
  GtkCssStyle *         (* update_style)                (GtkCssNode            *cssnode,
                                                         GtkCssChange           pending_changes,
88
                                                         gint64                 timestamp,
89 90
                                                         GtkCssStyle           *old_style);
  void                  (* invalidate)                  (GtkCssNode            *node);
91 92
  void                  (* queue_validate)              (GtkCssNode            *node);
  void                  (* dequeue_validate)            (GtkCssNode            *node);
93
  void                  (* validate)                    (GtkCssNode            *node);
94 95 96
};

GType                   gtk_css_node_get_type           (void) G_GNUC_CONST;
97

98 99
GtkCssNode *            gtk_css_node_new                (void);

100 101
void                    gtk_css_node_set_parent         (GtkCssNode            *cssnode,
                                                         GtkCssNode            *parent);
102 103
void                    gtk_css_node_insert_after       (GtkCssNode            *parent,
                                                         GtkCssNode            *cssnode,
104
                                                         GtkCssNode            *previous_sibling);
105 106
void                    gtk_css_node_insert_before      (GtkCssNode            *parent,
                                                         GtkCssNode            *cssnode,
107
                                                         GtkCssNode            *next_sibling);
108 109
void                    gtk_css_node_reverse_children   (GtkCssNode            *cssnode);

110
GtkCssNode *            gtk_css_node_get_parent         (GtkCssNode            *cssnode);
111 112 113 114
GtkCssNode *            gtk_css_node_get_first_child    (GtkCssNode            *cssnode);
GtkCssNode *            gtk_css_node_get_last_child     (GtkCssNode            *cssnode);
GtkCssNode *            gtk_css_node_get_previous_sibling(GtkCssNode           *cssnode);
GtkCssNode *            gtk_css_node_get_next_sibling   (GtkCssNode            *cssnode);
115

116 117 118 119
void                    gtk_css_node_set_visible        (GtkCssNode            *cssnode,
                                                         gboolean               visible);
gboolean                gtk_css_node_get_visible        (GtkCssNode            *cssnode);

120 121 122
void                    gtk_css_node_set_name           (GtkCssNode            *cssnode,
                                                         /*interned*/const char*name);
/*interned*/const char *gtk_css_node_get_name           (GtkCssNode            *cssnode);
123 124 125
void                    gtk_css_node_set_widget_type    (GtkCssNode            *cssnode,
                                                         GType                  widget_type);
GType                   gtk_css_node_get_widget_type    (GtkCssNode            *cssnode);
126
void                    gtk_css_node_set_id             (GtkCssNode            *cssnode,
127 128
                                                         /*interned*/const char*id);
/*interned*/const char *gtk_css_node_get_id             (GtkCssNode            *cssnode);
129
void                    gtk_css_node_set_state          (GtkCssNode            *cssnode,
130 131 132 133 134
                                                         GtkStateFlags          state_flags);
GtkStateFlags           gtk_css_node_get_state          (GtkCssNode            *cssnode);
void                    gtk_css_node_set_junction_sides (GtkCssNode            *cssnode,
                                                         GtkJunctionSides       junction_sides);
GtkJunctionSides        gtk_css_node_get_junction_sides (GtkCssNode            *cssnode);
Benjamin Otte's avatar
Benjamin Otte committed
135 136 137
void                    gtk_css_node_set_classes        (GtkCssNode            *cssnode,
                                                         const char           **classes);
char **                 gtk_css_node_get_classes        (GtkCssNode            *cssnode);
138
void                    gtk_css_node_add_class          (GtkCssNode            *cssnode,
139
                                                         GQuark                 style_class);
140
void                    gtk_css_node_remove_class       (GtkCssNode            *cssnode,
141 142 143
                                                         GQuark                 style_class);
gboolean                gtk_css_node_has_class          (GtkCssNode            *cssnode,
                                                         GQuark                 style_class);
144 145
const GQuark *          gtk_css_node_list_classes       (GtkCssNode            *cssnode,
                                                         guint                 *n_classes);
146
void                    gtk_css_node_add_region         (GtkCssNode            *cssnode,
147 148
                                                         GQuark                 region,
                                                         GtkRegionFlags         flags);
149
void                    gtk_css_node_remove_region      (GtkCssNode            *cssnode,
150 151 152 153 154 155 156 157
                                                         GQuark                 region);
gboolean                gtk_css_node_has_region         (GtkCssNode            *cssnode,
                                                         GQuark                 region,
                                                         GtkRegionFlags        *out_flags);
GList *                 gtk_css_node_list_regions       (GtkCssNode            *cssnode);

const GtkCssNodeDeclaration *
                        gtk_css_node_get_declaration    (GtkCssNode            *cssnode);
158
GtkCssStyle *           gtk_css_node_get_style          (GtkCssNode            *cssnode);
159

160

161 162
void                    gtk_css_node_invalidate_style_provider
                                                        (GtkCssNode            *cssnode);
163 164 165
void                    gtk_css_node_invalidate_frame_clock
                                                        (GtkCssNode            *cssnode,
                                                         gboolean               just_timestamp);
166 167
void                    gtk_css_node_invalidate         (GtkCssNode            *cssnode,
                                                         GtkCssChange           change);
168
void                    gtk_css_node_validate           (GtkCssNode            *cssnode);
169 170

gboolean                gtk_css_node_init_matcher       (GtkCssNode            *cssnode,
171
                                                         GtkCssMatcher         *matcher);
172 173
GtkWidgetPath *         gtk_css_node_create_widget_path (GtkCssNode            *cssnode);
const GtkWidgetPath *   gtk_css_node_get_widget_path    (GtkCssNode            *cssnode);
174
GtkStyleProviderPrivate *gtk_css_node_get_style_provider(GtkCssNode            *cssnode);
175

176 177 178 179 180
void                    gtk_css_node_print              (GtkCssNode                *cssnode,
                                                         GtkStyleContextPrintFlags  flags,
                                                         GString                   *string,
                                                         guint                      indent);

181 182 183
G_END_DECLS

#endif /* __GTK_CSS_NODE_PRIVATE_H__ */