From 8ac5bd7bea78d87fabc063d5699183e5c06cacac Mon Sep 17 00:00:00 2001 From: gdkhd812 Date: Thu, 4 Feb 2016 23:07:01 +0530 Subject: [PATCH] =?utf8?q?=E8=AB=96=E7=90=86=E3=82=B9=E3=82=AF=E3=83=AD?= =?utf8?q?=E3=83=BC=E3=83=AB=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=97=E3=81=9F?= =?utf8?q?=E3=80=82=E3=81=93=E3=82=8C=E3=81=AB=E3=81=A8=E3=82=82=E3=81=AA?= =?utf8?q?=E3=81=84=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=90=8D=E3=82=92?= =?utf8?q?=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Core/EditView.cs | 20 -------------------- Core/ViewBase.cs | 28 ++++++++++++++++++++++++---- Metro/FooEditEngine/FooTextBox.cs | 13 +++++++------ WPF/FooEditEngine/FooTextBox.cs | 14 ++++++++------ 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/Core/EditView.cs b/Core/EditView.cs index 51c6088..d9dccc3 100644 --- a/Core/EditView.cs +++ b/Core/EditView.cs @@ -821,26 +821,6 @@ namespace FooEditEngine } /// - /// 指定した座標までスクロールする - /// - /// - /// - /// - /// 範囲外の座標を指定した場合、範囲内に収まるように調整されます - /// - public void Scroll(double x, double y) - { - if (x < 0) - x = 0; - if (y < 0) - y = 0; - double totalHeight = this.LayoutLines.Count * this.render.emSize.Height; - if (y > totalHeight) - y = totalHeight - this.render.TextArea.Height; - base.TryScroll(x, y); - } - - /// /// 指定行までスクロールする /// /// 行 diff --git a/Core/ViewBase.cs b/Core/ViewBase.cs index 0ef7b23..afbf15a 100644 --- a/Core/ViewBase.cs +++ b/Core/ViewBase.cs @@ -297,19 +297,39 @@ namespace FooEditEngine return false; } - public virtual bool TryScroll(double x, double y) + Point total = new Point(); + double noti; + public virtual bool TryRelativeScroll(double delta_x, double delta_y, bool logical_scroll = true) { + total.X += delta_x; + total.Y += delta_y; + noti += Math.Abs(delta_y); //負の値が飛んでくる可能性がある + + if (noti < this.render.emSize.Height && logical_scroll) + return true; + + noti = 0; + + double totalHeight = this.LayoutLines.Count * this.render.emSize.Height; + if (total.Y > totalHeight) + total.Y = totalHeight - this.render.TextArea.Height; + if (total.Y < 0) + total.Y = 0; + if (total.X < 0) + total.X = 0; + int row; - if (y > 0) - row = (int)(y / this.render.emSize.Height + 1.0); //レタリング時にオフセットするために切り上げる + if (total.Y > 0) + row = (int)(total.Y / this.render.emSize.Height + 1.0); //レタリング時にオフセットするために切り上げる else row = 0; //0の時だけは切り上げると困るので何もしない if (row < 0) return true; if (row > this.LayoutLines.Count - 1) return true; - this.Document.Src = new SrcPoint(x, row, y); + this.Document.Src = new SrcPoint(total.X, row, total.Y); this.SrcChanged(this, null); + return false; } diff --git a/Metro/FooEditEngine/FooTextBox.cs b/Metro/FooEditEngine/FooTextBox.cs index b487009..c647990 100644 --- a/Metro/FooEditEngine/FooTextBox.cs +++ b/Metro/FooEditEngine/FooTextBox.cs @@ -812,13 +812,14 @@ namespace FooEditEngine.Metro //Xの絶対値が大きければ横方向のスクロールで、そうでなければ縦方向らしい if (Math.Abs(e.Cumulative.Translation.X) < Math.Abs(e.Cumulative.Translation.Y)) { - System.Diagnostics.Debug.WriteLine("tran y:{0}", translation.Y); //下に動かした場合はマイナスの値が飛んでくる、上に動かした場合はプラスの値が飛んでくる - this.View.Scroll(this.Document.Src.X, this.Document.Src.Y - translation.Y); - this.View.IsFocused = false; - this.Document.SelectGrippers.BottomLeft.Enabled = false; - this.Document.SelectGrippers.BottomRight.Enabled = false; - this.Refresh(); + if(!this.View.TryRelativeScroll(0, -translation.Y, false)) + { + this.View.IsFocused = false; + this.Document.SelectGrippers.BottomLeft.Enabled = false; + this.Document.SelectGrippers.BottomRight.Enabled = false; + this.Refresh(); + } return; } diff --git a/WPF/FooEditEngine/FooTextBox.cs b/WPF/FooEditEngine/FooTextBox.cs index c152e34..d7841bc 100644 --- a/WPF/FooEditEngine/FooTextBox.cs +++ b/WPF/FooEditEngine/FooTextBox.cs @@ -994,12 +994,14 @@ namespace FooEditEngine.WPF if (Math.Abs(e.CumulativeManipulation.Translation.X) < Math.Abs(e.CumulativeManipulation.Translation.Y)) { //下に動かした場合はマイナスの値が飛んでくる、上に動かした場合はプラスの値が飛んでくる - this.View.Scroll(this.Document.Src.X, this.Document.Src.Y - translation.Y); - this.View.IsFocused = false; - this.Document.SelectGrippers.BottomLeft.Enabled = false; - this.Document.SelectGrippers.BottomRight.Enabled = false; - this.touchScrolled = true; - this.Refresh(); + if(!this.View.TryRelativeScroll(0, -translation.Y)) + { + this.View.IsFocused = false; + this.Document.SelectGrippers.BottomLeft.Enabled = false; + this.Document.SelectGrippers.BottomRight.Enabled = false; + this.touchScrolled = true; + this.Refresh(); + } return; } -- 2.11.0