2009-09-20 00:43:49 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2010-11-10 22:00:45 +00:00
|
|
|
/*
|
|
|
|
* st-theme-node.h: style information for one node in a tree of themed objects
|
|
|
|
*
|
|
|
|
* Copyright 2008-2010 Red Hat, Inc.
|
|
|
|
* Copyright 2009, 2010 Florian Müllner
|
|
|
|
* Copyright 2010 Giovanni Campagna
|
|
|
|
*
|
|
|
|
* This program 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.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
#ifndef __ST_THEME_NODE_H__
|
|
|
|
#define __ST_THEME_NODE_H__
|
|
|
|
|
|
|
|
#include <clutter/clutter.h>
|
2009-09-20 20:50:42 +00:00
|
|
|
#include "st-border-image.h"
|
2010-11-01 02:06:48 +00:00
|
|
|
#include "st-icon-colors.h"
|
2009-11-21 03:19:56 +00:00
|
|
|
#include "st-shadow.h"
|
2009-09-20 00:43:49 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
2011-11-02 16:24:49 +00:00
|
|
|
* SECTION:st-theme-node
|
2009-09-20 00:43:49 +00:00
|
|
|
* @short_description: style information for one node in a tree of themed objects
|
|
|
|
*
|
|
|
|
* A #StThemeNode represents the CSS style information (the set of CSS properties) for one
|
|
|
|
* node in a tree of themed objects. In typical usage, it represents the style information
|
|
|
|
* for a single #ClutterActor. A #StThemeNode is immutable: attributes such as the
|
|
|
|
* CSS classes for the node are passed in at construction. If the attributes of the node
|
|
|
|
* or any parent node change, the node should be discarded and a new node created.
|
|
|
|
* #StThemeNode has generic accessors to look up properties by name and specific
|
|
|
|
* accessors for standard CSS properties that add caching and handling of various
|
|
|
|
* details of the CSS specification. #StThemeNode also has convenience functions to help
|
|
|
|
* in implementing a #ClutterActor with borders and padding.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _StTheme StTheme;
|
|
|
|
typedef struct _StThemeContext StThemeContext;
|
|
|
|
|
|
|
|
typedef struct _StThemeNode StThemeNode;
|
|
|
|
typedef struct _StThemeNodeClass StThemeNodeClass;
|
|
|
|
|
|
|
|
#define ST_TYPE_THEME_NODE (st_theme_node_get_type ())
|
|
|
|
#define ST_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ST_TYPE_THEME_NODE, StThemeNode))
|
|
|
|
#define ST_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ST_TYPE_THEME_NODE, StThemeNodeClass))
|
|
|
|
#define ST_IS_THEME_NODE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), ST_TYPE_THEME_NODE))
|
|
|
|
#define ST_IS_THEME_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ST_TYPE_THEME_NODE))
|
|
|
|
#define ST_THEME_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ST_TYPE_THEME_NODE, StThemeNodeClass))
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ST_SIDE_TOP,
|
2009-09-20 13:08:08 +00:00
|
|
|
ST_SIDE_RIGHT,
|
|
|
|
ST_SIDE_BOTTOM,
|
|
|
|
ST_SIDE_LEFT
|
2009-09-20 00:43:49 +00:00
|
|
|
} StSide;
|
|
|
|
|
2009-09-20 13:08:08 +00:00
|
|
|
typedef enum {
|
|
|
|
ST_CORNER_TOPLEFT,
|
|
|
|
ST_CORNER_TOPRIGHT,
|
|
|
|
ST_CORNER_BOTTOMRIGHT,
|
|
|
|
ST_CORNER_BOTTOMLEFT
|
|
|
|
} StCorner;
|
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
/* These are the CSS values; that doesn't mean we have to implement blink... */
|
|
|
|
typedef enum {
|
|
|
|
ST_TEXT_DECORATION_UNDERLINE = 1 << 0,
|
|
|
|
ST_TEXT_DECORATION_OVERLINE = 1 << 1,
|
|
|
|
ST_TEXT_DECORATION_LINE_THROUGH = 1 << 2,
|
|
|
|
ST_TEXT_DECORATION_BLINK = 1 << 3
|
|
|
|
} StTextDecoration;
|
|
|
|
|
2010-06-22 20:04:45 +00:00
|
|
|
typedef enum {
|
|
|
|
ST_TEXT_ALIGN_LEFT = PANGO_ALIGN_LEFT,
|
|
|
|
ST_TEXT_ALIGN_CENTER = PANGO_ALIGN_CENTER,
|
|
|
|
ST_TEXT_ALIGN_RIGHT = PANGO_ALIGN_RIGHT,
|
|
|
|
ST_TEXT_ALIGN_JUSTIFY
|
|
|
|
} StTextAlign;
|
|
|
|
|
2009-11-14 21:39:22 +00:00
|
|
|
typedef enum {
|
|
|
|
ST_GRADIENT_NONE,
|
|
|
|
ST_GRADIENT_VERTICAL,
|
2010-01-10 01:17:01 +00:00
|
|
|
ST_GRADIENT_HORIZONTAL,
|
|
|
|
ST_GRADIENT_RADIAL
|
2009-11-14 21:39:22 +00:00
|
|
|
} StGradientType;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
typedef struct _StThemeNodePaintState StThemeNodePaintState;
|
|
|
|
|
|
|
|
struct _StThemeNodePaintState {
|
2013-04-05 03:06:29 +00:00
|
|
|
StThemeNode *node;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
float alloc_width;
|
|
|
|
float alloc_height;
|
|
|
|
|
2013-07-03 16:01:00 +00:00
|
|
|
float box_shadow_width;
|
|
|
|
float box_shadow_height;
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
CoglHandle box_shadow_material;
|
|
|
|
CoglHandle prerendered_texture;
|
|
|
|
CoglHandle prerendered_material;
|
|
|
|
CoglHandle corner_material[4];
|
|
|
|
};
|
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
GType st_theme_node_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
StThemeNode *st_theme_node_new (StThemeContext *context,
|
|
|
|
StThemeNode *parent_node, /* can be null */
|
|
|
|
StTheme *theme, /* can be null */
|
|
|
|
GType element_type,
|
|
|
|
const char *element_id,
|
|
|
|
const char *element_class,
|
2009-09-20 02:56:09 +00:00
|
|
|
const char *pseudo_class,
|
|
|
|
const char *inline_style);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
|
|
|
StThemeNode *st_theme_node_get_parent (StThemeNode *node);
|
|
|
|
|
|
|
|
StTheme *st_theme_node_get_theme (StThemeNode *node);
|
|
|
|
|
2010-05-25 18:07:53 +00:00
|
|
|
gboolean st_theme_node_equal (StThemeNode *node_a, StThemeNode *node_b);
|
2012-11-08 17:50:01 +00:00
|
|
|
guint st_theme_node_hash (StThemeNode *node);
|
2010-05-25 18:07:53 +00:00
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
GType st_theme_node_get_element_type (StThemeNode *node);
|
|
|
|
const char *st_theme_node_get_element_id (StThemeNode *node);
|
2012-11-07 18:44:33 +00:00
|
|
|
GStrv st_theme_node_get_element_classes (StThemeNode *node);
|
|
|
|
GStrv st_theme_node_get_pseudo_classes (StThemeNode *node);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
|
|
|
/* Generic getters ... these are not cached so are less efficient. The other
|
|
|
|
* reason for adding the more specific version is that we can handle the
|
|
|
|
* details of the actual CSS rules, which can be complicated, especially
|
|
|
|
* for fonts
|
|
|
|
*/
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 21:38:36 +00:00
|
|
|
gboolean st_theme_node_lookup_color (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
ClutterColor *color);
|
|
|
|
gboolean st_theme_node_lookup_double (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
double *value);
|
|
|
|
gboolean st_theme_node_lookup_length (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
gdouble *length);
|
2012-08-07 14:20:43 +00:00
|
|
|
gboolean st_theme_node_lookup_time (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
gdouble *value);
|
2011-01-13 23:27:24 +00:00
|
|
|
gboolean st_theme_node_lookup_shadow (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
StShadow **shadow);
|
2013-04-16 12:43:51 +00:00
|
|
|
gboolean st_theme_node_lookup_url (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
gboolean inherit,
|
|
|
|
char **value);
|
StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of
these functions (return TRUE or FALSE and return the actual value in
an out parameter) is useful, it's mostly just annoying at the
application level, where you generally know that the CSS property is
going to specified, and there is no especially sane fallback if it's
not.
So rename the current methods to lookup_color, lookup_double, and
lookup_length, and add new get_color, get_double, and get_length
methods that don't take an "inherit" parameter, and return their
values directly. (Well, except for get_color, due to the lack of (out
caller-allocates) in gjs.)
And update the code to use either the old or new methods as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=632590
2010-09-26 21:38:36 +00:00
|
|
|
|
|
|
|
/* Easier-to-use variants of the above, for application-level use */
|
|
|
|
void st_theme_node_get_color (StThemeNode *node,
|
|
|
|
const char *property_name,
|
|
|
|
ClutterColor *color);
|
|
|
|
gdouble st_theme_node_get_double (StThemeNode *node,
|
|
|
|
const char *property_name);
|
|
|
|
gdouble st_theme_node_get_length (StThemeNode *node,
|
|
|
|
const char *property_name);
|
2011-01-13 23:27:24 +00:00
|
|
|
StShadow *st_theme_node_get_shadow (StThemeNode *node,
|
|
|
|
const char *property_name);
|
2013-04-16 12:43:51 +00:00
|
|
|
char *st_theme_node_get_url (StThemeNode *node,
|
|
|
|
const char *property_name);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
|
|
|
/* Specific getters for particular properties: cached
|
|
|
|
*/
|
|
|
|
void st_theme_node_get_background_color (StThemeNode *node,
|
|
|
|
ClutterColor *color);
|
|
|
|
void st_theme_node_get_foreground_color (StThemeNode *node,
|
|
|
|
ClutterColor *color);
|
2009-11-14 21:39:22 +00:00
|
|
|
void st_theme_node_get_background_gradient (StThemeNode *node,
|
|
|
|
StGradientType *type,
|
|
|
|
ClutterColor *start,
|
|
|
|
ClutterColor *end);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
|
|
|
const char *st_theme_node_get_background_image (StThemeNode *node);
|
|
|
|
|
2010-02-11 02:10:49 +00:00
|
|
|
int st_theme_node_get_border_width (StThemeNode *node,
|
2009-09-20 13:08:08 +00:00
|
|
|
StSide side);
|
2010-02-11 02:10:49 +00:00
|
|
|
int st_theme_node_get_border_radius (StThemeNode *node,
|
2009-09-20 13:08:08 +00:00
|
|
|
StCorner corner);
|
|
|
|
void st_theme_node_get_border_color (StThemeNode *node,
|
|
|
|
StSide side,
|
|
|
|
ClutterColor *color);
|
|
|
|
|
2010-05-26 20:50:24 +00:00
|
|
|
int st_theme_node_get_outline_width (StThemeNode *node);
|
|
|
|
void st_theme_node_get_outline_color (StThemeNode *node,
|
|
|
|
ClutterColor *color);
|
|
|
|
|
2009-09-20 13:08:08 +00:00
|
|
|
double st_theme_node_get_padding (StThemeNode *node,
|
|
|
|
StSide side);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
2010-03-11 17:04:08 +00:00
|
|
|
double st_theme_node_get_horizontal_padding (StThemeNode *node);
|
|
|
|
double st_theme_node_get_vertical_padding (StThemeNode *node);
|
|
|
|
|
2009-10-17 00:05:30 +00:00
|
|
|
int st_theme_node_get_width (StThemeNode *node);
|
|
|
|
int st_theme_node_get_height (StThemeNode *node);
|
|
|
|
int st_theme_node_get_min_width (StThemeNode *node);
|
|
|
|
int st_theme_node_get_min_height (StThemeNode *node);
|
2010-02-12 18:58:24 +00:00
|
|
|
int st_theme_node_get_max_width (StThemeNode *node);
|
|
|
|
int st_theme_node_get_max_height (StThemeNode *node);
|
2009-10-17 00:05:30 +00:00
|
|
|
|
2010-05-30 21:06:37 +00:00
|
|
|
int st_theme_node_get_transition_duration (StThemeNode *node);
|
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
|
|
|
|
|
2010-06-22 20:04:45 +00:00
|
|
|
StTextAlign st_theme_node_get_text_align (StThemeNode *node);
|
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
/* Font rule processing is pretty complicated, so we just hardcode it
|
|
|
|
* under the standard font/font-family/font-size/etc names. This means
|
|
|
|
* you can't have multiple separate styled fonts for a single item,
|
|
|
|
* but that should be OK.
|
|
|
|
*/
|
|
|
|
const PangoFontDescription *st_theme_node_get_font (StThemeNode *node);
|
|
|
|
|
2009-09-20 20:50:42 +00:00
|
|
|
StBorderImage *st_theme_node_get_border_image (StThemeNode *node);
|
2011-01-13 23:27:24 +00:00
|
|
|
StShadow *st_theme_node_get_box_shadow (StThemeNode *node);
|
2010-07-24 14:56:50 +00:00
|
|
|
StShadow *st_theme_node_get_text_shadow (StThemeNode *node);
|
2009-09-20 00:43:49 +00:00
|
|
|
|
2011-01-13 23:27:24 +00:00
|
|
|
StShadow *st_theme_node_get_background_image_shadow (StThemeNode *node);
|
|
|
|
|
2010-11-01 02:06:48 +00:00
|
|
|
StIconColors *st_theme_node_get_icon_colors (StThemeNode *node);
|
|
|
|
|
2009-09-20 17:41:13 +00:00
|
|
|
/* Helpers for get_preferred_width()/get_preferred_height() ClutterActor vfuncs */
|
|
|
|
void st_theme_node_adjust_for_height (StThemeNode *node,
|
|
|
|
float *for_height);
|
|
|
|
void st_theme_node_adjust_preferred_width (StThemeNode *node,
|
|
|
|
float *min_width_p,
|
|
|
|
float *natural_width_p);
|
|
|
|
void st_theme_node_adjust_for_width (StThemeNode *node,
|
|
|
|
float *for_width);
|
|
|
|
void st_theme_node_adjust_preferred_height (StThemeNode *node,
|
|
|
|
float *min_height_p,
|
|
|
|
float *natural_height_p);
|
|
|
|
|
|
|
|
/* Helper for allocate() ClutterActor vfunc */
|
|
|
|
void st_theme_node_get_content_box (StThemeNode *node,
|
2010-09-15 00:56:34 +00:00
|
|
|
const ClutterActorBox *allocation,
|
2009-09-20 17:41:13 +00:00
|
|
|
ClutterActorBox *content_box);
|
2010-06-04 13:21:59 +00:00
|
|
|
/* Helper for StThemeNodeTransition */
|
|
|
|
void st_theme_node_get_paint_box (StThemeNode *node,
|
2010-09-15 00:56:34 +00:00
|
|
|
const ClutterActorBox *allocation,
|
2010-06-04 13:21:59 +00:00
|
|
|
ClutterActorBox *paint_box);
|
2011-02-04 00:45:16 +00:00
|
|
|
/* Helper for background prerendering */
|
|
|
|
void st_theme_node_get_background_paint_box (StThemeNode *node,
|
|
|
|
const ClutterActorBox *allocation,
|
|
|
|
ClutterActorBox *paint_box);
|
2009-09-20 17:41:13 +00:00
|
|
|
|
|
|
|
gboolean st_theme_node_geometry_equal (StThemeNode *node,
|
|
|
|
StThemeNode *other);
|
2010-08-26 18:10:46 +00:00
|
|
|
gboolean st_theme_node_paint_equal (StThemeNode *node,
|
|
|
|
StThemeNode *other);
|
2009-09-20 17:41:13 +00:00
|
|
|
|
2010-02-08 18:40:25 +00:00
|
|
|
void st_theme_node_paint (StThemeNode *node,
|
2013-04-05 00:29:59 +00:00
|
|
|
StThemeNodePaintState *state,
|
2010-02-08 18:40:25 +00:00
|
|
|
const ClutterActorBox *box,
|
|
|
|
guint8 paint_opacity);
|
|
|
|
|
2013-04-05 01:22:34 +00:00
|
|
|
void st_theme_node_invalidate_background_image (StThemeNode *node);
|
|
|
|
void st_theme_node_invalidate_border_image (StThemeNode *node);
|
|
|
|
|
2013-04-05 01:43:42 +00:00
|
|
|
gchar * st_theme_node_to_string (StThemeNode *node);
|
|
|
|
|
2013-04-05 00:29:59 +00:00
|
|
|
void st_theme_node_paint_state_init (StThemeNodePaintState *state);
|
|
|
|
void st_theme_node_paint_state_free (StThemeNodePaintState *state);
|
|
|
|
void st_theme_node_paint_state_copy (StThemeNodePaintState *state,
|
|
|
|
StThemeNodePaintState *other);
|
2013-04-05 01:22:34 +00:00
|
|
|
void st_theme_node_paint_state_invalidate (StThemeNodePaintState *state);
|
2013-07-10 09:22:07 +00:00
|
|
|
void st_theme_node_paint_state_set_node (StThemeNodePaintState *state,
|
|
|
|
StThemeNode *node);
|
2010-02-08 18:40:25 +00:00
|
|
|
|
2009-09-20 00:43:49 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __ST_THEME_NODE_H__ */
|