Scrolling
Posted: Fri Aug 02, 2019 4:28 pm
BlackBox TextView scrolling made bad in the way, that it updates TextView three times for each mouse wheel tick.
This can be fixed in HostWindows.
And in TextViews.
This can be fixed in HostWindows.
Code: Select all
diff --git a/BlackBox/_Windows_GUI/Host/Mod/Windows.odc b/BlackBox/_Windows_GUI/Host/Mod/Windows.odc
index e67a835..cea3000 100644
--- a/BlackBox/_Windows_GUI/Host/Mod/Windows.odc
+++ b/BlackBox/_Windows_GUI/Host/Mod/Windows.odc
@@ -1241,8 +1241,11 @@ MODULE HostWindows;
BEGIN
delta := wParam DIV 10000H; keys := wParam MOD 10000H;
w := ThisWindow(wnd);
- lines := 3;
+
+ lines := 1;
+ (*
res := WinApi.SystemParametersInfoW(104 (*SPI_GETWHEELSCROLLLINES*), 0, SYSTEM.ADR(lines), 0);
+ *)
p.x := lParam MOD 65536; p.y := lParam DIV 65536;
res := WinApi.ScreenToClient(wnd, p);
msg.x := p.x * w.port.unit; msg.y := p.y * w.port.unit;
Code: Select all
diff --git a/BlackBox/Text/Mod/Views.odc b/BlackBox/Text/Mod/Views.odc
index dcd18eb..1f71b85 100644
--- a/BlackBox/Text/Mod/Views.odc
+++ b/BlackBox/Text/Mod/Views.odc
@@ -10,6 +10,7 @@ MODULE TextViews;
- 20070820, bh, TextSetters.Reader.sString, cache.short, cache.sbuf, & CacheSString eliminated
- 20150610, center #60, underlining white space
+ - 20190721, Anton Dmitriev & Ivan Denisov, scrolling by 3 steps
##<="
issues = "##=>
@@ -37,8 +38,7 @@ MODULE TextViews;
mm = Ports.mm; inch16 = Ports.inch DIV 16; point = Ports.point;
maxScrollHeight = 16 * point; maxScrollSteps = 100; fuseScrollHeight = maxScrollHeight DIV 2;
maxHeight = maxScrollHeight * maxScrollSteps;
- adjustMask = {TextRulers.leftAdjust, TextRulers.rightAdjust};
-
+
(* SetOp.mode *)
setMarks = 0; setSetter = 1; setDefs = 2;
@@ -769,7 +769,7 @@ MODULE TextViews;
PROCEDURE Scroll (v: StdView; f: Views.Frame; VAR msg: Controllers.ScrollMsg);
VAR st: TextSetters.Setter; box, box0: TextSetters.LineBox;
- t, t1, trailer: Line; org, len, dy, h, h1, sh, steps, step: INTEGER;
+ t, t1, trailer: Line; org, len, dy, h, h1, sh, steps, step, i: INTEGER;
poll: Controllers.PollSectionMsg;
BEGIN
IF msg.vertical THEN
@@ -780,26 +780,35 @@ MODULE TextViews;
org := v.org; dy := v.dy; st := v.ThisSetter(); trailer := v.trailer;
CASE msg.op OF
Controllers.decLine:
- IF dy <= -(maxScrollHeight + fuseScrollHeight) THEN
- INC(dy, maxScrollHeight)
- ELSIF dy < 0 THEN
- dy := 0
- ELSIF org > 0 THEN
- org := st.PreviousLine(org); st.GetLine(org, box);
- h1 := box.asc + box.dsc + st.GridOffset(-1, box);
- IF h1 > maxScrollHeight + fuseScrollHeight THEN
- sh := h1 - h1 MOD maxScrollHeight;
- IF h1 - sh < fuseScrollHeight THEN DEC(sh, maxScrollHeight) END;
- dy := -sh
- ELSE dy := 0
+ FOR i := 1 TO 3 DO
+ IF dy <= -(maxScrollHeight + fuseScrollHeight) THEN
+ INC(dy, maxScrollHeight)
+ ELSIF dy < 0 THEN
+ dy := 0
+ ELSIF org > 0 THEN
+ org := st.PreviousLine(org);
+ st.GetLine(org, box);
+ h1 := box.asc + box.dsc + st.GridOffset(-1, box);
+ IF h1 > maxScrollHeight + fuseScrollHeight THEN
+ sh := h1 - h1 MOD maxScrollHeight;
+ IF h1 - sh < fuseScrollHeight THEN DEC(sh, maxScrollHeight) END;
+ dy := -sh
+ ELSE dy := 0
+ END
END
END
| Controllers.incLine:
t := trailer.next;
- IF t.h + dy > maxScrollHeight + fuseScrollHeight THEN
- DEC(dy, maxScrollHeight)
- ELSIF ~t.box.eot THEN
- org := t.next.start; dy := 0
+ FOR i := 1 TO 3 DO
+ IF t.h + dy > maxScrollHeight + fuseScrollHeight THEN
+ DEC(dy, maxScrollHeight)
+ ELSIF ~t.box.eot THEN
+ IF t.next # NIL THEN
+ org := t.next.start;
+ dy := 0;
+ t := t.next
+ END
+ END
END
| Controllers.decPage:
sh := f.b; DEC(sh, maxScrollHeight + sh MOD maxScrollHeight);
@@ -1568,7 +1577,7 @@ MODULE TextViews;
(* StdDirectory *)
PROCEDURE (d: StdDirectory) New (text: TextModels.Model): View;
- VAR v: StdView; c: Controllers.Controller; r: TextRulers.Ruler;
+ VAR v: StdView; r: TextRulers.Ruler;
BEGIN
r := TextRulers.dir.New(NIL);
IF text = NIL THEN text := TextModels.dir.New() END;