from pathlib import Path

import omni.ui as ui
from omni.ui import color as cl
from omni.ui import constant as fl

CURRENT_PATH = Path(__file__).parent
ICON_PATH = CURRENT_PATH.parent.parent.parent.parent.joinpath("icons")

fl.welcome_open_thumbnail_size = 145
fl.welcome_open_lable_size = 30
cl.welcome_open_item_selected = cl.shade(cl("#77878A"))
cl.welcome_open_label = cl.shade(cl("#9E9E9E"))


OPEN_PAGE_STYLE = {
    "RadioButton": {"background_color": cl.transparent, "stack_direction": ui.Direction.LEFT_TO_RIGHT, "padding": 0, "margin": 0},
    "RadioButton.Label": {"font_size": fl.welcome_title_font_size, "color": cl.welcome_label, "alignment": ui.Alignment.LEFT_CENTER},
    "RadioButton.Label:checked": {"color": cl.welcome_label_selected},
    "RadioButton:checked": {"background_color": cl.transparent},
    "RadioButton:hovered": {"background_color": cl.transparent},
    "RadioButton:pressed": {"background_color": cl.transparent},
    "RadioButton.Image::STAGE": {"image_url": f"{ICON_PATH}/USD.svg"},
    "RadioButton.Image::SAMPLES": {"image_url": f"{ICON_PATH}/image.svg"},
    "RadioButton.Image::FILE": {"image_url": f"{ICON_PATH}/hdd.svg"},
    "RadioButton.Image": {"color": cl.welcome_label, "alignment": ui.Alignment.RIGHT_CENTER},
    "RadioButton.Image:checked": {"color": cl.welcome_label_selected},

    "ThumbnailGrid.Separator": {"color": cl.welcome_window_background, "border_width": 1.5},
    "ThumbnailGrid.Title": {"color": 0xFFCCCCCC, "font_size": fl.welcome_title_font_size},
    "ThumbnailGrid.Mode": {"margin": 2},
    "ThumbnailGrid.Mode::grid": {"image_url": f"{ICON_PATH}/thumbnail.svg"},
    "ThumbnailGrid.Mode::table": {"image_url": f"{ICON_PATH}/list.svg"},
    "ThumbnailGrid.Frame": {
        "background_color": cl.transparent,
        "secondary_color": 0xFF808080,
        "border_radius": 0,
        "scrollbar_size": 10,
    },
    "ThumbnailGrid.Selection": {
        "background_color": cl.transparent,
    },
    "ThumbnailGrid.Selection:selected": {
        "border_width": 1,
        "border_color": cl.welcome_open_item_selected,
        "border_radius": 0,
    },
    "ThumbnailGrid.Item.Background": {
        "background_color": cl.transparent,
    },
    "ThumbnailGrid.Item.Background:selected": {
        "background_color": 0xFF525252,
    },
    "ThumbnailGrid.Item": {
        "margin_width": 2,
        "color": cl.welcome_label,
    },
    "Template.Add": {"color": 0xFFFFFFFF},
    "Template.Add:hovered": {"color": cl.welcome_label_selected},
    "Template.Add:pressed": {"color": cl.welcome_label_selected},
    "Template.Add:selected": {"color": cl.welcome_label_selected},

    "Stage.Label": {"color": cl.welcome_open_label, "margin_width": 6},
    "Stage.Button": {
        "background_color": 0xFF23211F,
        "selected_color": 0xFF8A8777,
        "color": cl.welcome_open_label,
        "margin": 0,
        "padding": 0
    },
    "Stage.Button:hovered": {"background_color": 0xFF3A3A3A},
    "Stage.Button.Label": {"color": cl.welcome_open_label},
    "Stage.Button.Label:disabled": {"color": 0xFF3A3A3A},

    "Stage.Separator": {"background_color": cl.welcome_window_background},
    "Stage.Blank": {"background_color": cl.welcome_content_background},
}