# Copyright (c) 2018-2020, 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__ = ["StageWidgetExtension"]

import omni.ext

from .stage_column_delegate_registry import StageColumnDelegateRegistry
from .visibility_column_delegate import VisibilityColumnDelegate
from .type_column_delegate import TypeColumnDelegate
from .delegates import NameColumnDelegate
from .stage_actions import register_actions, deregister_actions
from .export_utils import _get_stage_open_sub
from .stage_style import Styles as StageStyles


class StageWidgetExtension(omni.ext.IExt):
    """The entry point for Stage Window"""

    def on_startup(self, ext_id):
        # Register column delegates
        self._name_column_sub = StageColumnDelegateRegistry().register_column_delegate("Name", NameColumnDelegate)
        self._type_column_sub = StageColumnDelegateRegistry().register_column_delegate("Type", TypeColumnDelegate)
        self._visibility_column_sub = StageColumnDelegateRegistry().register_column_delegate("Visibility", VisibilityColumnDelegate)
        self._ext_name = omni.ext.get_extension_name(ext_id)
        StageStyles.on_startup()
        self._registered_hotkeys = []
        register_actions(self._ext_name, self)

        self._stage_open_sub = _get_stage_open_sub()

    def on_shutdown(self):
        self._name_column_sub = None
        self._visibility_column_sub = None
        self._type_column_sub = None
        deregister_actions(self._ext_name, self)
        self._stage_open_sub = None
