From 15b2dbf9a8e6de17fb74eef989ed5923ef6c6180 Mon Sep 17 00:00:00 2001 From: Lapo Calamandrei Date: Wed, 27 Jul 2016 22:54:20 +0200 Subject: [PATCH] Adwaita: use a transition to animate checks and radios see https://bugzilla.gnome.org/show_bug.cgi?id=762260 --- gtk/theme/Adwaita/_common.scss | 45 ++++++++++-------------- gtk/theme/Adwaita/gtk-contained-dark.css | 45 +++++++++--------------- gtk/theme/Adwaita/gtk-contained.css | 45 +++++++++--------------- 3 files changed, 53 insertions(+), 82 deletions(-) diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 58a320c511..c0d4595435 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -2626,7 +2626,6 @@ radio { -gtk-icon-shadow: none; color: inherit; border-color: currentColor; - animation: none; } } } @@ -2653,34 +2652,28 @@ radio { -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } } -// let's animate things -@keyframes check_check { - from { -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); } - to { -gtk-icon-transform: unset; } +// ANIMATION: +// this is made with those pretty convoluted transitions, since checks and radios have to animate only on state changes, +// the transformation is set on the active state and it get reset on the checked state. +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 { - check:not(:indeterminate):checked, - radio:not(:indeterminate):checked, - check:indeterminate:checked:active, - radio:indeterminate:checked { animation: none; } + radio, + check { + &:checked:not(:backdrop), &:indeterminate:not(:backdrop) { transition: none; } + } } treeview.view check, diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css index 76801c7947..8423911a2d 100644 --- a/gtk/theme/Adwaita/gtk-contained-dark.css +++ b/gtk/theme/Adwaita/gtk-contained-dark.css @@ -2970,8 +2970,7 @@ radio { box-shadow: none; -gtk-icon-shadow: none; color: inherit; - border-color: currentColor; - animation: none; } + border-color: currentColor; } check { border-radius: 3px; } @@ -2990,35 +2989,25 @@ radio { radio:indeterminate { -gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } -@keyframes check_check { - 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); } - 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):not(:checked):active:not(:backdrop) { + -gtk-icon-transform: scale(0); } -radio:not(:indeterminate):checked { - animation: check_radio 400ms; } +check:not(:indeterminate):not(:checked):active:not(:backdrop) { + -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); } -check:indeterminate:checked, radio:indeterminate:checked { - animation: check_indeterminate 400ms; } +radio:active, +check:active { + -gtk-icon-transform: scale(0, 1); } +radio:checked:not(:backdrop), radio:indeterminate:not(:backdrop), +check:checked:not(:backdrop), +check:indeterminate:not(:backdrop) { + -gtk-icon-transform: unset; + transition: 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; } +menu menuitem radio:checked:not(:backdrop), menu menuitem radio:indeterminate:not(:backdrop), +menu menuitem check:checked:not(:backdrop), +menu menuitem check:indeterminate:not(:backdrop) { + transition: none; } treeview.view check:selected:focus, treeview.view check:selected, treeview.view radio:selected:focus, diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index 1e71d62509..ab18b543de 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -3000,8 +3000,7 @@ radio { box-shadow: none; -gtk-icon-shadow: none; color: inherit; - border-color: currentColor; - animation: none; } + border-color: currentColor; } check { border-radius: 3px; } @@ -3020,35 +3019,25 @@ radio { radio:indeterminate { -gtk-icon-source: image(-gtk-recolor(url("assets/dash-symbolic.svg")), -gtk-recolor(url("assets/dash-symbolic.symbolic.png"))); } -@keyframes check_check { - 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); } - 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):not(:checked):active:not(:backdrop) { + -gtk-icon-transform: scale(0); } -radio:not(:indeterminate):checked { - animation: check_radio 400ms; } +check:not(:indeterminate):not(:checked):active:not(:backdrop) { + -gtk-icon-transform: translate(6px, -3px) rotate(-45deg) scaleY(0.2) rotate(45deg) scaleX(0); } -check:indeterminate:checked, radio:indeterminate:checked { - animation: check_indeterminate 400ms; } +radio:active, +check:active { + -gtk-icon-transform: scale(0, 1); } +radio:checked:not(:backdrop), radio:indeterminate:not(:backdrop), +check:checked:not(:backdrop), +check:indeterminate:not(:backdrop) { + -gtk-icon-transform: unset; + transition: 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; } +menu menuitem radio:checked:not(:backdrop), menu menuitem radio:indeterminate:not(:backdrop), +menu menuitem check:checked:not(:backdrop), +menu menuitem check:indeterminate:not(:backdrop) { + transition: none; } treeview.view check:selected:focus, treeview.view check:selected, treeview.view radio:selected:focus,