cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to dynamically add GUI-Objects?

t.albrecht
Associate II

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!

13 REPLIES 13
Martin KJELDSEN
Chief III

Hi @t.albrecht​,

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

Martin KJELDSEN
Chief III

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.

t.albrecht
Associate II

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

Hi @t.albrecht​,

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

Thank you!

Best regards,

Martin

t.albrecht
Associate II

Hi, @Martin KJELDSEN​ 

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

Best regards,

Tillmann

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

Best regards,

Martin

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!

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

ALin
Associate II

@Martin KJELDSEN​ Thank you reply.

First, I wrote below declaration on header file ( Header Files/generated/gui_generated/main_screen)

  1. touchgfx::Circle circle2;
  2. touchgfx::PainterRGB565 circle2Painter;

and I typed definition of the object on the click button function (Source files/generated/gui_generated/main_screen)

  1. circle2.setPosition(309, 136, 90, 90);
  2. circle2.setCenter(45, 45);
  3. circle2.setRadius(40);
  4. circle2.setLineWidth(10);
  5. circle2.setArc(0, 280);
  6. circle2.setCapPrecision(180);
  7.  
  8. circle2Painter.setColor(touchgfx::Color::getColorFrom24BitRGB(255, 255, 255));
  9. circle2.setPainter(circle1Painter);
  10.  
  11. add(circle2);
  12. circle2.invalidate();

But ,after I clicked the button, the circle didn't show on the screen.

Can you teach me what process I may miss?

Thanks for you reply!