]> O.S.I.I.S - jp/crow.git/commitdiff
debug mouse hangling and focus
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 21 Jul 2016 14:55:02 +0000 (16:55 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 21 Jul 2016 14:55:02 +0000 (16:55 +0200)
src/GraphicObjects/Window.cs

index a36019e3328def0bd9afd1f9f1fe7cfa8ef12634..1866b46796a61ad2272d0bda7dd1e4ada49acf50 100644 (file)
@@ -97,60 +97,78 @@ namespace Crow
                        if (!hoverBorder) {
                                currentDirection = Direction.None;
                                Interface.CurrentInterface.MouseCursor = XCursor.Default;
+                               Debug.WriteLine ("not hover border");
                                return;
                        }
-                       
-                       if (e.Mouse.IsButtonDown (MouseButton.Left)) {                          
-
-                               int currentLeft = this.Left;
-                               int currentTop = this.Top;
-
-                               if (currentLeft == 0)
-                                       currentLeft = this.Slot.Left;
-                               if (currentTop == 0)
-                                       currentTop = this.Slot.Top;
-
-                               switch (currentDirection) {
-                               case Direction.None:
-                                       this.Left = currentLeft + e.XDelta;                             
-                                       this.Top = currentTop + e.YDelta;
-                                       break;
-                               case Direction.N:
-                                       this.Top = currentTop + e.YDelta;
-                                       this.Height -= e.YDelta;
-                                       break;
-                               case Direction.S:
-                                       this.Height += e.YDelta;
-                                       break;
-                               case Direction.W:
-                                       this.Left = currentLeft + e.XDelta;
-                                       this.Width -= e.XDelta;
-                                       break;
-                               case Direction.E:
-                                       this.Width += e.XDelta;
-                                       break;
-                               case Direction.NW:
-                                       this.Left = currentLeft + e.XDelta;
-                                       this.Top = currentTop + e.YDelta;
-                                       this.Width -= e.XDelta;
-                                       this.Height -= e.YDelta;
-                                       break;
-                               case Direction.NE:
-                                       this.Width += e.XDelta;
-                                       this.Top = currentTop + e.YDelta;
-                                       this.Height -= e.YDelta;
-                                       break;
-                               case Direction.SW:
-                                       this.Left = currentLeft + e.XDelta;
-                                       this.Width -= e.XDelta;
-                                       this.Height += e.YDelta;
-                                       break;
-                               case Direction.SE:
-                                       this.Width += e.XDelta;
-                                       this.Height += e.YDelta;
-                                       break;
+
+                       if (this.HasFocus) {
+                               
+                               if (e.Mouse.IsButtonDown (MouseButton.Left)) {                          
+
+                                       int currentLeft = this.Left;
+                                       int currentTop = this.Top;
+                                       int currentWidth, currentHeight;
+
+                                       if (currentLeft == 0) {
+                                               currentLeft = this.Slot.Left;
+                                               //this.Left = currentLeft;
+                                       }
+                                       if (currentTop == 0) {
+                                               currentTop = this.Slot.Top;
+                                               //this.Top = currentTop;
+                                       }
+                                       if (this.Width.IsFixed)
+                                               currentWidth = this.Width;
+                                       else
+                                               currentWidth = this.Slot.Width;
+                               
+                                       if (this.Height.IsFixed)
+                                               currentHeight = this.Height;
+                                       else
+                                               currentHeight = this.Slot.Height;
+
+                                       switch (currentDirection) {
+                                       case Direction.None:
+                                               this.Left = currentLeft + e.XDelta;                             
+                                               this.Top = currentTop + e.YDelta;
+                                               break;
+                                       case Direction.N:
+                                               this.Top = currentTop + e.YDelta;
+                                               this.Height = currentHeight - e.YDelta;
+                                               break;
+                                       case Direction.S:
+                                               this.Height = currentHeight + e.YDelta;
+                                               break;
+                                       case Direction.W:
+                                               this.Left = currentLeft + e.XDelta;
+                                               this.Width = currentWidth - e.XDelta;
+                                               break;
+                                       case Direction.E:
+                                               this.Width = currentWidth + e.XDelta;
+                                               break;
+                                       case Direction.NW:
+                                               this.Left = currentLeft + e.XDelta;
+                                               this.Top = currentTop + e.YDelta;
+                                               this.Width = currentWidth - e.XDelta;
+                                               this.Height = currentHeight - e.YDelta;
+                                               break;
+                                       case Direction.NE:
+                                               this.Width = currentWidth + e.XDelta;
+                                               this.Top = currentTop + e.YDelta;
+                                               this.Height = currentHeight - e.YDelta;
+                                               break;
+                                       case Direction.SW:
+                                               this.Left = currentLeft + e.XDelta;
+                                               this.Width = currentWidth - e.XDelta;
+                                               this.Height = currentHeight + e.YDelta;
+                                               break;
+                                       case Direction.SE:
+                                               this.Width = currentWidth + e.XDelta;
+                                               this.Height = currentHeight + e.YDelta;
+                                               break;
+                                       }
+                                       return;
                                }
-                               return;
                        }
 //                     GraphicObject firstFocusableAncestor = otkgw.hoverWidget;
 //                     while (firstFocusableAncestor != this) {