Hi,
I am trying to redraw component with the below code, what am I doing wrong.
void main_screen_Action_OnClick_Button1()
{
main_screen.Label1 -> text.caption = "Hello World";
vtft_draw_component(_vtft, (vtft_component*)(&main_screen.Label1));
}
Trying to update Label
Re: Trying to update Label
fixed
vtft_draw_component(_vtft, (vtft_component*)(&main_screen.Label1));
changed to this
vtft_draw_component(_vtft, (vtft_component*)(main_screen.Label1));
How is a label cleared?
vtft_draw_component(_vtft, (vtft_component*)(&main_screen.Label1));
changed to this
vtft_draw_component(_vtft, (vtft_component*)(main_screen.Label1));
How is a label cleared?
Re: Trying to update Label
Not trying to resurrect a dead post, but, did you ever find an answer to this question Addiction (be it yourself or through a support ticket)? I am also trying to solve this exact same problem with my own application lol - I am currently having to refresh the screen with a vtft_refresh_current_screen() function call in order to accomplish that, but it's kind of a half-measure since it's redrawing the -entire- screen which is not desirable for my app's intended usage.
Re: Trying to update Label
For those interested, the way I am working around this is by drawing a box underneath my label - whenever I want to update my Label, I am drawing a box on top of the obsolete label.
Example:
vtft_draw_component(&vtft, xyz_screen.XBox);
vtft_draw_component(&vtft, xyz_screen.X);
Where XBox is my box for my X value, and X is my label. I do this for each Label I want to update.
Otherwise, I am calling...
vtft_refresh_current_screen(&vtft)
...every time I want to refresh the screen. Keep in mind this redraws the ENTIRE screen and ALL of its components - very slow, noticeably slower than just drawing smaller rectangles essentially over obsolete Labels. Couldn't find a way to just arbitrarily, dynamically change an already drawn label.
Hope this helps whoever else is running into this issue.
Example:
vtft_draw_component(&vtft, xyz_screen.XBox);
vtft_draw_component(&vtft, xyz_screen.X);
Where XBox is my box for my X value, and X is my label. I do this for each Label I want to update.
Otherwise, I am calling...
vtft_refresh_current_screen(&vtft)
...every time I want to refresh the screen. Keep in mind this redraws the ENTIRE screen and ALL of its components - very slow, noticeably slower than just drawing smaller rectangles essentially over obsolete Labels. Couldn't find a way to just arbitrarily, dynamically change an already drawn label.
Hope this helps whoever else is running into this issue.
Re: Trying to update Label
...Also important to note that for the above solution to work, in your scr_<my_screen>.h file, make sure that whatever you are redrawing via vtft_draw_component() is NOT a const variable.
Re: Trying to update Label
Hi,
You can also do something like this for example :
Be sure to include gl.h in your source file.
Regards,
Filip.
You can also do something like this for example :
Code: Select all
gl_set_brush_style(GL_BRUSH_STYLE_FILL);
gl_set_brush_color(main_screen.screen_data->color);
gl_set_pen(GL_BLACK,0);
gl_draw_rect(620,350,120,90);
vtft_draw_component(_vtft,(vtft_component *)main_screen.Label2);
Regards,
Filip.
Re: Trying to update Label
Just want to be sure how this is working...
Does drawing a black rectangle over a label just update a section of the current "canvas"?
This doesn't mean that in the background I'm creating unseen children in the background every time I do this that will take up more and more memory and never be deleted?
Thanks
Does drawing a black rectangle over a label just update a section of the current "canvas"?
This doesn't mean that in the background I'm creating unseen children in the background every time I do this that will take up more and more memory and never be deleted?
Thanks
Re: Trying to update Label
Hi,
The code will simply draw a filled rectangle over a desired label.
Regards,
Filip.
The code will simply draw a filled rectangle over a desired label.
Regards,
Filip.
-
- Posts: 17
- Joined: 27 Jan 2022 08:15
Re: Trying to update Label
Works, as it updates to new label, but leaves both old and new label intertwined on screen. So you have to do the vtft_refresh_current_screen(_vtft); anyway. Am I missing something?filip wrote: ↑25 Feb 2021 13:54Hi,
You can also do something like this for example :Be sure to include gl.h in your source file.Code: Select all
gl_set_brush_style(GL_BRUSH_STYLE_FILL); gl_set_brush_color(main_screen.screen_data->color); gl_set_pen(GL_BLACK,0); gl_draw_rect(620,350,120,90); vtft_draw_component(_vtft,(vtft_component *)main_screen.Label2);
Regards,
Filip.
Re: Trying to update Label
Hi,
For now this is the only way.
Regards,
Filip.
For now this is the only way.
Regards,
Filip.