[gnome-clocks/wip/analogtimer] Play with a pattern for the timer cursor
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/analogtimer] Play with a pattern for the timer cursor
- Date: Thu, 1 Aug 2013 15:43:28 +0000 (UTC)
commit 99e2eefa94856cf9bf22bdae3ea41c54f015c1f1
Author: Paolo Borelli <pborelli gnome org>
Date: Thu Aug 1 17:42:50 2013 +0200
Play with a pattern for the timer cursor
src/timer.vala | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/timer.vala b/src/timer.vala
index 62d324d..88258bc 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -24,6 +24,8 @@ public class CountdownFrame : Gtk.Frame {
public double progress { get; set; }
+ private Cairo.Pattern cursor_pattern;
+
private int calculate_diameter () {
var child = get_child ();
if (child != null && child.visible) {
@@ -69,7 +71,6 @@ public class CountdownFrame : Gtk.Frame {
base.draw(cr);
var context = get_style_context ();
-
Gtk.Allocation allocation;
get_allocation (out allocation);
var center_x = allocation.width / 2;
@@ -97,6 +98,22 @@ public class CountdownFrame : Gtk.Frame {
cr.arc (center_x, center_y, radius - 4.5, 1.5 * Math.PI, (1.5 + progress * 2 ) * Math.PI);
Gdk.cairo_set_source_rgba (cr, color);
cr.stroke ();
+
+ if (progress < 1) {
+ if (cursor_pattern == null) {
+ cursor_pattern = new Cairo.Pattern.radial (0, 0, 6, 0, 0, 18);
+ cursor_pattern.add_color_stop_rgba (0, color.red, color.green, color.blue, 1);
+ cursor_pattern.add_color_stop_rgba (0.5, color.red, color.green, color.blue, 0);
+ }
+
+ var x = center_x + (radius -4.5) * Math.cos((1.5 + progress * 2) * Math.PI);
+ var y = center_y + (radius -4.5) * Math.sin((1.5 + progress * 2) * Math.PI);
+
+ cr.arc (x, y, 18, 0, 2 * Math.PI);
+ cr.translate (x, y);
+ cr.set_source (cursor_pattern);
+ cr.fill ();
+ }
}
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]