Skip to main content
t.albrecht
Associate
March 13, 2019
Question

Is it possible to dynamically add GUI-Objects?

  • March 13, 2019
  • 13 replies
  • 3671 views

Hi folks,

I'm trying to add a set of objects (in this case: a circle) to the GUI, as soon as the user presses a button. Therefore, I'm trying to execute the following code on the button press:

touchgfx::Circle circle2;
touchgfx::PainterRGB565 circle2Painter;
 
circle2.setPosition(309, 136, 90, 90);
circle2.setCenter(45, 45);
circle2.setRadius(40);
circle2.setLineWidth(10);
circle2.setArc(0, 280);
circle2.setCapPrecision(180);
 
circle2Painter.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
circle2.setPainter(circle1Painter);
 
add(circle2);
circle2.invalidate();

As soon as the button is pressed, the system won't react anymore. The "clicked_button" bitmap is displayed, nothing else happens.

What am I missing out? Is it actually possible to add GUI-objects at runtime? Is the buffer to small?

Thanks for your help!

This topic has been closed for replies.

13 replies

Martin KJELDSEN
Principal III
April 3, 2019

Hi @t.albrecht​,

Are you still having this problem? Did you try increasing the size of the buffer?

Martin KJELDSEN
Principal III
April 3, 2019

And it's possible to add objects at runtime as long as they are statically allocated (default). TouchGFX measures the size of your View/Presenter and will reuse that memory for other screens. Move the declaration of circle2 to your headerfile, the definition to setupScreen() of your view and then add it on button click.

Let me know.

ALin
Associate
August 1, 2019

Hello@Martin KJELDSEN

I had the same question, and I adopted the method you proposed. I wrote the declaration of circle on headerfile, and the definition on the function of button click. But I clicked the button, the circle didn't show on the screen.

What am I missing out. Are there other methods to add GUI-objects at runtime?

Thanks for you reply!

Martin KJELDSEN
Principal III
August 5, 2019

Can you show me the code? Maybe you didn't invalidate the area covered by the Circle.

t.albrecht
Associate
April 3, 2019

Hi @Martin KJELDSEN​ ,

thank you for your answer.

In the meantime, we have resigned from using TouchGFX for our work, as we faced too many hurdles on the way of our specific project.

With kind regards,

Tillmann Albrecht

Martin KJELDSEN
Principal III
April 3, 2019

Hi @t.albrecht​,

Sorry to hear that. Are you interested in sharing some of those hurdles?

Thank you!

Best regards,

Martin

t.albrecht
Associate
April 3, 2019

Hi, @Martin KJELDSEN​ 

sorry again, but unfortunately, I can't do that, as this is a confidential project of our customer.

Best regards,

Tillmann

Martin KJELDSEN
Principal III
April 3, 2019

I understand. Good luck :) Let me know if there's anything you need help with.

Best regards,

Martin

ari_v2
Senior
October 3, 2021

Hi,

I'm using TouchGFX 4.17. Since 3 years passed from this discussion I would like to ask again:

Is it possible to to add objects at runtime, dynamically using the heap, or they must be statically allocated at compile time?

Thank you,

Ari

Romain DIELEMAN
ST Employee
October 4, 2021

Hi,

They still must be statically allocated at compile time so you must know/guess the max amount of element you could add at runtime.

/Romain

ari_v2
Senior
October 5, 2021

Thanks