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