forked from KDE/breeze
-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
styleclassik.cpp
executable file
·321 lines (263 loc) · 10.6 KB
/
styleclassik.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*
* SPDX-FileCopyrightText: 2021 Paul A McAuley <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "styleclassik.h"
namespace Breeze
{
void RenderStyleClassik18By18::renderCloseIcon()
{
if(notInTitlebar) {
RenderDecorationButtonIcon18By18::renderCloseIcon();
} else {
if(boldButtonIcons) {
pen.setWidthF( pen.widthF() *1.75 );
painter->setPen( pen );
}
// slightly larger X to tie-in with design of square maximize button
painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) );
painter->drawLine( QPointF(13.5, 4.5), QPointF(4.5, 13.5) );
}
}
void RenderStyleClassik18By18::renderMaximizeIcon()
{
if(!notInTitlebar) {
if(boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.666666 );
} else {
QColor penColor = pen.color();
penColor.setAlphaF( penColor.alphaF() * 0.9 );
//close button appears more grey when fine so reduce maximize opacity slightly to give a balanced look
pen.setColor( penColor );
}
}
pen.setJoinStyle( Qt::BevelJoin );
painter->setPen( pen );
//large square
painter->drawRoundedRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ), 0.025, 0.025, Qt::RelativeSize);
//painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ) );
}
void RenderStyleClassik18By18::renderRestoreIcon()
{
pen.setJoinStyle( Qt::BevelJoin );
painter->setPen( pen );
if(this->notInTitlebar){
//disable antialiasing to remove blur at small sizes
painter->setRenderHints( QPainter::Antialiasing, false );
//overlapping windows icon
painter->drawRect( QRectF( QPointF( 4, 6 ), QPointF( 11, 13 ) ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 6, 6 ),
QPointF( 6, 4 ),
QPointF( 13, 4 ),
QPointF( 13, 11 ),
QPointF( 11, 11 )} );
} else {
if(boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.3 );
painter->setPen( pen );
}
//overlapping windows icon
//foregreound square
painter->drawRect( QRectF( QPointF( 4.5, 6.5 ), QPointF( 11.5, 13.5 ) ) );
//background square
painter->drawPolyline( QVector<QPointF>{
QPointF( 6.5, 6 ),
QPointF( 6.5, 4.5 ),
QPointF( 13.5, 4.5 ),
QPointF( 13.5, 11.5 ),
QPointF( 12, 11.5 )} );
}
}
void RenderStyleClassik18By18::renderMinimizeIcon()
{
if( boldButtonIcons ) {
//tiny filled square
pen.setJoinStyle( Qt::BevelJoin );
painter->setBrush( pen.color() );
painter->setPen( pen );
painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 10.5, 10.5 ) ) );
} else { // in fine mode the dense minimize button appears bolder than the others so reduce its opacity to compensate
QColor penColor = pen.color();
QColor brushColor = penColor;
brushColor.setAlphaF(brushColor.alphaF()* 0.75);
penColor.setAlphaF(penColor.alphaF()* 0.6);
pen.setColor(penColor);
//tiny filled square
pen.setJoinStyle( Qt::BevelJoin );
painter->setBrush( brushColor );
painter->setPen( pen );
painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 10.5, 10.5 ) ) );
}
}
/*//Experimental 3 squares
void RenderStyleClassik18By18::renderKeepBehindIcon()
{
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
//foreground squares
painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) );
painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) );
//filled background square
painter->setBrush( pen.color() );
painter->drawPolygon( QPolygonF()
<< QPointF( 8.5, 5.5 )
<< QPointF( 12.5, 5.5 )
<< QPointF( 12.5, 9.5 )
<< QPointF( 9.5, 9.5 )
<< QPointF( 9.5, 12.5 )
<< QPointF( 5.5, 12.5 )
<< QPointF( 5.5, 8.5 )
<< QPointF( 8.5, 8.5 )
);
}
void RenderStyleClassik18By18::renderKeepInFrontIcon()
{
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
//background squares
painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) );
painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) );
//filled foreground square
painter->setBrush( pen.color() );
painter->drawRect( QRectF( QPointF( 5.5, 5.5 ), QPointF( 12.5, 12.5 ) ) );
}
*/
/*//Experimental 2 squares
void RenderStyleClassik18By18::renderKeepBehindIcon()
{
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
//foreground square
painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) );
//filled background square
painter->setBrush( pen.color() );
painter->drawPolygon( QPolygonF()
<< QPointF( 4.5, 4.5 )
<< QPointF( 10.5, 4.5 )
<< QPointF( 10.5, 7.5 )
<< QPointF( 7.5, 7.5 )
<< QPointF( 7.5, 10.5 )
<< QPointF( 4.5, 10.5 )
);
}
void RenderStyleClassik18By18::renderKeepInFrontIcon()
{
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
//background square
painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) );
//filled foreground square
painter->setBrush( pen.color() );
painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 10.5, 10.5 ) ) );
}
*/
/* //Experimental filled arrows
void RenderStyleClassik18By18::renderKeepBehindIcon()
{
//horizontal lines
painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) );
painter->drawLine( QPointF( 9.5, 9.5 ), QPointF( 13.5, 9.5 ) );
painter->drawLine( QPointF( 9.5, 5.5 ), QPointF( 13.5, 5.5 ) );
//arrow
painter->drawLine( QPointF( 4.5, 3.5 ), QPointF( 4.5, 11.5 ) );
painter->setBrush( pen.color() );
painter->drawConvexPolygon( QPolygonF()
<< QPointF( 2.5, 8.5 )
<< QPointF( 4.5, 11.5 )
<< QPointF( 6.5, 8.5 ) );
}
void RenderStyleClassik18By18::renderKeepInFrontIcon()
{
//horizontal lines
painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) );
painter->drawLine( QPointF( 4.5, 8.5 ), QPointF( 8.5, 8.5 ) );
painter->drawLine( QPointF( 4.5, 12.5 ), QPointF( 8.5, 12.5 ) );
//arrow
painter->drawLine( QPointF( 13.5, 6.5 ), QPointF( 13.5, 14.5 ) );
painter->setBrush( pen.color() );
painter->drawConvexPolygon( QPolygonF()
<< QPointF( 11.5, 9.5 )
<< QPointF( 13.5, 6.5 )
<< QPointF( 15.5, 9.5 ) );
}
*/
// For consistency with breeze icon set
void RenderStyleClassik18By18::renderKeepBehindIcon()
{
if((!notInTitlebar) && boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.1 );
painter->setPen( pen );
}
//horizontal lines
painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) );
painter->drawLine( QPointF( 9.5, 9.5 ), QPointF( 13.5, 9.5 ) );
painter->drawLine( QPointF( 9.5, 5.5 ), QPointF( 13.5, 5.5 ) );
//arrow
painter->drawLine( QPointF( 4.5, 3.5 ), QPointF( 4.5, 11.5 ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 2.5, 9.5 ),
QPointF( 4.5, 11.5 ),
QPointF( 6.5, 9.5 )} );
}
void RenderStyleClassik18By18::renderKeepInFrontIcon()
{
if((!notInTitlebar) && boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.1 );
painter->setPen( pen );
}
//horizontal lines
painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) );
painter->drawLine( QPointF( 4.5, 8.5 ), QPointF( 8.5, 8.5 ) );
painter->drawLine( QPointF( 4.5, 12.5 ), QPointF( 8.5, 12.5 ) );
//arrow
painter->drawLine( QPointF( 13.5, 6.5 ), QPointF( 13.5, 14.5 ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 11.5, 8.5 ),
QPointF( 13.5, 6.5 ),
QPointF( 15.5, 8.5 )} );
}
void RenderStyleClassik18By18::renderContextHelpIcon()
{
if((!notInTitlebar) && boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.6 );
}
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
//main body of question mark
QPainterPath path;
path.moveTo( 7, 5 );
path.arcTo( QRectF( 6.5, 3.5, 5.5, 5 ), 150, -160 );
path.cubicTo( QPointF(12, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) );
painter->drawPath( path );
//dot of question mark
painter->setPen( Qt::NoPen );
painter->setBrush( pen.color() );
if((!notInTitlebar) && boldButtonIcons) painter->drawEllipse( QRectF( 8, 14, 2, 2 ) );
else painter->drawEllipse( QRectF( 8.25, 14.25, 1.5, 1.5 ) );
}
void RenderStyleClassik18By18::renderShadeIcon()
{
if((!notInTitlebar) && boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.3 );
painter->setPen( pen );
}
RenderDecorationButtonIcon18By18::renderShadeIcon();
}
void RenderStyleClassik18By18::renderUnShadeIcon()
{
if((!notInTitlebar) && boldButtonIcons) {
//thicker pen in titlebar
pen.setWidthF( pen.widthF() *1.3 );
painter->setPen( pen );
}
RenderDecorationButtonIcon18By18::renderUnShadeIcon();
}
}