Close

Overloading screen

3 replies [Last post]
FransUrbo's picture
FransUrbo
User offline. Last seen 14 weeks 2 days ago. Offline
Mobile Conjurer
Joined: 02/25/2010
Posts: 39

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();
Sam Pickard's picture
Sam Pickard
User offline. Last seen 1 day 23 hours ago. Offline
Mobile Sorcerer
Joined: 03/19/2009
Posts: 337

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's picture
niklas
User offline. Last seen 28 weeks 6 days ago. Offline
Mobile Conjurer
Joined: 12/18/2007
Posts: 68

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

FransUrbo's picture
FransUrbo
User offline. Last seen 14 weeks 2 days ago. Offline
Mobile Conjurer
Joined: 02/25/2010
Posts: 39

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!