From: jp Date: Thu, 14 Apr 2016 21:50:44 +0000 (+0200) Subject: several fix, proportional Spinner X-Git-Tag: v0.4~69 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=bbe51d8097fd368a1f87086af3fdda668ec75b6e;p=jp%2Fcrow.git several fix, proportional Spinner --- diff --git a/OTKCrow/OpenTKGameWindow.cs b/OTKCrow/OpenTKGameWindow.cs index 73beb67f..efe0d941 100644 --- a/OTKCrow/OpenTKGameWindow.cs +++ b/OTKCrow/OpenTKGameWindow.cs @@ -185,9 +185,10 @@ namespace Crow void OpenGLDraw() { bool blend = GL.GetBoolean (GetPName.Blend); + bool depthTest = GL.GetBoolean (GetPName.DepthTest); GL.Enable (EnableCap.Blend); - GL.DepthMask (false); GL.Disable (EnableCap.DepthTest); + shader.Enable (); GL.BindTexture (TextureTarget.Texture2D, texID); lock (CrowInterface.RenderMutex) { @@ -204,8 +205,8 @@ namespace Crow shader.Disable (); if (!blend) GL.Disable (EnableCap.Blend); - GL.DepthMask (true); - GL.Enable (EnableCap.DepthTest); + if (depthTest) + GL.Enable (EnableCap.DepthTest); } #endregion diff --git a/Templates/Spinner.goml b/Templates/Spinner.goml index b8fbf832..c7b5cfb9 100755 --- a/Templates/Spinner.goml +++ b/Templates/Spinner.goml @@ -1,20 +1,18 @@  - - - - \ No newline at end of file + + + + + + + + diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 0a909b73..769220dd 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -357,7 +357,7 @@ namespace Crow if (lc == 0) lc = 1; - return (int)(fe.Height * lc) + Margin * 2; + return (int)Math.Ceiling(fe.Height * lc) + Margin * 2; } foreach (string s in lines) { @@ -396,70 +396,65 @@ namespace Crow Rectangle cb = ClientRectangle; - //ignore text alignment if size to content = true - //TODO: split horizontal and vertical logic - if (Width == Measure.Fit || Height == Measure.Fit) + rText.X = cb.X; + rText.Y = cb.Y; + + if (horizontalStretch) { + widthRatio = (float)cb.Width / (float)rText.Width; + if (!verticalStretch) + heightRatio = widthRatio; + } + + if (verticalStretch) { + heightRatio = (float)cb.Height / (float)rText.Height; + if (!horizontalStretch) + widthRatio = heightRatio; + } + + rText.Width = (int)(widthRatio * (float)rText.Width); + rText.Height = (int)(heightRatio * (float)rText.Height); + + switch (TextAlignment) { + case Alignment.TopLeft: //ok rText.X = cb.X; rText.Y = cb.Y; - }else{ - if (horizontalStretch) { - widthRatio = (float)cb.Width / rText.Width; - if (!verticalStretch) - heightRatio = widthRatio; - } - - if (verticalStretch) { - heightRatio = (float)cb.Height / rText.Height; - if (!horizontalStretch) - widthRatio = heightRatio; - } - - rText.Width = (int)(widthRatio * rText.Width); - rText.Height = (int)(heightRatio * rText.Height); - - switch (TextAlignment) - { - case Alignment.TopLeft: //ok - rText.X = cb.X; - rText.Y = cb.Y; - break; - case Alignment.Top: //ok - rText.Y = cb.Y; - rText.X = cb.X + cb.Width / 2 - rText.Width / 2; - break; - case Alignment.TopRight: //ok - rText.Y = cb.Y; - rText.X = cb.Right - rText.Width; - break; - case Alignment.Left://ok - rText.X = cb.X; - rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; - break; - case Alignment.Right://ok - rText.X = cb.X + cb.Width - rText.Width; - rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; - break; - case Alignment.Bottom://ok - rText.X = cb.Width / 2 - rText.Width / 2; - rText.Y = cb.Height - rText.Height; - break; - case Alignment.BottomLeft://ok - rText.X = cb.X; - rText.Y = cb.Bottom - rText.Height; - break; - case Alignment.BottomRight://ok - rText.Y = cb.Bottom - rText.Height; - rText.X = cb.Right - rText.Width; - break; - case Alignment.Center://ok - rText.X = cb.X + cb.Width / 2 - rText.Width / 2; - rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; - break; - } + break; + case Alignment.Top: //ok + rText.Y = cb.Y; + rText.X = cb.X + cb.Width / 2 - rText.Width / 2; + break; + case Alignment.TopRight: //ok + rText.Y = cb.Y; + rText.X = cb.Right - rText.Width; + break; + case Alignment.Left://ok + rText.X = cb.X; + rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; + break; + case Alignment.Right://ok + rText.X = cb.X + cb.Width - rText.Width; + rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; + break; + case Alignment.Bottom://ok + rText.X = cb.Width / 2 - rText.Width / 2; + rText.Y = cb.Height - rText.Height; + break; + case Alignment.BottomLeft://ok + rText.X = cb.X; + rText.Y = cb.Bottom - rText.Height; + break; + case Alignment.BottomRight://ok + rText.Y = cb.Bottom - rText.Height; + rText.X = cb.Right - rText.Width; + break; + case Alignment.Center://ok + rText.X = cb.X + cb.Width / 2 - rText.Width / 2; + rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2; + break; } - gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0); + gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0); fe = gr.FontExtents; #region draw text cursor