comparison gtk-3.20/_drawing.scss @ 24:1b8713fff1e1

Add initial GTK3.20 support ready for upgrade to openSUSE Leap 42.2
author IBBoard <dev@ibboard.co.uk>
date Tue, 22 Nov 2016 20:58:58 +0000
parents
children d49665775e8b
comparison
equal deleted inserted replaced
23:279a2801a81b 24:1b8713fff1e1
1 // Drawing mixins
2
3 // generic drawing of more complex things
4
5 @function _widget_edge($c:$borders_edge) {
6 // outer highlight "used" on most widgets
7 @if $c == none { @return none; }
8 @else { @return 0 1px $c; }
9 }
10
11 @mixin _shadows($shadow1, $shadow2:none, $shadow3:none, $shadow4:none) {
12 //
13 // Helper function to stack up to 4 box-shadows;
14 //
15 @if $shadow4!=none { box-shadow: $shadow1, $shadow2, $shadow3, $shadow4; }
16 @else if $shadow3!=none { box-shadow: $shadow1, $shadow2, $shadow3; }
17 @else if $shadow2!=none { box-shadow: $shadow1, $shadow2; }
18 @else { box-shadow: $shadow1; }
19 }
20
21 // entries
22
23 @function entry_focus_border($fc:$selected_bg_color) {
24 @if $variant == 'light' { @return $fc; }
25 @else { @return if($fc==$selected_bg_color, $selected_borders_color, darken($fc, 35%)); }
26 }
27
28 @function entry_focus_shadow($fc:$selected_bg_color) {
29 @return inset 0 0 0 1px $fc;
30 }
31
32 @function entry_gradient($c) {
33 @if $variant=='light' { @return linear-gradient(to bottom, mix($borders_color, $c, 45%),
34 mix($borders_color, $c, 3%) 2px,
35 $c 90%); }
36 @else { @return linear-gradient(to bottom, mix($borders_color, $c, 95%),
37 mix($borders_color, $c, 40%) 3px,
38 $c 90%); }
39 }
40
41 @mixin entry($t, $fc:$selected_bg_color, $edge: none) {
42 //
43 // Entries drawing function
44 //
45 // $t: entry type
46 // $fc: focus color
47 // $edge: set to none to not draw the bottom edge or specify a color to not
48 // use the default one
49 //
50 // possible $t values:
51 // normal, focus, insensitive, backdrop, backdrop-insensitive, osd, osd-focus, osd-backdrop;
52 //
53
54 $_blank_edge: if($edge == none, none, 0 1px transparentize($edge, 1));
55 $_entry_edge: if($edge == none, none, _widget_edge($edge));
56
57 @if $t==normal {
58 color: $text_color;
59 border-color: $borders_color;
60 background-image: entry_gradient($base_color);
61 @include _shadows(entry_focus_shadow(transparentize($fc, 1)), $_entry_edge);
62 // for the transition to work the number of shadows in different states needs to match, hence the transparent shadow here.
63 }
64 @if $t==focus {
65 @include _shadows(entry_focus_shadow($fc), $_entry_edge);
66 border-color: entry_focus_border($fc);
67 }
68 @if $t==insensitive {
69 color: $insensitive_fg_color;
70 border-color: $borders_color;
71 background-image: linear-gradient(to bottom, $insensitive_bg_color);
72 box-shadow: $_entry_edge;
73 }
74 @if $t==backdrop {
75 color: $backdrop_text_color;
76 border-color: $backdrop_borders_color;
77 background-image: linear-gradient(to bottom, $backdrop_base_color);
78 box-shadow: $_blank_edge;
79 }
80 @if $t==backdrop-insensitive {
81 color: $backdrop_insensitive_color;
82 border-color: $backdrop_borders_color;
83 background-image: linear-gradient(to bottom, $insensitive_bg_color);
84 box-shadow: $_blank_edge;
85 }
86 @if $t==osd {
87 color: $osd_text_color;
88 border-color: $osd_borders_color;
89 background-image: linear-gradient(to bottom, transparentize(opacify($osd_borders_color, 1), 0.5));
90 background-clip: padding-box;
91 box-shadow: none;
92 text-shadow: 0 1px black;
93 -gtk-icon-shadow: 0 1px black;
94 }
95 @if $t==osd-focus {
96 color: $osd_text_color;
97 border-color: $selected_bg_color;
98 background-image: linear-gradient(to bottom, transparentize(opacify($osd_borders_color, 1), 0.5));
99 background-clip: padding-box;
100 box-shadow: entry_focus_shadow($fc);
101 text-shadow: 0 1px black;
102 -gtk-icon-shadow: 0 1px black;
103 }
104 @if $t==osd-insensitive {
105 color: $osd_insensitive_fg_color;
106 border-color: $osd_borders_color;
107 background-image: linear-gradient(to bottom, $osd_insensitive_bg_color);
108 background-clip: padding-box;
109 box-shadow: none;
110 text-shadow: none;
111 -gtk-icon-shadow: none;
112 }
113 @if $t==osd-backdrop {
114 color: $osd_text_color;
115 border-color: $osd_borders_color;
116 background-image: linear-gradient(to bottom, transparentize(opacify($osd_borders_color, 1), 0.5));
117 background-clip: padding-box;
118 box-shadow: none;
119 text-shadow: none;
120 -gtk-icon-shadow: none;
121 }
122 }
123
124 // buttons
125
126 @function _border_color ($c) { @return darken($c, 25%); } // colored buttons want
127 // the border form the
128 // base color
129
130 @function _text_shadow_color ($tc: $fg_color, $bg: $bg_color) {
131 //
132 // calculate the color of text shadows
133 //
134 // $tc is the text color
135 // $bg is the background color
136 //
137 $_lbg: lightness($bg)/100%;
138 @if lightness($tc)<50% { @return transparentize(white, 1-$_lbg/($_lbg*1.3)); }
139 @else { @return transparentize(black, $_lbg*0.8); }
140 }
141
142 @function _button_hilight_color($c) {
143 //
144 // calculate the right top hilight color for buttons
145 //
146 // $c: base color;
147 //
148 @if lightness($c)>95% { @return white; }
149 @else if lightness($c)>90% { @return transparentize(white, 0.2); }
150 @else if lightness($c)>80% { @return transparentize(white, 0.4); }
151 @else if lightness($c)>50% { @return transparentize(white, 0.6); }
152 @else if lightness($c)>40% { @return transparentize(white, 0.8); }
153 @else { @return transparentize(white, 0.95); }
154 }
155
156 @mixin _button_text_shadow ($tc:$fg_color, $bg:$bg_color) {
157 //
158 // helper function for the text emboss effect
159 //
160 // $tc is the optional text color, not the shadow color
161 //
162 // TODO: this functions needs a way to deal with special cases
163 //
164
165 $_shadow: _text_shadow_color($tc, $bg);
166
167 @if lightness($tc)<50% {
168 text-shadow: 0 1px $_shadow;
169 -gtk-icon-shadow: 0 1px $_shadow;
170 }
171 @else {
172 text-shadow: 0 -1px $_shadow;
173 -gtk-icon-shadow: 0 -1px $_shadow;
174 }
175 }
176
177 @mixin button($t, $c:$bg_color, $tc:$fg_color, $edge: none) {
178 //
179 // Button drawing function
180 //
181 // $t: button type,
182 // $c: base button color for colored* types
183 // $tc: optional text color for colored* types
184 // $edge: set to none to not draw the bottom edge or specify a color to not
185 // use the default one
186 //
187 // possible $t values:
188 // normal, hover, active, insensitive, insensitive-active,
189 // backdrop, backdrop-active, backdrop-insensitive, backdrop-insensitive-active,
190 // osd, osd-hover, osd-active, osd-insensitive, osd-backdrop, undecorated
191 //
192
193 $_hilight_color: _button_hilight_color($c);
194 $_button_edge: if($edge == none, none, _widget_edge($edge));
195 $_blank_edge: if($edge == none, none, _widget_edge(transparentize($edge,1)));
196
197 @if $t==normal {
198 //
199 // normal button
200 //
201 color: $tc;
202 outline-color: transparentize($tc, 0.7);
203 border-color: if($c!=$bg_color, _border_color($c), $borders_color);
204 @if $variant == 'light' { background-image: linear-gradient(to bottom, $c, darken($c, 4%) 60%, darken($c, 10%)); }
205 @else { background-image: linear-gradient(to bottom, darken($c, 2%), darken($c, 4%) 60%, darken($c, 6%)); }
206 @include _button_text_shadow($tc, $c);
207 @include _shadows(inset 0 1px $_hilight_color, $_button_edge);
208 }
209
210 @else if $t==hover {
211 //
212 // hovered button
213 //
214 color: $tc;
215 outline-color: transparentize($tc, 0.7);
216 border-color: if($c!=$bg_color, _border_color($c), $borders_color);
217 @if $variant == 'light' {
218 background-image: linear-gradient(to bottom, lighten($c, 6%), $c 60%, darken($c, 4%));
219 @include _button_text_shadow($tc,lighten($c, 6%));
220 @include _shadows(inset 0 1px _button_hilight_color(lighten($c, 6%)), $_button_edge);
221 }
222 @else {
223 background-image: linear-gradient(to bottom, lighten($c, 1%), darken($c, 2%) 60%, darken($c, 4%));
224 @include _button_text_shadow($tc,lighten($c, 6%));
225 @include _shadows(inset 0 1px _button_hilight_color(darken($c, 2%)), $_button_edge);
226 }
227 }
228
229 @if $t==normal-alt {
230 //
231 // normal button alternative look
232 //
233 color: $tc;
234 outline-color: transparentize($tc, 0.7);
235 border-color: if($c!=$bg_color, _border_color($c), $borders_color);
236 @include _button_text_shadow($tc, $c);
237 @if $variant == 'light' {
238 background-image: linear-gradient(to bottom, lighten($c, 5%) 20%, $c 90%);
239 @include _shadows(inset 0 1px _button_hilight_color(lighten($c, 6%)),
240 inset 0 -2px lighten($c, 2%),
241 inset 0 -1px darken($c, 12%),
242 $_button_edge);
243 }
244 @else {
245 background-image: linear-gradient(to bottom, darken($c, 3%) 20%, darken($c, 6%) 90%);
246 @include _shadows(inset 0 1px $_hilight_color,
247 inset 0 -2px darken($c, 4%),
248 inset 0 -1px darken($c, 9%),
249 $_button_edge);
250 }
251 }
252
253 @else if $t==hover-alt {
254 //
255 // hovered button alternative look
256 //
257 color: $tc;
258 outline-color: transparentize($tc, 0.7);
259 border-color: if($c!=$bg_color, _border_color($c), $borders_color);
260 @if $variant == 'light' {
261 background-image: linear-gradient(to bottom, lighten($c, 9%) 10%, lighten($c, 4%) 90%);
262 box-shadow: inset 0 1px _button_hilight_color(lighten($c, 6%)),
263 inset 0 -2px lighten($c, 5%),
264 inset 0 -1px darken($c, 10%),
265 $_button_edge;
266 }
267 @else {
268 background-image: linear-gradient(to bottom, $c 20%, darken($c, 4%) 90%);
269 @include _shadows(inset 0 1px $_hilight_color,
270 inset 0 -2px darken($c, 3%),
271 inset 0 -1px darken($c, 6%),
272 $_button_edge);
273 }
274 }
275
276
277 @else if $t==active {
278 //
279 // pushed button
280 //
281 color: $tc;
282 outline-color: transparentize($tc, 0.7);
283 border-color: if($c!=$bg_color, _border_color($c), $borders_color);
284 @if $variant == 'light' { background-image: linear-gradient(to bottom, darken($c, 13%), darken($c, 5%)); }
285 @else { background-image: linear-gradient(to bottom, darken($c, 9%), darken($c, 5%)); }
286 @include _button_text_shadow($tc, darken($c,10%));
287 @include _shadows(inset 0 2px 1px -2px transparentize(black,0.4),
288 $_button_edge);
289 }
290 @else if $t==insensitive {
291 //
292 // insensitive button
293 //
294 $_bg: if($c!=$bg_color, mix($c, $base_color, 85%), $insensitive_bg_color);
295
296 label, & { color: if($tc!=$fg_color, mix($tc, $_bg, 50%), $insensitive_fg_color); }
297
298 border-color: if($c!=$bg_color, _border_color($c),
299 $insensitive_borders_color);
300 background-image: linear-gradient(to bottom, $_bg);
301 text-shadow: none;
302 -gtk-icon-shadow: none;
303 // white with 0 alpha to avoid an ugly transition, since no color means
304 // black with 0 alpha
305 @include _shadows(inset 0 1px transparentize(white, 1), $_button_edge);
306 }
307 @else if $t==insensitive-active {
308 //
309 // insensitive pushed button
310 //
311 $_bg: if($c!=$bg_color, darken(mix($c,$base_color, 85%), 5%),
312 $insensitive_bg_color);
313 $_bc: if($c!=$bg_color, _border_color($c), $insensitive_borders_color);
314
315 label, & { color: if($c!=$bg_color, mix($tc, $_bg, 60%), $insensitive_fg_color); }
316
317 border-color: $_bc;
318 background-image: linear-gradient(to bottom, mix($_bc, $_bg, 10%), $_bg);
319 // white with 0 alpha to avoid an ugly transition, since no color means
320 // black with 0 alpha
321 @include _shadows(inset 0 1px transparentize(white, 1), $_button_edge);
322 }
323
324 @else if $t==backdrop {
325 //
326 // backdrop button
327 //
328 $_bg: if($c!=$bg_color,$c,$backdrop_bg_color);
329 $_bc: if($variant=='light',$c,_border_color($c));
330
331 label, & { color: if($tc!=$fg_color,mix($tc, $_bg, 80%), $backdrop_fg_color); }
332
333 border-color: if($c!=$bg_color, $_bc, $backdrop_borders_color);
334 background-image: linear-gradient(to bottom, $_bg);
335 text-shadow: none;
336 -gtk-icon-shadow: none;
337 @include _shadows(inset 0 1px transparentize(white, 1),
338 $_blank_edge);
339 }
340
341 @else if $t==backdrop-active {
342 //
343 // backdrop pushed button FIXME no colors here!
344 //
345 $_bg: if($c!=$bg_color, darken($c, 10%), $backdrop_dark_fill);
346 $_bc: if($variant=='light',$_bg,_border_color($c));
347
348 label, & { color: if($tc!=$fg_color, mix($tc, $_bg, 80%), $backdrop_fg_color); }
349
350 border-color: if($c!=$bg_color, $_bc, $backdrop_borders_color);
351 background-image: linear-gradient(to bottom, $_bg);
352 @include _shadows(inset 0 1px transparentize(white, 1),
353 $_blank_edge);
354 }
355
356 @else if $t==backdrop-insensitive {
357 //
358 // backdrop insensitive button
359 //
360
361 $_bg: if($c!=$bg_color, mix($c, $base_color, 85%), $insensitive_bg_color);
362 $_bc: if($variant=='light', $_bg,_border_color($c));
363
364 label, & { color: if($c!=$bg_color, mix($tc, $_bg, 35%), $backdrop_insensitive_color); }
365
366 border-color: if($c!=$bg_color, $_bc, $backdrop_borders_color);
367 background-image: linear-gradient(to bottom, $_bg);
368 text-shadow: none;
369 -gtk-icon-shadow: none;
370 // white with 0 alpha to avoid an ugly transition, since no color means
371 // black with 0 alpha
372 @include _shadows(inset 0 1px transparentize(white, 1),
373 $_blank_edge);
374 }
375
376 @else if $t==backdrop-insensitive-active {
377 //
378 // backdrop insensitive pushed button
379 //
380
381 $_bg: if($c!=$bg_color, darken(mix($c, $base_color, 85%), 5%),
382 darken($insensitive_bg_color, 5%));
383 $_bc: if($variant=='light', $_bg,_border_color($c));
384
385 label { color: if($c!=$bg_color, mix($tc, $_bg, 35%), $backdrop_insensitive_color); }
386
387 border-color: if($c!=$bg_color, $_bc, $backdrop_borders_color);
388 background-image: linear-gradient(to bottom, $_bg);
389 @include _shadows(inset 0 1px transparentize(white, 1),
390 $_blank_edge);
391 }
392
393 @else if $t==osd {
394 //
395 // normal osd button
396 //
397 $_bg: if($c!=$bg_color, transparentize($c, 0.5),
398 $osd_bg_color);
399
400 color: $osd_fg_color;
401 border-color: $osd_borders_color;
402 background-image: linear-gradient(to bottom, $_bg);
403 background-clip: padding-box;
404 box-shadow: inset 0 1px transparentize(white, 0.9);
405 text-shadow: 0 1px black;
406 -gtk-icon-shadow: 0 1px black;
407 outline-color: transparentize($osd_fg_color, 0.7);
408 }
409 @else if $t==osd-hover {
410 //
411 // active osd button
412 //
413 $_bg: if($c!=$bg_color, transparentize($c, 0.3),
414 lighten($osd_bg_color, 12%));
415
416 color: white;
417 border-color: $osd_borders_color;
418 background-image: linear-gradient(to bottom, $_bg);
419 background-clip: padding-box;
420 box-shadow: inset 0 1px transparentize(white, 0.9);
421 text-shadow: 0 1px black;
422 -gtk-icon-shadow: 0 1px black;
423 outline-color: transparentize($osd_fg_color, 0.7);
424 }
425 @else if $t==osd-active {
426 //
427 // active osd button
428 //
429 $_bg: if($c!=$bg_color, $c, $osd_borders_color);
430
431 color: white;
432 border-color: $osd_borders_color;
433 background-image: linear-gradient(to bottom, $_bg);
434 background-clip: padding-box;
435 box-shadow: none;
436 text-shadow: none;
437 -gtk-icon-shadow: none;
438 outline-color: transparentize($osd_fg_color, 0.7);
439 }
440 @else if $t==osd-insensitive {
441 //
442 // insensitive osd button
443 //
444 color: $osd_insensitive_fg_color;
445 border-color: $osd_borders_color;
446 background-image: linear-gradient(to bottom, $osd_insensitive_bg_color);
447 background-clip: padding-box;
448 box-shadow: none;
449 text-shadow: none;
450 -gtk-icon-shadow: none;
451 }
452 @else if $t==osd-backdrop {
453 //
454 // backdrop osd button
455 //
456 $_bg: if($c!=$bg_color, transparentize($c, 0.5),
457 $osd_bg_color);
458
459 color: $osd_fg_color;
460 border-color: $osd_borders_color;
461 background-image: linear-gradient(to bottom, $_bg);
462 background-clip: padding-box;
463 box-shadow: none;
464 text-shadow: none;
465 -gtk-icon-shadow: none;
466 }
467 @else if $t==undecorated {
468 //
469 // reset
470 //
471 border-color: transparent;
472 background-color: transparent;
473 background-image: none;
474
475 @include _shadows(inset 0 1px transparentize(white, 1),
476 $_blank_edge);
477
478 text-shadow: none;
479 -gtk-icon-shadow: none;
480 }
481 }
482
483 @mixin trough($flat:false, $c:$bg_color, $tc:$fg_color, $noedge:true) {
484 color: mix($tc, $bg_color, 80%);
485 @if $flat { background-image: linear-gradient(to bottom, $c); }
486 @else {
487 background-image: linear-gradient(to bottom,
488 mix(black,$c,15%) 5%,
489 mix(black,$c,10%) 20%,
490 mix(black,$c,10%) 90%,
491 $c);
492 }
493
494 border-color: if($c!=$bg_color, _border_color($c), $border_color);
495
496 @if not($noedge) {
497 @if lightness($c) > 60% {
498 box-shadow: inset 0 -1px $borders_edge,
499 0 1px $borders_edge;
500 }
501 @else {
502 box-shadow: inset 0 -1px transparentize($borders_edge, 0.5),
503 0 1px transparentize($borders_edge, 0.5);
504 }
505 }
506 @else { box-shadow: none; }
507 }
508
509 @mixin headerbar_fill($c:$headerbar_color, $hc:$top_hilight, $ov: none) {
510 //
511 // headerbar fill
512 //
513 // $c: base color
514 // $hc: top highlight color
515 // $ov: a background layer for background shorthand (hence no commas!)
516 //
517 $gradient: linear-gradient(to top, darken($c, 13%), darken($c, 2%) 2px, $c 3px);
518
519 @if $variant == 'dark' { $gradient: linear-gradient(to top, darken($c, 3%), darken($c, 1%) 2px, $c 3px); }
520
521 @if $ov != none { background: $c $ov, $gradient; }
522 @else { background: $c $gradient; }
523
524 box-shadow: inset 0 1px $hc; // top highlight
525 }
526
527 @mixin overshoot($p, $t:normal, $c:$fg_color) {
528 //
529 // overshoot
530 //
531 // $p: position
532 // $t: type
533 // $c: base color
534 //
535 // possible $p values:
536 // top, bottom, right, left
537 //
538 // possible $t values:
539 // normal, backdrop
540 //
541
542 $_small_gradient_length: 5%;
543 $_big_gradient_length: 100%;
544
545 $_position: center top;
546 $_small_gradient_size: 100% $_small_gradient_length;
547 $_big_gradient_size: 100% $_big_gradient_length;
548
549 @if $p==bottom {
550 $_position: center bottom;
551 $_linear_gradient_direction: to top;
552 }
553
554 @else if $p==right {
555 $_position: right center;
556 $_small_gradient_size: $_small_gradient_length 100%;
557 $_big_gradient_size: $_big_gradient_length 100%;
558 }
559
560 @else if $p==left {
561 $_position: left center;
562 $_small_gradient_size: $_small_gradient_length 100%;
563 $_big_gradient_size: $_big_gradient_length 100%;
564 }
565
566 $_small_gradient_color: $c;
567 $_big_gradient_color: $c;
568
569 @if $c==$fg_color {
570 $_small_gradient_color: darken($borders_color, 10%);
571 $_big_gradient_color: $fg_color;
572
573 @if $t==backdrop { $_small_gradient_color: $backdrop_borders_color; }
574 }
575
576 $_small_gradient: -gtk-gradient(radial,
577 $_position, 0,
578 $_position, 0.5,
579 to($_small_gradient_color),
580 to(transparentize($_small_gradient_color, 1)));
581
582 $_big_gradient: -gtk-gradient(radial,
583 $_position, 0,
584 $_position, 0.6,
585 from(transparentize($_big_gradient_color, 0.93)),
586 to(transparentize($_big_gradient_color, 1)));
587
588 @if $t==normal {
589 background-image: $_small_gradient, $_big_gradient;
590 background-size: $_small_gradient_size, $_big_gradient_size;
591 }
592
593 @else if $t==backdrop {
594 background-image: $_small_gradient;
595 background-size: $_small_gradient_size;
596 }
597
598 background-repeat: no-repeat;
599 background-position: $_position;
600
601 background-color: transparent; // reset some properties to be sure to not inherit them somehow
602 border: none; //
603 box-shadow: none; //
604 }
605
606 @mixin undershoot($p) {
607 //
608 // undershoot
609 //
610 // $p: position
611 //
612 // possible $p values:
613 // top, bottom, right, left
614 //
615
616 $_undershoot_color_dark: transparentize(black, 0.8);
617 $_undershoot_color_light: transparentize(white, 0.8);
618
619 $_gradient_dir: left;
620 $_dash_bg_size: 10px 1px;
621 $_gradient_repeat: repeat-x;
622 $_bg_pos: center $p;
623
624 background-color: transparent; // shouldn't be needed, but better to be sure;
625
626 @if ($p == left) or ($p == right) {
627 $_gradient_dir: top;
628 $_dash_bg_size: 1px 10px;
629 $_gradient_repeat: repeat-y;
630 $_bg_pos: $p center;
631 }
632
633 background-image: linear-gradient(to $_gradient_dir, // this is the dashed line
634 $_undershoot_color_light 50%,
635 $_undershoot_color_dark 50%);
636
637 padding-#{$p}: 1px;
638 background-size: $_dash_bg_size;
639 background-repeat: $_gradient_repeat;
640 background-origin: content-box;
641 background-position: $_bg_pos;
642 border: none;
643 box-shadow: none;
644 }