@@ -1061,7 +1061,7 @@ public static void DrawPlayhead(float x, float yMin, float yMax, float thickness
10611061 {
10621062 if ( Event . current . type != EventType . Repaint )
10631063 return ;
1064-
1064+ InitStyles ( ) ;
10651065 float halfThickness = thickness * 0.5f ;
10661066 Color lineColor = styles . playhead . normal . textColor . AlphaMultiplied ( alpha ) ;
10671067 if ( thickness > 1f )
@@ -1201,160 +1201,6 @@ public TimeRulerDragMode BrowseRuler(Rect position, int id, ref float time, floa
12011201 return TimeRulerDragMode . None ;
12021202 }
12031203
1204- /* public void GridGUI ()
1205- {
1206- GUI.BeginGroup(drawRect);
1207-
1208- if (Event.current.type != EventType.Repaint)
1209- {
1210- GUI.EndGroup();
1211- return;
1212- }
1213-
1214- InitStyles ();
1215- SetTickMarkerRanges();
1216-
1217- Color tempCol = GUI.color;
1218-
1219- HandleUtility.ApplyWireMaterial ();
1220- GL.Begin (GL.LINES);
1221-
1222-
1223- // Cache framed area rect as fetching the property takes some calculations
1224- Rect rect = shownArea;
1225-
1226- float lineStart, lineEnd;
1227- // Draw time markers of various strengths
1228- hTicks.SetTickStrengths(settings.hTickStyle.distMin, settings.hTickStyle.distFull, false);
1229- if (settings.hTickStyle.stubs)
1230- {
1231- lineStart = rect.yMin;
1232- lineEnd = rect.yMin - 40 / scale.y;
1233- }
1234- else
1235- {
1236- lineStart = Mathf.Max(rect.yMin, vRangeMin);
1237- lineEnd = Mathf.Min(rect.yMax, vRangeMax);
1238- }
1239- for (int l=0; l<hTicks.tickLevels; l++)
1240- {
1241- float strength = hTicks.GetStrengthOfLevel(l);
1242- GL.Color (settings.hTickStyle.color * new Color(1,1,1,strength) * new Color (1, 1, 1, 0.75f));
1243- float[] ticks = hTicks.GetTicksAtLevel(l, true);
1244- for (int j=0; j<ticks.Length; j++)
1245- if (ticks[j] > hRangeMin && ticks[j] < hRangeMax)
1246- DrawLine(new Vector2 (ticks[j], lineStart), new Vector2 (ticks[j], lineEnd));
1247- }
1248- // Draw bounds of allowed range
1249- GL.Color (settings.hTickStyle.color * new Color(1,1,1,1) * new Color (1, 1, 1, 0.75f));
1250- if (hRangeMin != Mathf.NegativeInfinity)
1251- DrawLine(new Vector2 (hRangeMin, lineStart), new Vector2 (hRangeMin, lineEnd));
1252- if (hRangeMax != Mathf.Infinity)
1253- DrawLine(new Vector2 (hRangeMax, lineStart), new Vector2 (hRangeMax, lineEnd));
1254-
1255- // Draw value markers of various strengths
1256- vTicks.SetTickStrengths(settings.vTickStyle.distMin, settings.vTickStyle.distFull, false);
1257- if (settings.vTickStyle.stubs)
1258- {
1259- lineStart = rect.xMin;
1260- lineEnd = rect.xMin + 40 / scale.x;
1261- }
1262- else
1263- {
1264- lineStart = Mathf.Max(rect.xMin, hRangeMin);
1265- lineEnd = Mathf.Min(rect.xMax, hRangeMax);
1266- }
1267- for (int l=0; l<vTicks.tickLevels; l++)
1268- {
1269- float strength = vTicks.GetStrengthOfLevel(l);
1270- GL.Color (settings.vTickStyle.color * new Color(1,1,1,strength) * new Color (1, 1, 1, 0.75f));
1271- float[] ticks = vTicks.GetTicksAtLevel(l, true);
1272- for (int j=0; j<ticks.Length; j++)
1273- if (ticks[j] > vRangeMin && ticks[j] < vRangeMax)
1274- DrawLine(new Vector2 (lineStart, ticks[j]), new Vector2 (lineEnd, ticks[j]));
1275- }
1276- // Draw bounds of allowed range
1277- GL.Color (settings.vTickStyle.color * new Color(1,1,1,1) * new Color (1, 1, 1, 0.75f));
1278- if (vRangeMin != Mathf.NegativeInfinity)
1279- DrawLine(new Vector2 (lineStart, vRangeMin), new Vector2 (lineEnd, vRangeMin));
1280- if (vRangeMax != Mathf.Infinity)
1281- DrawLine(new Vector2 (lineStart, vRangeMax), new Vector2 (lineEnd, vRangeMax));
1282-
1283- GL.End ();
1284-
1285- if (settings.hTickStyle.distLabel > 0)
1286- {
1287- // Draw time labels
1288- GUI.color = settings.hTickStyle.labelColor;
1289- int labelLevel = hTicks.GetLevelWithMinSeparation(settings.hTickStyle.distLabel);
1290-
1291- // Calculate how many decimals are needed to show the differences between the labeled ticks
1292- int decimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(hTicks.GetPeriodOfLevel(labelLevel));
1293-
1294- // now draw
1295- float[] ticks = hTicks.GetTicksAtLevel(labelLevel, false);
1296- float vpos = Mathf.Floor(drawRect.height);
1297- for (int i=0; i<ticks.Length; i++)
1298- {
1299- if (ticks[i] < hRangeMin || ticks[i] > hRangeMax)
1300- continue;
1301- Vector2 pos = DrawingToViewTransformPoint(new Vector2 (ticks[i], 0));
1302- // Important to take floor of positions of GUI stuff to get pixel correct alignment of
1303- // stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
1304- pos = new Vector2(Mathf.Floor(pos.x), vpos);
1305- GUI.Label(new Rect(pos.x-50+22, pos.y-16 - settings.hTickLabelOffset, 50, 16), ticks[i].ToString("n"+decimals)+settings.hTickStyle.unit, styles.labelTickMarks);
1306- }
1307- }
1308-
1309- if (settings.vTickStyle.distLabel > 0)
1310- {
1311- // Draw value labels
1312- GUI.color = settings.vTickStyle.labelColor;
1313- int labelLevel = vTicks.GetLevelWithMinSeparation(settings.vTickStyle.distLabel);
1314-
1315- float[] ticks = vTicks.GetTicksAtLevel(labelLevel, false);
1316-
1317- // Calculate how many decimals are needed to show the differences between the labeled ticks
1318- int decimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(vTicks.GetPeriodOfLevel(labelLevel));
1319-
1320- // Calculate the size of the biggest shown label
1321- float labelSize = 35;
1322- if (!settings.vTickStyle.stubs && ticks.Length > 1)
1323- {
1324- string minNumber = ticks[1 ].ToString("n"+decimals)+settings.vTickStyle.unit;
1325- string maxNumber = ticks[ticks.Length-2].ToString("n"+decimals)+settings.vTickStyle.unit;
1326- labelSize = Mathf.Max(
1327- styles.labelTickMarks.CalcSize(new GUIContent(minNumber)).x,
1328- styles.labelTickMarks.CalcSize(new GUIContent(maxNumber)).x
1329- ) + 6;
1330- }
1331-
1332- // now draw
1333- for (int i=0; i<ticks.Length; i++)
1334- {
1335- if (ticks[i] < vRangeMin || ticks[i] > vRangeMax)
1336- continue;
1337- Vector2 pos = DrawingToViewTransformPoint(new Vector2 (0, ticks[i]));
1338- // Important to take floor of positions of GUI stuff to get pixel correct alignment of
1339- // stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
1340- pos = new Vector2(25, Mathf.Floor(pos.y));
1341- GUI.Label(new Rect(pos.x, pos.y, labelSize, 16), ticks[i].ToString("n"+decimals)+settings.vTickStyle.unit, styles.labelTickMarks);
1342- }
1343- }
1344-
1345- GUI.color = tempCol;
1346-
1347- GUI.EndGroup();
1348- }
1349- */
1350-
1351- // FIXME remove when grid drawing function has been properly rewritten
1352- void DrawLine ( Vector2 lhs , Vector2 rhs )
1353- {
1354- GL . Vertex ( DrawingToViewTransformPoint ( new Vector3 ( lhs . x , lhs . y , 0 ) ) ) ;
1355- GL . Vertex ( DrawingToViewTransformPoint ( new Vector3 ( rhs . x , rhs . y , 0 ) ) ) ;
1356- }
1357-
13581204 private float FrameToPixel ( float i , float frameRate , Rect rect , Rect theShownArea )
13591205 {
13601206 return ( i - theShownArea . xMin * frameRate ) * rect . width / ( theShownArea . width * frameRate ) ;
0 commit comments