~cairo-dock-team/cairo-dock-plug-ins/plug-ins

« back to all changes in this revision

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

  • Committer: Matthieu Baerts
  • Date: 2014-10-19 00:26:10 UTC
  • Revision ID: matttbe@gmail.com-20141019002610-ulf26s9b4c4rw10r
We just switched from BZR to Git.
Follow us on Github: https://github.com/Cairo-Dock

Note: we will only use Github to manage our source code and all pull requests.
Please continue to report your bugs/ideas/messages on our forum or Launchpad! 

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
 
#include <stdlib.h>
21
 
#include <string.h>
22
 
 
23
 
#include "applet-struct.h"
24
 
#include "applet-draw.h"
25
 
 
26
 
 
27
 
void cd_xeyes_render_to_texture (GldiModuleInstance *myApplet, int iWidth, int iHeight)
28
 
{
29
 
        CD_APPLET_START_DRAWING_MY_ICON_OR_RETURN ();
30
 
        
31
 
        _cairo_dock_enable_texture ();
32
 
        _cairo_dock_set_blend_alpha ();
33
 
        _cairo_dock_set_alpha (1.);
34
 
        
35
 
        if (myData.bWink && myData.pEyelidImage)
36
 
        {
37
 
                cairo_dock_apply_image_buffer_texture (myData.pToonImage);
38
 
                
39
 
                _cairo_dock_set_blend_pbuffer ();
40
 
                
41
 
                cairo_dock_apply_image_buffer_texture_with_offset (myData.pEyelidImage,
42
 
                        -.5*iWidth + myData.iXeyelid + .5*myData.pEyelidImage->iWidth,
43
 
                        .5*iHeight - myData.iYeyelid - .5*myData.pEyelidImage->iHeight);
44
 
        }
45
 
        else
46
 
        {
47
 
                if (myData.pBgImage)
48
 
                {
49
 
                        _cairo_dock_set_blend_source ();
50
 
                        cairo_dock_apply_image_buffer_texture_with_offset (myData.pBgImage,
51
 
                                -.5*iWidth + myData.iXbg + .5*myData.pBgImage->iWidth,
52
 
                                .5*iHeight - myData.iYbg - .5*myData.pBgImage->iHeight);
53
 
                }
54
 
                _cairo_dock_set_blend_alpha ();
55
 
                int i;
56
 
                for (i = 0; i < 2; i ++)
57
 
                {
58
 
                        if (myData.pPupilImage[i] != 0)
59
 
                        {
60
 
                                cairo_dock_apply_image_buffer_texture_with_offset (myData.pPupilImage[i],
61
 
                                        -.5*iWidth + myData.fXpupil[i],
62
 
                                        .5*iHeight - myData.fYpupil[i]);
63
 
                        }
64
 
                }
65
 
                _cairo_dock_set_blend_pbuffer ();
66
 
                cairo_dock_apply_image_buffer_texture (myData.pToonImage);
67
 
        }
68
 
        
69
 
        _cairo_dock_disable_texture ();
70
 
        
71
 
        CD_APPLET_FINISH_DRAWING_MY_ICON;
72
 
}
73
 
 
74
 
 
75
 
void cd_xeyes_render_to_surface (GldiModuleInstance *myApplet, int iWidth, int iHeight)
76
 
{
77
 
        CD_APPLET_START_DRAWING_MY_ICON_OR_RETURN_CAIRO ();
78
 
        ///cairo_dock_erase_cairo_context (myDrawContext);
79
 
        if (myData.bWink && myData.pEyelidImage)
80
 
        {
81
 
                cairo_dock_apply_image_buffer_surface_with_offset (myData.pToonImage, myDrawContext,
82
 
                        .5*(iWidth - myData.pToonImage->iWidth),
83
 
                        .5*(iHeight - myData.pToonImage->iHeight),
84
 
                        1.);
85
 
                
86
 
                cairo_dock_apply_image_buffer_surface_with_offset (myData.pEyelidImage, myDrawContext,
87
 
                        myData.iXeyelid,
88
 
                        myData.iYeyelid,
89
 
                        1.);    
90
 
        }
91
 
        else
92
 
        {
93
 
                if (myData.pBgImage)
94
 
                {
95
 
                        cairo_dock_apply_image_buffer_surface_with_offset (myData.pBgImage, myDrawContext,
96
 
                                myData.iXbg,
97
 
                                myData.iYbg,
98
 
                                1.);
99
 
                }
100
 
                
101
 
                int i;
102
 
                for (i = 0; i < 2; i ++)
103
 
                {
104
 
                        if (myData.pPupilImage[i])
105
 
                        {
106
 
                                cairo_dock_apply_image_buffer_surface_with_offset (myData.pPupilImage[i], myDrawContext,
107
 
                                        myData.fXpupil[i] - .5*myData.pPupilImage[i]->iWidth,
108
 
                                        myData.fYpupil[i] - .5*myData.pPupilImage[i]->iHeight,
109
 
                                        1.);
110
 
                        }
111
 
                }
112
 
                cairo_dock_apply_image_buffer_surface_with_offset (myData.pToonImage, myDrawContext,
113
 
                        .5*(iWidth - myData.pToonImage->iWidth),
114
 
                        .5*(iHeight - myData.pToonImage->iHeight),
115
 
                        1.);
116
 
        }
117
 
        CD_APPLET_FINISH_DRAWING_MY_ICON_CAIRO;
118
 
}