~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to Toons/src/applet-draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
/******************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
******************************************************************************/
 
28
 
 
29
#include <stdlib.h>
 
30
#include <string.h>
 
31
 
 
32
#include "applet-struct.h"
 
33
#include "applet-draw.h"
 
34
 
 
35
 
 
36
void cd_xeyes_render_to_texture (CairoDockModuleInstance *myApplet, int iWidth, int iHeight)
 
37
{
 
38
        CD_APPLET_START_DRAWING_MY_ICON_OR_RETURN ();
 
39
        
 
40
        _cairo_dock_enable_texture ();
 
41
        _cairo_dock_set_blend_alpha ();
 
42
        _cairo_dock_set_alpha (1.);
 
43
        
 
44
        if (myData.bWink && myData.iEyelidTexture)
 
45
        {
 
46
                _cairo_dock_apply_texture_at_size (myData.iToonTexture,
 
47
                        myData.iToonWidth,
 
48
                        myData.iToonHeight);
 
49
                
 
50
                _cairo_dock_set_blend_pbuffer ();
 
51
                
 
52
                glPushMatrix ();
 
53
                glTranslatef (-.5*iWidth + myData.iXeyelid + .5*myData.iEyelidWidth,
 
54
                        .5*iHeight - myData.iYeyelid - .5*myData.iEyelidHeight,
 
55
                        0.);
 
56
                _cairo_dock_apply_texture_at_size (myData.iEyelidTexture,
 
57
                        myData.iEyelidWidth,
 
58
                        myData.iEyelidHeight);
 
59
                glPopMatrix ();
 
60
        }
 
61
        else
 
62
        {
 
63
                if (myData.iBgTexture)
 
64
                {
 
65
                        _cairo_dock_set_blend_source ();
 
66
                        glPushMatrix ();
 
67
                        glTranslatef (-.5*iWidth + myData.iXbg + .5*myData.iBgWidth,
 
68
                                .5*iHeight - myData.iYbg - .5*myData.iBgHeight,
 
69
                                0.);
 
70
                        _cairo_dock_apply_texture_at_size (myData.iBgTexture,
 
71
                                myData.iBgWidth,
 
72
                                myData.iBgHeight);
 
73
                        glPopMatrix ();
 
74
                }
 
75
                _cairo_dock_set_blend_alpha ();
 
76
                int i;
 
77
                for (i = 0; i < 2; i ++)
 
78
                {
 
79
                        if (myData.iPupilTexture[i] != 0)
 
80
                        {
 
81
                                glPushMatrix ();
 
82
                                glTranslatef (-.5*iWidth + myData.fXpupil[i],
 
83
                                        .5*iHeight - myData.fYpupil[i],
 
84
                                        0.);
 
85
                                _cairo_dock_apply_texture_at_size (myData.iPupilTexture[i],
 
86
                                        myData.iPupilWidth[i],
 
87
                                        myData.iPupilHeight[i]);
 
88
                                glPopMatrix ();
 
89
                        }
 
90
                }
 
91
                _cairo_dock_set_blend_pbuffer ();
 
92
                _cairo_dock_apply_texture_at_size (myData.iToonTexture,
 
93
                        myData.iToonWidth,
 
94
                        myData.iToonHeight);
 
95
        }
 
96
        
 
97
        _cairo_dock_disable_texture ();
 
98
        
 
99
        CD_APPLET_FINISH_DRAWING_MY_ICON;
 
100
}
 
101
 
 
102
 
 
103
void cd_xeyes_render_to_surface (CairoDockModuleInstance *myApplet, int iWidth, int iHeight)
 
104
{
 
105
        cairo_dock_erase_cairo_context (myDrawContext);
 
106
        
 
107
        if (myData.bWink && myData.pEyelidSurface)
 
108
        {
 
109
                cairo_set_source_surface (myDrawContext,
 
110
                        myData.pToonSurface,
 
111
                        .5*(iWidth - myData.iToonWidth),
 
112
                        .5*(iHeight - myData.iToonHeight));
 
113
                cairo_paint (myDrawContext);
 
114
                
 
115
                cairo_set_source_surface (myDrawContext,
 
116
                        myData.pEyelidSurface,
 
117
                        myData.iXeyelid,
 
118
                        myData.iYeyelid);
 
119
                cairo_paint (myDrawContext);
 
120
        }
 
121
        else
 
122
        {
 
123
                if (myData.pBgSurface)
 
124
                {
 
125
                        cairo_set_source_surface (myDrawContext,
 
126
                                myData.pBgSurface,
 
127
                                myData.iXbg,
 
128
                                myData.iYbg);
 
129
                        cairo_paint (myDrawContext);
 
130
                }
 
131
                
 
132
                int i;
 
133
                for (i = 0; i < 2; i ++)
 
134
                {
 
135
                        if (myData.pPupilSurface[i])
 
136
                        {
 
137
                                cairo_set_source_surface (myDrawContext,
 
138
                                        myData.pPupilSurface[i],
 
139
                                        myData.fXpupil[i] - .5*myData.iPupilWidth[i],
 
140
                                        myData.fYpupil[i] - .5*myData.iPupilHeight[i]);
 
141
                                cairo_paint (myDrawContext);
 
142
                        }
 
143
                }
 
144
                cairo_set_source_surface (myDrawContext,
 
145
                        myData.pToonSurface,
 
146
                        .5*(iWidth - myData.iToonWidth),
 
147
                        .5*(iHeight - myData.iToonHeight));
 
148
        }
 
149
        
 
150
        cairo_paint (myDrawContext);
 
151
        
 
152
        CD_APPLET_UPDATE_REFLECT_ON_MY_ICON;
 
153
}