~mterry/ubuntu/natty/gnome-shell/wip

« back to all changes in this revision

Viewing changes to src/st/st-theme-node.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-10-12 22:44:00 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012224400-k91p42yvou07i525
Tags: 2.28.0-0ubuntu1
* New upstream version
* debian/control:
  - updated build requirement
* debian/patches/80_git_change_fix_alt_tab_ressource_usage.patch:
  - git change to fix ressources not being freed on alt-tab

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 
2
#ifndef __ST_THEME_NODE_H__
 
3
#define __ST_THEME_NODE_H__
 
4
 
 
5
#include <clutter/clutter.h>
 
6
#include "st-border-image.h"
 
7
 
 
8
G_BEGIN_DECLS
 
9
 
 
10
/**
 
11
 * SECTION:StThemeNode
 
12
 * @short_description: style information for one node in a tree of themed objects
 
13
 *
 
14
 * A #StThemeNode represents the CSS style information (the set of CSS properties) for one
 
15
 * node in a tree of themed objects. In typical usage, it represents the style information
 
16
 * for a single #ClutterActor. A #StThemeNode is immutable: attributes such as the
 
17
 * CSS classes for the node are passed in at construction. If the attributes of the node
 
18
 * or any parent node change, the node should be discarded and a new node created.
 
19
 * #StThemeNode has generic accessors to look up properties by name and specific
 
20
 * accessors for standard CSS properties that add caching and handling of various
 
21
 * details of the CSS specification. #StThemeNode also has convenience functions to help
 
22
 * in implementing a #ClutterActor with borders and padding.
 
23
 */
 
24
 
 
25
typedef struct _StTheme          StTheme;
 
26
typedef struct _StThemeContext   StThemeContext;
 
27
 
 
28
typedef struct _StThemeNode      StThemeNode;
 
29
typedef struct _StThemeNodeClass StThemeNodeClass;
 
30
 
 
31
#define ST_TYPE_THEME_NODE              (st_theme_node_get_type ())
 
32
#define ST_THEME_NODE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME_NODE, StThemeNode))
 
33
#define ST_THEME_NODE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass),     ST_TYPE_THEME_NODE, StThemeNodeClass))
 
34
#define ST_IS_THEME_NODE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME_NODE))
 
35
#define ST_IS_THEME_NODE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass),     ST_TYPE_THEME_NODE))
 
36
#define ST_THEME_NODE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),     ST_TYPE_THEME_NODE, StThemeNodeClass))
 
37
 
 
38
typedef enum {
 
39
    ST_SIDE_TOP,
 
40
    ST_SIDE_RIGHT,
 
41
    ST_SIDE_BOTTOM,
 
42
    ST_SIDE_LEFT
 
43
} StSide;
 
44
 
 
45
typedef enum {
 
46
    ST_CORNER_TOPLEFT,
 
47
    ST_CORNER_TOPRIGHT,
 
48
    ST_CORNER_BOTTOMRIGHT,
 
49
    ST_CORNER_BOTTOMLEFT
 
50
} StCorner;
 
51
 
 
52
/* These are the CSS values; that doesn't mean we have to implement blink... */
 
53
typedef enum {
 
54
    ST_TEXT_DECORATION_UNDERLINE    = 1 << 0,
 
55
    ST_TEXT_DECORATION_OVERLINE     = 1 << 1,
 
56
    ST_TEXT_DECORATION_LINE_THROUGH = 1 << 2,
 
57
    ST_TEXT_DECORATION_BLINK        = 1 << 3
 
58
} StTextDecoration;
 
59
 
 
60
GType st_theme_node_get_type (void) G_GNUC_CONST;
 
61
 
 
62
StThemeNode *st_theme_node_new (StThemeContext *context,
 
63
                                StThemeNode    *parent_node,   /* can be null */
 
64
                                StTheme        *theme,         /* can be null */
 
65
                                GType           element_type,
 
66
                                const char     *element_id,
 
67
                                const char     *element_class,
 
68
                                const char     *pseudo_class,
 
69
                                const char     *inline_style);
 
