diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-07 12:19:09 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-07 12:19:09 +0200 |
| commit | ac08ff01dbc59628a94a6e09cd0aff07f588f05f (patch) | |
| tree | b65ff6c0306e31cc8a10a6ccd822ec432e6a2f12 | |
| parent | 167e50bf7c4af84a6793326e39b0d3e41d4eb8bf (diff) | |
* Tests.csproj:
* 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
| -rwxr-xr-x | Templates/Window.goml | 8 | ||||
| -rwxr-xr-x | Tests/GOLIBTest_HStack.cs | 42 | ||||
| -rw-r--r-- | Tests/GOLIBTest_Window.cs | 10 | ||||
| -rwxr-xr-x | Tests/Interfaces/testHStack.goml | 11 | ||||
| -rwxr-xr-x | Tests/Interfaces/testWindow.goml | 14 | ||||
| -rw-r--r-- | Tests/Tests.csproj | 6 | ||||
| -rw-r--r-- | src/GraphicObjects/Window.cs | 113 | ||||
| -rwxr-xr-x | src/OpenTKGameWindow.cs | 16 |
8 files changed, 194 insertions, 26 deletions
diff --git a/Templates/Window.goml b/Templates/Window.goml index afc63723..d082ca02 100755 --- a/Templates/Window.goml +++ b/Templates/Window.goml @@ -3,12 +3,12 @@ <VerticalStack Height="0" Width="0" Margin="0">
<Border BorderWidth="1" BorderColor="LightGray" Height="-1" Width="0" Background="BlueCrayola">
<HorizontalStack Name="hs" Margin="1" Spacing="1" Height="-1" Width="0" Focusable="false" >
- <Image Name="Image" Margin="1" Width="16" Height="16" Path="#go.Images.Icons.tetra.png"/>
- <Label Width="0" Name="Title" Margin="5" />
- <Image Focusable="true" Name="Image" Margin="1" Width="16" Height="16" Path="#go.Images.Icons.exit.svg"
+ <Image Name="Image" Margin="1" Width="12" Height="12" Path="#go.Images.Icons.tetra.png"/>
+ <Label Width="0" Name="Title" Margin="1" />
+ <Image Focusable="true" Name="Image" Margin="1" Width="12" Height="12" Path="#go.Images.Icons.exit.svg"
MouseEnter="{Background=Red}" MouseLeave="{Background=Transparent}" MouseClick="butQuitPress"/>
</HorizontalStack>
</Border>
- <Container Name="Content" Margin="1"/>
+ <Container Name="Content" Margin="1" Width="0" Height="0"/>
</VerticalStack>
</Border>
\ No newline at end of file diff --git a/Tests/GOLIBTest_HStack.cs b/Tests/GOLIBTest_HStack.cs new file mode 100755 index 00000000..ac8e0a33 --- /dev/null +++ b/Tests/GOLIBTest_HStack.cs @@ -0,0 +1,42 @@ +#define MONO_CAIRO_DEBUG_DISPOSE
+
+
+using System;
+using System.Runtime.InteropServices;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+using System.Diagnostics;
+
+//using GGL;
+using go;
+using System.Threading;
+
+
+namespace test3
+{
+ class GOLIBTest_HStack : OpenTKGameWindow
+ {
+ public GOLIBTest_HStack ()
+ : base(1024, 600,"test")
+ {}
+
+ protected override void OnLoad (EventArgs e)
+ {
+ base.OnLoad (e);
+ LoadInterface("Interfaces/testHStack.goml");
+
+ }
+
+ [STAThread]
+ static void Main ()
+ {
+ Console.WriteLine ("starting example");
+
+ using (GOLIBTest_HStack win = new GOLIBTest_HStack( )) {
+ win.Run (30.0);
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/Tests/GOLIBTest_Window.cs b/Tests/GOLIBTest_Window.cs index d998d858..56a7712b 100644 --- a/Tests/GOLIBTest_Window.cs +++ b/Tests/GOLIBTest_Window.cs @@ -73,11 +73,11 @@ namespace test {
base.OnLoad (e);
LoadInterface("Interfaces/testWindow.goml", out g);
- LoadInterface("Interfaces/testWindow.goml", out g);
- LoadInterface("Interfaces/testWindow.goml", out g);
- LoadInterface("Interfaces/testWindow.goml", out g);
- LoadInterface("Interfaces/testWindow.goml", out g);
- LoadInterface("Interfaces/testWindow.goml", out g);
+// LoadInterface("Interfaces/testWindow.goml", out g);
+// LoadInterface("Interfaces/testWindow.goml", out g);
+// LoadInterface("Interfaces/testWindow.goml", out g);
+// LoadInterface("Interfaces/testWindow.goml", out g);
+// LoadInterface("Interfaces/testWindow.goml", out g);
}
protected override void OnRenderFrame (FrameEventArgs e)
diff --git a/Tests/Interfaces/testHStack.goml b/Tests/Interfaces/testHStack.goml new file mode 100755 index 00000000..8e4083a0 --- /dev/null +++ b/Tests/Interfaces/testHStack.goml @@ -0,0 +1,11 @@ +<?xml version="1.0"?>
+<!--<HorizontalStack Background="Gray" Margin="1">-->
+<Group Background="Gray" Margin="5" Height="-1" Width="-1">
+ <VerticalStack Background="Green" Margin="1">
+ <HorizontalStack Width="-1" Height="-1" Margin="5" Background="Red">
+ <Checkbox Height="100" Width="200" Background="Blue"/>
+ <!-- <Checkbox Height="-1" Width="-1"/>-->
+ </HorizontalStack>
+ </VerticalStack>
+</Group>
+<!--</HorizontalStack>-->
\ No newline at end of file diff --git a/Tests/Interfaces/testWindow.goml b/Tests/Interfaces/testWindow.goml index 32c64401..d4246ac2 100755 --- a/Tests/Interfaces/testWindow.goml +++ b/Tests/Interfaces/testWindow.goml @@ -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"
Focusable="True">
<VerticalStack Height="0" Width="0">
+ <Slider Name="slider" Height="10" Width="150"/>
<Label Text="{fps}" Background="DarkRed"/>
<Label Text="{fpsMin}" />
<Label Text="{fpsMax}" />
- <Checkbox Height="-1" Width="-1"/>
+ <HorizontalStack Width="150" Height="-1" Margin="5" Background="Red">
+ <Checkbox Height="-1" Width="-1"/>
+ <Checkbox Height="-1" Width="-1"/>
+ </HorizontalStack>
<GroupBox Title="test" Height="-1" Width="-1" Margin="5">
<VerticalStack Width="100">
- <RadioButton Height="-1" Width="-1"/>
- <RadioButton Height="-1" Width="-1"/>
- <RadioButton Height="-1" Width="-1"/>
+ <RadioButton Caption="Radio 1"/>
+ <RadioButton Caption="Radio 2" IsChecked="true"/>
+ <RadioButton Caption="Radio 3"/>
+
</VerticalStack>
</GroupBox>
-
</VerticalStack>
</Window>
<!--</Group>-->
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index fed8ee3e..c3aca549 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -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"> @@ -141,6 +142,9 @@ <None Include="Interfaces\itemTmp.goml"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="Interfaces\testHStack.goml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <ItemGroup> <Folder Include="Interfaces\" /> diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index ad3ec5bb..d7988c92 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -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; } diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 59e02cf1..8c648d0e 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -318,8 +318,16 @@ namespace go AddWidget (result as GraphicObject);
return result;
}
+ public GraphicObject LoadInterface (string path)
+ {
+ GraphicObject tmp = Interface.Load (path, this);
+ AddWidget (tmp);
+ return tmp;
+ }
#endregion
-
+ public virtual void OnRender(FrameEventArgs e)
+ {
+ }
#region Game win overrides
protected override void OnUpdateFrame(FrameEventArgs e)
{
@@ -328,8 +336,14 @@ namespace go }
protected override void OnRenderFrame(FrameEventArgs e)
{
+ GL.Clear (ClearBufferMask.ColorBufferBit);
+
base.OnRenderFrame(e);
+
OpenGLDraw ();
+ OnRender (e);
+
+ SwapBuffers ();
}
protected override void OnLoad(EventArgs e)
{
|