2019-12-11 12:32 AM
hi everyone.
I have a screen what has a many elements inside. Therfore, screen has very long kode that difficult to control. I want to group some of this code in another cpp files. This new cpp file should be like original screenView.cpp. I want to write code in this file for configurate widgets that in the screenbase. I should be access everything inside screenbase.hpp. Especially, I want to override action functions in screenbase.hpp with this file.
I create a new class that based on screenview class. I thought it would work but it didn't.
I'm pretty new at c++. Maybe this is too easy or impossible. I don't know. Forgive if i'm wrong. Thank you for answer already. :)
2019-12-11 01:32 AM
The way screens are structured in C++ code in TouchGFX is that you have your Base class generated by the designer, and then a class in the gui/ folder that inherits from this generated class. This allows you to use the designer to generate _some_ code and let's you do the test.
Does that answer your question?
/Martin
2019-12-11 04:29 AM
Hi @Martin KJELDSEN
I couldn't explain myself well. I already using actual class under gui/ folder. I want a new cpp file under gui folder for use like view.cpp. I will try to explain myself with code.
I create a screen named screen. This screen has a button with action and a text.
Here is base file under generated/ for this screen;
/*********** Base.hpp file ***********/
class screenViewBase : public touchgfx::View<screenPresenter>
{
public:
screenViewBase();
virtual ~screenViewBase() {}
virtual void setupScreen();
/*
* Virtual Action Handlers
*/
virtual void buttonPres()
{
// Override and implement this function in screen
}
protected:
touchgfx::ButtonWithLabel Button;
touchgfx::TextArea textArea;
}
Here is view file under gui/ for this screen;
/*********** view.hpp file ***********/
class screenView : public screenViewBase
{
public:
screenView();
virtual ~screenView() {}
virtual void setupScreen();
/*
* Virtual Action Handlers
*/
virtual void buttonPres()
{
}
protected:
}
Here is a file what I want to create under gui/ for this screen;
/*********** new.hpp file ***********/
class testNew: public screenView
{
public:
testNew();
virtual ~testNew() {}
/*
* Virtual Action Handlers
*/
void buttonPres()
{
textArea.setVisible(true);
textArea.invalidate();
}
protected:
}
This is what I want to do. I hope this explains well the situation.
2019-12-11 09:33 PM
hi @Martin KJELDSEN
Is there any clue you can give about that? I am trying several things but there is any solution yet.
2019-12-12 06:23 AM
I may not be understanding you correctly, but I have added files in the screen1_screen folder (or whatever you name your screen in the designer) and it compiled.
I have also added files in the gui/common folder and it has compiled and worked well.
Are you placing the hpp files in the "include" section and the cpp files in the src section?
2019-12-12 06:28 AM
It's not what I want to do. I want to split view file for improve code readability.