Syntax
Skin = LoadSkin(Path$="", Flags=#Null)
Description
Loads skin definition files (typically `.css`-like files) from a specified directory path or a predefined location based on the application name and creates a skin object containing the parsed rules.
Parameters
Path$ (optional)
The path to the directory containing the skin files.
If empty (""), ProGUI attempts to load from a default location:
%APPDATA%\[AppName]\Skins\Default\[AppDirectory]\Skins\Default\
%APPDATA%\[AppName]\Skins\MyTheme\[AppDirectory]\Skins\MyTheme\
Flags (optional)
Flags modifying the loading behavior. Currently unused. Default is
#Null.
Return Value
Returns a handle to the newly loaded skin object if successful (i.e., if the directory exists and contains
valid `.css` files). Returns #Null or #False if the path is invalid or no
valid skin files are found.
Remarks
ProGUI searches the specified directory for files with a `.css` extension. Each file found is parsed for styling rules. The filename (without extension) is treated as the theme name (e.g., `dark.css` defines rules for the `dark` theme, `default.css` defines rules for the default/base theme). Rules within these files should follow a CSS-like syntax understood by ProGUI's internal parser (see SkinSetValue() for property/value examples). The function automatically sets up file watching on the skin directory; if any `.css` file is modified, the skin will be reloaded automatically.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Assume a skin named "MyCoolSkin" exists in "[AppDir]\Skins\MyCoolSkin"
; containing at least "default.css" and maybe "dark.css"
LoadedSkin = LoadSkin("MyCoolSkin") ; Look for it in default locations
If LoadedSkin
Debug "Skin 'MyCoolSkin' loaded successfully."
; Set it as the application default skin
SkinSetDefault(LoadedSkin)
; Optionally, activate a specific theme if it exists
SkinSetTheme("dark")
; --- Create window and widgets ---
MyWindow = CreateWindow(0, 0, 300, 200, "Loaded Skin")
Layout = WindowGetLayout(MyWindow)
LayoutSetPadding(Layout, 10)
MyButton = CreateWidget(0, 0, 100, 30)
WidgetSetClass(MyButton, "my-button") ; Class should match rules in the CSS
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow
Else
Debug "Failed to load skin 'MyCoolSkin'. Check paths and CSS files."
EndIf
StopProGUI()
See Also
CreateSkin, SkinSave, SkinSetValue, SkinSetDefault, SkinSetTheme
Supported OS
Windows, Linux