summaryrefslogtreecommitdiff
path: root/src/renderers/pieRenderer.vala
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-01-21 19:14:06 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-01-21 19:19:46 +0100
commitc05883f47c498be4e11893e5178c5bc37ffd9f4a (patch)
treedbd3cd7ad3d7771405ad63af2f1e9d14d4ae5a35 /src/renderers/pieRenderer.vala
parent31539042f11bc210a29e923f45586779c3ad46b2 (diff)
parent60560a030fda3c539ff9dc1563b9926414a193da (diff)
Merge commit 'upstream/0.4.0'
Diffstat (limited to 'src/renderers/pieRenderer.vala')
-rw-r--r--src/renderers/pieRenderer.vala74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/renderers/pieRenderer.vala b/src/renderers/pieRenderer.vala
index ffaf776..67a6b56 100644
--- a/src/renderers/pieRenderer.vala
+++ b/src/renderers/pieRenderer.vala
@@ -31,7 +31,7 @@ public class PieRenderer : GLib.Object {
/// gets executed when the user clicks on the middle of the pie)
/////////////////////////////////////////////////////////////////////
- public int quick_action { get; private set; }
+ public int quickaction { get; private set; }
/////////////////////////////////////////////////////////////////////
/// The index of the currently active slice.
@@ -83,13 +83,13 @@ public class PieRenderer : GLib.Object {
public PieRenderer() {
this.slices = new Gee.ArrayList<SliceRenderer?>();
this.center = new CenterRenderer(this);
- this.quick_action = -1;
+ this.quickaction = -1;
this.active_slice = -2;
this.size = 0;
}
/////////////////////////////////////////////////////////////////////
- /// Loads an Pie. All members are initialized accordingly.
+ /// Loads a Pie. All members are initialized accordingly.
/////////////////////////////////////////////////////////////////////
public void load_pie(Pie pie) {
@@ -102,8 +102,8 @@ public class PieRenderer : GLib.Object {
this.slices.add(renderer);
renderer.load(action, slices.size-1);
- if (action.is_quick_action) {
- this.quick_action = count;
+ if (action.is_quickaction) {
+ this.quickaction = count;
}
++count;
@@ -112,7 +112,7 @@ public class PieRenderer : GLib.Object {
this.turbo_mode = PieManager.get_is_turbo(pie.id);
- this.set_highlighted_slice(this.quick_action);
+ this.set_highlighted_slice(this.quickaction);
this.size = (int)fmax(2*Config.global.theme.radius + 2*Config.global.theme.slice_radius*Config.global.theme.max_zoom,
2*Config.global.theme.center_radius);
@@ -227,39 +227,41 @@ public class PieRenderer : GLib.Object {
/////////////////////////////////////////////////////////////////////
public void draw(double frame_time, Cairo.Context ctx, int mouse_x, int mouse_y) {
- double distance = sqrt(mouse_x*mouse_x + mouse_y*mouse_y);
- double angle = 0.0;
+ if (this.size > 0) {
+ double distance = sqrt(mouse_x*mouse_x + mouse_y*mouse_y);
+ double angle = 0.0;
- if (this.key_board_control) {
- angle = 2.0*PI*this.active_slice/(double)slice_count();
- } else {
-
- if (distance > 0) {
- angle = acos(mouse_x/distance);
- if (mouse_y < 0)
- angle = 2*PI - angle;
- }
+ if (this.key_board_control) {
+ angle = 2.0*PI*this.active_slice/(double)slice_count();
+ } else {
- int next_active_slice = this.active_slice;
+ if (distance > 0) {
+ angle = acos(mouse_x/distance);
+ if (mouse_y < 0)
+ angle = 2*PI - angle;
+ }
+
+ int next_active_slice = this.active_slice;
+
+ if (distance < Config.global.theme.active_radius
+ && this.quickaction >= 0 && this.quickaction < this.slices.size) {
+
+ next_active_slice = this.quickaction;
+ angle = 2.0*PI*quickaction/(double)slice_count();
+ } else if (distance > Config.global.theme.active_radius && this.slice_count() > 0) {
+ next_active_slice = (int)(angle*slices.size/(2*PI) + 0.5) % this.slice_count();
+ } else {
+ next_active_slice = -1;
+ }
- if (distance < Config.global.theme.active_radius
- && this.quick_action >= 0 && this.quick_action < this.slices.size) {
-
- next_active_slice = this.quick_action;
- angle = 2.0*PI*quick_action/(double)slice_count();
- } else if (distance > Config.global.theme.active_radius && this.slice_count() > 0) {
- next_active_slice = (int)(angle*slices.size/(2*PI) + 0.5) % this.slice_count();
- } else {
- next_active_slice = -1;
+ this.set_highlighted_slice(next_active_slice);
}
-
- this.set_highlighted_slice(next_active_slice);
- }
- center.draw(frame_time, ctx, angle, distance);
-
- foreach (var slice in this.slices)
- slice.draw(frame_time, ctx, angle, distance);
+ center.draw(frame_time, ctx, angle, distance);
+
+ foreach (var slice in this.slices)
+ slice.draw(frame_time, ctx, angle, distance);
+ }
}
/////////////////////////////////////////////////////////////////////
@@ -278,8 +280,8 @@ public class PieRenderer : GLib.Object {
if (index != this.active_slice) {
if (index >= 0 && index < this.slice_count())
this.active_slice = index;
- else if (this.quick_action >= 0)
- this.active_slice = this.quick_action;
+ else if (this.quickaction >= 0)
+ this.active_slice = this.quickaction;
else
this.active_slice = -1;