Skip to main content
Roger.ch
Associate III
September 17, 2023
Solved

How can a container refresh a view/screen?

  • September 17, 2023
  • 3 replies
  • 1568 views

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

This topic has been closed for replies.
Best answer by Panchev68

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

3 replies

Tinnagit
Senior II
September 17, 2023

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.

Panchev68Best answer
Senior
September 18, 2023

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

Roger.ch
Roger.chAuthor
Associate III
September 18, 2023

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