1 /* -*- mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5 * An OpenGL based 'interactive canvas' library.
7 * Authored By: Tomas Frydrych <tf@openedhand.com>
8 * Emmanuele Bassu <ebassi@linux.intel.com>
10 * Copyright (C) 2007, 2008 OpenedHand
11 * Copyright (C) 2009 Intel Corp.
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
27 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
28 #error "Only <clutter/clutter.h> can be included directly."
31 #ifndef __CLUTTER_UNITS_H__
32 #define __CLUTTER_UNITS_H__
34 #include <glib-object.h>
36 #include <cogl/cogl.h>
43 * An opaque structure, to be used to store sizing and positioning
44 * values along with their unit.
48 typedef struct _ClutterUnits ClutterUnits;
53 ClutterUnitType unit_type;
57 /* pre-filled by the provided constructors */
59 /* cached pixel value */
62 /* whether the :pixels field is set */
65 /* the serial coming from the backend, used to evict the cache */
68 /* padding for eventual expansion */
73 GType clutter_units_get_type (void) G_GNUC_CONST;
74 ClutterUnitType clutter_units_get_unit_type (const ClutterUnits *units);
75 gfloat clutter_units_get_unit_value (const ClutterUnits *units);
77 ClutterUnits * clutter_units_copy (const ClutterUnits *units);
78 void clutter_units_free (ClutterUnits *units);
80 void clutter_units_from_pixels (ClutterUnits *units,
82 void clutter_units_from_em (ClutterUnits *units,
84 void clutter_units_from_em_for_font (ClutterUnits *units,
85 const gchar *font_name,
87 void clutter_units_from_mm (ClutterUnits *units,
89 void clutter_units_from_cm (ClutterUnits *units,
91 void clutter_units_from_pt (ClutterUnits *units,
94 gfloat clutter_units_to_pixels (ClutterUnits *units);
96 gboolean clutter_units_from_string (ClutterUnits *units,
98 gchar * clutter_units_to_string (const ClutterUnits *units);
100 /* shorthands for the constructors */
101 #define clutter_units_pixels clutter_units_from_pixels
102 #define clutter_units_em clutter_units_from_em
103 #define clutter_units_em_for_font clutter_units_from_em_for_font
104 #define clutter_units_mm clutter_units_from_mm
105 #define clutter_units_cm clutter_units_from_cm
106 #define clutter_units_pt clutter_units_from_pt
108 #define CLUTTER_TYPE_UNITS (clutter_units_get_type ())
109 #define CLUTTER_TYPE_PARAM_UNITS (clutter_param_units_get_type ())
110 #define CLUTTER_PARAM_SPEC_UNITS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_UNITS, ClutterParamSpecUnits))
111 #define CLUTTER_IS_PARAM_SPEC_UNITS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), CLUTTER_TYPE_PARAM_UNITS))
114 * CLUTTER_VALUE_HOLDS_UNITS:
117 * Evaluates to %TRUE if @x holds a #ClutterUnits value
121 #define CLUTTER_VALUE_HOLDS_UNITS(x) (G_VALUE_HOLDS ((x), CLUTTER_TYPE_UNITS))
123 typedef struct _ClutterParamSpecUnits ClutterParamSpecUnits;
126 * ClutterParamSpecUnits: (skip)
127 * @default_type: default type
128 * @default_value: default value
129 * @minimum: lower boundary
130 * @maximum: higher boundary
132 * #GParamSpec subclass for unit based properties.
136 struct _ClutterParamSpecUnits
139 GParamSpec parent_instance;
142 ClutterUnitType default_type;
144 gfloat default_value;
149 GType clutter_param_units_get_type (void) G_GNUC_CONST;
151 GParamSpec * clutter_param_spec_units (const gchar *name,
154 ClutterUnitType default_type,
157 gfloat default_value,
160 void clutter_value_set_units (GValue *value,
161 const ClutterUnits *units);
162 const ClutterUnits * clutter_value_get_units (const GValue *value);
166 #endif /* __CLUTTER_UNITS_H__ */