Revisión | 1ba70d8417ca5aa4f92347a6e36eba10b8a365f4 (tree) |
---|---|
Tiempo | 2021-01-08 00:34:39 |
Autor | test <test@yaho...> |
Commiter | test |
スクロールをピクセル単位で行うようにした
@@ -422,7 +422,6 @@ namespace FooEditEngine | ||
422 | 422 | this.SelectWithMoveCaret(isSelected); |
423 | 423 | } |
424 | 424 | |
425 | - double noti; | |
426 | 425 | /// <summary> |
427 | 426 | /// スクロールする |
428 | 427 | /// </summary> |
@@ -430,7 +429,7 @@ namespace FooEditEngine | ||
430 | 429 | /// <param name="delta">ピクセル単位の値でスクロール量を指定する</param> |
431 | 430 | /// <param name="isSelected">選択状態にするなら真</param> |
432 | 431 | /// <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) | |
434 | 433 | { |
435 | 434 | if (this.Document.FireUpdateEvent == false) |
436 | 435 | throw new InvalidOperationException(""); |
@@ -441,23 +440,20 @@ namespace FooEditEngine | ||
441 | 440 | return; |
442 | 441 | } |
443 | 442 | |
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) | |
445 | 448 | { |
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 | - | |
455 | 449 | this.View.TryScroll(0, delta); |
456 | 450 | } |
457 | 451 | |
458 | 452 | if (withCaret) |
459 | 453 | { |
460 | 454 | //カーソルを適切な位置に移動させる必要がある |
455 | + TextPoint tp = this.View.GetTextPointFromPostion(this.View.CaretLocation); | |
456 | + this.View.JumpCaret(tp.row, tp.col); | |
461 | 457 | this.View.AdjustCaretAndSrc(); |
462 | 458 | this.SelectWithMoveCaret(isSelected); |
463 | 459 | } |
@@ -549,6 +549,7 @@ namespace FooEditEngine.UWP | ||
549 | 549 | if (autocomplete != null && autocomplete.ProcessKeyDown(this, e, isControlPressed, isShiftPressed)) |
550 | 550 | return; |
551 | 551 | |
552 | + double alignedPage = (int)(this.Render.TextArea.Height / this.Render.emSize.Height) * this.Render.emSize.Height; | |
552 | 553 | switch (e.Key) |
553 | 554 | { |
554 | 555 | case VirtualKey.Up: |
@@ -576,12 +577,12 @@ namespace FooEditEngine.UWP | ||
576 | 577 | isMovedCaret = true; |
577 | 578 | break; |
578 | 579 | case VirtualKey.PageUp: |
579 | - this._Controller.Scroll(ScrollDirection.Up, this._View.LineCountOnScreen, isShiftPressed, true); | |
580 | + this._Controller.ScrollByPixel(ScrollDirection.Up, alignedPage, isShiftPressed, true); | |
580 | 581 | this.Refresh(); |
581 | 582 | isMovedCaret = true; |
582 | 583 | break; |
583 | 584 | case VirtualKey.PageDown: |
584 | - this._Controller.Scroll(ScrollDirection.Down, this._View.LineCountOnScreen, isShiftPressed, true); | |
585 | + this._Controller.ScrollByPixel(ScrollDirection.Down, alignedPage, isShiftPressed, true); | |
585 | 586 | this.Refresh(); |
586 | 587 | isMovedCaret = true; |
587 | 588 | break; |
@@ -724,6 +724,7 @@ namespace FooEditEngine.WPF | ||
724 | 724 | } |
725 | 725 | |
726 | 726 | bool movedCaret = false; |
727 | + double alignedPage = (int)(this.Render.TextArea.Height / this.Render.emSize.Height) * this.Render.emSize.Height; | |
727 | 728 | switch (e.Key) |
728 | 729 | { |
729 | 730 | case Key.Up: |
@@ -751,12 +752,12 @@ namespace FooEditEngine.WPF | ||
751 | 752 | movedCaret = true; |
752 | 753 | break; |
753 | 754 | 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); | |
755 | 756 | this.Refresh(); |
756 | 757 | movedCaret = true; |
757 | 758 | break; |
758 | 759 | 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); | |
760 | 761 | this.Refresh(); |
761 | 762 | movedCaret = true; |
762 | 763 | break; |
@@ -1290,6 +1290,7 @@ namespace FooEditEngine.Windows | ||
1290 | 1290 | if (e.Handled) |
1291 | 1291 | return; |
1292 | 1292 | |
1293 | + double alignedPage = (int)(this.render.TextArea.Height / this.render.emSize.Height) * this.render.emSize.Height; | |
1293 | 1294 | switch (e.KeyCode) |
1294 | 1295 | { |
1295 | 1296 | case Keys.Up: |
@@ -1309,11 +1310,11 @@ namespace FooEditEngine.Windows | ||
1309 | 1310 | this.Refresh(); |
1310 | 1311 | break; |
1311 | 1312 | 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); | |
1313 | 1314 | this.Refresh(); |
1314 | 1315 | break; |
1315 | 1316 | 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); | |
1317 | 1318 | this.Refresh(); |
1318 | 1319 | break; |
1319 | 1320 | case Keys.Insert: |