]> git.0d.be Git - empathy.git/blob - src/empathy-rounded-texture.c
Move should_create_salut_account to local-xmpp-assistant-widget
[empathy.git] / src / empathy-rounded-texture.c
1 /*
2  * empathy-rounded-texture.c - Source for EmpathyRoundedTexture
3  * Copyright (C) 2011 Collabora Ltd.
4  * @author Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20
21
22 #include <clutter/clutter.h>
23
24 #include "empathy-rounded-texture.h"
25
26 G_DEFINE_TYPE (EmpathyRoundedTexture,
27     empathy_rounded_texture,
28     CLUTTER_TYPE_TEXTURE)
29
30 static void
31 empathy_rounded_texture_paint (ClutterActor *texture)
32 {
33   ClutterActorBox allocation = { 0, };
34   gfloat width, height;
35
36   clutter_actor_get_allocation_box (texture, &allocation);
37   clutter_actor_box_get_size (&allocation, &width, &height);
38
39   cogl_path_new ();
40
41   /* create and store a path describing a rounded rectangle */
42   cogl_path_round_rectangle (0, 0, width, height, height / 16., 0.1);
43
44   cogl_clip_push_from_path ();
45
46   CLUTTER_ACTOR_CLASS (empathy_rounded_texture_parent_class)->paint (texture);
47
48   /* Flip */
49   cogl_rectangle_with_texture_coords (0, 0, width, height,
50       1., 0., 0., 1.);
51
52   cogl_clip_pop ();
53 }
54
55 static void
56 empathy_rounded_texture_init (EmpathyRoundedTexture *self)
57 {
58 }
59
60 static void
61 empathy_rounded_texture_class_init (EmpathyRoundedTextureClass *klass)
62 {
63   ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
64
65   actor_class->paint = empathy_rounded_texture_paint;
66 }
67
68 ClutterActor *
69 empathy_rounded_texture_new (void)
70 {
71   return CLUTTER_ACTOR (
72     g_object_new (EMPATHY_TYPE_ROUNDED_TEXTURE, NULL));
73 }