]> O.S.I.I.S - jp/crow.git/commitdiff
* Tests.csproj:
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 7 Sep 2015 10:19:09 +0000 (12:19 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 7 Sep 2015 10:19:09 +0000 (12:19 +0200)
* Window.goml:
* GOLIBTest_HStack.cs:
* GOLIBTest_Window.cs:
* testHStack.goml:
* testWindow.goml: debug and tests

* Window.cs: Resizing window with corsors

* OpenTKGameWindow.cs: OnRender function, hidding clear and swap
  overridable with OnRenderFrame

Templates/Window.goml
Tests/GOLIBTest_HStack.cs [new file with mode: 0755]
Tests/GOLIBTest_Window.cs
Tests/Interfaces/testHStack.goml [new file with mode: 0755]
Tests/Interfaces/testWindow.goml
Tests/Tests.csproj
src/GraphicObjects/Window.cs
src/OpenTKGameWindow.cs

index afc63723bb12480e66bbd2b8304275c185d4b996..d082ca02442dd47fdba65f6f91744426f84e976c 100755 (executable)
@@ -3,12 +3,12 @@
        <VerticalStack Height="0" Width="0" Margin="0">\r
                <Border BorderWidth="1" BorderColor="LightGray"  Height="-1" Width="0" Background="BlueCrayola">\r
                        <HorizontalStack Name="hs" Margin="1" Spacing="1" Height="-1" Width="0" Focusable="false" >\r
-                               <Image Name="Image" Margin="1" Width="16" Height="16" Path="#go.Images.Icons.tetra.png"/>\r
-                               <Label Width="0" Name="Title" Margin="5" />\r
-                               <Image Focusable="true" Name="Image" Margin="1" Width="16" Height="16" Path="#go.Images.Icons.exit.svg"\r
+                               <Image Name="Image" Margin="1" Width="12" Height="12" Path="#go.Images.Icons.tetra.png"/>\r
+                               <Label Width="0" Name="Title" Margin="1" />\r
+                               <Image Focusable="true" Name="Image" Margin="1" Width="12" Height="12" Path="#go.Images.Icons.exit.svg"\r
                                        MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}" MouseClick="butQuitPress"/>\r
                        </HorizontalStack>\r
                </Border>\r
-               <Container Name="Content" Margin="1"/>\r
+               <Container Name="Content" Margin="1" Width="0" Height="0"/>\r
        </VerticalStack>\r
 </Border>
