numix-gtk-theme/gtk-3.20/scss/widgets/_button.scss

559 lines
17 KiB
SCSS
Raw Normal View History

2016-04-09 04:30:09 +00:00
/*********
! Buttons
**********/
@include exports("button_extends") {
// stuff for .needs-attention
$_dot_color: if($variant=='light', $selected_bg_color, lighten($selected_bg_color, .15));
@keyframes needs_attention {
from {
background-image: -gtk-gradient(radial, center center, 0, center center, .01, to($_dot_color), to(transparent));
}
to {
background-image: -gtk-gradient(radial, center center, 0, center center, .5, to($selected_bg_color), to(transparent));
}
}
%needs_attention {
animation: needs_attention 150ms ease-in;
$_dot_shadow: _text_shadow_color();
$_dot_shadow_r: if($variant=='light', .5, .45);
background-image: -gtk-gradient(radial, center center, 0, center center, .5, to($_dot_color), to(transparent)),
-gtk-gradient(radial, center center, 0, center center, $_dot_shadow_r, to($_dot_shadow), to(transparent));
background-size: 6px 6px, 6px 6px;
background-repeat: no-repeat;
@if $variant == 'light' {
background-position: right 3px, right 4px;
} @else {
background-position: right 3px, right 2px;
}
&:backdrop { background-size: 6px 6px, 0 0; }
&:dir(rtl) {
@if $variant == 'light' {
background-position: left 3px, left 4px;
} @else {
background-position: left 3px, left 2px;
}
}
}
2016-04-09 04:30:09 +00:00
%button {
2016-08-29 07:24:36 +00:00
min-height: 22px;
min-width: 20px;
padding: ($spacing - 3px) ($spacing + 1px);
2016-04-09 04:30:09 +00:00
border-width: 1px;
border-style: solid;
border-radius: $roundness;
transition: 150ms ease;
outline-color: transparent;
}
2016-05-08 09:54:48 +00:00
%undecorated_button {
border-color: transparent;
background-color: transparent;
background-image: none;
box-shadow: none;
}
2016-04-09 04:30:09 +00:00
%linked_middle {
border-radius: 0;
border-left-style: none;
border-right-style: solid;
&:dir(rtl) {
border-radius: 0; // needed when including %linked_middle:dir(rtl)
border-right-style: none;
border-left-style: solid;
}
}
%linked_vertical_middle {
border-radius: 0;
border-top-style: none;
border-bottom-style: solid;
&:dir(rtl) {
border-radius: 0; // needed when including %linked_vertical_middle:dir(rtl)
border-top-style: none;
border-bottom-style: solid;
}
}
2016-04-09 04:30:09 +00:00
%linked_button {
border-width: 1px;
border-style: solid;
border-radius: 0;
border-right-style: none;
border-left-style: none;
&:first-child {
border-width: 1px;
border-radius: $roundness;
border-left-style: solid;
border-right-style: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
&:dir(rtl) {
border-left-style: none;
border-right-style: solid;
}
}
&:last-child {
border-width: 1px;
border-radius: $roundness;
border-left-style: none;
border-right-style: solid;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
&:dir(rtl) {
border-left-style: solid;
border-right-style: none;
}
}
&:only-child, &:first-child:only-child {
border-width: 1px;
border-style: solid;
}
&:only-child {
2016-04-09 04:30:09 +00:00
border-radius: $roundness;
}
}
%linked_vertical_button {
border-width: 1px;
border-style: solid;
border-radius: 0;
border-top-style: none;
border-bottom-style: none;
&:first-child {
border-width: 1px;
border-radius: $roundness;
border-top-style: solid;
border-bottom-style: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
&:dir(rtl) {
border-top-style: none;
border-bottom-style: solid;
}
}
&:last-child {
border-width: 1px;
border-radius: $roundness;
border-top-style: none;
border-bottom-style: solid;
border-top-left-radius: 0;
border-top-right-radius: 0;
&:dir(rtl) {
border-top-style: solid;
border-bottom-style: none;
}
}
&:only-child, &:first-child:only-child {
border-width: 1px;
border-style: solid;
}
&:only-child {
border-radius: $roundness;
}
}
2016-04-09 04:30:09 +00:00
}
@mixin linked_button($bg) {
$border_strength: if(lightness($bg) > 50, 0, .1);
$shadow_strength: if(lightness($bg) > 50, 0, .1);
2016-04-09 04:30:09 +00:00
@extend %linked_button;
2016-04-09 04:30:09 +00:00
box-shadow: inset -1px 0 border_normal(rgba(0, 0, 0, .12 + $border_strength)),
0 1px 2px -1px alpha($dark_shadow, .12 + $shadow_strength);
&:focus, &:hover {
box-shadow: inset -1px 0 border_focus(rgba(0, 0, 0, .12 + $border_strength)),
0 1px 2px -1px alpha($dark_shadow, .32 + $shadow_strength);
}
&:active, &:active:hover,
&:active:focus, &:active:hover:focus,
&:checked, &:checked:hover,
&:checked:focus, &:checked:hover:focus {
box-shadow: inset -1px 0 border_active(rgba(0, 0, 0, .12 + $border_strength)),
inset 0 1px alpha($dark_shadow, .07),
inset 0 -1px alpha($dark_shadow, .05);
}
&:disabled { box-shadow: inset -1px 0 shade($bg, .8); }
&:last-child, &:only-child { box-shadow: 0 1px 2px -1px alpha($dark_shadow, .12 + $shadow_strength); }
&:last-child:hover, &:only-child:hover { box-shadow: 0 1px 2px -1px alpha($dark_shadow, .32 + $shadow_strength); }
&:disabled:last-child, &:disabled:only-child,
&:active:disabled:last-child, &:active:disabled:only-child,
&:checked:disabled:last-child, &:checked:disabled:only-child { box-shadow: none; }
&:active:last-child, &:active:last-child:focus, &:active:last-child:hover, &:active:last-child:hover:focus,
&:checked:last-child, &:checked:last-child:focus, &:checked:last-child:hover, &:checked:last-child:hover:focus {
box-shadow: inset 0 1px alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .06);
}
&:active:only-child, &:active:only-child:focus, &:active:only-child:hover, &:active:only-child:hover:focus,
&:checked:only-child, &:checked:only-child:focus, &:checked:only-child:hover, &:checked:only-child:hover:focus {
box-shadow: inset 1px 0 alpha($dark_shadow, .06),
inset 0 1px alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .06);
}
}
@mixin linked_vertical_button($bg) {
$border_strength: if(lightness($bg) > 50, 0, .1);
$shadow_strength: if(lightness($bg) > 50, 0, .1);
@extend %linked_vertical_button;
box-shadow: inset 0 -1px border_normal(rgba(0, 0, 0, .12 + $border_strength)),
0 1px 2px -1px alpha($dark_shadow, .12 + $shadow_strength);
&:focus, &:hover {
box-shadow: inset 0 -1px border_focus(rgba(0, 0, 0, .12 + $border_strength)),
0 1px 2px -1px alpha($dark_shadow, .32 + $shadow_strength);
}
&:active, &:active:hover,
&:active:focus, &:active:hover:focus,
&:checked, &:checked:hover,
&:checked:focus, &:checked:hover:focus {
box-shadow: inset 0 -1px border_active(rgba(0, 0, 0, .12 + $border_strength)),
inset 1px 0 alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .05);
}
&:disabled { box-shadow: inset 0 -1px shade($bg, .8); }
&:last-child, &:only-child { box-shadow: 0 1px 2px -1px alpha($dark_shadow, .12 + $shadow_strength); }
&:last-child:hover, &:only-child:hover { box-shadow: 0 1px 2px -1px alpha($dark_shadow, .32 + $shadow_strength); }
&:disabled:last-child, &:disabled:only-child,
&:active:disabled:last-child, &:active:disabled:only-child,
&:checked:disabled:last-child, &:checked:disabled:only-child { box-shadow: none; }
&:active:last-child, &:active:last-child:focus, &:active:last-child:hover, &:active:last-child:hover:focus,
&:checked:last-child, &:checked:last-child:focus, &:checked:last-child:hover, &:checked:last-child:hover:focus {
box-shadow: inset 0 1px alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .06);
}
&:active:only-child, &:active:only-child:focus, &:active:only-child:hover, &:active:only-child:hover:focus,
&:checked:only-child, &:checked:only-child:focus, &:checked:only-child:hover, &:checked:only-child:hover:focus {
box-shadow: inset 1px 0 alpha($dark_shadow, .06),
inset 0 1px alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .06);
}
}
2016-04-09 04:30:09 +00:00
@mixin button($bg, $fg) {
$border_strength: if(lightness($bg) > 50, 0, .1);
$shadow_strength: if(lightness($bg) > 50, 0, .1);
2016-04-09 04:30:09 +00:00
$button_bg: if(hue($bg) == 0deg, shade($bg, 1.2), $bg);
2016-04-09 04:30:09 +00:00
@extend %button;
@include linear-gradient($button_bg);
@include border(rgba(0, 0, 0, .12 + $border_strength));
2016-04-09 04:30:09 +00:00
color: $fg;
box-shadow: 0 1px 2px -1px alpha($dark_shadow, .12 + $shadow_strength);
&.flat {
border-color: alpha($button_bg, 0);
background-color: alpha($button_bg, 0);
background-image: none;
box-shadow: none;
}
&, &.flat {
&:focus, &:hover {
@include linear-gradient(shade($button_bg, 1.2));
@include border(rgba(0, 0, 0, .2 + $border_strength));
2016-04-09 04:30:09 +00:00
box-shadow: 0 1px 2px -1px alpha($dark_shadow, .32 + $shadow_strength);
}
&:checked, &:active {
2016-04-09 04:30:09 +00:00
@include linear-gradient(shade($button_bg, .7), to top);
2016-04-09 04:30:09 +00:00
color: $white;
box-shadow: inset 1px 0 alpha($dark_shadow, .06),
inset 0 1px alpha($dark_shadow, .07),
inset -1px 0 alpha($dark_shadow, .06),
inset 0 -1px alpha($dark_shadow, .05);
&:focus, &:hover {
@include linear-gradient(shade($button_bg, .65), to top);
2016-04-09 04:30:09 +00:00
color: $white;
}
}
&:focus, &:hover { color: $fg; }
&:active:disabled, &:checked:disabled {
@include linear-gradient(shade($button_bg, .9));
2016-04-09 04:30:09 +00:00
color: $fg;
box-shadow: none;
}
2016-08-23 22:37:45 +00:00
&:disabled:disabled {
@if (lightness($button_bg) > 50) {
@include linear-gradient(shade($button_bg, .95));
} @else {
@include linear-gradient(alpha($button_bg, .3));
}
color: mix($bg, $fg, .5);
box-shadow: none;
}
}
&.flat {
2016-04-09 04:30:09 +00:00
&:disabled:disabled {
2016-08-23 11:24:23 +00:00
background-color: transparent;
background-image: none;
2016-04-09 04:30:09 +00:00
color: mix($bg, $fg, .5);
box-shadow: none;
}
}
2016-08-29 07:24:36 +00:00
&.image-button {
min-width: 24px;
padding-left: $spacing;
padding-right: $spacing;
}
&.text-button {
padding-left: $spacing * 2;
padding-right: $spacing * 2;
}
&.text-button.image-button {
padding-left: $spacing;
padding-right: $spacing;
label {
padding-left: $spacing;
padding-right: $spacing;
}
}
2016-04-09 04:30:09 +00:00
&.separator, .separator {
border: 1px solid currentColor;
color: shade($bg, ($contrast + .1));
&:disabled { color: shade($button_bg, .85); }
}
}
@include exports("button") {
%close_button {
2016-08-29 07:24:36 +00:00
min-height: 22px;
min-width: 16px;
2016-04-09 04:30:09 +00:00
border: 1px solid transparent;
background-color: transparent;
background-image: none;
box-shadow: none;
&:focus, &:hover {
border: 1px solid alpha($black, .3);
background-color: alpha($white, .2);
background-image: none;
box-shadow: none;
}
&:active, &:checked, &:active:hover, &:checked:hover {
border: 1px solid alpha($black, .3);
background-color: alpha($black, .1);
background-image: none;
box-shadow: none;
}
}
button {
@include button(shade($bg_color, 1.2), $fg_color);
2016-05-15 18:06:17 +00:00
.inline-toolbar &,
.linked > & { @include linked_button(shade($bg_color, 1.2)); }
2016-04-09 04:30:09 +00:00
.linked.vertical > & { @include linked_vertical_button(shade($bg_color, 1.2)); }
2016-06-09 16:04:47 +00:00
2016-08-29 07:24:36 +00:00
&.osd {
@include button($osd_bg, $osd_fg);
&.image-button {
padding: 0;
min-height: 36px;
min-width: 36px;
}
}
&.circular,
&.circular-button { // FIXME: aggregate to buttons
padding: 0;
min-width: 26px;
min-height: 26px;
border-radius: 9999px; // Fixed: https://github.com/GNOME/gtk/commit/a6409458f0d50d673a4dc370b9251993b7835b6b
-gtk-outline-radius: 9999px;
2016-06-09 16:04:47 +00:00
label { padding: 0; }
}
}
2016-04-09 04:30:09 +00:00
spinbutton {
button {
color: mix($text_color, $base_color, .4);
2016-04-09 04:30:09 +00:00
&:active, &:checked, &:hover { color: $text_color; }
&:disabled { color: alpha($insensitive_fg_color, .8); }
&:backdrop { color: mix($backdrop_base_color, $backdrop_fg_color, .9); }
&:backdrop:disabled { color: alpha($backdrop_insensitive_color, .8); }
2016-04-09 04:30:09 +00:00
}
&:not(.vertical) {
@extend %entry;
@include linear-gradient($base_color, to top);
@include border($base_color);
padding: 0;
color: $text_color;
caret-color: $text_color;
&:focus, &:active { border-color: border_focus($borders_color); }
&:disabled {
@include linear-gradient(shade($base_color, .9), to top);
color: mix($base_color, $text_color, .5);
}
entry {
// reset all the other props since the spinbutton node is styled here
border: 0;
border-radius: 0;
box-shadow: none;
2016-04-09 04:30:09 +00:00
}
button {
border-radius: 0;
border-color: alpha($borders_color, .8);
border-style: none none none solid;
background-image: none;
box-shadow: none;
&:dir(rtl) { border-style: none solid none none; }
&:active { box-shadow: inset 0 2px 3px -1px transparentize($black, .8); }
&:backdrop { border-color: alpha($backdrop_borders_color, .8); }
2016-04-09 04:30:09 +00:00
&:backdrop:disabled {
border-style: none none none solid; // It is needed or it gets overridden
2016-04-09 04:30:09 +00:00
&:dir(rtl) { border-style: none solid none none; }
}
&:dir(rtl):first-child { border-radius: $roundness 0 0 $roundness; }
&:dir(ltr):last-child { border-radius: 0 $roundness $roundness 0; }
2016-04-09 04:30:09 +00:00
}
}
2016-04-09 04:30:09 +00:00
&.vertical {
2016-08-29 07:24:36 +00:00
button, entry {
min-width: 0;
padding-left: $spacing - 1px;
padding-right: $spacing - 1px;
}
entry {
// reset all the other props since the spinbutton node is styled here
border-radius: 0;
2016-04-09 04:30:09 +00:00
}
button {
&.up {
border-style: solid solid none solid;
border-radius: $roundness $roundness 0 0;
}
&.down {
border-style: none solid solid solid;
2016-08-23 11:24:23 +00:00
border-radius: 0 0 $roundness $roundness;
}
2016-04-09 04:30:09 +00:00
}
}
}
}
/******************
! ComboBoxes *
*******************/
@include exports("combobox") {
combobox {
button.combo {
// otherwise the arrow placement is not symmetric
min-width: 0;
padding-left: 8px;
padding-right: 8px;
}
2016-04-13 05:40:46 +00:00
arrow {
-gtk-icon-source: -gtk-icontheme('pan-down-symbolic');
min-height: 16px;
min-width: 16px;
}
2016-04-09 04:30:09 +00:00
box button, box entry {
@extend %linked_button;
2016-08-29 07:24:36 +00:00
padding: ($spacing - 3px) ($spacing + 1px);
2016-04-09 04:30:09 +00:00
}
.linked:not(.vertical) > & > box > button.combo {
2016-04-09 04:30:09 +00:00
// the combo is a composite widget so the way we do button linked doesn't
// work, special case needed. See
// https://bugzilla.gnome.org/show_bug.cgi?id=733979
&:dir(ltr) { @extend %linked_middle; }
// specificity bump
&:dir(rtl) { @extend %linked_middle:dir(rtl); }
}
.linked:not(.vertical) > &:first-child > box > button.combo { @extend %linked_button:first-child; }
.linked:not(.vertical) > &:last-child > box > button.combo { @extend %linked_button:last-child; }
2016-04-09 04:30:09 +00:00
.linked:not(.vertical) > &:only-child > box > button.combo { @extend %linked_button:only-child; }
2016-04-09 04:30:09 +00:00
}
}