diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-18 15:42:59 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-18 15:42:59 +0200 |
commit | 84a27086bbd9f493128b354300f9c77ccb32a56b (patch) | |
tree | 977cb323f0ac6953f10bc20d84f45ebd5a6d4535 /src/renderers/sliceRenderer.vala | |
parent | b683ce2789d95b2e9f221e75adc30efd91cfb901 (diff) |
Imported Upstream version 0.6.0upstream/0.6.0
Diffstat (limited to 'src/renderers/sliceRenderer.vala')
-rw-r--r-- | src/renderers/sliceRenderer.vala | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/src/renderers/sliceRenderer.vala b/src/renderers/sliceRenderer.vala index 2ecf7c4..862e2a5 100644 --- a/src/renderers/sliceRenderer.vala +++ b/src/renderers/sliceRenderer.vala @@ -1,19 +1,19 @@ -/* -Copyright (c) 2011 by Simon Schneegans - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the Free -Software Foundation, either version 3 of the License, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see <http://www.gnu.org/licenses/>. -*/ +///////////////////////////////////////////////////////////////////////// +// Copyright (c) 2011-2015 by Simon Schneegans +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or (at +// your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////// using GLib.Math; @@ -94,7 +94,14 @@ public class SliceRenderer : GLib.Object { public SliceRenderer(PieRenderer parent) { this.parent = parent; + this.reset_anim(); + } + ///////////////////////////////////////////////////////////////////// + /// Put all AnimatedValues in their initial values + ///////////////////////////////////////////////////////////////////// + + public void reset_anim() { 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); @@ -147,7 +154,7 @@ public class SliceRenderer : GLib.Object { } ///////////////////////////////////////////////////////////////////// - /// Activaes the Action of this slice. + /// Activates the Action of this slice. ///////////////////////////////////////////////////////////////////// public void activate() { @@ -189,7 +196,7 @@ public class SliceRenderer : GLib.Object { /// Draws all layers of the slice. ///////////////////////////////////////////////////////////////////// - public void draw(double frame_time, Cairo.Context ctx, double angle, double distance) { + public void draw(double frame_time, Cairo.Context ctx, double angle, int slice_track) { // update the AnimatedValues this.scale.update(frame_time); @@ -199,16 +206,23 @@ public class SliceRenderer : GLib.Object { 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 direction = 2.0 * PI * (position-parent.first_slice_idx)/parent.total_slice_count + + parent.first_slice_angle + 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; + if (diff > 2 * PI) { + diff = diff - 2 * PI; + } + + if (diff > PI) { + diff = 2 * PI - diff; + } + - active = ((parent.active_slice >= 0) && (diff < PI/parent.slice_count())); + active = ((parent.active_slice >= 0) && (diff < PI/parent.total_slice_count)); - if (parent.active_slice >= 0) { + if (slice_track != 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); @@ -228,7 +242,7 @@ public class SliceRenderer : GLib.Object { - max_scale = (parent.active_slice >= 0 ? max_scale : 1.0/Config.global.theme.max_zoom); + max_scale = (slice_track != 0 ? max_scale : 1.0/Config.global.theme.max_zoom); if (fabs(this.scale.end - max_scale) > Config.global.theme.max_zoom*0.005) this.scale.reset_target(max_scale, Config.global.theme.transition_time); @@ -240,9 +254,9 @@ public class SliceRenderer : GLib.Object { // increase radius if there are many slices in a pie if (atan((Config.global.theme.slice_radius+Config.global.theme.slice_gap) - /(radius/Config.global.theme.max_zoom)) > PI/parent.slice_count()) { + /(radius/Config.global.theme.max_zoom)) > PI/parent.total_slice_count) { radius = (Config.global.theme.slice_radius+Config.global.theme.slice_gap) - /tan(PI/parent.slice_count())*Config.global.theme.max_zoom; + /tan(PI/parent.total_slice_count)*Config.global.theme.max_zoom; } // transform the context |