# Copyright (c) 2023, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
__all__ = ["welcome_widget_style"]

from omni.ui import color as cl
from omni.ui import constant as fl
from omni.ui import url
import omni.kit.app
import omni.ui as ui
import pathlib

EXTENSION_FOLDER_PATH = pathlib.Path(
    omni.kit.app.get_app().get_extension_manager().get_extension_path_by_module(__name__)
)

# Pre-defined constants. It's possible to change them runtime.
cl.welcome_widget_attribute_bg = cl("#1f2124")
cl.welcome_widget_attribute_fg = cl("#0f1115")
cl.welcome_widget_hovered = cl("#FFFFFF")
cl.welcome_widget_text = cl("#CCCCCC")
fl.welcome_widget_attr_hspacing = 10
fl.welcome_widget_attr_spacing = 1
fl.welcome_widget_group_spacing = 2
url.welcome_widget_icon_closed = f"{EXTENSION_FOLDER_PATH}/data/closed.svg"
url.welcome_widget_icon_opened = f"{EXTENSION_FOLDER_PATH}/data/opened.svg"

# The main style dict
welcome_widget_style = {
    "Label::attribute_name": {
        "alignment": ui.Alignment.RIGHT_CENTER,
        "margin_height": fl.welcome_widget_attr_spacing,
        "margin_width": fl.welcome_widget_attr_hspacing,
    },
    "Label::title": {"alignment": ui.Alignment.CENTER, "color": cl.welcome_widget_text, "font_size": 30},
    "Label::attribute_name:hovered": {"color": cl.welcome_widget_hovered},
    "Label::collapsable_name": {"alignment": ui.Alignment.LEFT_CENTER},
    "Slider::attribute_int:hovered": {"color": cl.welcome_widget_hovered},
    "Slider": {
        "background_color": cl.welcome_widget_attribute_bg,
        "draw_mode": ui.SliderDrawMode.HANDLE,
    },
    "Slider::attribute_float": {
        "draw_mode": ui.SliderDrawMode.FILLED,
        "secondary_color": cl.welcome_widget_attribute_fg,
    },
    "Slider::attribute_float:hovered": {"color": cl.welcome_widget_hovered},
    "Slider::attribute_vector:hovered": {"color": cl.welcome_widget_hovered},
    "Slider::attribute_color:hovered": {"color": cl.welcome_widget_hovered},
    "CollapsableFrame::group": {"margin_height": fl.welcome_widget_group_spacing},
    "Image::collapsable_opened": {"color": cl.welcome_widget_text, "image_url": url.welcome_widget_icon_opened},
    "Image::collapsable_closed": {"color": cl.welcome_widget_text, "image_url": url.welcome_widget_icon_closed},
}
