2019-03-28 06:13 AM
Hello all,
I am trying to switch the screen throuch code in touchgfx.
If I use SwitchScreen, how shall I state the argument (screen* newScreen)?
If, for example I want to switch to Screen7.
Shall I call the function with SwitchScreen(scr7)?
where scr7 is declared as follows:
ScreenView7 scr7;
Solved! Go to Solution.
2019-09-05 11:27 PM
Hi @HP,
Yes, this is the way you transition to other screens. Using the designer, they're generated for you when you have a "change screen" interaction defined. Here's an example - From screen 2 i defined an interaction to go to screen1 with NO special transition animation. The possibilibies are:
This interaction will cause the following methods to be generated:
/*
* Screen Transition Declarations
*/
// Screen1
void FrontendApplicationBase::gotoScreen1ScreenNoTransition()
{
transitionCallback = touchgfx::Callback<FrontendApplicationBase>(this, &FrontendApplication::gotoScreen1ScreenNoTransitionImpl);
pendingScreenTransitionCallback = &transitionCallback;
}
void FrontendApplicationBase::gotoScreen1ScreenNoTransitionImpl()
{
makeTransition<Screen1View, Screen1Presenter, touchgfx::NoTransition, Model >(¤tScreen, ¤tPresenter, frontendHeap, ¤tTransition, &model);
}
If you'd chosen another transition then the methods and arguments would be different. If you want to transition to a screen programatically, e.g. if you get a certain message from the backend, you will call it like in the code in the previous post:
static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen1ScreenNoTransition();
The methods generated by the designer are in gui_generated/src/common/FrontEndApplicationBase.cpp
You can add your own, manually, in gui/src/common/FrontEndApplication.cpp
/Martin
2019-03-28 06:25 AM
Hi,
Just use the generated goto methods:
e.g. you may define a method void gotoScreen() that takes some enum, switch on the argument value to transition to a screen (Depending on the screen transition you will have goto methods with or without transitions):
void BasePresenter::gotoScreen(ScreenType _type)
{
...
case SETTINGS:
static_cast<FrontendApplication*>(Application::getInstance())->gotoSettingsScreen();
break;
...
}
Does that make sense?
2019-03-28 10:12 PM
Yes, definitely. Thank you very much for the prompt response.
But, the parameters on which I have to decide whether to switch to a new screen or not depend wholly on code.
So, in the designer, I cant decide when to switch the screen.
Thats the reason, I wont be able to use the generated code, from thre designer.
Can you please tell me another alternativethan using the generated goto method?
2019-04-02 12:28 AM
There is a "problem" right now where you will not have your goto methods generated if you don't have an interaction to do so specified. You can get some inspiration from how to the designer generates gotomethods and define them yourself in your concrete user code version of FrontEndApplication ( Check out FrontEndApplicationBase in a project with a screen transition).
Once you have those, you can use the method i mentioned above.
/Martin
2019-09-05 08:39 AM
Sorry for bringing this thread back to life..
Is this still the preferred way to change screens or is there another way?
I must admit that I'm not all that familiar with those goto methods - where are they located?
I too need a way to programatically change the screen withouth button presses.
2019-09-05 11:27 PM
Hi @HP,
Yes, this is the way you transition to other screens. Using the designer, they're generated for you when you have a "change screen" interaction defined. Here's an example - From screen 2 i defined an interaction to go to screen1 with NO special transition animation. The possibilibies are:
This interaction will cause the following methods to be generated:
/*
* Screen Transition Declarations
*/
// Screen1
void FrontendApplicationBase::gotoScreen1ScreenNoTransition()
{
transitionCallback = touchgfx::Callback<FrontendApplicationBase>(this, &FrontendApplication::gotoScreen1ScreenNoTransitionImpl);
pendingScreenTransitionCallback = &transitionCallback;
}
void FrontendApplicationBase::gotoScreen1ScreenNoTransitionImpl()
{
makeTransition<Screen1View, Screen1Presenter, touchgfx::NoTransition, Model >(¤tScreen, ¤tPresenter, frontendHeap, ¤tTransition, &model);
}
If you'd chosen another transition then the methods and arguments would be different. If you want to transition to a screen programatically, e.g. if you get a certain message from the backend, you will call it like in the code in the previous post:
static_cast<FrontendApplication*>(Application::getInstance())->gotoScreen1ScreenNoTransition();
The methods generated by the designer are in gui_generated/src/common/FrontEndApplicationBase.cpp
You can add your own, manually, in gui/src/common/FrontEndApplication.cpp
/Martin
2019-09-05 11:54 PM
Great, thanks for the pointers!
2019-09-06 01:53 AM
No problem!
/Martin
2020-02-06 11:25 AM
Can someone please help with providing a better example of creating custom methods that were not created by designer?
I need to enter a screen when a user presses a hardware button.
2020-02-12 10:19 PM
For me while screen transition, drag I can see, completely first screen is not going, when second screen comes . What to do to resolve this