Adwaita: use a transition to animate checks and radios

see https://bugzilla.gnome.org/show_bug.cgi?id=762260
This commit is contained in:
Lapo Calamandrei 2016-07-27 22:54:20 +02:00
parent ddee89f4a3
commit 15b2dbf9a8
3 changed files with 53 additions and 82 deletions

View File

@ -2626,7 +2626,6 @@ radio {
-gtk-icon-shadow: none; -gtk-icon-shadow: none;
color: inherit; color: inherit;
border-color: currentColor; border-color: currentColor;
animation: none;
} }
} }
} }
@ -2653,34 +2652,28 @@ radio {
-gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); }
} }
// let's animate things // ANIMATION:
@keyframes check_check { // this is made with those pretty convoluted transitions, since checks and radios have to animate only on state changes,
from { -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); } // the transformation is set on the active state and it get reset on the checked state.
to { -gtk-icon-transform: unset; } radio:not(:indeterminate):not(:checked):active:not(:backdrop) { -gtk-icon-transform: scale(0); }
check:not(:indeterminate):not(:checked):active:not(:backdrop) { -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); }
radio,
check {
&:active { -gtk-icon-transform: scale(0, 1); } // should tackle the indeterminate state, untested
&:checked:not(:backdrop), &:indeterminate:not(:backdrop) {
-gtk-icon-transform: unset;
transition: 400ms;
}
} }
@keyframes check_radio {
from { -gtk-icon-transform: scale(0); }
to { -gtk-icon-transform: unset; }
}
@keyframes check_indeterminate {
from { -gtk-icon-transform: scale(0, 1); }
to { -gtk-icon-transform: unset; }
}
check:not(:indeterminate):checked { animation: check_check 400ms; }
radio:not(:indeterminate):checked { animation: check_radio 400ms; }
check:indeterminate:checked, radio:indeterminate:checked { animation: check_indeterminate 400ms; }
// no animations in menus
menu menuitem { menu menuitem {
check:not(:indeterminate):checked, radio,
radio:not(:indeterminate):checked, check {
check:indeterminate:checked:active, &:checked:not(:backdrop), &:indeterminate:not(:backdrop) { transition: none; }
radio:indeterminate:checked { animation: none; } }
} }
treeview.view check, treeview.view check,

View File

@ -2970,8 +2970,7 @@ radio {
box-shadow: none; box-shadow: none;
-gtk-icon-shadow: none; -gtk-icon-shadow: none;
color: inherit; color: inherit;
border-color: currentColor; border-color: currentColor; }
animation: none; }
check { check {
border-radius: 3px; } border-radius: 3px; }
@ -2990,35 +2989,25 @@ radio {
radio:indeterminate { radio:indeterminate {
-gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } -gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); }
@keyframes check_check { radio:not(:indeterminate):not(:checked):active:not(:backdrop) {
from {
-gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); }
to {
-gtk-icon-transform: unset; } }
@keyframes check_radio {
from {
-gtk-icon-transform: scale(0); } -gtk-icon-transform: scale(0); }
to {
-gtk-icon-transform: unset; } } check:not(:indeterminate):not(:checked):active:not(:backdrop) {
@keyframes check_indeterminate { -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); }
from {
radio:active,
check:active {
-gtk-icon-transform: scale(0, 1); } -gtk-icon-transform: scale(0, 1); }
to { radio:checked:not(:backdrop), radio:indeterminate:not(:backdrop),
-gtk-icon-transform: unset; } } check:checked:not(:backdrop),
check:not(:indeterminate):checked { check:indeterminate:not(:backdrop) {
animation: check_check 400ms; } -gtk-icon-transform: unset;
transition: 400ms; }
radio:not(:indeterminate):checked { menu menuitem radio:checked:not(:backdrop), menu menuitem radio:indeterminate:not(:backdrop),
animation: check_radio 400ms; } menu menuitem check:checked:not(:backdrop),
menu menuitem check:indeterminate:not(:backdrop) {
check:indeterminate:checked, radio:indeterminate:checked { transition: none; }
animation: check_indeterminate 400ms; }
menu menuitem check:not(:indeterminate):checked,
menu menuitem radio:not(:indeterminate):checked,
menu menuitem check:indeterminate:checked:active,
menu menuitem radio:indeterminate:checked {
animation: none; }
treeview.view check:selected:focus, treeview.view check:selected, treeview.view check:selected:focus, treeview.view check:selected,
treeview.view radio:selected:focus, treeview.view radio:selected:focus,

View File

@ -3000,8 +3000,7 @@ radio {
box-shadow: none; box-shadow: none;
-gtk-icon-shadow: none; -gtk-icon-shadow: none;
color: inherit; color: inherit;
border-color: currentColor; border-color: currentColor; }
animation: none; }
check { check {
border-radius: 3px; } border-radius: 3px; }
@ -3020,35 +3019,25 @@ radio {
radio:indeterminate { radio:indeterminate {
-gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } -gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); }
@keyframes check_check { radio:not(:indeterminate):not(:checked):active:not(:backdrop) {
from {
-gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); }
to {
-gtk-icon-transform: unset; } }
@keyframes check_radio {
from {
-gtk-icon-transform: scale(0); } -gtk-icon-transform: scale(0); }
to {
-gtk-icon-transform: unset; } } check:not(:indeterminate):not(:checked):active:not(:backdrop) {
@keyframes check_indeterminate { -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); }
from {
radio:active,
check:active {
-gtk-icon-transform: scale(0, 1); } -gtk-icon-transform: scale(0, 1); }
to { radio:checked:not(:backdrop), radio:indeterminate:not(:backdrop),
-gtk-icon-transform: unset; } } check:checked:not(:backdrop),
check:not(:indeterminate):checked { check:indeterminate:not(:backdrop) {
animation: check_check 400ms; } -gtk-icon-transform: unset;
transition: 400ms; }
radio:not(:indeterminate):checked { menu menuitem radio:checked:not(:backdrop), menu menuitem radio:indeterminate:not(:backdrop),
animation: check_radio 400ms; } menu menuitem check:checked:not(:backdrop),
menu menuitem check:indeterminate:not(:backdrop) {
check:indeterminate:checked, radio:indeterminate:checked { transition: none; }
animation: check_indeterminate 400ms; }
menu menuitem check:not(:indeterminate):checked,
menu menuitem radio:not(:indeterminate):checked,
menu menuitem check:indeterminate:checked:active,
menu menuitem radio:indeterminate:checked {
animation: none; }
treeview.view check:selected:focus, treeview.view check:selected, treeview.view check:selected:focus, treeview.view check:selected,
treeview.view radio:selected:focus, treeview.view radio:selected:focus,