2025-01-04 04:38 PM
Hi,
I have a container with buttons, images and text (around 30).
I would like to change the alpha from 255 to 128 of each widget inside the container.
On the documentation, it says it it possible with container with FadeAnimator in Mixins :
but I think it is a mistake in the documentation.
So, without this feature, what is the best way to change all the alpha value of each widget in a container ?
If the function forEachChild (https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_container#function-foreachchild) is recommended, can I have a link of an exemple program using this function or a zip file with a test program with this feature ?
Regards,
Sébastien
2025-01-04 10:32 PM - edited 2025-01-04 10:49 PM
Hi @COSEBE ,
Step 1
class DoThisToEveryChild : public GenericCallback< Drawable & > { virtual void execute ( Drawable & d ) override final { // user code here e.g. // d.setVisible ( false ); } virtual bool isValid () const override final { return true; } };
Step 2
DoThisToEveryChild doThis {}; // now 'DoThisToEveryChild::execute ()' will be called for every child ticks.forEachChild ( & doThis );
2025-01-05 03:35 AM
Hi ferro,
Thank you for your answer, but I already see your 2-step code in the community, but I still do not understand, because I am not professional in C++.
I do not understand where to put the step 1 code, what is "override final", what is the goal of isValid method.
In step 2 code, where ticks come from ? is it the refresh tick ? if I want to change Alpha on each widget in container, I have to call myContainer.forEachChild(& doThis); ?
Do we absolutely have to create a new class to use this function ?
2025-01-05 04:40 AM
"what is "override final", what is the goal of isValid method"
Have a look into \touchgfx\Callback.hpp
https://stackoverflow.com/questions/29412412/does-final-imply-override
"I do not understand where to put the step 1 code."
Sorry about my previous confusing reply. Example attached using forEachChild(). But only Y position of all children of container is changing.
I see that setAlpha() is not member of Drawable. Hm.. Not sure what to do now. Seems you need to set alpha for each button individually.
"Do we absolutely have to create a new class to use this function ?"
I think so, yes.