Skip to main content

Theme Module

note

Added in v3.4.0

This is the module responsible for changing the themes (Light & Dark) in Operating System. Every module in settings requires a widget that is shown in the frontend to the user and this is what user interacts with.

By default, Operating System Simulator plugin has a Blueprint derived from UOperatingSystemSettingModule_Theme called BP_OS_Module_Theme and can be found in the following path: /OperatingSystemSimulator/Content/OperatingSystemContent/Shared/Blueprints/Programs/OperatingSystemSettings.

When you open it, you can see the default colors assigned to both light and dark themes.

Screenshot

From the details panel, you will be able to access WBP_OS_Settings_Theme. This is the widget class responsible for showing the theme interface and where you change the theme. The widget is extremely simple at the moment with only a combo box with theme names and when you change the theme, it will set the theme and apply the setting.

Screenshot

Once you apply the setting, the underlying module will call Broadcast on the Device Messenger so any object listening to the given event will execute. Here, we use a static event name called Get Theme Change Event Name to make this easier.

For any program to affect theme change, make sure to implement the interface function OnOperatingSystemThemeChanged. For all programs, this function is automatically called when theme changes. Here is an example from Video Player program.

Screenshot

For any custom widget, make sure to inherit from UOperatingSystemWidgetBase. If you don't want to inherit from it then implement the interface IOperatingSystemThemeInterface. Finally make sure you listen to the event Get Theme Change Event Name via your Parent OS's Messenger object.