Overloading screen

4 posts / 0 new
Last post
turbo@bayour.com
turbo@bayour.com's picture
Offline
Mobile Conjurer
Joined: 25 Feb 2010
Posts:
Overloading screen

My initial screen takes quite a long time to load on the device, so I thought I create a screen with a label that just reads 'Loading, please wait' which is shown while the main screen loads...

But it don't seem to work.

LoadScreen *ls = new LoadScreen();
ls->show();

MainScreen *ms = new MainScreen();
ms->show();

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

What does it do? I think it will probably stop the loading of the main screen. What I've done in the past is to just use maDrawImage() to show a png with a 'please wait' message unti I can call the show() method.

Niklas Nummelin
niklas's picture
Offline
Mobile Wizard
Joined: 18 Dec 2007
Posts:

The problem is that the redrawing of the widgets will be done when the execution has been handed back to the Moblet system. You can do what Samuel said and not care at all about the widgets and just do regular drawing using syscalls. I would probably override Screen::show() in your LoadScreen like this:

void LoadScreen::show() {
    Screen::show();
    main->draw(true); // forceDraw == true
}

That way you enforce drawing of the Screen directly.

// Niklas

turbo@bayour.com
turbo@bayour.com's picture
Offline
Mobile Conjurer
Joined: 25 Feb 2010
Posts:

Niiiice! I first tried with a Resource, but then I found maDrawText(), which is just enough for me. Unless someone like to share a 'Please wait' image that's prettier!? (I'm a coder, not an artist - even though I think/thought of myself as an artist coder Laughing out loud.

Just one note. Using the following LoadScreen class constructor:

LoadScreen::LoadScreen(void) {
	maSetDrawTarget(HANDLE_SCREEN);

	maSetColor(0xffffff);
	maDrawText(PADDING*2, 40, "Please wait while loading...");

	maUpdateScreen();
}
void LoadScreen::show(void) {
    Screen::show();
//    main->draw(true); // forceDraw == true
}

I get a crash ("Attempted to access null pointer.") if I uncomment the main->draw() line... I DO see the text, but I guess it crashes when the MainScreen tries to load... Ah, well. I probably missunderstood something or other. No matter, it works exactly as I wanted/intended!

Thanx a mill!