~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/cairo-dock-separator-factory.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
Import upstream version 2.2.0~0beta4

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 <math.h>
21
 
#include <string.h>
22
 
#include <cairo.h>
23
 
#include <stdlib.h>
24
 
 
25
 
#ifdef HAVE_GLITZ
26
 
#include <gdk/gdkx.h>
27
 
#include <glitz-glx.h>
28
 
#include <cairo-glitz.h>
29
 
#endif
30
 
 
31
 
#include "cairo-dock-icons.h"
32
 
#include "cairo-dock-load.h"
33
 
#include "cairo-dock-surface-factory.h"
34
 
#include "cairo-dock-log.h"
35
 
#include "cairo-dock-internal-icons.h"
36
 
#include "cairo-dock-dock-factory.h"
37
 
#include "cairo-dock-separator-factory.h"
38
 
 
39
 
 
40
 
cairo_surface_t *cairo_dock_create_separator_surface (cairo_t *pSourceContext, double fMaxScale, gboolean bIsHorizontal, gboolean bDirectionUp, double *fWidth, double *fHeight)
41
 
{
42
 
        g_return_val_if_fail (cairo_status (pSourceContext) == CAIRO_STATUS_SUCCESS, NULL);
43
 
        
44
 
        cairo_surface_t *pNewSurface = NULL;
45
 
        if (myIcons.cSeparatorImage == NULL)
46
 
        {
47
 
                *fWidth = myIcons.tIconAuthorizedWidth[CAIRO_DOCK_SEPARATOR12];
48
 
                *fHeight = myIcons.tIconAuthorizedHeight[CAIRO_DOCK_SEPARATOR12];
49
 
                pNewSurface = _cairo_dock_create_blank_surface (pSourceContext,
50
 
                        ceil (*fWidth * fMaxScale),
51
 
                        ceil (*fHeight * fMaxScale));
52
 
        }
53
 
        else
54
 
        {
55
 
                gchar *cImagePath = cairo_dock_generate_file_path (myIcons.cSeparatorImage);
56
 
                double fRotationAngle;  // on est oblig� de faire la rotation maintenant plutot que pendant le dessin, a cause du reflet a charger en cairo.
57
 
                if (! myIcons.bRevolveSeparator)
58
 
                        fRotationAngle = 0;
59
 
                else if (bIsHorizontal)
60
 
                        if (bDirectionUp)
61
 
                                fRotationAngle = 0;
62
 
                        else
63
 
                                fRotationAngle = G_PI;
64
 
                else
65
 
                        if (bDirectionUp)
66
 
                                fRotationAngle = -G_PI/2;
67
 
                        else
68
 
                                fRotationAngle = G_PI/2;
69
 
                
70
 
                pNewSurface = cairo_dock_create_surface_from_image (cImagePath,
71
 
                        pSourceContext,
72
 
                        fMaxScale,
73
 
                        myIcons.tIconAuthorizedWidth[CAIRO_DOCK_SEPARATOR12],
74
 
                        myIcons.tIconAuthorizedHeight[CAIRO_DOCK_SEPARATOR12],
75
 
                        CAIRO_DOCK_FILL_SPACE,
76
 
                        fWidth,
77
 
                        fHeight,
78
 
                        NULL, NULL);
79
 
                if (fRotationAngle != 0)  /// le faire pendant le dessin ...
80
 
                {
81
 
                        cairo_surface_t *pNewSurfaceRotated = cairo_dock_rotate_surface (pNewSurface, pSourceContext, *fWidth * fMaxScale, *fHeight * fMaxScale, fRotationAngle);
82
 
                        cairo_surface_destroy (pNewSurface);
83
 
                        pNewSurface = pNewSurfaceRotated;
84
 
                }
85
 
                g_free (cImagePath);
86
 
        }
87
 
        
88
 
        return pNewSurface;
89
 
}
90
 
 
91
 
 
92
 
 
93
 
Icon *cairo_dock_create_separator_icon (cairo_t *pSourceContext, int iSeparatorType, CairoDock *pDock)
94
 
{
95
 
        //g_print ("%s ()\n", __func__);
96
 
        if ((iSeparatorType & 1) && ! myIcons.iSeparateIcons)
97
 
                return NULL;
98
 
        
99
 
        //\____________ On cree l'icone.
100
 
        Icon *icon = g_new0 (Icon, 1);
101
 
        icon->iType = iSeparatorType;
102
 
        
103
 
        //\____________ On remplit ses buffers.
104
 
        cairo_dock_fill_icon_buffers_for_dock (icon, pSourceContext, pDock);
105
 
        ///cairo_dock_fill_one_icon_buffer (icon, pSourceContext, 1 + myIcons.fAmplitude, pDock->container.bIsHorizontal, pDock->container.bDirectionUp);
106
 
 
107
 
        return icon;
108
 
}