[chronojump] Better draw movingBar adjusting speed being faster at beginning



commit 87882c417e4277180a166fc32b396b1559fdb56f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun May 29 19:29:33 2016 +0200

    Better draw movingBar adjusting speed being faster at beginning

 src/gui/eventExecute.cs  |   10 +++++-----
 src/gui/usefulObjects.cs |   24 +++++++++++++++++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index b7a8d11..1e675f9 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -971,7 +971,7 @@ public partial class ChronoJumpWindow
        {
                if(isLast && animate) {
                        timerBar = true;
-                       movingBar = new MovingBar(x, y + alto -1, barWidth, 1, y, alto, pen_bar_bg, 
simulated, result, layout);
+                       movingBar = new MovingBar(x, y + alto, barWidth, y, alto, pen_bar_bg, simulated, 
result, layout);
                        GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerBar));
                }
                else {
@@ -991,12 +991,12 @@ public partial class ChronoJumpWindow
        { 
                if (!timerBar) 
                        return false;
-                       
-               Rectangle rect = new Rectangle(movingBar.X, movingBar.Y, movingBar.Width, movingBar.Alto);
+               
+               movingBar.Next();
+               Rectangle rect = new Rectangle(movingBar.X, movingBar.Y, movingBar.Width, movingBar.Step);
                event_execute_pixmap.DrawRectangle(movingBar.Pen_bar_bg, true, rect);
-               event_execute_drawingarea.QueueDrawArea(movingBar.X, movingBar.Y, movingBar.Width, 
movingBar.Alto);
+               event_execute_drawingarea.QueueDrawArea(movingBar.X, movingBar.Y, movingBar.Width, 
movingBar.Step);
                
-               movingBar.Y = movingBar.Y -1;
                if(movingBar.Y <= movingBar.YTop) {
                        rect = new Rectangle(movingBar.X, movingBar.YTop, movingBar.Width, movingBar.AltoTop);
                        event_execute_pixmap.DrawRectangle(pen_black, false, rect);
diff --git a/src/gui/usefulObjects.cs b/src/gui/usefulObjects.cs
index 153ae33..9265527 100644
--- a/src/gui/usefulObjects.cs
+++ b/src/gui/usefulObjects.cs
@@ -315,11 +315,20 @@ public class UpdateProgressBar {
 }
 
 //for animate last jump, run, pulse on a bar graph
-public class MovingBar {
+public class MovingBar 
+{
        public int X;
-       public int Y; //y will go from (y + alto -2) to y (ytop)
+       public int Y; 
+       /*
+        * y will go from (y + alto -speed) to (ytop)
+        * eg a vertical bar that goes from the bottom to the top, will go from:
+        * YTop 37, Y 380
+        * to
+        * YTop 37, Y 37
+        * so y will be decreasing
+        */
+       
        public int Width;
-       public int Alto; //always 1
 
        public int YTop; //stored y value
        public int AltoTop; //stored alto value
@@ -327,20 +336,25 @@ public class MovingBar {
        public Gdk.GC Pen_bar_bg;
        public bool Simulated;
        public double Result;
+       public int Step;
        public Pango.Layout Layout;
        
-       public MovingBar(int x, int y, int width, int alto, int yTop, int altoTop, 
+       public MovingBar(int x, int y, int width, int yTop, int altoTop, 
                        Gdk.GC pen_bar_bg, bool simulated, double result, Pango.Layout layout) {
                this.X = x;
                this.Y = y;
                this.Width = width;
-               this.Alto = alto;
                this.YTop = yTop;
                this.AltoTop = altoTop;
                this.Pen_bar_bg = pen_bar_bg;
                this.Simulated = simulated;
                this.Result = result;
                this.Layout = layout;
+       } 
+       
+       public void Next() {
+               Step = Convert.ToInt32(Math.Ceiling((Y-YTop)/100.0));
+               Y = Y - Step;
        }
 
        ~MovingBar() {}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]