# 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 Length"""

from omni import ui
from .doc_page import DocPage

SPACING = 5


class LengthDoc(DocPage):
    """ document for Length classes"""

    def create_doc(self, navigate_to=None):
        self._section_title("Lengths")

        self._text(
            "The Framework UI offers several different units for expressing length: Pixel, Percent and Fraction."
        )
        self._text("There is no restriction on which units can be used where.")

        self._caption("Pixel", navigate_to)
        self._text("Pixel is the size in pixels and scaled with the HiDPI scale factor.")

        with ui.HStack():
            ui.Button("40px", width=ui.Pixel(40))
            ui.Button("60px", width=ui.Pixel(60))
            ui.Button("100px", width=100)
            ui.Button("120px", width=120)
            ui.Button("150px", width=150)

        self._code(
            """
        with ui.HStack():
            ui.Button("40px", width=ui.Pixel(40))
            ui.Button("60px", width=ui.Pixel(60))
            ui.Button("100px", width=100)
            ui.Button("120px", width=120)
            ui.Button("150px", width=150)
            """
        )

        self._caption("Percent", navigate_to)
        self._text("Percent and Fraction units make it possible to specify sizes relative to the parent size.")
        self._text("Percent is 1/100th of the parent size.")

        with ui.HStack():
            ui.Button("5%", width=ui.Percent(5))
            ui.Button("10%", width=ui.Percent(10))
            ui.Button("15%", width=ui.Percent(15))
            ui.Button("20%", width=ui.Percent(20))
            ui.Button("25%", width=ui.Percent(25))

        self._code(
            """
        with ui.HStack():
            ui.Button("5%", width=ui.Percent(5))
            ui.Button("10%", width=ui.Percent(10))
            ui.Button("15%", width=ui.Percent(15))
            ui.Button("20%", width=ui.Percent(20))
            ui.Button("25%", width=ui.Percent(25))
            """
        )

        self._caption("Fraction", navigate_to)
        self._text(
            "Fraction length is made to take the available space of the parent widget and then divide it among all the "
            "child widgets with Fraction length in proportion to their Fraction factor."
        )

        with ui.HStack():
            ui.Button("One", width=ui.Fraction(1))
            ui.Button("Two", width=ui.Fraction(2))
            ui.Button("Three", width=ui.Fraction(3))
            ui.Button("Four", width=ui.Fraction(4))
            ui.Button("Five", width=ui.Fraction(5))

        self._code(
            """
        with ui.HStack():
            ui.Button("One", width=ui.Fraction(1))
            ui.Button("Two", width=ui.Fraction(2))
            ui.Button("Three", width=ui.Fraction(3))
            ui.Button("Four", width=ui.Fraction(4))
            ui.Button("Five", width=ui.Fraction(5))
            """
        )

        ui.Spacer(height=10)
