From dcf100def542956b86b1d5b46515e7d6607d6b96 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Wed, 9 Sep 2015 10:43:24 +0200 Subject: [PATCH] * GOLib.csproj: * XCursor.cs: * OpenTKGameWindow.cs: * GOLIBTest_Window.cs: * Window.cs: * testWindow.goml: Horizontal and vertical Resizing * Interface.cs: Border threshold --- GOLib.csproj | 3 ++ Tests/GOLIBTest_Window.cs | 9 +++-- Tests/Interfaces/testWindow.goml | 28 ++++++++++++--- src/GraphicObjects/Window.cs | 60 ++++++++++++++++++-------------- src/Interface.cs | 3 ++ src/OpenTKGameWindow.cs | 3 +- src/XCursor.cs | 4 +-- 7 files changed, 74 insertions(+), 36 deletions(-) diff --git a/GOLib.csproj b/GOLib.csproj index 70181412..0cfcf445 100644 --- a/GOLib.csproj +++ b/GOLib.csproj @@ -189,6 +189,9 @@ + + + diff --git a/Tests/GOLIBTest_Window.cs b/Tests/GOLIBTest_Window.cs index 4ce0b654..8a05c4a4 100644 --- a/Tests/GOLIBTest_Window.cs +++ b/Tests/GOLIBTest_Window.cs @@ -71,12 +71,12 @@ namespace test : base(800, 600,"test") {} - Window g; protected override void OnLoad (EventArgs e) { base.OnLoad (e); - LoadInterface("Interfaces/testWindow.goml", out g); + LoadInterface("Interfaces/testWindow.goml"); + LoadInterface("Interfaces/testWindow.goml"); // LoadInterface("Interfaces/testWindow.goml", out g); // LoadInterface("Interfaces/testWindow.goml", out g); // LoadInterface("Interfaces/testWindow.goml", out g); @@ -107,6 +107,11 @@ namespace test this.Quit (); } + void butQuitPress (object sender, MouseButtonEventArgs e) + { + DeleteWidget (sender as GraphicObject); + } + [STAThread] static void Main () { diff --git a/Tests/Interfaces/testWindow.goml b/Tests/Interfaces/testWindow.goml index dc9dc3dc..efad1d8f 100755 --- a/Tests/Interfaces/testWindow.goml +++ b/Tests/Interfaces/testWindow.goml @@ -1,7 +1,27 @@  - + + @@ -9,8 +29,8 @@ - - + + diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index c1a117eb..0c275f7a 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -33,12 +33,7 @@ namespace go public Window () : base() { } - - void Window_MouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e) - { - - - } + enum Direction { None, @@ -49,7 +44,7 @@ namespace go NW, NE, SW, - SE + SE, } Direction currentDirection = Direction.None; @@ -59,41 +54,46 @@ namespace go OpenTKGameWindow otkgw = TopContainer as OpenTKGameWindow; - int borderLim = 5; - - - - if (TopContainer.activeWidget == null) { + if (otkgw.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; + if (Math.Abs (e.Position.Y - this.Slot.Y) < Interface.BorderThreshold) { + if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + currentDirection = Direction.NW; + else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + currentDirection = Direction.NE; + else + currentDirection = Direction.N; + } else if (Math.Abs (e.Position.Y - this.Slot.Bottom) < Interface.BorderThreshold) { + if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + currentDirection = Direction.SW; + else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + currentDirection = Direction.SE; + else + currentDirection = Direction.S; + } else if (Math.Abs (e.Position.X - this.Slot.X) < Interface.BorderThreshold) + currentDirection = Direction.W; + else if (Math.Abs (e.Position.X - this.Slot.Right) < Interface.BorderThreshold) + currentDirection = Direction.E; else currentDirection = Direction.None; - if (currentDirection != lastDir) { switch (currentDirection) { case Direction.None: otkgw.Cursor = XCursor.Default; break; case Direction.N: - otkgw.Cursor = XCursor.Cross; + otkgw.Cursor = XCursor.V; break; case Direction.S: - otkgw.Cursor = XCursor.Cross; + otkgw.Cursor = XCursor.V; break; case Direction.E: - otkgw.Cursor = XCursor.Cross; + otkgw.Cursor = XCursor.H; break; case Direction.W: - otkgw.Cursor = XCursor.Cross; + otkgw.Cursor = XCursor.H; break; case Direction.NW: otkgw.Cursor = XCursor.NW; @@ -123,12 +123,18 @@ namespace go this.Top += e.YDelta; break; case Direction.N: + this.Top += e.YDelta; + this.Height -= e.YDelta; break; case Direction.S: - break; - case Direction.E: + this.Height += e.YDelta; break; case Direction.W: + this.Left += e.XDelta; + this.Width -= e.XDelta; + break; + case Direction.E: + this.Width += e.XDelta; break; case Direction.NW: this.Left += e.XDelta; diff --git a/src/Interface.cs b/src/Interface.cs index 3e0f8771..d7a35f81 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -34,7 +34,10 @@ namespace go public static int TabSize = 4; public static string LineBreak = "\r\n"; public static bool ReplaceTabsWithSpace = false; + /// Allow rendering of interface in development environment public static bool DesignerMode = false; + /// Threshold to catch borders for sizing + public static int BorderThreshold = 5; /// /// Graphic objects References use in dynamic delegates for binding diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 23e72576..d34d6bfa 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -40,7 +40,8 @@ namespace go XCursor.NE = XCursorFile.Load("#go.Images.Icons.Cursors.top_right_corner").Cursors[0]; XCursor.SW = XCursorFile.Load("#go.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; XCursor.SE = XCursorFile.Load("#go.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; - + XCursor.H = XCursorFile.Load("#go.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; + XCursor.V = XCursorFile.Load("#go.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; } #endregion diff --git a/src/XCursor.cs b/src/XCursor.cs index a186fcfe..8120530e 100644 --- a/src/XCursor.cs +++ b/src/XCursor.cs @@ -151,8 +151,8 @@ namespace go public static XCursor NE; public static XCursor N; public static XCursor S; - - + public static XCursor V; + public static XCursor H; public uint Width; public uint Height; -- 2.47.3