Implementing a splash screen

48 views
asked Jan 4 in Embedded Wizard Studio by ezed413

How do I implement a splash screen for a few seconds. I am trying to do it with a timer from a method in the main application but it's not working. Here is a code snippet.

 

var Core::Group mainscreen = new Application::MainScreen;
var Core::Group Splash = new Application::splashScreen;

PresentDialog( Splash, null, null, FadeOut, null, null, null, null, null, false );
splashTimer.Enabled = true;
while( TimesUp == false );
splashTimer.Enabled = true;
TimesUp = false;
DismissDialog( Splash, null, null, null, null, null, false );

PresentDialog( mainscreen, null, null, FadeOut, null, null, null, null, null, false );

 

1 Answer

0 votes
answered Jan 5 by Paul Banach

Hello,

the while-loop in your implementation will not work. It results in an endless loop. Even if you have started the timer before, the GUI application will not process any timer events as long as it processes the loop. You will need to split the code in two parts. Try following:

1. Ensure, that the already existing splashTimer is configured with properties Enabled=false, Period=0, Begin=<delay to hide the splash screen in ms>

2. Add a new slot method to your GUI component. Name it e.g. onTimer.

3. Connect the slot method to your already existing splashTimer.

4. Within the onTimer slot method put following part of your original implementation:

// Determine the previously presented splash dialog
var Core::Group theCurrentDialog = FindCurrentDialog();

// Hide it ...
DismissDialog( theCurrentDialog, null, null, null, null, null, false );

// Create the main screen dialog
var Core::Group mainscreen = new Application::MainScreen;

// ... and present it
PresentDialog( mainscreen, null, null, FadeOut, null, null, null, null, null, false );

5. Within the method where you implemented the original code, modify this implementation to the following:

// Create the splash screen dialog
var Core::Group Splash = new Application::splashScreen;

// Present it
PresentDialog( Splash, null, null, FadeOut, null, null, null, null, null, false );

// Start the timer to hide the dialog. The timer is processed in its 'onTimer'
// slot method
splashTimer.Enabled = true;

Now, when your method is executed, the splash screen dialog is presented and the timer is triggered. After the delay specified in the property Begin of the timer, the onTimer slot method is triggered. This method dismisses the splash screen dialog again and presents the main screen dialog.

Does it help you further?

Best regards

Paul Banach

commented Jan 5 by ezed413
Yes, this helped! It worked! Thank you.

Now how would I get the splash screen to fade out? Can't quite figure that out.

PS: We are close to purchasing Embedded Wizard. The president of our company said we have to money for it. The CTO just wants to make sure it is going to do what we need it to do.
commented Jan 5 by Paul Banach

Hello,

try following:

in step 5: modify the code to following:

// Create the splash screen dialog
var Core::Group Splash = new Application::splashScreen;

// Present it
PresentDialog( Splash, null, Effects::FadeInOutCentered, null, null, null, null, null, null, false );

// Start the timer to hide the dialog. The timer is processed in its 'onTimer'
// slot method
splashTimer.Enabled = true;

This modification instructs the splash dialog to use the 'fade opacity' transition for the fade-out operation. Please note the function of the diverse parameters in the PresentDialog() invocation. The documentation section Use default Dialog transition objects lists all pre-configured transitions. If you want special transitions, please see the section Customize provided Dialog transition animations

Does it help you?

Best regards

Paul Banach

commented Jan 6 by ezed413
Thank you Paul. I'll try it tonight. One more question, is it possible to display another splash screen after the first one closes?
commented Jan 6 by Paul Banach

Hello,

In this case, just after you have dismissed the first splash screen present the second one. Then when you dismiss the second splash screen, present the main screen. To ensure that these operations are performed with right order, you will implement a kind of state machine. The simplest is to evaluate for this purpose the class of the actually shown dialog. If it is the class of the first splash screen, then you can present the second screen. If it belongs to the second splash screen, then you present the main screen.

For this purpose modify the step 4 as follows:

// Determine the previously presented splash dialog
var Core::Group theCurrentDialog = FindCurrentDialog();

// Is the actually shown dialog the first splash screen?
if ((Application::splashScreen)theCurrentDialog != null )
{
  // In such case hide it ...
  DismissDialog( theCurrentDialog, null, null, null, null, null, false );

  // create the second splash screen dialog and ...
  var Core::Group splashscreen = new Application::splashScreen2;

  // ... present it
  PresentDialog( splashscreen, null, null, null, null, null, null, null, null, false );

  // Restart the timer to hide the second splash screen
  splashTimer.Enabled = true;
}

// Is the actually shown dialog the second splash screen
else if ((Application::splashScreen2)theCurrentDialog != null )
{
  // Hide it ...
  DismissDialog( theCurrentDialog, null, null, null, null, null, false );

  // Create the main screen dialog
  var Core::Group mainscreen = new Application::MainScreen;

  // ... and present it
  PresentDialog( mainscreen, null, null, null, null, null, null, null, null, false );
}

If the both splash screens do perform some transitions during their present/dismiss operation, these transitions are executed consequently one after another. If you want that the second splash screen performs its present transition simultanously while the first screen performs the dismiss transition, change the last parameter in the invocation of PresentDialog() when you present the second screen to the value true. See also: Perform several Dialog transitions simultaneously.

[...]

// In such case hide it ...
DismissDialog( theCurrentDialog, null, null, null, null, null, false );

// create the second splash screen dialog and ...
var Core::Group splashscreen = new Application::splashScreen2;

// ... present it. Note the specified transition and the value 'true' in the last parameter 
PresentDialog( splashscreen, Effects::FadeInOutCentered, null, null, null, null, null, null,
               null, true );

[...]

Does it help you?

Best regards

Paul Banach

commented Jan 7 by ezed413
Worked like a charm, thanks!
commented Jan 17 by Mike_PPsys
"PS: We are close to purchasing Embedded Wizard. The president of our company said we have to money for it. The CTO just wants to make sure it is going to do what we need it to do."

We've been using licensed copies for about a year. And you wont find an IDE better supported. There's a bit of a learning curve because of its hardware agnostic nature. But it's well worth the effort and cost.

Mike Spenard // PP Systems

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...