# 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.
#
"""The documentation for Shapes"""

from omni import ui
from .doc_page import DocPage
import inspect
import omni.usd
from .colorwidget_doc import USDColorModel

SPACING = 5


def simplest_field():
    ui.MultiIntField(0, 0, 0, 0)


def simplest_drag():
    ui.MultiFloatDragField(0.0, 0.0, 0.0, 0.0)


def matrix_field():
    args = [1.0 if i % 5 == 0 else 0.0 for i in range(16)]
    ui.MultiFloatField(*args, width=ui.Percent(50), h_spacing=5, v_spacing=2)


def usd_field():
    with ui.HStack(spacing=SPACING):
        model = USDColorModel()
        ui.ColorWidget(model, width=0)
        ui.MultiFloatField(model)


def usd_drag():
    with ui.HStack(spacing=SPACING):
        model = USDColorModel()
        ui.ColorWidget(model, width=0)
        ui.MultiFloatDragField(model, min=0.0, max=2.0)


class MultiFieldDoc(DocPage):
    """Document for MultiField"""

    def create_doc(self, navigate_to=None):
        """Descriptions for MultiField"""

        self._section_title("MultiField")

        self._text(
            "MultiField widget groups are the widgets that have multiple similar widgets to represent each item in the "
            "model. It's handy to use them for arrays and multi-component data like float3, matrix, and color."
        )

        simplest_field()
        self._code(inspect.getsource(simplest_field).split("\n", 1)[-1])

        simplest_drag()
        self._code(inspect.getsource(simplest_drag).split("\n", 1)[-1])

        matrix_field()
        self._code(inspect.getsource(matrix_field).split("\n", 1)[-1])

        # TODO omni.ui: restore functionality for Kit Next
        if False:
            usd_field()
            self._code(inspect.getsource(usd_field).split("\n", 1)[-1])

            usd_drag()
            self._code(inspect.getsource(usd_drag).split("\n", 1)[-1])
