# Copyright (c) 2018-2023, 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.
#
import re
import os
import carb.settings
import omni.kit.app
import omni.ui as ui
from omni.kit.window.preferences import PreferenceBuilder, SettingType, PERSISTENT_SETTINGS_PREFIX
from omni.kit.quicklayout import QuickLayout


class LayoutTemplatesPreferences(PreferenceBuilder):
    def __init__(self):
        super().__init__("Template Startup")

    def build(self):
        layout_names = {"Open Last Used Layout": "$$last_used$$"}

        for item in QuickLayout.get_default_layouts():
            layout_names[item[0]] = item[0]

        with ui.VStack(height=0):
            with self.add_frame("Default Layout"):
                with ui.VStack():
                    self.create_setting_widget_combo("Default Layout", PERSISTENT_SETTINGS_PREFIX + "/app/quicklayout/defaultLayout", layout_names, setting_is_index=True)