\ No newline at end of file
diff --git a/Tests/GOLIBTest_HStack.cs b/Tests/GOLIBTest_HStack.cs
new file mode 100755 (executable)
index 0000000..ac8e0a3
--- /dev/null
@@ -0,0 +1,42 @@
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+\r
+\r
+namespace test3\r
+{\r
+       class GOLIBTest_HStack : OpenTKGameWindow\r
+       {\r
+               public GOLIBTest_HStack ()\r
+                       : base(1024, 600,"test")\r
+               {}\r
+\r
+               protected override void OnLoad (EventArgs e)\r
+               {\r
+                       base.OnLoad (e);\r
+                       LoadInterface("Interfaces/testHStack.goml");\r
+\r
+               }                       \r
+\r
+               [STAThread]\r
+               static void Main ()\r
+               {\r
+                       Console.WriteLine ("starting example");\r
+\r
+                       using (GOLIBTest_HStack win = new GOLIBTest_HStack( )) {\r
+                               win.Run (30.0);\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file
index d998d8589d3f50e4966d32c849646d0d60b0a088..56a7712b6273f2023f10966504df7c85dd834946 100644 (file)
@@ -73,11 +73,11 @@ namespace test
                {\r
                        base.OnLoad (e);\r
                        LoadInterface("Interfaces/testWindow.goml", out g);\r
-                       LoadInterface("Interfaces/testWindow.goml", out g);\r
-                       LoadInterface("Interfaces/testWindow.goml", out g);\r
-                       LoadInterface("Interfaces/testWindow.goml", out g);\r
-                       LoadInterface("Interfaces/testWindow.goml", out g);\r
-                       LoadInterface("Interfaces/testWindow.goml", out g);\r
+//                     LoadInterface("Interfaces/testWindow.goml", out g);\r
+//                     LoadInterface("Interfaces/testWindow.goml", out g);\r
+//                     LoadInterface("Interfaces/testWindow.goml", out g);\r
+//                     LoadInterface("Interfaces/testWindow.goml", out g);\r
+//                     LoadInterface("Interfaces/testWindow.goml", out g);\r
 \r
                }\r
                protected override void OnRenderFrame (FrameEventArgs e)\r
diff --git a/Tests/Interfaces/testHStack.goml b/Tests/Interfaces/testHStack.goml
new file mode 100755 (executable)
index 0000000..8e4083a
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>\r
+<!--<HorizontalStack Background="Gray" Margin="1">-->\r
+<Group  Background="Gray" Margin="5" Height="-1" Width="-1">\r
+       <VerticalStack Background="Green" Margin="1">\r
+               <HorizontalStack Width="-1" Height="-1" Margin="5" Background="Red">\r
+                       <Checkbox Height="100" Width="200" Background="Blue"/>\r
+       <!--            <Checkbox Height="-1" Width="-1"/>-->\r
+               </HorizontalStack>\r
+       </VerticalStack>\r
+</Group>\r
+<!--</HorizontalStack>-->
\ No newline at end of file
index 32c64401d080381f3da782b9fedbd103392327c4..d4246ac293089f52f03a9da610e82a303ff2e3ae 100755 (executable)
@@ -3,18 +3,22 @@
 <Window Name="window1" Left="10" Top="10" Title="Test window" Width="200" Height="200" Background="0,5;0,5;0,5;0,5" \r
        Focusable="True">\r
        <VerticalStack Height="0" Width="0">\r
+               <Slider Name="slider" Height="10" Width="150"/>\r
                <Label Text="{fps}"  Background="DarkRed"/>\r
                <Label Text="{fpsMin}"  />\r
                <Label Text="{fpsMax}"  />\r
-               <Checkbox Height="-1" Width="-1"/>\r
+               <HorizontalStack Width="150" Height="-1" Margin="5" Background="Red">\r
+                       <Checkbox Height="-1" Width="-1"/>\r
+                       <Checkbox Height="-1" Width="-1"/>\r
+               </HorizontalStack>\r
                <GroupBox Title="test"  Height="-1" Width="-1" Margin="5">\r
                        <VerticalStack Width="100">\r
-                               <RadioButton  Height="-1" Width="-1"/>\r
-                               <RadioButton  Height="-1" Width="-1"/>\r
-                               <RadioButton  Height="-1" Width="-1"/>\r
+                               <RadioButton  Caption="Radio 1"/>\r
+                               <RadioButton  Caption="Radio 2" IsChecked="true"/>\r
+                               <RadioButton  Caption="Radio 3"/>\r
+\r
                        </VerticalStack>\r
                </GroupBox>\r
-\r
        </VerticalStack>\r
 </Window>\r
 <!--</Group>-->\r
index fed8ee3e2e902fbba26cd80908d79fbb3ff49dad..c3aca54939f59567e1ef2174a94509d249976620 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_4</StartupObject>
+    <StartupObject>test3.GOLIBTest_HStack</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
@@ -64,6 +64,7 @@
     <Compile Include="GOLIBTest_0.cs" />
     <Compile Include="GOLIBTest_TypeViewer.cs" />
     <Compile Include="GOLIBTest_stack.cs" />
+    <Compile Include="GOLIBTest_HStack.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
     <None Include="Interfaces\itemTmp.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\testHStack.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index ad3ec5bbaedcf95afc8453f3eda6a56702e9e17c..d7988c92b8cd10f0e9fd19c614ec09cdbb4e5ff2 100644 (file)
@@ -39,32 +39,125 @@ namespace go
 
 
                }
+               enum Direction
+               {
+                       None,
+                       N,
+                       S,
+                       E,
+                       W,
+                       NW,
+                       NE,
+                       SW,
+                       SE
+               }
+               Direction currentDirection = Direction.None;
+
                public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseMove (sender, e);
 
-
                        OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
 
-                       if ((e.Position - this.Slot.TopLeft).Length < 5)
-                               otkgw.Cursor = XCursor.NW;
-                       else
-                               otkgw.Cursor = XCursor.Cross;
-
+                       int borderLim = 5;
+
+
+
+                       if (TopContainer.activeWidget == null) {
+                               Direction lastDir = currentDirection;
+
+                               if ((e.Position - this.Slot.TopLeft).Length < borderLim)
+                                       currentDirection = Direction.NW;
+                               else if ((e.Position - this.Slot.TopRight).Length < borderLim)
+                                       currentDirection = Direction.NE;
+                               else if ((e.Position - this.Slot.BottomLeft).Length < borderLim)
+                                       currentDirection = Direction.SW;
+                               else if ((e.Position - this.Slot.BottomRight).Length < borderLim)
+                                       currentDirection = Direction.SE;
+                               else
+                                       currentDirection = Direction.None;
+
+
+                               if (currentDirection != lastDir) {
+                                       switch (currentDirection) {
+                                       case Direction.None:
+                                               otkgw.Cursor = XCursor.Default;
+                                               break;
+                                       case Direction.N:
+                                               otkgw.Cursor = XCursor.Cross;
+                                               break;
+                                       case Direction.S:
+                                               otkgw.Cursor = XCursor.Cross;
+                                               break;
+                                       case Direction.E:
+                                               otkgw.Cursor = XCursor.Cross;
+                                               break;
+                                       case Direction.W:
+                                               otkgw.Cursor = XCursor.Cross;
+                                               break;
+                                       case Direction.NW:
+                                               otkgw.Cursor = XCursor.NW;
+                                               break;
+                                       case Direction.NE:
+                                               otkgw.Cursor = XCursor.NE;
+                                               break;
+                                       case Direction.SW:
+                                               otkgw.Cursor = XCursor.SW;
+                                               break;
+                                       case Direction.SE:
+                                               otkgw.Cursor = XCursor.SE;
+                                               break;
+                                       }
+                               }                               
+                               return;
+                       }
 
                        if (TopContainer.activeWidget != this)
                                return;
-                       
+                               
                        this.TopContainer.redrawClip.AddRectangle (this.ScreenCoordinates(this.Slot));
-                       this.Left += e.XDelta;
-                       this.Top += e.YDelta;
-                       this.registerForGraphicUpdate ();                       
-
 
+                       switch (currentDirection) {
+                       case Direction.None:
+                               this.Left += e.XDelta;
+                               this.Top += e.YDelta;
+                               break;
+                       case Direction.N:
+                               break;
+                       case Direction.S:
+                               break;
+                       case Direction.E:
+                               break;
+                       case Direction.W:
+                               break;
+                       case Direction.NW:
+                               this.Left += e.XDelta;
+                               this.Top += e.YDelta;
+                               this.Width -= e.XDelta;
+                               this.Height -= e.YDelta;
+                               break;
+                       case Direction.NE:
+                               this.Width += e.XDelta;
+                               this.Top += e.YDelta;
+                               this.Height -= e.YDelta;
+                               break;
+                       case Direction.SW:
+                               this.Left += e.XDelta;
+                               this.Width -= e.XDelta;
+                               this.Height += e.YDelta;
+                               break;
+                       case Direction.SE:
+                               this.Width += e.XDelta;
+                               this.Height += e.YDelta;
+                               break;
+                       }
+               
+                       this.RegisterForLayouting ((int)LayoutingType.All);                     
                }
                public override void onMouseLeave (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseLeave (sender, e);
+                       currentDirection = Direction.None;
                        OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow;
                        otkgw.Cursor = XCursor.Default;
                }
index 59e02cf1f4226b06876840f43104d5a0c408b48e..8c648d0e3421a0e01fbafab7e7b134d887f6ce76 100755 (executable)
@@ -318,8 +318,16 @@ namespace go
                        AddWidget (result as GraphicObject);\r
                        return result;\r
                }\r
+               public GraphicObject LoadInterface (string path)\r
+               {\r
+                       GraphicObject tmp = Interface.Load (path, this);\r
+                       AddWidget (tmp);\r
+                       return tmp;\r
+               }\r
                #endregion\r
-                       \r
+               public virtual void OnRender(FrameEventArgs e)\r
+               {\r
+               }\r
                #region Game win overrides\r
                protected override void OnUpdateFrame(FrameEventArgs e)\r
                {       \r
@@ -328,8 +336,14 @@ namespace go
                }\r
                protected override void OnRenderFrame(FrameEventArgs e)\r
                {\r
+                       GL.Clear (ClearBufferMask.ColorBufferBit);\r
+\r
                        base.OnRenderFrame(e);\r
+\r
                        OpenGLDraw ();\r
+                       OnRender (e);\r
+\r
+                       SwapBuffers ();\r
                }\r
                protected override void OnLoad(EventArgs e)\r
         {\r