Explorar el Código

Appearance tweaks to the animation editor

BearishSun hace 9 años
padre
commit
7318fa1ed0

+ 15 - 12
Source/MBansheeEditor/Windows/Animation/GUIGraphValues.cs

@@ -9,9 +9,11 @@ namespace BansheeEditor
      *  @{
      *  @{
      */
      */
 
 
+    // TODO DOC
     internal class GUIGraphValues
     internal class GUIGraphValues
     {
     {
-        private static readonly Color COLOR_DARK_GRAY = new Color(40.0f / 255.0f, 40.0f / 255.0f, 40.0f / 255.0f, 1.0f);
+        private static readonly Color COLOR_TRANSPARENT_LIGHT_GRAY = 
+            new Color(200.0f / 255.0f, 200.0f / 255.0f, 200.0f / 255.0f, 0.5f);
 
 
         private GUITicks tickHandler;
         private GUITicks tickHandler;
         private GUICanvas canvas;
         private GUICanvas canvas;
@@ -21,8 +23,6 @@ namespace BansheeEditor
         private float rangeStart = -1.0f;
         private float rangeStart = -1.0f;
         private float rangeEnd = 1.0f;
         private float rangeEnd = 1.0f;
 
 
-        private float maxTextHeight;
-
         public GUIGraphValues(GUILayout layout, int width, int height)
         public GUIGraphValues(GUILayout layout, int width, int height)
         {
         {
             canvas = new GUICanvas();
             canvas = new GUICanvas();
@@ -30,9 +30,6 @@ namespace BansheeEditor
 
 
             tickHandler = new GUITicks();
             tickHandler = new GUITicks();
 
 
-            maxTextHeight = GUIUtility.CalculateTextBounds("99:999", EditorBuiltin.DefaultFont,
-               EditorStyles.DefaultFontSize).y;
-
             SetSize(width, height);
             SetSize(width, height);
         }
         }
 
 
@@ -66,7 +63,7 @@ namespace BansheeEditor
             Rebuild();
             Rebuild();
         }
         }
 
 
-        private void DrawTime(int yPos, float seconds, bool minutes)
+        private void DrawTime(int yPos, float seconds, bool minutes, bool above)
         {
         {
             TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
             TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
 
 
@@ -81,9 +78,15 @@ namespace BansheeEditor
 
 
             Vector2I textPosition = new Vector2I();
             Vector2I textPosition = new Vector2I();
             textPosition.x = width - textBounds.x;
             textPosition.x = width - textBounds.x;
-            textPosition.y = yPos - textBounds.y;
 
 
-            canvas.DrawText(timeString, textPosition, EditorBuiltin.DefaultFont, Color.LightGray,
+            if (above)
+                textPosition.y = yPos - textBounds.y;
+            else // Below
+            {
+                const int PADDING = 3; // So the text doesn't touch the tick
+                textPosition.y = yPos + PADDING;
+            }
+            canvas.DrawText(timeString, textPosition, EditorBuiltin.DefaultFont, COLOR_TRANSPARENT_LIGHT_GRAY,
                 EditorStyles.DefaultFontSize);
                 EditorStyles.DefaultFontSize);
         }
         }
 
 
@@ -118,14 +121,14 @@ namespace BansheeEditor
                         Vector2I start = new Vector2I(0, yPos);
                         Vector2I start = new Vector2I(0, yPos);
                         Vector2I end = new Vector2I((int) (width*strength), yPos);
                         Vector2I end = new Vector2I((int) (width*strength), yPos);
 
 
-                        Color color = Color.LightGray;
-                        color.a *= strength;
+                        Color color = COLOR_TRANSPARENT_LIGHT_GRAY;
+                        color.a *= MathEx.Clamp01(strength);
 
 
                         canvas.DrawLine(start, end, color);
                         canvas.DrawLine(start, end, color);
 
 
                         // Draw text for the highest level ticks
                         // Draw text for the highest level ticks
                         if (i == 0)
                         if (i == 0)
-                            DrawTime(yPos, ticks[j], displayAsMinutes);
+                            DrawTime(yPos, ticks[j], displayAsMinutes, ticks[j] <= 0.0f);
                     }
                     }
                 }
                 }
             }
             }

+ 2 - 0
Source/MBansheeEditor/Windows/Animation/GUITicks.cs

@@ -75,6 +75,8 @@ namespace BansheeEditor
             float step = validSteps[maxLevel + level];
             float step = validSteps[maxLevel + level];
 
 
             // Round up and down so we get one extra tick on either side (outside of value range)
             // 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 startTick = MathEx.FloorToInt(valueRangeStart / step);
             int endTick = MathEx.CeilToInt(valueRangeEnd / step);
             int endTick = MathEx.CeilToInt(valueRangeEnd / step);
 
 

+ 4 - 2
Source/MBansheeEditor/Windows/AnimationWindow.cs

@@ -84,7 +84,9 @@ namespace BansheeEditor
             GUIPanel sidebarPanel = GUI.AddPanel(-10);
             GUIPanel sidebarPanel = GUI.AddPanel(-10);
             sidebarPanel.SetPosition(0, 20 + buttonLayout.Bounds.height);
             sidebarPanel.SetPosition(0, 20 + buttonLayout.Bounds.height);
 
 
-            sidebar = new GUIGraphValues(sidebarPanel, 40, Height - 20 - buttonLayout.Bounds.height);
+            sidebar = new GUIGraphValues(sidebarPanel, 30, Height - 20 - buttonLayout.Bounds.height);
+
+            curveDrawing.SetSize(Width, Height - 20 - buttonLayout.Bounds.height);
 
 
             // TODO - Calculate min/max Y and range to set as default
             // TODO - Calculate min/max Y and range to set as default
             //  - Also recalculate whenever curves change and increase as needed
             //  - Also recalculate whenever curves change and increase as needed
@@ -107,7 +109,7 @@ namespace BansheeEditor
         {
         {
             timeline.SetSize(width, 20);
             timeline.SetSize(width, 20);
             curveDrawing.SetSize(width, height - 20 - buttonLayout.Bounds.height);
             curveDrawing.SetSize(width, height - 20 - buttonLayout.Bounds.height);
-            sidebar.SetSize(40, height - 20 - buttonLayout.Bounds.height);
+            sidebar.SetSize(30, height - 20 - buttonLayout.Bounds.height);
         }
         }
 
 
         private void OnEditorUpdate()
         private void OnEditorUpdate()