]> O.S.I.I.S - jp/crow.git/commitdiff
several fix, proportional Spinner
authorjp <jp_bruyere@hotmail.com>
Thu, 14 Apr 2016 21:50:44 +0000 (23:50 +0200)
committerjp <jp_bruyere@hotmail.com>
Thu, 14 Apr 2016 21:50:44 +0000 (23:50 +0200)
OTKCrow/OpenTKGameWindow.cs
Templates/Spinner.goml
src/GraphicObjects/Label.cs

index 73beb67f62fec0e95a60d3addc81f37720242e28..efe0d94150dc8ac72188e2ef1b3f8627b1d5847a 100644 (file)
@@ -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
 
index b8fbf8321f222307f4196c3dd3c2c0e99c3d7320..c7b5cfb9ecdc988946028e350320739ecbb21d6e 100755 (executable)
@@ -1,20 +1,18 @@
 <?xml version="1.0"?>
-<Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}"
-       Foreground="Gray"
-       Background="White">
-       <HorizontalStack Name="hstack" Margin="0" Spacing="2" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}">
-               <Label Foreground="DimGray" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}" 
-                       Text="{../../../Value}" Margin="1" TextAlignment="Right"/>
-               <VerticalStack Width="-1" Height="{../../../HeightPolicy}" Spacing="0" >
-                       <Button MouseRepeat="true" Width="12" Height="8" MouseClick="../../../../onUp"
-                               Template="#Crow.Templates.ArrowButTemplate.crow">
-                               <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/>
-                       </Button>
-                               
-                       <Button MouseRepeat="true" Width="12" Height="8" MouseClick="../../../../onDown" 
-                               Template="#Crow.Templates.ArrowButTemplate.crow">
-                               <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
-                       </Button>
-               </VerticalStack>
-       </HorizontalStack>
-</Border>
\ No newline at end of file
+<HorizontalStack Name="hstack" Margin="0" Spacing="0" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
+       <Border BorderWidth="1" Height="{../../HeightPolicy}" Width="80%"  Background="White" 
+               Foreground="DimGray" Margin="0">
+               <Label Foreground="DimGray" Height="{../../../HeightPolicy}" Width="Stretched"
+                       Text="{../../../Value}" TextAlignment="Right" Margin="0"/>
+       </Border>
+       <VerticalStack Width="20%" Height="Stretched" Spacing="0" Margin="0" Background="Red">
+               <Button MouseRepeat="true" Width="Stretched" Height="50%" Margin="0" MouseClick="../../../onUp"
+                       Template="#Crow.Templates.ArrowButTemplate.crow">
+                       <Image Path="#Crow.Images.Icons.updown.svg" SvgSub="up" Margin="0"/>
+               </Button>                               
+               <Button MouseRepeat="true" Width="Stretched" Height="50%" Margin="0" MouseClick="../../../onDown" 
+                       Template="#Crow.Templates.ArrowButTemplate.crow">
+                       <Image Path="#Crow.Images.Icons.updown.svg" SvgSub="down" Margin="0"/>
+               </Button>
+       </VerticalStack>
+</HorizontalStack>
index 0a909b7342f815f3c38d05a6f8a40d4164963f55..769220dd25767d2fbe928f0927ac77501aa4adaf 100644 (file)
@@ -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