-
Notifications
You must be signed in to change notification settings - Fork 0
Themes
Lucy Poulton edited this page Aug 2, 2023
·
1 revision
Themes are a way of customising the appearance of widgets and dialogs.
Themes control:
- Text and background colours for dialogs, widgets, and text
- Sets of colours to use for button states
- Padding between elements, and standard sizing for buttons
- Icon textures
Objects that accept a theme, including dialogs and themed widgets, implement the Themed
interface. This interface has one abstract property, theme
, defining its theme.
Delegation is your friend here! If you're creating a custom widget, accept Themed
(for a dialog) and delegate to that:
class MyFunnyWidget(theme: Themed): CompoundWidget(...), Themed by theme
Themes themselves implement Themed
too, so if you don't have your own theme, you can delegate to DefaultTheme
:
class BoringUnthemedDialog : Dialog(), Themed by DefaultTheme
or Theme.Active
(this is so that users could change the default theme to something else):
class SlightlyLessBoringDialog : Dialog(), Themed by Theme.Active