# Copyright (c) 2021-2022, 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__ = ["ViewportMenuSpacer"]

from .viewport_menu_item import ViewportMenuItem
from typing import Dict
import omni.ui as ui


class ViewportMenuSpacer(ViewportMenuItem):
    """A simple spacer"""
    def __init__(self):
        self.__spacer: Dict[int, ui.Spacer] = {}
        super().__init__(order_setting_path="/exts/omni.kit.viewport.menubar.core/spacer/order")

    def build_fn(self, factory_args: Dict):
        viewport_api_id = factory_args['viewport_api'].id
        self.__spacer[viewport_api_id] = ui.Spacer()

    def get_computed_width(self, factory_args: Dict) -> float:
        viewport_api_id = factory_args['viewport_api'].id
        return self.__spacer[viewport_api_id].computed_width if viewport_api_id in self.__spacer else 0
