_drawing.scss 17 KB

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