OSDN Git Service

タッチモードでの選択周りを標準のテキストボックスの奴と合わせた
authorkonekoneko <test2214@hotmail.co.jp>
Sun, 3 May 2015 17:02:19 +0000 (02:02 +0900)
committerkonekoneko <test2214@hotmail.co.jp>
Sun, 3 May 2015 17:02:19 +0000 (02:02 +0900)
Metro/FooEditEngine/FooTextBox.cs
Metro/FooEditEngine/GripperManager.cs

index 8a952d9..f63eef2 100644 (file)
@@ -91,8 +91,8 @@ namespace FooEditEngine.Metro
             this._Controller = new Controller(this.Document, this.View);\r
             this._Controller.SelectionChanged += Controller_SelectionChanged;\r
 \r
-            this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Upper);\r
-            this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.Bottom);\r
+            this.FirstGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomLeft);\r
+            this.SecondGripper = new Gripper(this._Controller, this.View, this.Render, GripperPostion.BottomRight);\r
 \r
             this.gestureRecongnizer.GestureSettings = GestureSettings.Drag | \r
                 GestureSettings.RightTap | \r
@@ -781,12 +781,14 @@ namespace FooEditEngine.Metro
             {\r
                 hittedGripper = this.FirstGripper;\r
                 HittedCaret = true;\r
+                System.Diagnostics.Debug.WriteLine("first gripper hitted");\r
             }\r
             \r
             else if (this.SecondGripper.IsHit(p))\r
             {\r
                 hittedGripper = this.SecondGripper;\r
                 HittedCaret = true;\r
+                System.Diagnostics.Debug.WriteLine("second gripper hitted");\r
             }\r
         }\r
 \r
@@ -825,7 +827,13 @@ namespace FooEditEngine.Metro
                 }\r
                 if (this.peer != null)\r
                     this.peer.OnNotifyCaretChanged();\r
+                if (this._Controller.SelectionLength != 0)\r
+                    this.FirstGripper.Enabled = true;\r
+                else\r
+                    this.FirstGripper.Enabled = false;\r
+\r
                 this.Refresh();\r
+                \r
                 return;\r
             }\r
             if (e.Delta.Scale < 1)\r
@@ -930,7 +938,6 @@ namespace FooEditEngine.Metro
         void gestureRecongnizer_Tapped(GestureRecognizer sender, TappedEventArgs e)\r
         {\r
             bool touched = e.PointerDeviceType == PointerDeviceType.Touch;\r
-            this.FirstGripper.Enabled = touched;\r
             this.SecondGripper.Enabled = touched;\r
             this.JumpCaret(e.Position);\r
         }\r
index a26f045..ab8a754 100644 (file)
@@ -14,8 +14,8 @@ namespace FooEditEngine
 {
     enum GripperPostion
     {
-        Upper,
-        Bottom,
+        BottomLeft,
+        BottomRight,
     }
     class Gripper : IEquatable<Gripper>
     {
@@ -55,20 +55,12 @@ namespace FooEditEngine
         public Point AdjustPoint(Point p)
         {
             Rectangle gripperRect = this.GetGripperRect(type, HitAreaWidth, HitAreaWidth);
-            if (this.type == GripperPostion.Upper)
-            {
-                if (gripperRect.IsHit(p))
-                    p.Y = gripperRect.Bottom + 1;
-                else
-                    p.Y += gripperRect.Height;
-            }
+            
+            if (gripperRect.IsHit(p))
+                p.Y = gripperRect.Y - 1;
             else
-            {
-                if (gripperRect.IsHit(p))
-                    p.Y = gripperRect.Y - 1;
-                else
-                    p.Y -= gripperRect.Height;
-            }
+                p.Y -= gripperRect.Height;
+
             if (p.Y < this.Render.TextArea.Y)
                 p.Y = this.Render.TextArea.Y;
             return p;
@@ -94,23 +86,17 @@ namespace FooEditEngine
             TextPoint tp;
             Point point;
             double radius = width / 2;
-            if (type == GripperPostion.Bottom)
-            {
+            if (type == GripperPostion.BottomRight)
                 tp = this.View.LayoutLines.GetTextPointFromIndex(this.Controller.SelectionStart + this.Controller.SelectionLength);
-                point = this.View.GetPostionFromTextPoint(tp);
-                double lineHeight = this.View.LayoutLines.GetLayout(tp.row).Height;
-                return new Rectangle(point.X - radius, point.Y + lineHeight, width, height);
-            }
-            else if (type == GripperPostion.Upper)
-            {
+            else if (type == GripperPostion.BottomLeft)
                 tp = this.View.LayoutLines.GetTextPointFromIndex(this.Controller.SelectionStart);
-                point = this.View.GetPostionFromTextPoint(tp);
-                return new Rectangle(point.X - radius, point.Y - height, width, height);
-            }
             else
-            {
                 throw new ArgumentOutOfRangeException();
-            }
+
+            point = this.View.GetPostionFromTextPoint(tp);
+            double lineHeight = this.View.LayoutLines.GetLayout(tp.row).Height;
+            
+            return new Rectangle(point.X - radius, point.Y + lineHeight, width, height);
         }
 
         public bool Equals(Gripper other)