From 84a27086bbd9f493128b354300f9c77ccb32a56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 18 Apr 2015 15:42:59 +0200 Subject: Imported Upstream version 0.6.0 --- src/gui/piePreviewDeleteSign.vala | 110 +++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'src/gui/piePreviewDeleteSign.vala') diff --git a/src/gui/piePreviewDeleteSign.vala b/src/gui/piePreviewDeleteSign.vala index 500d876..6ba4dcb 100644 --- a/src/gui/piePreviewDeleteSign.vala +++ b/src/gui/piePreviewDeleteSign.vala @@ -1,25 +1,25 @@ -/* -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 . -*/ +///////////////////////////////////////////////////////////////////////// +// 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 . +///////////////////////////////////////////////////////////////////////// using GLib.Math; namespace GnomePie { -///////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////// /// The delete sign, displayed in the upper right corner of each /// Slice. ///////////////////////////////////////////////////////////////////////// @@ -31,17 +31,17 @@ public class PiePreviewDeleteSign : GLib.Object { ///////////////////////////////////////////////////////////////////// public signal void on_clicked(); - + ///////////////////////////////////////////////////////////////////// /// The image used to display this oject. ///////////////////////////////////////////////////////////////////// - + public Image icon { get; private set; } - + ///////////////////////////////////////////////////////////////////// /// Some constants determining the look and behaviour of this Slice. ///////////////////////////////////////////////////////////////////// - + private static const int radius = 18; private static const double globale_scale = 0.8; private static const double click_cancel_treshold = 5; @@ -51,24 +51,24 @@ public class PiePreviewDeleteSign : GLib.Object { ///////////////////////////////////////////////////////////////////// private bool visible = false; - + ///////////////////////////////////////////////////////////////////// /// Some AnimatedValues for smooth transitions. ///////////////////////////////////////////////////////////////////// - + private AnimatedValue size; - private AnimatedValue alpha; - private AnimatedValue activity; - private AnimatedValue clicked; - + private AnimatedValue alpha; + private AnimatedValue activity; + private AnimatedValue clicked; + ///////////////////////////////////////////////////////////////////// /// Storing the position where a mouse click was executed. Useful for /// canceling the click when the mouse moves some pixels. ///////////////////////////////////////////////////////////////////// - + private double clicked_x = 0.0; private double clicked_y = 0.0; - + ///////////////////////////////////////////////////////////////////// /// C'tor, sets everything up. ///////////////////////////////////////////////////////////////////// @@ -79,7 +79,7 @@ public class PiePreviewDeleteSign : GLib.Object { this.activity = new AnimatedValue.cubic(AnimatedValue.Direction.OUT, -3, -3, 0, 0.0); this.clicked = new AnimatedValue.cubic(AnimatedValue.Direction.OUT, 1, 1, 0, 0.0); } - + ///////////////////////////////////////////////////////////////////// /// Loads an Action. All members are initialized accordingly. ///////////////////////////////////////////////////////////////////// @@ -87,26 +87,26 @@ public class PiePreviewDeleteSign : GLib.Object { public void load() { this.icon = new Icon("stock_delete", PiePreviewDeleteSign.radius*2); } - + ///////////////////////////////////////////////////////////////////// /// Makes this object visible. ///////////////////////////////////////////////////////////////////// - + public void show() { if (!this.visible) { this.visible = true; - this.alpha.reset_target(1.0, 0.3); + this.alpha.reset_target(1.0, 0.3); } } - + ///////////////////////////////////////////////////////////////////// /// Makes this object invisible. ///////////////////////////////////////////////////////////////////// - + public void hide() { if (this.visible) { this.visible = false; - this.alpha.reset_target(0.0, 0.3); + this.alpha.reset_target(0.0, 0.3); } } @@ -117,7 +117,7 @@ public class PiePreviewDeleteSign : GLib.Object { public void set_size(double size) { this.size.reset_target(size, 0.2); } - + ///////////////////////////////////////////////////////////////////// /// Draws the sign to the given context. ///////////////////////////////////////////////////////////////////// @@ -127,46 +127,46 @@ public class PiePreviewDeleteSign : GLib.Object { this.alpha.update(frame_time); this.activity.update(frame_time); this.clicked.update(frame_time); - + if (this.alpha.val > 0) { ctx.save(); - + // transform the context - double scale = (this.size.val*this.clicked.val + double scale = (this.size.val*this.clicked.val + this.activity.val*0.2 - 0.2)*PiePreviewDeleteSign.globale_scale; ctx.scale(scale, scale); - + // paint the image icon.paint_on(ctx, this.alpha.val); - + ctx.restore(); } } - + ///////////////////////////////////////////////////////////////////// /// Called when the mouse moves to another position. ///////////////////////////////////////////////////////////////////// - + public bool on_mouse_move(double x, double y) { if (this.clicked.end == 0.9) { double dist = GLib.Math.pow(x-this.clicked_x, 2) + GLib.Math.pow(y-this.clicked_y, 2); if (dist > PiePreviewDeleteSign.click_cancel_treshold*PiePreviewDeleteSign.click_cancel_treshold) this.clicked.reset_target(1.0, 0.1); } - - if (GLib.Math.fabs(x) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale && GLib.Math.fabs(y) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale) { - this.activity.reset_target(1.0, 0.2); - return true; - } - + + if (GLib.Math.fabs(x) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale && GLib.Math.fabs(y) <= PiePreviewDeleteSign.radius*PiePreviewDeleteSign.globale_scale) { + this.activity.reset_target(1.0, 0.2); + return true; + } + this.activity.reset_target(0.0, 0.2); return false; } - + ///////////////////////////////////////////////////////////////////// /// Called when a button of the mouse is pressed. ///////////////////////////////////////////////////////////////////// - + public bool on_button_press(double x, double y) { if (this.activity.end == 1.0) { this.clicked.reset_target(0.9, 0.1); @@ -176,16 +176,16 @@ public class PiePreviewDeleteSign : GLib.Object { } return false; } - + ///////////////////////////////////////////////////////////////////// /// Called when a button of the mouse is released. ///////////////////////////////////////////////////////////////////// - + public bool on_button_release(double x, double y) { if (this.clicked.end == 0.9) { this.clicked.reset_target(1.0, 0.1); this.on_clicked(); - + return true; } return false; -- cgit v1.2.3