2023-09-17 02:47 AM
I have a container with a switch on my screen. On the screen there are about 20 other containers that should change their appearance depending on the switch in the first container. How can I refresh a whole screen with all elements from one container?
Best regards, Roger
Solved! Go to Solution.
2023-09-18 02:48 AM - edited 2023-09-18 03:23 AM
I would do it that way
Container
#ifndef CONTAINER1_HPP
#define CONTAINER1_HPP
#include <functional>
#include <gui_generated/containers/Container1Base.hpp>
class Container1 : public Container1Base
{
public:
Container1 ();
virtual ~Container1 () {}
virtual void initialize ();
void bindInvalidateFunc (const std::function<void ()> & fn)
{
_invalidate = fn;
}
/// \brief Invalidate Screen
void emitInvalidateScreen ()
{
if (_invalidate != nullptr) _invalidate ();
}
protected:
private:
std::function<void ()> _invalidate;
};
#endif // CONTAINER1_HPP
Screen
#include <gui/screen1_screen/Screen1View.hpp>
Screen1View::Screen1View ()
{
}
void Screen1View::setupScreen ()
{
Screen1ViewBase::setupScreen ();
container1.bindInvalidateFunc ([this] { invalidate (); });
}
void Screen1View::tearDownScreen ()
{
Screen1ViewBase::tearDownScreen ();
}
Greetings
2023-09-17 05:08 AM
I think that it's not some function to do it directly but you can recall that page again. it's like as change page but the destination is own page.
2023-09-18 02:48 AM - edited 2023-09-18 03:23 AM
I would do it that way
Container
#ifndef CONTAINER1_HPP
#define CONTAINER1_HPP
#include <functional>
#include <gui_generated/containers/Container1Base.hpp>
class Container1 : public Container1Base
{
public:
Container1 ();
virtual ~Container1 () {}
virtual void initialize ();
void bindInvalidateFunc (const std::function<void ()> & fn)
{
_invalidate = fn;
}
/// \brief Invalidate Screen
void emitInvalidateScreen ()
{
if (_invalidate != nullptr) _invalidate ();
}
protected:
private:
std::function<void ()> _invalidate;
};
#endif // CONTAINER1_HPP
Screen
#include <gui/screen1_screen/Screen1View.hpp>
Screen1View::Screen1View ()
{
}
void Screen1View::setupScreen ()
{
Screen1ViewBase::setupScreen ();
container1.bindInvalidateFunc ([this] { invalidate (); });
}
void Screen1View::tearDownScreen ()
{
Screen1ViewBase::tearDownScreen ();
}
Greetings
2023-09-18 01:18 PM
Thank you very much Panchev.
This looks nice. Will test it tomorrow.
Best regards, Roger