70
 
 
71
StThemeNode *st_theme_node_get_parent (StThemeNode *node);
 
72
 
 
73
StTheme *st_theme_node_get_theme (StThemeNode *node);
 
74
 
 
75
GType       st_theme_node_get_element_type  (StThemeNode *node);
 
76
const char *st_theme_node_get_element_id    (StThemeNode *node);
 
77
const char *st_theme_node_get_element_class (StThemeNode *node);
 
78
const char *st_theme_node_get_pseudo_class  (StThemeNode *node);
 
79
 
 
80
/* Generic getters ... these are not cached so are less efficient. The other
 
81
 * reason for adding the more specific version is that we can handle the
 
82
 * details of the actual CSS rules, which can be complicated, especially
 
83
 * for fonts
 
84
 */
 
85
gboolean st_theme_node_get_color  (StThemeNode  *node,
 
86
                                   const char   *property_name,
 
87
                                   gboolean      inherit,
 
88
                                   ClutterColor *color);
 
89
 
 
90
gboolean st_theme_node_get_double (StThemeNode  *node,
 
91
                                   const char   *property_name,
 
92
                                   gboolean      inherit,
 
93
                                   double       *value);
 
94
 
 
95
gboolean st_theme_node_get_length (StThemeNode *node,
 
96
                                   const char  *property_name,
 
97
                                   gboolean     inherit,
 
98
                                   gdouble     *length);
 
99
 
 
100
/* Specific getters for particular properties: cached
 
101
 */
 
102
void st_theme_node_get_background_color (StThemeNode  *node,
 
103
                                         ClutterColor *color);
 
104
void st_theme_node_get_foreground_color (StThemeNode  *node,
 
105
                                         ClutterColor *color);
 
106
 
 
107
const char *st_theme_node_get_background_image (StThemeNode *node);
 
108
 
 
109
double st_theme_node_get_border_width  (StThemeNode  *node,
 
110
                                        StSide        side);
 
111
double st_theme_node_get_border_radius (StThemeNode  *node,
 
112
                                        StCorner      corner);
 
113
void   st_theme_node_get_border_color  (StThemeNode  *node,
 
114
                                        StSide        side,
 
115
                                        ClutterColor *color);
 
116
 
 
117
double st_theme_node_get_padding       (StThemeNode  *node,
 
118
                                        StSide        side);
 
119
 
 
120
StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
 
121
 
 
122
/* Font rule processing is pretty complicated, so we just hardcode it
 
123
 * under the standard font/font-family/font-size/etc names. This means
 
124
 * you can't have multiple separate styled fonts for a single item,
 
125
 * but that should be OK.
 
126
 */
 
127
const PangoFontDescription *st_theme_node_get_font (StThemeNode *node);
 
128
 
 
129
StBorderImage *st_theme_node_get_border_image (StThemeNode *node);
 
130
 
 
131
/* Helpers for get_preferred_width()/get_preferred_height() ClutterActor vfuncs */
 
132
void st_theme_node_adjust_for_height       (StThemeNode  *node,
 
133
                                            float        *for_height);
 
134
void st_theme_node_adjust_preferred_width  (StThemeNode  *node,
 
135
                                            float        *min_width_p,
 
136
                                            float        *natural_width_p);
 
137
void st_theme_node_adjust_for_width        (StThemeNode  *node,
 
138
                                            float        *for_width);
 
139
void st_theme_node_adjust_preferred_height (StThemeNode  *node,
 
140
                                            float        *min_height_p,
 
141
                                            float        *natural_height_p);
 
142
 
 
143
/* Helper for allocate() ClutterActor vfunc */
 
144
void st_theme_node_get_content_box         (StThemeNode        *node,
 
145
                                            const ClutterActorBox *actor_box,
 
146
                                            ClutterActorBox       *content_box);
 
147
 
 
148
gboolean st_theme_node_geometry_equal (StThemeNode *node,
 
149
                                       StThemeNode *other);
 
150
 
 
151
G_END_DECLS
 
152
 
 
153
#endif /* __ST_THEME_NODE_H__ */