_buttons.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /***********
  2. * Buttons *
  3. ***********/
  4. // stuff for .needs-attention
  5. $_dot_color: if($variant=='light', $selected_bg_color,
  6. lighten($selected_bg_color,15%));
  7. @keyframes needs_attention {
  8. from { background-image: radial-gradient(farthest-side, $_dot_color 0%, transparentize($_dot_color, 1) 0%); }
  9. to { background-image: radial-gradient(farthest-side, $_dot_color 95%, transparentize($_dot_color, 1)); }
  10. }
  11. %button,
  12. button {
  13. @at-root %button_basic, & {
  14. min-height: 24px;
  15. min-width: 16px;
  16. padding: 4px 8px;
  17. border: none;
  18. border-radius: 3px;
  19. transition: $button_transition;
  20. @include button(normal);
  21. &.flat {
  22. @include button(undecorated);
  23. // to avoid adiacent buttons borders clashing when transitioning, the transition on the normal state is set
  24. // to none, while it's added back in the hover state, so the button decoration will fade in on hover, but
  25. // it won't fade out when the pointer leave the button allocation area. To make the transition more evident
  26. // in this case the duration is increased.
  27. transition: none;
  28. &:hover {
  29. transition: $button_transition;
  30. transition-duration: 500ms;
  31. &:active { transition: $button_transition; }
  32. }
  33. }
  34. &:hover {
  35. @include button(hover,$selected_bg_color,$selected_fg_color);
  36. -gtk-icon-filter: brightness(1.2);
  37. }
  38. &:active,
  39. &:checked {
  40. @include button(active,darken($selected_bg_color,5%),$selected_fg_color);
  41. transition-duration: 50ms;
  42. }
  43. &:backdrop {
  44. &.flat, & {
  45. @include button(backdrop);
  46. transition: $backdrop_transition;
  47. -gtk-icon-filter: none;
  48. &:active,
  49. &:checked { @include button(backdrop-active); }
  50. &:disabled {
  51. @include button(backdrop-insensitive);
  52. &:active,
  53. &:checked { @include button(backdrop-insensitive-active); }
  54. }
  55. }
  56. }
  57. &.flat { &:backdrop, &:disabled, &:backdrop:disabled { @include button(undecorated); }}
  58. &:disabled {
  59. @include button(insensitive);
  60. &:active,
  61. &:checked { @include button(insensitive-active); }
  62. }
  63. &.image-button {
  64. min-width: 24px;
  65. padding-left: 4px;
  66. padding-right: 4px;
  67. }
  68. &.text-button {
  69. padding-left: 16px;
  70. padding-right: 16px;
  71. }
  72. &.text-button.image-button {
  73. padding-left: 8px;
  74. padding-right: 8px;
  75. label {
  76. padding-left: 8px;
  77. padding-right: 8px;
  78. }
  79. }
  80. &:drop(active) {
  81. color: $drop_target_color;
  82. border-color: $drop_target_color;
  83. box-shadow: inset 0 0 0 1px $drop_target_color;
  84. }
  85. }
  86. @at-root %button_selected, & {
  87. row:selected & {
  88. @if $variant == 'light' { border-color: $selected_borders_color; }
  89. &.flat:not(:active):not(:checked):not(:hover):not(disabled) {
  90. color: $selected_fg_color;
  91. border-color: transparent;
  92. &:backdrop { color: if($variant=='light', $backdrop_base_color, $backdrop_fg_color); }
  93. }
  94. }
  95. }
  96. // big standalone buttons like in Documents pager
  97. &.osd {
  98. min-width: 24px;
  99. min-height: 32px;
  100. &.image-button { min-width: 32px; }
  101. color: $osd_fg_color;
  102. border-radius: 5px;
  103. outline-color: transparentize($osd_fg_color, 0.7); //FIXME: define a color var?
  104. @include button(osd);
  105. border: none;
  106. box-shadow: none;
  107. &:hover {
  108. @include button(osd-hover);
  109. border: none;
  110. box-shadow: none;
  111. }
  112. &:active,
  113. &:checked {
  114. @include button(osd-active);
  115. border: none;
  116. box-shadow: none;
  117. }
  118. &:disabled {
  119. &:backdrop, & {
  120. @include button(osd-insensitive);
  121. border: none;
  122. }
  123. }
  124. &:backdrop {
  125. @include button(osd-backdrop);
  126. border: none;
  127. }
  128. }
  129. //overlay / OSD style
  130. @at-root %osd_button,
  131. .osd & {
  132. @include button(osd);
  133. &:hover { @include button(osd-hover); }
  134. &:active,
  135. &:checked { &:backdrop, & { @include button(osd-active); }}
  136. &:disabled { &:backdrop, & { @include button(osd-insensitive); }}
  137. &:backdrop { @include button(osd-backdrop); }
  138. &.flat {
  139. @include button(undecorated);
  140. box-shadow: none; //FIXME respect no edge on the button mixin
  141. text-shadow: 0 1px black;
  142. -gtk-icon-shadow: 0 1px black;
  143. &:hover { @include button(osd-hover); }
  144. &:disabled {
  145. @include button(osd-insensitive);
  146. background-image: none;
  147. border-color: transparent;
  148. box-shadow: none;
  149. }
  150. &:backdrop { @include button(undecorated); }
  151. &:active,
  152. &:checked { @include button(osd-active); }
  153. }
  154. }
  155. // Suggested and Destructive Action buttons
  156. @each $b_type, $b_color in (suggested-action, $purple),
  157. (destructive-action, $destructive_color) {
  158. &.#{$b_type} {
  159. @include button(normal, $b_color, white);
  160. &.flat {
  161. @include button(undecorated);
  162. color: $b_color; //FIXME: does it work on the dark variant?
  163. }
  164. &:hover { @include button(hover, $b_color, white); }
  165. &:active,
  166. &:checked { @include button(active, $b_color, white); }
  167. &:backdrop,
  168. &.flat:backdrop {
  169. @include button(backdrop, $b_color, white);
  170. label { color: transparentize(white, 0.5);}
  171. &:active,
  172. &:checked { @include button(backdrop-active, $b_color, white); }
  173. &:disabled {
  174. @include button(backdrop-insensitive, $b_color, white);
  175. label { color: transparentize(white, 0.5);}
  176. &:active,
  177. &:checked { @include button(backdrop-insensitive-active, $b_color, white); }
  178. }
  179. }
  180. &.flat {
  181. &:backdrop, &:disabled, &:backdrop:disabled {
  182. @include button(undecorated);
  183. color: transparentize($b_color, 0.2);
  184. }
  185. }
  186. &:disabled {
  187. @include button(insensitive, $b_color, white);
  188. label { color: transparentize($selected_fg_color, 0.2); }
  189. &:active,
  190. &:checked { @include button(insensitive-active, $b_color, white); }
  191. }
  192. .osd & {
  193. @include button(osd, $b_color);
  194. &:hover { @include button(osd-hover, $b_color); }
  195. &:active,
  196. &:checked { &:backdrop, & { @include button(osd-active, $b_color); }}
  197. &:disabled { &:backdrop, & { @include button(osd-insensitive, $b_color); }}
  198. &:backdrop { @include button(osd-backdrop, $b_color); }
  199. }
  200. }
  201. }
  202. .stack-switcher > & {
  203. // to position the needs attention dot, padding is added to the button
  204. // child, a label needs just lateral padding while an icon needs vertical
  205. // padding added too.
  206. outline-offset: -3px; // needs to be set or it gets overriden by GtkRadioButton outline-offset
  207. > label {
  208. padding-left: 6px; // label padding
  209. padding-right: 6px; //
  210. }
  211. > image {
  212. padding-left: 6px; // image padding
  213. padding-right: 6px; //
  214. padding-top: 3px; //
  215. padding-bottom: 3px; //
  216. }
  217. &.text-button {
  218. // compensate text-button paddings
  219. padding-left: 10px;
  220. padding-right: 10px;
  221. }
  222. &.image-button {
  223. // we want image buttons to have a 1:1 aspect ratio, so compensation
  224. // of the padding added to the GtkImage is needed
  225. padding-left: 2px;
  226. padding-right: 2px;
  227. }
  228. &.needs-attention {
  229. > label,
  230. > image { @extend %needs_attention; }
  231. &:active,
  232. &:checked {
  233. > label,
  234. > image {
  235. animation: none;
  236. background-image: none;
  237. }
  238. }
  239. }
  240. }
  241. //inline-toolbar buttons
  242. .inline-toolbar &, .inline-toolbar &:backdrop {
  243. border-radius: 2px;
  244. border-width: 1px;
  245. @extend %linked;
  246. }
  247. .primary-toolbar & { -gtk-icon-shadow: none; } // tango icons don't need shadows
  248. .linked > &,
  249. .linked > &:hover,
  250. .linked > &:active,
  251. .linked > &:checked,
  252. .linked > &:backdrop { @extend %linked; }
  253. .linked.vertical > &,
  254. .linked.vertical > &:hover,
  255. .linked.vertical > &:active,
  256. .linked.vertical > &:checked,
  257. .linked.vertical > &:backdrop { @extend %linked_vertical; }
  258. }
  259. %needs_attention {
  260. animation: needs_attention 150ms ease-in;
  261. $_dot_shadow: _text_shadow_color();
  262. $_dot_shadow_r: if($variant=='light',0.5,0.45);
  263. background-image: radial-gradient(farthest-side, $_dot_color 96%, transparentize($_dot_color,1 ));
  264. background-size: 6px 6px, 6px 6px;
  265. background-repeat: no-repeat;
  266. @if $variant == 'light' { background-position: right 3px, right 4px; }
  267. @else { background-position: right 3px, right 2px; }
  268. &:backdrop { background-size: 6px 6px, 0 0;}
  269. &:dir(rtl) {
  270. @if $variant == 'light' { background-position: left 3px, left 4px; }
  271. @else { background-position: left 3px, left 2px; }
  272. }
  273. }
  274. toolbar {
  275. button {
  276. &:hover { @include button(normal,darken($bg_color,7%));}
  277. &:active { @include button(normal,darken($bg_color,12%));}
  278. }
  279. }
  280. // all the following is for the +|- buttons on inline toolbars, that way
  281. // should really be deprecated...
  282. .inline-toolbar toolbutton > button { // redefining the button look is
  283. // needed since those are flat...
  284. @include button(undecorated);
  285. &:hover { color: $selected_bg_color; }
  286. &:active,
  287. &:checked{ color: darken($selected_bg_color, 5%); }
  288. &:disabled {
  289. color: $backdrop_text_color;
  290. &:active,
  291. &:checked { color: transparentize(darken($selected_bg_color, 5%),0.7); }
  292. }
  293. &:backdrop {
  294. color: $backdrop_text_color;
  295. &:active,
  296. &:checked { color: darken($selected_bg_color, 5%); }
  297. &:disabled {
  298. color: $backdrop_text_color;
  299. &:active,
  300. &:checked { color: transparentize(darken($selected_bg_color, 5%),0.7); }
  301. }
  302. }
  303. }
  304. // More inline toolbar buttons
  305. toolbar.inline-toolbar toolbutton,
  306. toolbar.inline-toolbar toolbutton:backdrop {
  307. > button.flat {
  308. &:backdrop {
  309. border-color: transparent;
  310. box-shadow: none;
  311. }
  312. }
  313. }
  314. %linked_middle {
  315. border: 1px solid $borders_color;
  316. border-radius: 0;
  317. border-right-style: none;
  318. box-shadow: inset 0px 1px 0px 0px $top_highlight;
  319. }
  320. %linked {
  321. @extend %linked_middle;
  322. &:first-child {
  323. border-top-left-radius: 3px;
  324. border-bottom-left-radius: 3px;
  325. }
  326. &:last-child {
  327. border-top-right-radius: 3px;
  328. border-bottom-right-radius: 3px;
  329. border-right-style: solid;
  330. }
  331. &:only-child {
  332. border-radius: 3px;
  333. border-style: solid;
  334. }
  335. }
  336. %linked_vertical_middle {
  337. border-style: solid solid none solid;
  338. border-radius: 0;
  339. }
  340. %linked_vertical{
  341. @extend %linked_vertical_middle;
  342. &:first-child {
  343. border-top-left-radius: 3px;
  344. border-top-right-radius: 3px;
  345. }
  346. &:last-child {
  347. border-bottom-left-radius: 3px;
  348. border-bottom-right-radius: 3px;
  349. border-style: solid;
  350. }
  351. &:only-child {
  352. border-radius: 3px;
  353. border-style: solid;
  354. }
  355. }
  356. %undecorated_button {
  357. background-color: transparent;
  358. background-image: none;
  359. border-color: transparent;
  360. box-shadow: inset 0 1px transparentize(white,1),
  361. 0 1px transparentize(white, 1);
  362. text-shadow: none;
  363. -gtk-icon-shadow: none;
  364. }
  365. /* menu buttons */
  366. modelbutton.flat,
  367. .menuitem.button.flat {
  368. min-height: 26px;
  369. padding-left: 5px;
  370. padding-right: 5px;
  371. border-radius: 3px;
  372. outline-offset: -2px;
  373. @extend %undecorated_button;
  374. &:hover { background-color: $popover_hover_color; }
  375. &:selected { @extend %selected_items; }
  376. &:backdrop,
  377. &:backdrop:hover { @extend %undecorated_button; }
  378. // FIXME: remove the following when the checks/radios rewrite lands
  379. check:last-child,
  380. radio:last-child { margin-left: 8px; }
  381. check:first-child,
  382. radio:first-child { margin-right: 8px; }
  383. }
  384. modelbutton.flat arrow {
  385. background: none;
  386. &:hover { background: none; }
  387. &.left { -gtk-icon-source: -gtk-icontheme("pan-start-symbolic"); }
  388. &.right { -gtk-icon-source: -gtk-icontheme("pan-end-symbolic"); }
  389. }
  390. button.color {
  391. padding: 4px;
  392. colorswatch:only-child {
  393. &, overlay { border-radius: 0; }
  394. @if $variant == 'light' {
  395. box-shadow: 0 1px _text_shadow_color();
  396. &:disabled,
  397. &:backdrop { box-shadow: none; }
  398. }
  399. }
  400. }
  401. notebook, list, .view, popover {
  402. button {
  403. box-shadow: inset 0px 0px 0px 1px $borders_color;
  404. &:backdrop {
  405. box-shadow: inset 0px 0px 0px 1px $borders_color;
  406. }
  407. }
  408. .linked > button {
  409. box-shadow: none;
  410. }
  411. }