Scrolling

Post Reply
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Scrolling

Post by Ivan Denisov »

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.

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;
And in TextViews.

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;
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Scrolling

Post by luowy »

Issue report:
The procedure windows(StdTabViews.View) of The CamProcScan https://zinnamturm.eu/downloadsAC.htm#Cam scroll only one line after applying this patch, How to fix it?
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: Scrolling

Post by Ivan Denisov »

luowy wrote:Issue report:
The procedure windows(StdTabViews.View) of The CamProcScan https://zinnamturm.eu/downloadsAC.htm#Cam scroll only one line after applying this patch, How to fix it?
Can be fixed in HostCFrames: nofLines * 3

Code: Select all

	PROCEDURE (f: ListBox) WheelMove (x, y: INTEGER; op, nofLines: INTEGER; VAR done: BOOLEAN);
	BEGIN
		ASSERT(~f.disabled, 100);
		IF f.rider # NIL THEN
			HandleWheel(f.i.ctrl, x DIV f.unit, y DIV f.unit, op, nofLines * 3, done)
		END
	END WheelMove;
luowy
Posts: 87
Joined: Thu Dec 17, 2015 1:32 pm

Re: Scrolling

Post by luowy »

yes, that's it! the nofLines*3 of the ListBox.WheelMove solving the problem!
User avatar
Mobatec
Posts: 18
Joined: Thu Oct 11, 2018 3:20 pm

Re: Scrolling

Post by Mobatec »

Nice to learn that my code of 15 years back is also used by others :geek:

I still check out this forum and the Component Pascal Collection regularly for nice improvements to BlackBox. Unfortunately,I didn't have (make :oops: ) much time to make my own programs generic and share them with the community...
Post Reply