_drawing.scss 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*****************
  2. * Drawing mixins *
  3. *****************/
  4. // drawing of depth/shadows
  5. $depth: 0 1px 2px rgba(0, 0, 0, 0.10);
  6. $depth2: 0 1px 2px rgba(0, 0, 0, 0.15);
  7. $depth3: inset 0 1px 1px rgba(0, 0, 0, 0.06);
  8. $depth4: inset 0 1px 2px rgba(0, 0, 0, 0.10);
  9. $depth5: inset 0 1px 2px rgba(0, 0, 0, 0.15);
  10. $depth6: 0 2px 4px 2px transparentize(black, 0.8);
  11. // generic drawing of more complex things
  12. @function _widget_edge($c:$borders_edge) {
  13. // outer highlight "used" on most widgets
  14. @return 0 1px $c;
  15. }
  16. // provide font size in rem, with px fallback
  17. @mixin fontsize($size: 24, $base: 16) {
  18. font-size: round($size) + pt;
  19. //font-size: ($size / $base) * 1rem;
  20. }
  21. @mixin _shadows($shadow1, $shadow2:none, $shadow3:none, $shadow4:none) {
  22. //
  23. // Helper function to stack up to 4 box-shadows;
  24. //
  25. @if $shadow4!=none { box-shadow: $shadow1, $shadow2, $shadow3, $shadow4; }
  26. @else if $shadow3!=none { box-shadow: $shadow1, $shadow2, $shadow3; }
  27. @else if $shadow2!=none { box-shadow: $shadow1, $shadow2; }
  28. @else { box-shadow: $shadow1; }
  29. }
  30. // entries
  31. @mixin entry($t, $fc:$selected_bg_color, $edge: $borders_edge) {
  32. //
  33. // Entries drawing function
  34. //
  35. // $t: entry type
  36. // $fc: focus color
  37. // $edge: set to none to not draw the bottom edge or specify a color to not
  38. // use the default one
  39. //
  40. // possible $t values:
  41. // normal, focus, insensitive
  42. //
  43. @if $t==normal {
  44. background-color: lighten($base_color, 5%);
  45. border-color: $borders_color;
  46. }
  47. @if $t==focus {
  48. box-shadow: inset 0px 0px 1px 1px $selected_bg_color;
  49. border-color: $selected_bg_color;
  50. }
  51. @if $t==hover {
  52. background-color: lighten($base_color, 8%);
  53. }
  54. @if $t==insensitive {
  55. color: $insensitive_fg_color;
  56. box-shadow: $depth;
  57. }
  58. }
  59. // buttons
  60. @function _border_color ($c) { @return darken($c,25%); } // colored buttons want
  61. // the border form the
  62. // base color
  63. @function _text_shadow_color ($tc:$fg_color, $bg:$bg_color) {
  64. //
  65. // calculate the color of text shadows
  66. //
  67. // $tc is the text color
  68. // $bg is the background color
  69. //
  70. $_lbg: lightness($bg)/100%;
  71. @if lightness($tc)<50% { @return transparentize(white,1-$_lbg/($_lbg*1.3)); }
  72. @else { @return transparentize(black,$_lbg*0.8); }
  73. }
  74. @function _button_hilight_color($c) {
  75. //
  76. // calculate the right top hilight color for buttons
  77. //
  78. // $c: base color;
  79. //
  80. @if lightness($c)>90% { @return white; }
  81. @else if lightness($c)>80% { @return transparentize(white, 0.3); }
  82. @else if lightness($c)>50% { @return transparentize(white, 0.5); }
  83. @else if lightness($c)>40% { @return transparentize(white, 0.7); }
  84. @else { @return transparentize(white, 0.9); }
  85. }
  86. @mixin _button_text_shadow ($tc:$fg_color, $bg:$bg_color) {
  87. //
  88. // helper function for the text emboss effect
  89. //
  90. // $tc is the optional text color, not the shadow color
  91. //
  92. // TODO: this functions needs a way to deal with special cases
  93. //
  94. $_shadow: _text_shadow_color($tc, $bg);
  95. @if lightness($tc)<50% {
  96. text-shadow: 0 1px $_shadow;
  97. icon-shadow: 0 1px $_shadow;
  98. }
  99. @else {
  100. text-shadow: 0 -1px $_shadow;
  101. icon-shadow: 0 -1px $_shadow;
  102. }
  103. }
  104. @mixin button($t, $c:$osd_bg_color, $tc:$fg_color, $edge: $borders_edge) {
  105. //
  106. // Button drawing function
  107. //
  108. // $t: button type,
  109. // $c: base button color for colored* types
  110. // $tc: optional text color for colored* types
  111. // $edge: set to none to not draw the bottom edge or specify a color to not
  112. // use the default one
  113. //
  114. // possible $t values:
  115. // normal, hover, active, insensitive, insensitive-active,
  116. // backdrop, backdrop-active, backdrop-insensitive, backdrop-insensitive-active,
  117. // osd, osd-hover, osd-active, osd-insensitive, osd-backdrop, undecorated
  118. //
  119. $_hilight_color: _button_hilight_color($c);
  120. $_button_edge: if($edge == none, none, _widget_edge($edge));
  121. $_blank_edge: if($edge == none, none, _widget_edge(transparentize($edge,1)));
  122. @if $t==normal {
  123. //
  124. // normal button
  125. //
  126. color: $fg_color;
  127. background-color: lighten($base_color, 2%);
  128. box-shadow: none;
  129. border: 1px solid $borders_color;
  130. text-shadow: 0 1px black;
  131. icon-shadow: 0 1px black;
  132. }
  133. @if $t==focus {
  134. //
  135. // focused button
  136. //
  137. $_bg: if($c!=$osd_bg_color, transparentize($c, 0.5),
  138. $osd_bg_color);
  139. background-color: lighten($base_color, 6%);
  140. color: $selected_fg_color;
  141. text-shadow: 0 1px black;
  142. icon-shadow: 0 1px black;
  143. box-shadow: none !important;
  144. border: 1px solid $borders_color;
  145. }
  146. @else if $t==hover {
  147. //
  148. // active osd button
  149. //
  150. $_bg: if($c!=$osd_bg_color, transparentize($c, 0.3),
  151. lighten($main_dark, 2%));
  152. background-color: lighten($base_color, 6%);
  153. color: $selected_fg_color;
  154. border: 1px solid $borders_color;
  155. text-shadow: 0 1px black;
  156. icon-shadow: 0 1px black;
  157. }
  158. @else if $t==active {
  159. //
  160. // active osd button
  161. //
  162. $_bg: if($c!=$bg_color, $c, $selected_bg_color);
  163. color: $purple;
  164. background-color: $_bg;
  165. // This should be none, but it's creating some issues with borders, so to
  166. // workaround it for now, use inset wich goes through a different code path.
  167. // see https://bugzilla.gnome.org/show_bug.cgi?id=752934
  168. border: 1px solid $borders_color;
  169. text-shadow: none;
  170. icon-shadow: none;
  171. }
  172. @else if $t==insensitive {
  173. //
  174. // insensitive osd button
  175. //
  176. $_bg: transparentize(mix($insensitive_fg_color,$osd_bg_color,20%),0.3);
  177. color: $insensitive_fg_color;
  178. background-color: $_bg;
  179. box-shadow: $depth4;
  180. border: none;
  181. text-shadow: none;
  182. icon-shadow: none;
  183. }
  184. @else if $t==undecorated {
  185. //
  186. // reset
  187. //
  188. border-color: transparent;
  189. background-color: transparent;
  190. background-image: none;
  191. @include _shadows(inset 0 1px transparentize(white,1),
  192. $_blank_edge);
  193. text-shadow: none;
  194. icon-shadow: none;
  195. }
  196. }
  197. @mixin gradient($c1: $g1, $c2: $g2, $dir: horizontal) {
  198. background-gradient-start: $c1;
  199. background-gradient-end: $c2;
  200. background-gradient-direction: $dir;
  201. }