_buttons.scss 13 KB

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