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

« back to all changes in this revision

Viewing changes to dialog-rendering/src/applet-decorator-3Dplane.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
#include <string.h>
 
29
#include <math.h>
 
30
#include <cairo-dock.h>
 
31
 
 
32
#include "applet-struct.h"
 
33
#include "applet-decorator-3Dplane.h"
 
34
 
 
35
#define DIALOG_REFLECT_SIZE 50
 
36
#define DIALOG_INCLINATION 60.
 
37
 
 
38
 
 
39
void cd_decorator_set_frame_size_3Dplane (CairoDialog *pDialog)
 
40
{
 
41
        double fInclination = tan (DIALOG_INCLINATION/180.*G_PI);
 
42
        double fFrameHeight = 10 + MIN (MAX (pDialog->iIconSize, pDialog->iTextHeight), DIALOG_REFLECT_SIZE);
 
43
        double fRadius = MIN (myConfig.iPlaneRadius, fFrameHeight/2);
 
44
        double fLineWidth = myConfig.iPlaneLineWidth;
 
45
        
 
46
        int iMargin = cairo_dock_calculate_extra_width_for_trapeze (fFrameHeight, fInclination, fRadius, fLineWidth)/2;
 
47
        pDialog->iRightMargin = iMargin;
 
48
        pDialog->iLeftMargin = iMargin;
 
49
        pDialog->iTopMargin = 0;
 
50
        pDialog->iBottomMargin = fFrameHeight - 10;
 
51
        pDialog->iMinBottomGap = 10;
 
52
        pDialog->iMinFrameWidth = 30;  // valeur au pif.
 
53
        pDialog->fAlign = .5;
 
54
        pDialog->fReflectAlpha = .4;
 
55
}
 
56
 
 
57
 
 
58
void cd_decorator_draw_decorations_3Dplane (cairo_t *pCairoContext, CairoDialog *pDialog)
 
59
{
 
60
        double fInclination = tan (DIALOG_INCLINATION/180.*G_PI);
 
61
        double fReflectHeight = MIN (MAX (pDialog->iIconSize, pDialog->iTextHeight), DIALOG_REFLECT_SIZE);
 
62
        double fFrameHeight = 10 + fReflectHeight;
 
63
        double fRadius = MIN (myConfig.iPlaneRadius, fFrameHeight/2);
 
64
        double fLineWidth = myConfig.iPlaneLineWidth;
 
65
        int sens = (pDialog->bDirectionUp ?     1 :     -1);
 
66
        double fFrameWidth = pDialog->iBubbleWidth;
 
67
        double fOffsetX = pDialog->iLeftMargin;
 
68
        double fOffsetY = pDialog->iTopMargin + pDialog->iBubbleHeight - 10;
 
69
        
 
70
        cairo_dock_draw_frame (pCairoContext, fRadius, fLineWidth, fFrameWidth, fFrameHeight, fOffsetX, fOffsetY, sens, fInclination, pDialog->bIsHorizontal);
 
71
        
 
72
        cairo_set_source_rgba (pCairoContext, myConfig.fPlaneColor[0], myConfig.fPlaneColor[1], myConfig.fPlaneColor[2], myConfig.fPlaneColor[3]);
 
73
        cairo_fill_preserve (pCairoContext);
 
74
 
 
75
        cairo_set_line_width (pCairoContext, 1.);
 
76
        cairo_set_source_rgba (pCairoContext, myConfig.fPlaneLineColor[0], myConfig.fPlaneLineColor[1], myConfig.fPlaneLineColor[2], myConfig.fPlaneLineColor[3]);
 
77
        cairo_stroke (pCairoContext);
 
78
        
 
79
        cairo_rectangle (pCairoContext,
 
80
                pDialog->iLeftMargin,
 
81
                pDialog->iTopMargin,
 
82
                pDialog->iBubbleWidth,
 
83
                pDialog->iBubbleHeight);
 
84
        cairo_set_source_rgba (pCairoContext, myDialogs.fDialogColor[0], myDialogs.fDialogColor[1], myDialogs.fDialogColor[2], myDialogs.fDialogColor[3]);
 
85
        cairo_fill (pCairoContext);
 
86
}
 
87
 
 
88
 
 
89
void cd_decorator_register_3Dplane (void)
 
90
{
 
91
        CairoDialogDecorator *pDecorator = g_new (CairoDialogDecorator, 1);
 
92
        pDecorator->set_size = cd_decorator_set_frame_size_3Dplane;
 
93
        pDecorator->render = cd_decorator_draw_decorations_3Dplane;
 
94
        pDecorator->render_opengl = NULL;
 
95
        pDecorator->cDisplayedName = D_ (MY_APPLET_DECORATOR_3DPLANE_NAME);
 
96
        cairo_dock_register_dialog_decorator (MY_APPLET_DECORATOR_3DPLANE_NAME, pDecorator);
 
97
}