• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditEngine: Commit


Commit MetaInfo

Revision1ba70d8417ca5aa4f92347a6e36eba10b8a365f4 (tree)
Time2021-01-08 00:34:39
Authortest <test@yaho...>
Commitertest

Log Message

スクロールをピクセル単位で行うようにした

Change Summary

Incremental Difference

--- a/Core/Controller.cs
+++ b/Core/Controller.cs
@@ -422,7 +422,6 @@ namespace FooEditEngine
422422 this.SelectWithMoveCaret(isSelected);
423423 }
424424
425- double noti;
426425 /// <summary>
427426 /// スクロールする
428427 /// </summary>
@@ -430,7 +429,7 @@ namespace FooEditEngine
430429 /// <param name="delta">ピクセル単位の値でスクロール量を指定する</param>
431430 /// <param name="isSelected">選択状態にするなら真</param>
432431 /// <param name="withCaret">同時にキャレットを移動させるなら真</param>
433- public void ScrollByPixel(ScrollDirection dir,int delta, bool isSelected, bool withCaret)
432+ public void ScrollByPixel(ScrollDirection dir,double delta, bool isSelected, bool withCaret)
434433 {
435434 if (this.Document.FireUpdateEvent == false)
436435 throw new InvalidOperationException("");
@@ -441,23 +440,20 @@ namespace FooEditEngine
441440 return;
442441 }
443442
444- if(dir == ScrollDirection.Up || dir == ScrollDirection.Down)
443+ if(dir == ScrollDirection.Up)
444+ {
445+ this.View.TryScroll(0, -delta);
446+ }
447+ else if (dir == ScrollDirection.Down)
445448 {
446- noti += delta;
447-
448- if (noti < this.View.render.emSize.Height)
449- return;
450-
451- int delta_row = (int)(noti / this.View.render.emSize.Height + 1.0);
452-
453- noti = 0;
454-
455449 this.View.TryScroll(0, delta);
456450 }
457451
458452 if (withCaret)
459453 {
460454 //カーソルを適切な位置に移動させる必要がある
455+ TextPoint tp = this.View.GetTextPointFromPostion(this.View.CaretLocation);
456+ this.View.JumpCaret(tp.row, tp.col);
461457 this.View.AdjustCaretAndSrc();
462458 this.SelectWithMoveCaret(isSelected);
463459 }
--- a/UWP/FooEditEngine.UWP/FooTextBox.cs
+++ b/UWP/FooEditEngine.UWP/FooTextBox.cs
@@ -549,6 +549,7 @@ namespace FooEditEngine.UWP
549549 if (autocomplete != null && autocomplete.ProcessKeyDown(this, e, isControlPressed, isShiftPressed))
550550 return;
551551
552+ double alignedPage = (int)(this.Render.TextArea.Height / this.Render.emSize.Height) * this.Render.emSize.Height;
552553 switch (e.Key)
553554 {
554555 case VirtualKey.Up:
@@ -576,12 +577,12 @@ namespace FooEditEngine.UWP
576577 isMovedCaret = true;
577578 break;
578579 case VirtualKey.PageUp:
579- this._Controller.Scroll(ScrollDirection.Up, this._View.LineCountOnScreen, isShiftPressed, true);
580+ this._Controller.ScrollByPixel(ScrollDirection.Up, alignedPage, isShiftPressed, true);
580581 this.Refresh();
581582 isMovedCaret = true;
582583 break;
583584 case VirtualKey.PageDown:
584- this._Controller.Scroll(ScrollDirection.Down, this._View.LineCountOnScreen, isShiftPressed, true);
585+ this._Controller.ScrollByPixel(ScrollDirection.Down, alignedPage, isShiftPressed, true);
585586 this.Refresh();
586587 isMovedCaret = true;
587588 break;
--- a/WPF/FooEditEngine/FooTextBox.cs
+++ b/WPF/FooEditEngine/FooTextBox.cs
@@ -724,6 +724,7 @@ namespace FooEditEngine.WPF
724724 }
725725
726726 bool movedCaret = false;
727+ double alignedPage = (int)(this.Render.TextArea.Height / this.Render.emSize.Height) * this.Render.emSize.Height;
727728 switch (e.Key)
728729 {
729730 case Key.Up:
@@ -751,12 +752,12 @@ namespace FooEditEngine.WPF
751752 movedCaret = true;
752753 break;
753754 case Key.PageUp:
754- this._Controller.Scroll(ScrollDirection.Up,this._View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
755+ this._Controller.ScrollByPixel(ScrollDirection.Up, alignedPage, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift), true);
755756 this.Refresh();
756757 movedCaret = true;
757758 break;
758759 case Key.PageDown:
759- this._Controller.Scroll(ScrollDirection.Down,this._View.LineCountOnScreen, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift),true);
760+ this._Controller.ScrollByPixel(ScrollDirection.Down, alignedPage, this.IsPressedModifierKey(modiferKeys, ModifierKeys.Shift), true);
760761 this.Refresh();
761762 movedCaret = true;
762763 break;
--- a/Windows/FooEditEngine/FooTextBox.cs
+++ b/Windows/FooEditEngine/FooTextBox.cs
@@ -1290,6 +1290,7 @@ namespace FooEditEngine.Windows
12901290 if (e.Handled)
12911291 return;
12921292
1293+ double alignedPage = (int)(this.render.TextArea.Height / this.render.emSize.Height) * this.render.emSize.Height;
12931294 switch (e.KeyCode)
12941295 {
12951296 case Keys.Up:
@@ -1309,11 +1310,11 @@ namespace FooEditEngine.Windows
13091310 this.Refresh();
13101311 break;
13111312 case Keys.PageUp:
1312- this.Controller.Scroll(ScrollDirection.Up, this.VScrollBar.LargeChange,e.Shift,true);
1313+ this.Controller.ScrollByPixel(ScrollDirection.Up, alignedPage,e.Shift,true);
13131314 this.Refresh();
13141315 break;
13151316 case Keys.PageDown:
1316- this.Controller.Scroll(ScrollDirection.Down, this.VScrollBar.LargeChange,e.Shift,true);
1317+ this.Controller.ScrollByPixel(ScrollDirection.Down, alignedPage, e.Shift, true);
13171318 this.Refresh();
13181319 break;
13191320 case Keys.Insert:
Show on old repository browser