I'm evaluating the TouchGFX tool additional to the STM32-Platform. Everything works "fine", like the interaction with some hardware resources of the STM32F746G-Discovery board, but there is another issue.
I created a custom keyboard (as seen as in the TouchGFX examples), but even before I enter the last Screen, where it should be visible, it appears on the screen before. I checked the View.hpp/.cpp and ViewBase.hpp/.cpp of both screens and I don't know why it is as it is.
Screen3View.hpp (Where the keyboard should be visible)
#ifndef SCREEN3VIEW_HPP
#define SCREEN3VIEW_HPP
#include <gui_generated/screen3_screen/Screen3ViewBase.hpp>
#include <gui/screen3_screen/Screen3Presenter.hpp>
#include <gui_generated/screen3_screen/Screen3ViewBase.hpp>
#include <gui/screen3_screen/Screen3Presenter.hpp>
#include <gui/common/CustomKeyboard.hpp>
#include <touchgfx/widgets/ButtonWithLabel.hpp>
class Screen3View : public Screen3ViewBase
{
public:
Screen3View();
virtual ~Screen3View() {}
virtual void setupScreen();
virtual void tearDownScreen();
protected:
CustomKeyboard keyboard;
};
#endif // SCREEN3VIEW_HPP
Screen3View.cpp
Screen3View::Screen3View()
{
keyboard.setPosition(16, 16, 400, 240);
add(keyboard);
}
Screen4View.hpp (where the keyboard should not be visible)
#ifndef SCREEN4VIEW_HPP
#define SCREEN4VIEW_HPP
#include <gui_generated/screen4_screen/Screen4ViewBase.hpp>
#include <gui/screen4_screen/Screen4Presenter.hpp>
class Screen4View : public Screen4ViewBase
{
public:
Screen4View();
virtual ~Screen4View() {}
virtual void setupScreen();
virtual void tearDownScreen();
protected:
};
#endif // SCREEN4VIEW_HPP
Screen4View.cpp
Screen4View::Screen4View()
{
}
all other.cpp of the TouchGFX files "say" the exact same thing. Just Screen 3 should have this keyboard, and not Screen 4 too.
So if anybody has an idea why it is like that please answer. :)
Thank you very much.
When you "switch screens" in a TouchGFX application this new frame will be rendered to some framebuffer memory (the complexity of running a simulator vs target hardware with multiple framebuffers is irrelevant when it comes to explaining what you're seeing).
When you activate a screen that renders nothing (like Screen4 since it has no widgets) you're basically staring at the state of the framebuffer left by the previous frame (which was Screen3 with the Keyboard). Imagine if Screen4 was the first thing you were trying to render - Then you would just see garbage/uninitialized memory.
This is why you're seeing a Keyboard, even if it is not even a part of Screen4. Add a box to Screen4 covering the full dimensions of the canvas and you won't see the previous framebuffer state anymore. This would be the same for any widget.
If you compare the glass of the LCD to a window in your house, by adding a box you're basically closing the blinds to that window, now unable to see the "Keyboard" just on the other side.