themes.py

themes.py - UI Themes Manager for LunaEngine

ENGINE PATH:
lunaengine -> ui -> themes.py

DESCRIPTION:
This module manages comprehensive UI themes with predefined color schemes
for various applications and visual styles. It includes a wide range of
themes from basic functional ones to brand-specific and aesthetic designs.

MAIN FEATURES:
- Loads themes from individual JSON files in lunaengine/assets/themes/
- Supports combined theme files with 'dark' and 'light' variants
- Fallback to legacy single-file format
- Global dark/light mode toggle via set_dark_mode()
- If directory is empty or missing, falls back to local themes.json
- If still not found, tries to download from GitHub
- Final fallback to default theme

class ThemeStyle

Description

Complete style definition for a single UI element state.

Attributes
color: Tuple[int, int, int] = None
alpha: float = 1.0
corner_radius: int = 0
border_width: int = 0
blur: int = 0
Methods
def to_rgb(self: Any) -> Tuple[int, int, int]
Return RGB tuple (alpha ignored).
def to_rgba(self: Any) -> Tuple[int, int, int, int]
Return RGBA tuple with alpha as 0-255.
def from_rgb_list(cls: Any, rgb_list: List[int], alpha: float = 1.0, corner_radius: int = 0, border_width: int = 0, blur: int = 0) -> 'ThemeStyle'
Create from a list of 3 or 4 integers.

class UITheme

Description

Complete UI theme configuration for all elements.

Attributes
button_normal: ThemeStyle = None
button_hover: ThemeStyle = None
button_pressed: ThemeStyle = None
button_disabled: ThemeStyle = None
button_text: ThemeStyle = None
dropdown_normal: ThemeStyle = None
dropdown_hover: ThemeStyle = None
dropdown_expanded: ThemeStyle = None
dropdown_text: ThemeStyle = None
dropdown_option_normal: ThemeStyle = None
dropdown_option_hover: ThemeStyle = None
dropdown_option_selected: ThemeStyle = None
slider_track: ThemeStyle = None
slider_thumb_normal: ThemeStyle = None
slider_thumb_hover: ThemeStyle = None
slider_thumb_pressed: ThemeStyle = None
slider_text: ThemeStyle = None
label_text: ThemeStyle = None
background: ThemeStyle = None
background2: ThemeStyle = None
text_primary: ThemeStyle = None
text_secondary: ThemeStyle = None
switch_track_on: ThemeStyle = None
switch_track_off: ThemeStyle = None
switch_thumb_on: ThemeStyle = None
switch_thumb_off: ThemeStyle = None
dialog_background: ThemeStyle = None
dialog_border: ThemeStyle = None
dialog_text: ThemeStyle = None
dialog_name_bg: ThemeStyle = None
dialog_name_text: ThemeStyle = None
dialog_continue_indicator: ThemeStyle = None
tooltip_background: ThemeStyle = None
tooltip_border: ThemeStyle = None
tooltip_text: ThemeStyle = None
notification_success_background: ThemeStyle = None
notification_success_border: ThemeStyle = None
notification_success_text: ThemeStyle = None
notification_info_background: ThemeStyle = None
notification_info_border: ThemeStyle = None
notification_info_text: ThemeStyle = None
notification_warning_background: ThemeStyle = None
notification_warning_border: ThemeStyle = None
notification_warning_text: ThemeStyle = None
notification_custom_background: ThemeStyle = None
notification_custom_border: ThemeStyle = None
notification_custom_text: ThemeStyle = None
notification_error_background: ThemeStyle = None
notification_error_border: ThemeStyle = None
notification_error_text: ThemeStyle = None
accent1: ThemeStyle = None
accent2: ThemeStyle = None
button_border: Optional[ThemeStyle] = None
dropdown_border: Optional[ThemeStyle] = None
border: Optional[ThemeStyle] = None
border2: Optional[ThemeStyle] = None
Methods

No methods defined.

class CombinedTheme

Description

Container for a theme that has both dark and light variants.

Attributes
dark: UITheme = None
light: UITheme = None
Methods

No methods defined.

class ThemeType

Description

Enumeration of all available theme types (base names only).

