OSDN Git Service

グリッパーを移動する部分をコントローラーに移動した
[fooeditengine/FooEditEngine.git] / Core / Controller.cs
index a0b85d3..bee7a83 100644 (file)
@@ -774,6 +774,55 @@ namespace FooEditEngine
             this.View.AdjustCaretAndSrc();
         }
 
+        /// <summary>
+        /// グリッパーとキャレットを同時に移動する
+        /// </summary>
+        /// <param name="p">ポインターの座標</param>
+        /// <param name="hittedGripper">動かす対象となるグリッパー</param>
+        /// <returns>移動できた場合は真を返す。そうでなければ偽を返す</returns>
+        /// <remarks>グリッパー内にポインターが存在しない場合、グリッパーはポインターの座標近くの行に移動する</remarks>
+        public bool MoveCaretAndGripper(Point p, GripperView hittedGripper)
+        {
+            bool HittedCaret = false;
+            TextPoint tp = this.View.GetTextPointFromPostion(p);
+            if (tp == this.View.CaretPostion)
+            {
+                HittedCaret = true;
+            }
+
+            if (HittedCaret || hittedGripper != null)
+            {
+                if (hittedGripper != null)
+                {
+                    tp = this.View.GetTextPointFromPostion(hittedGripper.AdjustPoint(p));
+                    if (this.IsReverseSelect())
+                    {
+                        if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomRight))
+                            this.MoveSelectBefore(tp);
+                        else
+                            this.MoveCaretAndSelect(tp);
+                    }
+                    else
+                    {
+                        if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomLeft))
+                            this.MoveSelectBefore(tp);
+                        else
+                            this.MoveCaretAndSelect(tp);
+                    }
+                    hittedGripper.Move(this.View, tp);
+                }
+                else
+                {
+                    tp = this.View.GetTextPointFromPostion(p);
+                    if (tp != TextPoint.Null)
+                        this.MoveCaretAndSelect(tp);
+                }
+                this.View.SelectGrippers.BottomLeft.Enabled = this.SelectionLength != 0;
+                return true;
+            }
+            return false;
+        }
+
         public void MoveSelectBefore(TextPoint tp)
         {
             int NewAnchorIndex;