_drawing.scss 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  194. }
  195. @else if $t==hover {
  196. //
  197. // hovered button
  198. //
  199. color: $tc;
  200. outline-color: transparentize($tc, 0.7);
  201. background-color: $c;
  202. text-shadow: none;
  203. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  204. }
  205. @if $t==normal-header {
  206. //
  207. // normal button headerbar look
  208. //
  209. color: if($tc==$text_color, $headerbar_fg_color, $tc);
  210. background-color: transparent;
  211. border-radius: 0;
  212. text-shadow: none;
  213. box-shadow: none;
  214. border: none;
  215. }
  216. @else if $t==hover-header {
  217. //
  218. // hovered button headerbar look
  219. //
  220. color: if($tc==$text_color, $headerbar_fg_color, $tc);
  221. background-color: transparent;
  222. border-radius: 0;
  223. text-shadow: none;
  224. box-shadow: none;
  225. }
  226. @else if $t==active-header {
  227. //
  228. // active button headerbar look
  229. //
  230. color: if($tc==$text_color, $selected_bg_color, $tc);
  231. background-color: transparentize($selected_bg_color, $amount: 0.4);
  232. border-radius: 7px;
  233. box-shadow: none;
  234. text-shadow: none;
  235. font-weight: bold;
  236. }
  237. @else if $t==backdrop-header {
  238. //
  239. // backdrop button headerbar look
  240. //
  241. color: if($tc==$text_color, transparentize($tc, 0.6), $tc);
  242. background-color: transparent;
  243. border-radius: 0;
  244. text-shadow: none;
  245. box-shadow: none;
  246. }
  247. @else if $t==active {
  248. //
  249. // pushed button
  250. //
  251. color: $tc;
  252. outline-color: transparentize($tc, 0.7);
  253. background-color: if($c==$base_color, $selected_bg_color, $c);
  254. text-shadow: none;
  255. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  256. }
  257. @else if $t==insensitive {
  258. //
  259. // insensitive button
  260. //
  261. color: if($tc==$text_color, $backdrop_text_color, $tc);
  262. outline-color: transparentize($tc, 0.7);
  263. background-color: if($c==$base_color, $insensitive_bg_color, $c);
  264. text-shadow: none;
  265. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  266. }
  267. @else if $t==insensitive-active {
  268. //
  269. // insensitive pushed button
  270. //
  271. color: transparentize($selected_fg_color, 0.3);
  272. outline-color: transparentize($tc, 0.7);
  273. background-color: if($c==$base_color, $selected_bg_color, $c);
  274. text-shadow: none;
  275. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  276. label { color: transparentize($selected_fg_color, 0.3); }
  277. }
  278. @else if $t==backdrop {
  279. //
  280. // backdrop button
  281. //
  282. color: if($tc==$text_color, $backdrop_text_color, transparentize($tc, 0.6));
  283. outline-color: transparentize($tc, 0.7);
  284. background-color: if($c==$base_color, $backdrop_base_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==backdrop-active {
  289. //
  290. // backdrop pushed button FIXME no colors here!
  291. //
  292. color: transparentize($selected_fg_color, 0.3);
  293. outline-color: transparentize($tc, 0.7);
  294. background-color: $selected_bg_color;
  295. text-shadow: none;
  296. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  297. label { color: transparentize($selected_fg_color, 0.3); }
  298. }
  299. @else if $t==backdrop-insensitive {
  300. //
  301. // backdrop insensitive button
  302. //
  303. color: if($tc==$text_color, $backdrop_text_color, $tc);
  304. outline-color: transparentize($tc, 0.7);
  305. background-color: if($c==$base_color, $insensitive_bg_color, $c);
  306. text-shadow: none;
  307. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  308. }
  309. @else if $t==backdrop-insensitive-active {
  310. //
  311. // backdrop insensitive pushed button
  312. //
  313. color: transparentize($selected_fg_color, 0.3);
  314. outline-color: transparentize($tc, 0.7);
  315. background-color: $selected_bg_color;
  316. text-shadow: none;
  317. @include _shadows(inset 0px 1px 0px 0px $top_highlight,inset 0px -1px 0px 0px $bottom_highlight);
  318. }
  319. @else if $t==osd {
  320. //
  321. // normal osd button
  322. //
  323. $_bg: if($c!=$base_color, transparentize($c, 0.5),
  324. $osd_bg_color);
  325. color: $osd_fg_color;
  326. border-color: $osd_borders_color;
  327. background-color: $_bg;
  328. background-clip: padding-box;
  329. box-shadow: inset 0 1px transparentize(white, 0.9);
  330. text-shadow: 0 1px black;
  331. -gtk-icon-shadow: 0 1px black;
  332. outline-color: transparentize($osd_fg_color, 0.7);
  333. }
  334. @else if $t==osd-hover {
  335. //
  336. // active osd button
  337. //
  338. $_bg: if($c!=$base_color, transparentize($c, 0.3),
  339. lighten($osd_bg_color, 12%));
  340. color: white;
  341. border-color: $osd_borders_color;
  342. background-image: linear-gradient(to bottom, $_bg, $_bg);
  343. background-clip: padding-box;
  344. box-shadow: inset 0 1px transparentize(white, 0.9);
  345. text-shadow: 0 1px black;
  346. -gtk-icon-shadow: 0 1px black;
  347. outline-color: transparentize($osd_fg_color, 0.7);
  348. }
  349. @else if $t==osd-active {
  350. //
  351. // active osd button
  352. //
  353. $_bg: if($c!=$base_color, $c, lighten($osd_bg_color, 6%));
  354. color: white;
  355. border-color: $osd_borders_color;
  356. background-image: linear-gradient(to bottom, $_bg, $_bg);
  357. background-clip: padding-box;
  358. box-shadow: inset 0 1px transparentize(white, 0.9);
  359. text-shadow: none;
  360. -gtk-icon-shadow: none;
  361. outline-color: transparentize($osd_fg_color, 0.7);
  362. }
  363. @else if $t==osd-insensitive {
  364. //
  365. // insensitive osd button
  366. //
  367. color: $osd_insensitive_fg_color;
  368. border-color: $osd_borders_color;
  369. background-image: linear-gradient(to bottom, $osd_insensitive_bg_color, $osd_insensitive_bg_color);
  370. background-clip: padding-box;
  371. box-shadow: none;
  372. text-shadow: none;
  373. -gtk-icon-shadow: none;
  374. }
  375. @else if $t==osd-backdrop {
  376. //
  377. // backdrop osd button
  378. //
  379. $_bg: if($c!=$base_color, transparentize($c, 0.5),
  380. $osd_bg_color);
  381. color: $osd_fg_color;
  382. border-color: $osd_borders_color;
  383. background-image: linear-gradient(to bottom, $_bg, $_bg);
  384. background-clip: padding-box;
  385. box-shadow: none;
  386. text-shadow: none;
  387. -gtk-icon-shadow: none;
  388. }
  389. @else if $t==undecorated {
  390. //
  391. // reset
  392. //
  393. border-color: transparent;
  394. background-color: transparent;
  395. background-image: none;
  396. @include _shadows(inset 0 1px transparentize(white, 1),
  397. $_blank_edge);
  398. text-shadow: none;
  399. -gtk-icon-shadow: none;
  400. }
  401. }
  402. @mixin trough($flat:false, $c:$bg_color, $tc:$fg_color, $noedge:true) {
  403. color: mix($tc, $bg_color, 80%);
  404. @if $flat { background-image: linear-gradient(to bottom, $c, $c); }
  405. @else {
  406. background-image: linear-gradient(to bottom,
  407. mix(black,$c,15%) 5%,
  408. mix(black,$c,10%) 20%,
  409. mix(black,$c,10%) 90%,
  410. $c);
  411. }
  412. border-color: if($c!=$bg_color, _border_color($c), $border_color);
  413. @if not($noedge) {
  414. @if lightness($c) > 60% {
  415. box-shadow: inset 0 -1px $borders_edge,
  416. 0 1px $borders_edge;
  417. }
  418. @else {
  419. box-shadow: inset 0 -1px transparentize($borders_edge, 0.5),
  420. 0 1px transparentize($borders_edge, 0.5);
  421. }
  422. }
  423. @else { box-shadow: none; }
  424. }
  425. @mixin headerbar_fill($c:$headerbar_color, $hc:$top_highlight, $ov: none) {
  426. //
  427. // headerbar fill
  428. //
  429. // $c: base color
  430. // $hc: top highlight color
  431. // $ov: a background layer for background shorthand (hence no commas!)
  432. //
  433. $gradient: linear-gradient(to top, darken($c, 13%), darken($c, 2%) 2px, $c 3px);
  434. @if $variant == 'dark' { $gradient: linear-gradient(to top, darken($c, 3%), darken($c, 1%) 2px, $c 3px); }
  435. @if $ov != none { background: $c $ov, $gradient; }
  436. @else { background: $c $gradient; }
  437. box-shadow: inset 0 1px $hc; // top highlight
  438. }
  439. @mixin overshoot($p, $t:normal, $c:lighten($base_color, 5%)) {
  440. //
  441. // overshoot
  442. //
  443. // $p: position
  444. // $t: type
  445. // $c: base color
  446. //
  447. // possible $p values:
  448. // top, bottom, right, left
  449. //
  450. // possible $t values:
  451. // normal, backdrop
  452. //
  453. $_small_gradient_length: 5%;
  454. $_big_gradient_length: 100%;
  455. $_position: center top;
  456. $_small_gradient_size: 100% $_small_gradient_length;
  457. $_big_gradient_size: 100% $_big_gradient_length;
  458. @if $p==bottom {
  459. $_position: center bottom;
  460. $_linear_gradient_direction: to top;
  461. }
  462. @else if $p==right {
  463. $_position: right center;
  464. $_small_gradient_size: $_small_gradient_length 100%;
  465. $_big_gradient_size: $_big_gradient_length 100%;
  466. }
  467. @else if $p==left {
  468. $_position: left center;
  469. $_small_gradient_size: $_small_gradient_length 100%;
  470. $_big_gradient_size: $_big_gradient_length 100%;
  471. }
  472. $_small_gradient_color: $c;
  473. $_big_gradient_color: $c;
  474. @if $c==$fg_color {
  475. $_small_gradient_color: darken($borders_color, 10%);
  476. $_big_gradient_color: $fg_color;
  477. @if $t==backdrop { $_small_gradient_color: $backdrop_borders_color; }
  478. }
  479. $_small_gradient: radial-gradient(farthest-side at $p,
  480. $_small_gradient_color 85%,
  481. transparentize($_small_gradient_color, 1));
  482. $_big_gradient: radial-gradient(farthest-side at $p,
  483. $_big_gradient_color,
  484. transparentize($_big_gradient_color, 1));
  485. @if $t==normal {
  486. background-image: $_small_gradient, $_big_gradient;
  487. background-size: $_small_gradient_size, $_big_gradient_size;
  488. }
  489. @else if $t==backdrop {
  490. background-image: $_small_gradient;
  491. background-size: $_small_gradient_size;
  492. }
  493. background-repeat: no-repeat;
  494. background-position: $_position;
  495. background-color: transparent; // reset some properties to be sure to not inherit them somehow
  496. border: none; //
  497. box-shadow: none; //
  498. }
  499. @mixin undershoot($p) {
  500. //
  501. // undershoot
  502. //
  503. // $p: position
  504. //
  505. // possible $p values:
  506. // top, bottom, right, left
  507. //
  508. $_undershoot_color_dark: transparentize(black, 0.8);
  509. $_undershoot_color_light: transparentize(white, 0.8);
  510. $_gradient_dir: left;
  511. $_dash_bg_size: 10px 1px;
  512. $_gradient_repeat: repeat-x;
  513. $_bg_pos: center $p;
  514. background-color: transparent; // shouldn't be needed, but better to be sure;
  515. @if ($p == left) or ($p == right) {
  516. $_gradient_dir: top;
  517. $_dash_bg_size: 1px 10px;
  518. $_gradient_repeat: repeat-y;
  519. $_bg_pos: $p center;
  520. }
  521. background-image: linear-gradient(to $_gradient_dir, // this is the dashed line
  522. $_undershoot_color_light 50%,
  523. $_undershoot_color_dark 50%);
  524. padding-#{$p}: 1px;
  525. background-size: $_dash_bg_size;
  526. background-repeat: $_gradient_repeat;
  527. background-origin: content-box;
  528. background-position: $_bg_pos;
  529. border: none;
  530. box-shadow: none;
  531. }