From a1a7ae3dd0d7b0249ca2a124550a41380cbead2d Mon Sep 17 00:00:00 2001 From: gdkhd812 Date: Sat, 24 Oct 2015 19:59:32 +0530 Subject: [PATCH] =?utf8?q?=E3=82=B0=E3=83=AA=E3=83=83=E3=83=91=E3=83=BC?= =?utf8?q?=E3=82=92=E7=A7=BB=E5=8B=95=E3=81=99=E3=82=8B=E9=83=A8=E5=88=86?= =?utf8?q?=E3=82=92=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC=E3=83=A9?= =?utf8?q?=E3=83=BC=E3=81=AB=E7=A7=BB=E5=8B=95=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Core/Controller.cs | 49 ++++++++++++++++++++++++++++++++++ Metro/FooEditEngine/FooTextBox.cs | 55 +++------------------------------------ 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/Core/Controller.cs b/Core/Controller.cs index a0b85d3..bee7a83 100644 --- a/Core/Controller.cs +++ b/Core/Controller.cs @@ -774,6 +774,55 @@ namespace FooEditEngine this.View.AdjustCaretAndSrc(); } + /// + /// グリッパーとキャレットを同時に移動する + /// + /// ポインターの座標 + /// 動かす対象となるグリッパー + /// 移動できた場合は真を返す。そうでなければ偽を返す + /// グリッパー内にポインターが存在しない場合、グリッパーはポインターの座標近くの行に移動する + 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; diff --git a/Metro/FooEditEngine/FooTextBox.cs b/Metro/FooEditEngine/FooTextBox.cs index b7aeff6..f01a8a4 100644 --- a/Metro/FooEditEngine/FooTextBox.cs +++ b/Metro/FooEditEngine/FooTextBox.cs @@ -780,8 +780,6 @@ namespace FooEditEngine.Metro this.textStore.NotifySelectionChanged(); } - bool HittedCaret; - GripperView hittedGripper; private void gestureRecongnizer_ManipulationInertiaStarting(GestureRecognizer sender, ManipulationInertiaStartingEventArgs e) { //sender.InertiaTranslationDeceleration = 0.001f; @@ -789,22 +787,11 @@ namespace FooEditEngine.Metro //sender.InertiaRotationDeceleration = 720.0f / (1000.0f * 1000.0f); } + GripperView hittedGripper; void gestureRecongnizer_ManipulationStarted(GestureRecognizer sender, ManipulationStartedEventArgs e) { - this.HittedCaret = false; - - Point p = e.Position; - TextPoint tp = this.View.GetTextPointFromPostion(p); - if (tp == this.View.CaretPostion) - { - HittedCaret = true; - } - + //Updateedの段階でヒットテストしてしまうとグリッパーを触ってもヒットしないことがある this.hittedGripper = this.View.HitGripperFromPoint(e.Position); - if (this.hittedGripper != null) - { - this.HittedCaret = true; - } } const int WheelNoti = 120; @@ -813,45 +800,11 @@ namespace FooEditEngine.Metro void gestureRecongnizer_ManipulationUpdated(GestureRecognizer sender, ManipulationUpdatedEventArgs e) { - if (HittedCaret) + if (this._Controller.MoveCaretAndGripper(e.Position, this.hittedGripper)) { - Point p; - if (this.hittedGripper == null) - p = e.Position; - else - p = this.hittedGripper.AdjustPoint(e.Position); - - if (hittedGripper != null) - { - TextPoint tp = this.View.GetTextPointFromPostion(p); - if (this._Controller.IsReverseSelect()) - { - if (Object.ReferenceEquals(hittedGripper,this.View.SelectGrippers.BottomRight)) - this._Controller.MoveSelectBefore(tp); - else - this._Controller.MoveCaretAndSelect(tp); - } - else - { - if (Object.ReferenceEquals(hittedGripper, this.View.SelectGrippers.BottomLeft)) - this._Controller.MoveSelectBefore(tp); - else - this._Controller.MoveCaretAndSelect(tp); - } - this.hittedGripper.Move(this.View, tp); - } - else - { - TextPoint tp = this.View.GetTextPointFromPostion(p); - if(tp != TextPoint.Null) - this._Controller.MoveCaretAndSelect(tp); - } if (this.peer != null) this.peer.OnNotifyCaretChanged(); - this.View.SelectGrippers.BottomLeft.Enabled = this._Controller.SelectionLength != 0; - - this.Refresh(); - + this.Refresh(); return; } -- 2.11.0