DPI changes
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Cabrito
|
||||
if (font == null)
|
||||
return (int)Height;
|
||||
|
||||
return (int)Mathf.Round(LineSpacing * font.Height * Scale.Y);
|
||||
return (int)Mathf.Round(LineSpacing * (font.Height / Platform.DpiScale) * Scale.Y);
|
||||
}
|
||||
|
||||
struct LineInfo
|
||||
@@ -89,7 +89,7 @@ namespace Cabrito
|
||||
|
||||
float fontWidth = (int)font.MeasureText("a").X; // hacky, but works for fixed-size fonts...
|
||||
int lineMaxChars = (int)(Width / fontWidth);
|
||||
int lineMaxLines = (int)(Height / font.Height);
|
||||
int lineMaxLines = (int)(Height / (font.Height / Platform.DpiScale)); // number of fully visible lines
|
||||
int numLines = 0;
|
||||
int lineIndex = lines.Count - 1;
|
||||
List<LineInfo> lineInfos = new List<LineInfo>(lineMaxLines);
|
||||
@@ -196,7 +196,8 @@ namespace Cabrito
|
||||
// Make sure lengthy lines are split
|
||||
CalculateVisibleLines(lines, out int startLine, out int lastLine, out LineInfo[] wrappedLines);
|
||||
|
||||
float lineHeight = font.Height;
|
||||
|
||||
float lineHeight = font.Height / Platform.DpiScale;
|
||||
float accumHeight = wrappedLines.Length * lineHeight;
|
||||
|
||||
int selectionLeftLine = selectionStartLine;
|
||||
@@ -351,10 +352,11 @@ namespace Cabrito
|
||||
CalculateVisibleLines(lines, out int startLine, out int lastLine, out LineInfo[] wrappedLines);
|
||||
|
||||
TextLayoutOptions layout = _layout;
|
||||
float lineHeight = font.Height;
|
||||
float lineHeightNormalized = font.Height;
|
||||
float lineHeight = lineHeightNormalized / Platform.DpiScale;
|
||||
float visibleHeight = wrappedLines.Length * lineHeight;
|
||||
float top = layout.Bounds.Bottom - visibleHeight;
|
||||
int lineMaxLines = (int)(Height / font.Height);
|
||||
float top = (layout.Bounds.Bottom - visibleHeight) / Platform.DpiScale; // UI coordinate space remains normalized
|
||||
int lineMaxLines = (int)(Height / lineHeight);
|
||||
|
||||
int hiddenLines = 0;
|
||||
if (wrappedLines.Length > lineMaxLines)
|
||||
@@ -362,21 +364,23 @@ namespace Cabrito
|
||||
//if (top < layout.Bounds.Top)
|
||||
// hiddenLines = (int)Math.Ceiling((layout.Bounds.Top - top) / (float)lineHeight);
|
||||
|
||||
int hitWrappedLine = (int)((location.Y - top) / lineHeight) + hiddenLines;
|
||||
int hitWrappedLine = (int)((location.Y - top) / lineHeight); //+ hiddenLines;
|
||||
if (hitWrappedLine < 0 || hitWrappedLine >= wrappedLines.Length)
|
||||
return false;
|
||||
|
||||
hitLine = wrappedLines[hitWrappedLine].lineIndex;
|
||||
string line = lines.ElementAt(hitLine);
|
||||
|
||||
layout.Bounds.Y = top + ((hitWrappedLine) * lineHeight) + 22.5f;
|
||||
layout.Bounds.Height = top + visibleHeight;
|
||||
layout.Bounds.Y = top + ((hitWrappedLine) * lineHeight);
|
||||
layout.Bounds.Height = top + 9999;//(visibleHeight / Platform.DpiScale);
|
||||
/*if (layout.Bounds.Y < 0)
|
||||
{
|
||||
layout.Bounds.Y = 1;
|
||||
}*/
|
||||
|
||||
hitChar = font.HitTestText(line, location, ref layout);
|
||||
|
||||
FlaxEngine.Debug.Log(string.Format("hit line {0}/{1}, max lines {2}", hitWrappedLine, wrappedLines.Length, lineMaxLines));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,12 +231,12 @@ namespace Cabrito
|
||||
|
||||
private void OnSendLog(LogType level, string msg, FlaxEngine.Object obj, string stackTrace)
|
||||
{
|
||||
Console.Print("[DEBUGs] " + msg);
|
||||
//Console.Print("[DEBUG] " + msg);
|
||||
}
|
||||
|
||||
private void OnSendExceptionLog(Exception exception, FlaxEngine.Object obj)
|
||||
{
|
||||
Console.Print("[EXCEP] " + exception.Message);
|
||||
//Console.Print("[EXCEP] " + exception.Message);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
|
||||
Reference in New Issue
Block a user