sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

Full Tutorial Part 11

See here for the previous part of the tutorial.

In the previous part, we wrote the submission function for the options page.

writing display page behaviour (part 1)

Now that the options page is done, we can work on the next part of our application. This will be the display page, which will display a image to the user for 10 seconds before automatically sending them back to the options page.

We can have a progress bar at the top of the page and leave the remaining space for a shader that does the actual displaying.

For now, we should first write the logic to actually show the display page. Similar to before, we make a new class SGCLPDisplayPage and write SGCLPDisplayPage::initialise and SGCLPDisplayPage::activate. For now we will only have a background.

By now, you should know how to declare static member functions and static member variables, so we will just go through the declaration to ensure that your variable names match, before going straight to the implementation.

If you get linker errors, check if you declared your static member variables.

Declarations:

static SGWBackground* instance; static SGWBackground* initialise(); static void activate();

Implementation of SGCLPDisplayPage::initialise

SGWBackground* SGCLPDisplayPage::initialise(){ return new SGWPageBackground(SGWWidget::parentWidget, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f); }

We will put more stuff here later

Implementation of SGCLPDisplayPage::activate

void SGCLPDisplayPage::activate(){ SGWBackground::enable(SGCLPDisplayPage::instance, &SGCLPDisplayPage::initialise, nullptr); }

The instance - initialise - (optionally) reset - activate - (optionally) terminate pattern is very common in SGEXTN UI programming and can be easily adapted to other frameworks, so you should be familiar with it.

The SGWidget resizing algorithm has actually been ported to C#, Python, and JS before, though obviously those versions are much worse than the C++ version which is what you are using now. Everything in SGEXTN can be freely ported to other languages, but if you can choose what language to use for a project, always go with C++.

Now that SGCLPDisplayPage::activate has been defined, we can add 2 lines to SGCLPOptionsPage::submitOptions so that it closes the options page and moves to the display page.

SGWBackground::disable(SGCLPOptionsPage::instance); SGCLPDisplayPage::activate();

Yes, you do need to add a preprocessor include directive to use SGCLPDisplayPage::activate.

With that, all the code for the options page is done.

See here for the next part of the tutorial.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects