[gnome-clocks] Replace css animation with AdwAnimation
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Replace css animation with AdwAnimation
- Date: Fri, 7 Jan 2022 17:23:46 +0000 (UTC)
commit 7d458d8d4f24f68855e15d6793be4f2933308eff
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Fri Dec 17 13:39:18 2021 +0100
Replace css animation with AdwAnimation
data/css/gnome-clocks.css | 19 -------------------
src/timer-row.vala | 43 +++++++++++++++++++++++++++++--------------
2 files changed, 29 insertions(+), 33 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index 4f47689f..9afdf460 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -56,25 +56,6 @@
font-weight: 300;
}
-@keyframes clocks-blink {
- 0% {
- color: @accent_color;
- }
- 100% {
- }
-}
-
-.timer-countdown.timer-paused {
- animation-name: clocks-blink;
- animation-iteration-count: infinite;
- animation-timing-function: steps(2);
- animation-duration: 1s;
-}
-
-.timer-countdown.timer-running {
- color: @accent_color;
-}
-
/* Stopwatch Panel */
.lap-time {
font-weight: bold;
diff --git a/src/timer-row.vala b/src/timer-row.vala
index 69eee31b..d94b1250 100644
--- a/src/timer-row.vala
+++ b/src/timer-row.vala
@@ -39,6 +39,7 @@ public class Row : Gtk.ListBoxRow {
}
}
private Item _item;
+ private Adw.TimedAnimation paused_animation;
[GtkChild]
@@ -80,6 +81,11 @@ public class Row : Gtk.ListBoxRow {
item.reset.connect (() => this.reset ());
delete_button.clicked.connect (() => deleted ());
+ var target = new Adw.CallbackAnimationTarget (animation_target);
+ paused_animation = new Adw.TimedAnimation (this, 0, 2, 2000, target);
+ paused_animation.repeat_count = Adw.DURATION_INFINITE;
+ paused_animation.easing = Adw.Easing.LINEAR;
+
reset ();
}
@@ -102,10 +108,11 @@ public class Row : Gtk.ListBoxRow {
reset_stack.visible_child_name = "empty";
delete_stack.visible_child_name = "button";
- countdown_label.remove_css_class ("timer-paused");
- countdown_label.remove_css_class ("dim-label");
- countdown_label.remove_css_class ("timer-ringing");
- countdown_label.remove_css_class ("timer-running");
+ countdown_label.remove_css_class ("accent");
+ countdown_label.add_css_class ("dim-label");
+
+ paused_animation.pause ();
+
start_stack.visible_child_name = "start";
name_revealer.reveal_child = true;
name_stack.visible_child_name = "edit";
@@ -114,11 +121,11 @@ public class Row : Gtk.ListBoxRow {
}
private void start () {
- countdown_label.add_css_class ("timer-running");
- countdown_label.remove_css_class ("timer-ringing");
- countdown_label.remove_css_class ("timer-paused");
+ countdown_label.add_css_class ("accent");
countdown_label.remove_css_class ("dim-label");
+ paused_animation.pause ();
+
reset_stack.visible_child_name = "empty";
delete_stack.visible_child_name = "empty";
@@ -128,16 +135,14 @@ public class Row : Gtk.ListBoxRow {
}
private void ring () {
- countdown_label.add_css_class ("timer-ringing");
- countdown_label.remove_css_class ("timer-paused");
- countdown_label.remove_css_class ("dim-label");
- countdown_label.remove_css_class ("timer-running");
+ paused_animation.pause ();
+
+ countdown_label.remove_css_class ("accent");
+ countdown_label.add_css_class ("dim-label");
}
private void pause () {
- countdown_label.add_css_class ("timer-paused");
- countdown_label.remove_css_class ("timer-ringing");
- countdown_label.remove_css_class ("timer-running");
+ paused_animation.play ();
reset_stack.visible_child_name = "button";
delete_stack.visible_child_name = "button";
@@ -149,6 +154,16 @@ public class Row : Gtk.ListBoxRow {
private void update_countdown (int h, int m, int s ) {
countdown_label.set_text ("%02i ∶ %02i ∶ %02i".printf (h, m, s));
}
+
+ private void animation_target (double val) {
+ if (val < 1.0) {
+ countdown_label.add_css_class ("dim-label");
+ countdown_label.remove_css_class ("accent");
+ } else {
+ countdown_label.add_css_class ("accent");
+ countdown_label.remove_css_class ("dim-label");
+ }
+ }
}
} // namespace Timer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]