ソースを参照

Draw extra ticks on the padding of the time display

BearishSun 9 年 前
コミット
1e50aacdab

+ 12 - 4
Source/MBansheeEditor/Windows/Animation/GUICurveDrawing.cs

@@ -93,7 +93,7 @@ namespace BansheeEditor
             this.xRange = xRange;
             this.yRange = yRange;
 
-            tickHandler.SetRange(0.0f, GetRange(), drawableWidth);
+            tickHandler.SetRange(0.0f, GetRange(true), drawableWidth + GUIGraphTime.PADDING);
 
             Rebuild();
         }
@@ -106,7 +106,7 @@ namespace BansheeEditor
         {
             this.fps = Math.Max(1, fps);
 
-            tickHandler.SetRange(0.0f, GetRange(), drawableWidth);
+            tickHandler.SetRange(0.0f, GetRange(true), drawableWidth + GUIGraphTime.PADDING);
 
             Rebuild();
         }
@@ -185,12 +185,20 @@ namespace BansheeEditor
         /// <summary>
         /// Returns the range of times displayed by the timeline rounded to the multiple of FPS.
         /// </summary>
+        /// <param name="padding">If true, extra range will be included to cover the right-most padding.</param>
         /// <returns>Time range rounded to a multiple of FPS.</returns>
-        private float GetRange()
+        private float GetRange(bool padding = false)
         {
             float spf = 1.0f / fps;
 
-            return ((int)xRange / spf) * spf;
+            float range = xRange;
+            if (padding)
+            {
+                float lengthPerPixel = xRange / drawableWidth;
+                range += lengthPerPixel * GUIGraphTime.PADDING;
+            }
+
+            return ((int)range / spf) * spf;
         }
 
         /// <summary>

+ 2 - 2
Source/MBansheeEditor/Windows/Animation/GUIGraphTicks.cs

@@ -121,8 +121,8 @@ namespace BansheeEditor
             // Round up and down so we get one extra tick on either side (outside of value range)
             // (Useful when rendering text above the ticks, so the text doesn't just pop-in when the tick appears, instead
             // it is slowly clipped-in.)
-            int startTick = MathEx.FloorToInt(valueRangeStart / step);
-            int endTick = MathEx.CeilToInt(valueRangeEnd / step);
+            int startTick = MathEx.CeilToInt(valueRangeStart / step);
+            int endTick = MathEx.FloorToInt(valueRangeEnd / step);
 
             int numTicks = endTick - startTick + 1;
 

+ 13 - 5
Source/MBansheeEditor/Windows/Animation/GUIGraphTime.cs

@@ -97,7 +97,7 @@ namespace BansheeEditor
             tickHeight = (int)(height * TICK_HEIGHT_PCT);
             drawableWidth = Math.Max(0, width - PADDING * 2);
 
-            tickHandler.SetRange(0.0f, GetRange(), drawableWidth);
+            tickHandler.SetRange(0.0f, GetRange(true), drawableWidth + PADDING);
 
             Rebuild();
         }
@@ -110,7 +110,7 @@ namespace BansheeEditor
         {
             rangeLength = Math.Max(0.0f, length);
 
-            tickHandler.SetRange(0.0f, GetRange(), drawableWidth);
+            tickHandler.SetRange(0.0f, GetRange(true), drawableWidth + PADDING);
 
             Rebuild();
         }
@@ -123,7 +123,7 @@ namespace BansheeEditor
         {
             this.fps = Math.Max(1, fps);
 
-            tickHandler.SetRange(0.0f, GetRange(), drawableWidth);
+            tickHandler.SetRange(0.0f, GetRange(true), drawableWidth + PADDING);
 
             Rebuild();
         }
@@ -198,12 +198,20 @@ namespace BansheeEditor
         /// <summary>
         /// Returns the range of times displayed by the timeline rounded to the multiple of FPS.
         /// </summary>
+        /// <param name="padding">If true, extra range will be included to cover the right-most padding.</param>
         /// <returns>Time range rounded to a multiple of FPS.</returns>
-        private float GetRange()
+        private float GetRange(bool padding = false)
         {
             float spf = 1.0f/fps;
 
-            return ((int)rangeLength/spf) * spf;
+            float range = rangeLength;
+            if (padding)
+            {
+                float lengthPerPixel = rangeLength/drawableWidth;
+                range += lengthPerPixel * PADDING;
+            }
+
+            return ((int)range / spf) * spf;
         }
 
         /// <summary>