2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
20
/*********************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
*********************************************************************************/
30
#include <cairo-dock.h>
32
#include "applet-struct.h"
33
#include "applet-decorator-modern.h"
36
void cd_decorator_set_frame_size_modern (CairoDialog *pDialog)
38
int iMargin = .5 * myConfig.iModernLineWidth + .5 * myConfig.iModernRadius;
39
pDialog->iRightMargin = iMargin;
40
pDialog->iLeftMargin = iMargin;
41
pDialog->iTopMargin = iMargin;
42
pDialog->iBottomMargin = iMargin;
43
pDialog->iMinBottomGap = 30;
44
pDialog->iMinFrameWidth = 30; // valeur au pif.
45
pDialog->fAlign = .33; // la pointe est a 33% du bord du dialogue.
46
pDialog->fReflectAlpha = 0.; // pas de reflet merci.
50
void cd_decorator_draw_decorations_modern (cairo_t *pCairoContext, CairoDialog *pDialog)
52
double fLineWidth = myConfig.iModernLineWidth;
53
double fRadius = MIN (myConfig.iModernRadius, pDialog->iBubbleHeight/2);
54
int sens = (pDialog->bDirectionUp ? 1 : -1);
55
int sens2 = (pDialog->bRight ? 1 : -1);
57
//\_________________ On part du haut.
58
double fOffsetX = (pDialog->bRight ? fLineWidth/2 : pDialog->iWidth - fLineWidth/2);
59
double fOffsetY = (pDialog->bDirectionUp ? 0. : pDialog->iHeight);
60
cairo_move_to (pCairoContext, fOffsetX, fOffsetY);
62
//\_________________ On remplit le fond.
63
cairo_rel_line_to (pCairoContext,
65
sens * (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - fRadius));
66
cairo_rel_line_to (pCairoContext,
69
cairo_rel_line_to (pCairoContext,
70
sens2 * pDialog->iBubbleWidth,
72
cairo_set_line_width (pCairoContext, fLineWidth);
73
cairo_set_source_rgba (pCairoContext, myConfig.fModernLineColor[0], myConfig.fModernLineColor[1], myConfig.fModernLineColor[2], myConfig.fModernLineColor[3]);
75
cairo_rel_line_to (pCairoContext,
77
- sens * (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - fRadius));
78
cairo_rel_line_to (pCairoContext,
81
cairo_close_path (pCairoContext);
82
cairo_set_source_rgba (pCairoContext, myDialogs.fDialogColor[0], myDialogs.fDialogColor[1], myDialogs.fDialogColor[2], myDialogs.fDialogColor[3]);
83
cairo_fill (pCairoContext);
85
//\_________________ On trace le cadre.
86
cairo_move_to (pCairoContext, fOffsetX, fOffsetY);
87
cairo_rel_line_to (pCairoContext,
89
sens * (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin - fRadius));
90
cairo_rel_line_to (pCairoContext,
93
cairo_rel_line_to (pCairoContext,
94
sens2 * pDialog->iBubbleWidth,
96
cairo_set_line_width (pCairoContext, fLineWidth);
97
cairo_set_source_rgba (pCairoContext, myConfig.fModernLineColor[0], myConfig.fModernLineColor[1], myConfig.fModernLineColor[2], myConfig.fModernLineColor[3]);
98
cairo_stroke (pCairoContext);
100
//\_________________ On part du haut, petit cote.
101
fOffsetX = (pDialog->bRight ? fRadius + fLineWidth/2 : pDialog->iWidth - fRadius - fLineWidth/2);
102
fOffsetY = (pDialog->bDirectionUp ? pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin : pDialog->iHeight - (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin));
104
//\_________________ On trace la pointe.
105
cairo_set_line_width (pCairoContext, 1.);
106
cairo_set_source_rgba (pCairoContext, myConfig.fModernLineColor[0], myConfig.fModernLineColor[1], myConfig.fModernLineColor[2], myConfig.fModernLineColor[3]);
107
int i, h = pDialog->iHeight - (pDialog->iBubbleHeight + pDialog->iTopMargin + pDialog->iBottomMargin);
108
double w1 = MAX (0, pDialog->iAimedX - pDialog->iPositionX - (pDialog->bRight ? fOffsetX : 0));
109
double w2 = MAX (0, pDialog->iPositionX + pDialog->iWidth - pDialog->iAimedX - (pDialog->bRight ? 0 : fRadius + fLineWidth/2));
110
//g_print ("%.2f,%.2f ; %d + %d > %d\n", w1, w2, pDialog->iPositionX, pDialog->iWidth, pDialog->iAimedX);
112
for (i = 0; i < h; i += 4)
114
y = fOffsetY + sens * i;
115
x = fOffsetX + 1. * sens2 * i / h * (pDialog->bRight ? w1 : w2);
116
w = (w1 + w2) * (h - i) / h;
117
cairo_move_to (pCairoContext, x, y);
118
cairo_rel_line_to (pCairoContext,
121
cairo_stroke (pCairoContext);
125
y = fOffsetY + sens * h;
126
x = fOffsetX + 1. * sens2 * (pDialog->bRight ? w1 : w2);
128
cairo_move_to (pCairoContext, x, y);
129
cairo_rel_line_to (pCairoContext,
132
cairo_stroke (pCairoContext);
137
void cd_decorator_register_modern (void)
139
CairoDialogDecorator *pDecorator = g_new (CairoDialogDecorator, 1);
140
pDecorator->set_size = cd_decorator_set_frame_size_modern;
141
pDecorator->render = cd_decorator_draw_decorations_modern;
142
pDecorator->render_opengl = NULL;
143
pDecorator->cDisplayedName = D_ (MY_APPLET_DECORATOR_MODERN_NAME);
144
cairo_dock_register_dialog_decorator (MY_APPLET_DECORATOR_MODERN_NAME, pDecorator);