Attributes
DEFAULT: Any = 'default'
PRIMARY: Any = 'primary'
SECONDARY: Any = 'secondary'
WARN: Any = 'warn'
ERROR: Any = 'error'
SUCCESS: Any = 'success'
INFO: Any = 'info'
FANTASY: Any = 'fantasy'
CHERRY: Any = 'cherry'
ECLIPSE: Any = 'eclipse'
MIDNIGHT: Any = 'midnight'
NEON: Any = 'neon'
RUBY: Any = 'ruby'
EMERALD: Any = 'emerald'
DIAMOND: Any = 'diamond'
SILVER: Any = 'silver'
COPPER: Any = 'copper'
BRONZE: Any = 'bronze'
AZURE: Any = 'azure'
EIGHTIES: Any = '80s'
CLOUDS: Any = 'clouds'
ROBLOX: Any = 'roblox'
DISCORD: Any = 'discord'
GMAIL: Any = 'gmail'
YOUTUBE: Any = 'youtube'
STEAM: Any = 'steam'
WHATSAPP: Any = 'whatsapp'
CRUNCHYROLL: Any = 'crunchyroll'
TWITCH: Any = 'twitch'
TELEGRAM: Any = 'telegram'
XBOX: Any = 'xbox'
PLAYSTATION: Any = 'playstation'
MINECRAFT: Any = 'minecraft'
CYBERPUNK: Any = 'cyberpunk'
QUEEN: Any = 'queen'
KING: Any = 'king'
MATRIX: Any = 'matrix'
BUILDER: Any = 'builder'
GALAXY: Any = 'galaxy'
FOREST: Any = 'forest'
SUNSET: Any = 'sunset'
OCEAN: Any = 'ocean'
LAVENDER: Any = 'lavender'
CHOCOLATE: Any = 'chocolate'
KIWI: Any = 'kiwi'
DEEP_SPACE: Any = 'deep_space'
NORD: Any = 'nord'
DRACULA: Any = 'dracula'
SOLARIZED: Any = 'solarized'
MONOKAI: Any = 'monokai'
GRUVBOX: Any = 'gruvbox'
BLACK: Any = 'black'
WINDOWS: Any = 'windows'
LINUX: Any = 'linux'
IOS: Any = 'ios'
ANDROID: Any = 'android'
NINJA: Any = 'ninja'
BRAZIL: Any = 'brazil'
JAPAN: Any = 'japan'
USA: Any = 'usa'
EUROPEAN: Any = 'european'
DYNASTY: Any = 'dynasty'
VIKINGS: Any = 'vikings'
Methods

No methods defined.

class ThemeManager

Description

Manages complete UI themes with local/remote loading.

Attributes
_themes: Dict[ThemeType, Union[UITheme, CombinedTheme]] = {}
_current_theme: ThemeType = ThemeType.DEFAULT
_themes_loaded: bool = False
_dark_mode: bool = True
GITHUB_THEMES_URL: Any = 'https://raw.githubusercontent.com/MrJuaumBR/LunaEngine/refs/heads/main/lunaengine/ui/themes.json'
Methods
def _get_themes_dir(cls: Any) -> str
No documentation
def _get_legacy_themes_file_path(cls: Any) -> str
No documentation
def _download_from_github(cls: Any) -> Optional[dict]
No documentation
def _save_legacy_cache(cls: Any, themes_data: dict) -> bool
No documentation
def _parse_theme_style(cls: Any, data: Union[dict, list, tuple]) -> ThemeStyle
Convert JSON data (new or legacy format) to ThemeStyle.
def _build_ui_theme_from_dict(cls: Any, data: dict) -> UITheme
Build a UITheme from a dictionary of style entries.
def _load_theme_from_json_file(cls: Any, filepath: str) -> Optional[Tuple[ThemeType, Union[UITheme, CombinedTheme]]]
No documentation
def _load_themes_from_directory(cls: Any) -> int
No documentation
def _process_legacy_themes_data(cls: Any, themes_data: dict) -> Any
No documentation
def _load_legacy_single_file(cls: Any) -> Any
No documentation
def _create_fallback_theme(cls: Any) -> Any
No documentation
def ensure_themes_loaded(cls: Any) -> Any
No documentation
def get_theme(cls: Any, theme_type: Optional[ThemeType] = None) -> UITheme
No documentation
def set_current_theme(cls: Any, theme_type: ThemeType) -> Any
No documentation
def get_current_theme(cls: Any) -> ThemeType
No documentation
def set_dark_mode(cls: Any, dark: bool) -> Any
Set global dark mode. True = dark, False = light.
def get_dark_mode(cls: Any) -> bool
No documentation
def get_theme_by_name(cls: Any, name: str) -> UITheme
No documentation
def get_theme_type_by_name(cls: Any, name: str) -> ThemeType
No documentation
def _get_style_property(cls: Any, color_name: color_name_type | str, property_name: str, theme_type: Optional[ThemeType] = None) -> Any
No documentation
def get_color(cls: Any, color_name: color_name_type | str, theme_type: Optional[ThemeType] = None) -> Tuple[int, int, int]
Return RGB tuple (ignores alpha).
def get_alpha(cls: Any, color_name: color_name_type | str, theme_type: Optional[ThemeType] = None) -> float
Return alpha (0.0–1.0).
def get_corner_radius(cls: Any, color_name: color_name_type | str, theme_type: Optional[ThemeType] = None) -> int
No documentation
def get_border_width(cls: Any, color_name: color_name_type | str, theme_type: Optional[ThemeType] = None) -> int
No documentation
def get_blur(cls: Any, color_name: color_name_type | str, theme_type: Optional[ThemeType] = None) -> int
No documentation
def get_color_legacy(cls: Any, color_name: color_name_type | str) -> Tuple[int, int, int]
Maintain compatibility with old `get_color` (no theme_type param).
def get_themes(cls: Any) -> Dict[ThemeType, Union[UITheme, CombinedTheme]]
No documentation
def get_theme_types(cls: Any) -> List[ThemeType]
No documentation
def get_theme_names(cls: Any) -> List[str]
No documentation
def reload_themes(cls: Any) -> Any
No documentation
def get_loaded_count(cls: Any) -> int
No documentation
Back to Ui Module