OSDN Git Service

論理スクロールに対応した。これにともないメソッド名を変更した
authorgdkhd812 <test@nnn.co.jp>
Thu, 4 Feb 2016 17:37:01 +0000 (23:07 +0530)
committergdkhd812 <test@nnn.co.jp>
Thu, 4 Feb 2016 17:37:01 +0000 (23:07 +0530)
Core/EditView.cs
Core/ViewBase.cs
Metro/FooEditEngine/FooTextBox.cs
WPF/FooEditEngine/FooTextBox.cs

index 51c6088..d9dccc3 100644 (file)
@@ -821,26 +821,6 @@ namespace FooEditEngine
         }
 
         /// <summary>
-        /// 指定した座標までスクロールする
-        /// </summary>
-        /// <param name="x"></param>
-        /// <param name="row"></param>
-        /// <remarks>
-        /// 範囲外の座標を指定した場合、範囲内に収まるように調整されます
-        /// </remarks>
-        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);
-        }
-
-        /// <summary>
         /// 指定行までスクロールする
         /// </summary>
         /// <param name="row">行</param>
index 0ef7b23..afbf15a 100644 (file)
@@ -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;
         }
 
index b487009..c647990 100644 (file)
@@ -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;
             }
 
index c152e34..d7841bc 100644 (file)
@@ -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;
             }