From 98f3ef2689de06e8ab8b46a91acfa7dd2056a3a6 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Mon, 5 Mar 2012 12:19:59 +0100 Subject: Imported Upstream version 0.5.1 --- src/renderers/pieRenderer.vala | 42 +++++++++++++++++++++++++++++----------- src/renderers/pieWindow.vala | 23 ++++++++++++++++++++++ src/renderers/sliceRenderer.vala | 32 +++++++++++++++++++++++------- 3 files changed, 79 insertions(+), 18 deletions(-) (limited to 'src/renderers') diff --git a/src/renderers/pieRenderer.vala b/src/renderers/pieRenderer.vala index 67a6b56..09c5f7a 100644 --- a/src/renderers/pieRenderer.vala +++ b/src/renderers/pieRenderer.vala @@ -58,23 +58,23 @@ public class PieRenderer : GLib.Object { public bool turbo_mode { get; private set; default=false; } ///////////////////////////////////////////////////////////////////// - /// All SliceRenderers used to draw this Pie. + /// True if the pie is currently navigated with the keyboard. This is + /// set to false as soon as the mouse moves. ///////////////////////////////////////////////////////////////////// - private Gee.ArrayList slices; + public bool key_board_control { get; set; default=false; } ///////////////////////////////////////////////////////////////////// - /// The renderer for the center of this pie. + /// All SliceRenderers used to draw this Pie. ///////////////////////////////////////////////////////////////////// - private CenterRenderer center; + private Gee.ArrayList slices; ///////////////////////////////////////////////////////////////////// - /// True if the pie is currently navigated with the keyboard. This is - /// set to false as soon as the mouse moves. + /// The renderer for the center of this pie. ///////////////////////////////////////////////////////////////////// - private bool key_board_control = false; + private CenterRenderer center; ///////////////////////////////////////////////////////////////////// /// C'tor, initializes members. @@ -130,9 +130,21 @@ public class PieRenderer : GLib.Object { ///////////////////////////////////////////////////////////////////// public void activate() { - if (this.active_slice >= 0 && this.active_slice < this.slices.size) + if (this.active_slice >= 0 && this.active_slice < this.slices.size) { slices[active_slice].activate(); - this.cancel(); + + if (this.active_slice == this.quickaction) + Logger.stats("ACTIVATE QUICKACTION %d".printf(this.active_slice)); + else + Logger.stats("ACTIVATE %d".printf(this.active_slice)); + } else { + Logger.stats("CANCEL"); + } + + foreach (var slice in this.slices) + slice.fade_out(); + + center.fade_out(); } ///////////////////////////////////////////////////////////////////// @@ -144,6 +156,8 @@ public class PieRenderer : GLib.Object { slice.fade_out(); center.fade_out(); + + Logger.stats("CANCEL"); } ///////////////////////////////////////////////////////////////////// @@ -161,6 +175,8 @@ public class PieRenderer : GLib.Object { this.set_highlighted_slice(this.active_slice+1); else if (this.active_slice != top) this.set_highlighted_slice((this.active_slice-1+this.slice_count())%this.slice_count()); + + this.key_board_control = true; } ///////////////////////////////////////////////////////////////////// @@ -178,6 +194,8 @@ public class PieRenderer : GLib.Object { this.set_highlighted_slice(this.active_slice-1); else if (this.active_slice != bottom) this.set_highlighted_slice((this.active_slice+1)%this.slice_count()); + + this.key_board_control = true; } ///////////////////////////////////////////////////////////////////// @@ -195,6 +213,8 @@ public class PieRenderer : GLib.Object { this.set_highlighted_slice(this.active_slice-1); else if (this.active_slice < left) this.set_highlighted_slice(this.active_slice+1); + + this.key_board_control = true; } ///////////////////////////////////////////////////////////////////// @@ -212,6 +232,8 @@ public class PieRenderer : GLib.Object { this.set_highlighted_slice((this.active_slice+1)%this.slice_count()); else if (this.active_slice < left && this.active_slice != right) this.set_highlighted_slice((this.active_slice-1+this.slice_count())%this.slice_count()); + + this.key_board_control = true; } ///////////////////////////////////////////////////////////////////// @@ -292,8 +314,6 @@ public class PieRenderer : GLib.Object { foreach (var slice in this.slices) slice.set_active_slice(active); - - this.key_board_control = true; } } } diff --git a/src/renderers/pieWindow.vala b/src/renderers/pieWindow.vala index 54dd691..852a739 100644 --- a/src/renderers/pieWindow.vala +++ b/src/renderers/pieWindow.vala @@ -192,6 +192,28 @@ public class PieWindow : Gtk.Window { }); } + ///////////////////////////////////////////////////////////////////// + /// Opens the window at a given location. + ///////////////////////////////////////////////////////////////////// + + public void open_at(int at_x, int at_y) { + this.open(); + this.move(at_x-this.width_request/2, at_y-this.height_request/2); + } + + ///////////////////////////////////////////////////////////////////// + /// Gets the center position of the window. + ///////////////////////////////////////////////////////////////////// + + public void get_center_pos(out int out_x, out int out_y) { + int x=0, y=0, width=0, height=0; + this.get_position(out x, out y); + this.get_size(out width, out height); + + out_x = x + width/2; + out_y = y + height/2; + } + ///////////////////////////////////////////////////////////////////// /// Draw the Pie. ///////////////////////////////////////////////////////////////////// @@ -303,6 +325,7 @@ public class PieWindow : Gtk.Window { else if (key >= 65 && key <= 90) index = (int)key - 55; if (index >= 0 && index < this.renderer.slice_count()) { + this.renderer.key_board_control = true; this.renderer.set_highlighted_slice(index); if (this.renderer.active_slice == index) { diff --git a/src/renderers/sliceRenderer.vala b/src/renderers/sliceRenderer.vala index 4803070..743f13e 100644 --- a/src/renderers/sliceRenderer.vala +++ b/src/renderers/sliceRenderer.vala @@ -86,6 +86,7 @@ public class SliceRenderer : GLib.Object { private AnimatedValue alpha; // for fading in/out private AnimatedValue fade_rotation; // for fading in/out private AnimatedValue fade_scale; // for fading in/out + private AnimatedValue wobble; // for organic wobbling ///////////////////////////////////////////////////////////////////// /// C'tor, initializes all AnimatedValues. @@ -94,9 +95,10 @@ public class SliceRenderer : GLib.Object { public SliceRenderer(PieRenderer parent) { this.parent = parent; - this.fade = new AnimatedValue.linear(0.0, 0.0, Config.global.theme.transition_time); - this.alpha = new AnimatedValue.linear(0.0, 1.0, Config.global.theme.fade_in_time); - this.scale = new AnimatedValue.cubic(AnimatedValue.Direction.OUT, + this.fade = new AnimatedValue.linear(0.0, 0.0, Config.global.theme.transition_time); + this.wobble = new AnimatedValue.linear(0.0, 0.0, Config.global.theme.transition_time); + this.alpha = new AnimatedValue.linear(0.0, 1.0, Config.global.theme.fade_in_time); + this.scale = new AnimatedValue.cubic(AnimatedValue.Direction.OUT, 1.0/Config.global.theme.max_zoom, 1.0/Config.global.theme.max_zoom, Config.global.theme.transition_time, @@ -127,8 +129,8 @@ public class SliceRenderer : GLib.Object { Config.global.theme.caption_color, Config.global.global_scale); - this.active_icon = new ThemedIcon(action.icon, true); - this.inactive_icon = new ThemedIcon(action.icon, false); + this.active_icon = new ThemedIcon(action.name, action.icon, true); + this.inactive_icon = new ThemedIcon(action.name, action.icon, false); this.color = new Color.from_icon(this.active_icon); @@ -195,20 +197,36 @@ public class SliceRenderer : GLib.Object { this.fade.update(frame_time); this.fade_scale.update(frame_time); this.fade_rotation.update(frame_time); + this.wobble.update(frame_time); double direction = 2.0 * PI * position/parent.slice_count() + this.fade_rotation.val; double max_scale = 1.0/Config.global.theme.max_zoom; double diff = fabs(angle-direction); - + if (diff > PI) diff = 2 * PI - diff; + + active = ((parent.active_slice >= 0) && (diff < PI/parent.slice_count())); + + if (parent.active_slice >= 0) { + double wobble = Config.global.theme.wobble*diff/PI*(1-diff/PI); + if ((direction < angle && direction > angle - PI) || direction > PI+angle) { + this.wobble.reset_target(-wobble, Config.global.theme.transition_time*0.5); + } else { + this.wobble.reset_target(wobble, Config.global.theme.transition_time*0.5); + } + } else { + this.wobble.reset_target(0, Config.global.theme.transition_time*0.5); + } + + direction += this.wobble.val; if (diff < 2 * PI * Config.global.theme.zoom_range) max_scale = (Config.global.theme.max_zoom/(diff * (Config.global.theme.max_zoom - 1) /(2 * PI * Config.global.theme.zoom_range) + 1)) /Config.global.theme.max_zoom; - active = ((parent.active_slice >= 0) && (diff < PI/parent.slice_count())); + max_scale = (parent.active_slice >= 0 ? max_scale : 1.0/Config.global.theme.max_zoom); -- cgit v1.2.3