cancel
Showing results for 
Search instead for 
Did you mean: 

How can a container refresh a view/screen?

Roger.ch
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Panchev68
Senior

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
View more

 

Screen

 

#include <gui/screen1_screen/Screen1View.hpp> Screen1View::Screen1View () { } void Screen1View::setupScreen () { Screen1ViewBase::setupScreen (); container1.bindInvalidateFunc ([this] { invalidate (); }); } void Screen1View::tearDownScreen () { Screen1ViewBase::tearDownScreen (); }

 

 

Greetings

View solution in original post

3 REPLIES 3
Tinnagit
Senior II

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.

Panchev68
Senior

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
View more

 

Screen

 

#include <gui/screen1_screen/Screen1View.hpp> Screen1View::Screen1View () { } void Screen1View::setupScreen () { Screen1ViewBase::setupScreen (); container1.bindInvalidateFunc ([this] { invalidate (); }); } void Screen1View::tearDownScreen () { Screen1ViewBase::tearDownScreen (); }

 

 

Greetings

Thank you very much Panchev.
This looks nice. Will test it tomorrow.
Best regards, Roger