Skip to main content
ferro
Lead
Nov 27, 2024 4:09 PM UTC
Solved

Even though gfx::Box position set outside of a screen, it is still visible

Hi,

Attached project starts with this screen:

ferro_1-1732723422268.png

 

When the white Box is moved to the left - with pressing 'a' key, it should completely go off the screen. However, one pixel thick line is always visible.

box1.setX ( box1.getX () - 1 );
box1.invalidate ();

ferro_0-1732723227217.png

Why ?

Thank you

This topic has been closed for replies.
LouisBBest answer
ST Employee
Nov 28, 2024 1:05 PM UTC

Hello @ferro,

 

Try to put an invalidate before "box1.setX ( box1.getX () - 1 );".

With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that.

Best regards,

Louis BOUDOST Software Engineer | TouchGFX

4 replies

LouisBBest answer
ST Employee
Nov 28, 2024 1:05 PM UTC

Hello @ferro,

 

Try to put an invalidate before "box1.setX ( box1.getX () - 1 );".

With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that.

Best regards,

Louis BOUDOST Software Engineer | TouchGFX
ferro
ferroAuthor
Lead
Nov 28, 2024 2:33 PM UTC

Thanks @LouisB 

Interesting, in all Gfx examples - i've seen so far - invalidate is placed after all actions on widgets.

So this works as expected now, with a single 'invalidate ()' before:

 

box1.invalidate ();
box1.setX ( box1.getX () - 1 );

 

 

"With only one invalidate at the end, it will only invalidate the area in the new position, so the line outside will not be refreshed. Also if you move your box in the screen you may have a (w+1) * h box due to that."

Thank you for this, will explore further.

ST Employee
Dec 2, 2024 10:30 AM UTC

Hello @ferro ,

You have to put the 2 invalidates, otherwise you will have unexpected behavior, try with (box1.getX()-100), you will see the unexpected behavior better.

Best regards,

Louis BOUDOST Software Engineer | TouchGFX