Tree View routine

Discussions related to mouse, keyboard and Graphical User Interface
svein
Posts: 21
Joined: Tue 03 Apr 2018, 19:34

Re: Tree View routine

Post by svein » Sun 30 Dec 2018, 18:12

Thank you p_m for testing.
You are correct in that i was not fully aware of these issues.
If you or others are interested, the jerky mouse pointer was caused by spamming the system with MOUSE ON messages.
BBC4W is forgiving, but not BBCsdl.
And after a window resize, issuing a new VDU 23,22... is ok in BBC4W but BBCsdl behaves differently.

Unless you used a very large rpt. file and/or an oldish cpu,
my guess is that the 3 minute delay at start is probably caused by this loop:

Code: Select all

DEF PROCparcefile
...
REPEAT
 text$=GET$#F%
UNTIL text$<>""
where the last line should have been:

Code: Select all

UNTIL text$<>"" OR EOF#F%
It was working in windows, but maybe not in Linux.

Lesson learned: when writing for BBCsdl, use BBCsdl and not BBC4W !
:
:
Richard:
<it's the font that determines the metrics rather than the other way around>
<it's important from an 'accessibility' viewpoint that there is some way of making it larger if the user has poor eyesight>
Ok, i'll make scaling possible. Found a few shortcuts and bad code decisions.

Svein

guest
Posts: 268
Joined: Mon 02 Apr 2018, 09:12

Re: Tree View routine

Post by guest » Mon 31 Dec 2018, 00:09

svein wrote:
Sun 30 Dec 2018, 18:12
VDU 23,22... is ok in BBC4W but BBCsdl behaves differently.
BBCSDL sets the SDL_WINDOWPOS_CENTERED flag. Whether it should I don't know, but it always has!

Code: Select all

REPEAT
 text$=GET$#F%
UNTIL text$<>""
It was working in windows, but maybe not in Linux.
GET$#F% (on all platforms) should return an empty string at EOF, and if it's not doing so it's a bug. Checking EOF# is 'good practice' but it should definitely not be essential, and it does add an overhead that will slow execution slightly. How sure are you that this really is happening? I can't see anything in the code that could explain it.

svein
Posts: 21
Joined: Tue 03 Apr 2018, 19:34

Re: Tree View routine

Post by svein » Mon 31 Dec 2018, 01:11

Not sure at all, guessing.
Hard to explain otherwise.

When code is not doing what is expected and GET$# is involved, i always get a mental warning flag based on previous experience.
Usually i have made a mistake, but sometimes the fault can not be explained. Adding an EOF# usually helps, if i remember correctly.
I also think the odd fault only happen to me when the file format/content was completely unknown.
And i think i at some point speculated if it was possible to 'miss' the EOF# and continue reading until the operating system stopped it.
I don't think i tested it, sounds a bit 'implausible'.

Can't test Linux at the moment, and especially not Debian, hence the guessing.

Svein

svein
Posts: 21
Joined: Tue 03 Apr 2018, 19:34

Re: Tree View routine

Post by svein » Wed 09 Jan 2019, 12:11

Status update:
Testing the program as in i presume would be the real case.
New bugs found and corrected, except one or maybe two. (slightly difficult ones)

Question: BBCsdl
Is it possible that one need to perform some 'thread synchronisation' in other cases than reading the system variables ?

Reason for asking:
I wanted to speed up the process of finding a strings width, and found 'TTF_SizeText' to be way faster than
MOVE 0,0:PRINT a$.
ie:

Code: Select all

W%=1 : SYS "TTF_SizeText",Font%,a$,^W%,^H% TO E%
IF E%<0 THEN SYS "SDL_GetError" TO E% : ERROR 0,$$E%
=W%*Scale 
vs:

Code: Select all

MOVE 0,0:PRINT a$;
IF POS
=@vdu.l.x%*2
The width returned from 'TTF_SizeText' need to be scaled to be correct.
In order to get the scale factor i measure a fixed string (once) by both methods, and divide one by the other.

And here comes the problem:
The following code will occasionally give the 'glyph not found' error.

Code: Select all

MOVE 0,0:PRINT a$;
W%=1 : SYS "TTF_SizeText",Font%,a$,^W%,^H% TO E%
IF E%<0 THEN SYS "SDL_GetError" TO E% : ERROR 0,$$E%
IF POS
Scale=@vdu.l.x%/W%*2
Whereas moving PRINT to after 'TTF_SizeText' has not yet given any errors.

Code: Select all

W%=1 : SYS "TTF_SizeText",Font%,a$,^W%,^H% TO E%
IF E%<0 THEN SYS "SDL_GetError" TO E% : ERROR 0,$$E%
MOVE 0,0:PRINT a$;
IF POS
Scale=@vdu.l.x%/W%*2
Just tested now to move IF POS, and it's working, but inserting dummy=0 does not.

Code: Select all

MOVE 0,0:PRINT a$;
IF POS REM dummy=0 does not work
W%=1 : SYS "TTF_SizeText",Font%,a$,^W%,^H% TO E%
IF E%<0 THEN SYS "SDL_GetError" TO E% : ERROR 0,$$E%
Scale=@vdu.l.x%/W%*2
So, multi-thread issue ?
If yes, where else do we need to consider this potential problem ?

Btw: starting to like BBCsdl more and more, despite this :)
Svein

Post Reply