Syntax
Success = SkinSave(Path$="", Skin=#Null)
Description
Saves the rules defined within a skin object to `.css` files in a specified directory. It organizes the rules into separate files based on themes.
Parameters
Path$ (optional)
The base directory path where the skin should be saved.
If empty (""), ProGUI attempts to save to a default location based on the application name:
%APPDATA%\[AppName]\Skins\[SkinName]\, creating directories as needed. If the path
doesn't contain a specific skin name subdirectory, it will be created based on the `Skin` object's
name. Default is "".
Skin (optional)
The handle of the skin object to save. If #Null, the
current default skin (set by SkinSetDefault()) is saved. Default is
#Null.
Return Value
Returns #True if the skin was successfully saved, or #False if the skin handle
was invalid, the path was invalid, or a file/directory creation/write error occurred.
Remarks
This function iterates through all rules stored in the skin object. It groups rules by theme (derived from the theme prefix in the selector path, e.g., "dark:") and writes them into corresponding `.css` files (e.g., `dark.css`, `default.css`). Rules without a theme prefix go into `default.css`. The output format attempts to resemble standard CSS. If the skin uses image resources (`url(...)`), this function will attempt to copy those image files into a `data` subdirectory within the saved skin's folder and update the `url()` paths in the generated CSS accordingly. The target directory and the `data` subdirectory will be created if they don't exist.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Create a new skin and add some rules
MySkin = CreateSkin("SavedSkin")
If MySkin
SkinSetDefault(MySkin) ; Make it default so we don't have to pass handle to SetValue/Save
SkinSetValue("button", "", "", "background-color", "rgb(100, 150, 200)")
SkinSetValue("button", "hover", "", "background-color", "rgb(120, 170, 220)")
SkinSetValue("dark:button", "", "", "background-color", "rgb(40, 40, 50)") ; Rule for 'dark' theme
SkinSetValue("dark:button", "hover", "", "background-color", "rgb(60, 60, 70)")
; Assume "my_icon.png" exists in the application directory
SkinSetValue("iconWidget", "", "", "background-image", "url('my_icon.png')")
; Save the skin to the default location (%APPDATA%\AppName\Skins\SavedSkin)
If SkinSave()
Debug "Skin 'SavedSkin' saved successfully to default location."
; You should now find SavedSkin\default.css, SavedSkin\dark.css,
; and SavedSkin\data\my_icon.png in the appropriate AppData folder.
Else
Debug "Failed to save skin."
EndIf
Else
Debug "Failed to create skin."
EndIf
StopProGUI()
See Also
CreateSkin, LoadSkin, SkinSetValue, SkinSetDefault, SkinSetTheme
Supported OS
Windows, Linux