[back to main site]
Snowdrop OS - a homebrew operating system from scratch, in assembly language

GUI framework section


Starting with version 28, GUI framework relies on a new graphics library
which supports a higher resolution.

Also, an extension interface was added to allow further GUI components
to be made available without a need to modify the GUI framework core.
The first extensions I wrote were a colour picker and a text box, both
used by the Draw application.

Starting in version 21, GUI applications can be created in BASIC, which hides
most complexity of initialization and callback setup.

See the BASIC page for more information.

Snowdrop's GUI framework provides an abstraction for user applications which want to rely on buttons, checkboxes, etc, while using a mouse for input. Another advantage is that the GUI framework ensures a consistent look and feel for all applications which rely on it.

Applications need not care about mouse management or UI component states.

The hellogui app is a "Hello, World!" for the GUI framework.

It's a great place to learn how to start with the GUI framework.

Consumer applications set up a few callback functions, after which they yield control permanently to the GUI framework.

After GUI framework initialization, a specific callback is invoked, allowing the consumer application to create components (buttons, checkboxes, etc.) as needed.

When the user interacts with the GUI components (usually via clicking), the consumer's callback are invoked.

The guitests app exercises all available component types (buttons, checkboxes, etc.).

It is not only useful for testing the GUI framework, but also to demonstrate how to design a moderately complex application.

Since it covers most GUI framework functionality, the guitests application also serves as an API reference. Public functions names begin with common_gui_, so they are easy to find.

To save space in consumer applications, callbacks do not need to preserve any registers.

Consumer-provided callbacks cannot assume the values of any registers other than the ones which explicitly hold input arguments (such as AX for handles, etc.). For example, if a string operation (stosX, lodsX, etc.) is used within a callback, the callback must correctly set up segment registers (DS, ES, etc.).

Callbacks must always use retf to return control to the GUI framework.

Users can always exit GUI framework applications by pressing CTRL-Q (irrespective of keyboard mode).

The GUI framework automatically shows a "loading..." notice between common_gui_prepare and common_gui_start. The time between those two calls is when long-running application initialization, such as reading from disk, etc. should be performed.

Snowmine is an example of a game based on the GUI framework.

GUI framework component diagram