OSDN Git Service

スクロールをピクセル単位で行うようにした
[fooeditengine/FooEditEngine.git] / Core / Controller.cs
index d468870..4e5949b 100644 (file)
@@ -422,7 +422,6 @@ namespace FooEditEngine
             this.SelectWithMoveCaret(isSelected);
         }
 
-        double noti;
         /// <summary>
         /// スクロールする
         /// </summary>
@@ -430,7 +429,7 @@ namespace FooEditEngine
         /// <param name="delta">ピクセル単位の値でスクロール量を指定する</param>
         /// <param name="isSelected">選択状態にするなら真</param>
         /// <param name="withCaret">同時にキャレットを移動させるなら真</param>
-        public void ScrollByPixel(ScrollDirection dir,int delta, bool isSelected, bool withCaret)
+        public void ScrollByPixel(ScrollDirection dir,double delta, bool isSelected, bool withCaret)
         {
             if (this.Document.FireUpdateEvent == false)
                 throw new InvalidOperationException("");
@@ -441,23 +440,20 @@ namespace FooEditEngine
                 return;
             }
 
-            if(dir == ScrollDirection.Up || dir == ScrollDirection.Down)
+            if(dir == ScrollDirection.Up)
+            {
+                this.View.TryScroll(0, -delta);
+            }
+            else if (dir == ScrollDirection.Down)
             {
-                noti += delta;
-
-                if (noti < this.View.render.emSize.Height)
-                    return;
-
-                int delta_row = (int)(noti / this.View.render.emSize.Height + 1.0);
-
-                noti = 0;
-
                 this.View.TryScroll(0, delta);
             }
 
             if (withCaret)
             {
                 //カーソルを適切な位置に移動させる必要がある
+                TextPoint tp = this.View.GetTextPointFromPostion(this.View.CaretLocation);
+                this.View.JumpCaret(tp.row, tp.col);
                 this.View.AdjustCaretAndSrc();
                 this.SelectWithMoveCaret(isSelected);
             }