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