from . import const, g
import bpy
from . import op
from .utils.trans import t


class EasyPatchMainPanel(bpy.types.Panel):
    bl_label = "Easy Patch"
    bl_idname = "VIEW3D_PT_OIMOYU_EASY_Patch_MAIN_PANEL"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_context = "mesh_edit"
    bl_options = {"DEFAULT_CLOSED"}

    bl_category = "Edit"
    bl_order = 1

    def draw(self, context):
        layout = self.layout

        if g.is_running:
            layout.row().operator(
                op.EasyPatchModalOperator.bl_idname,
                text=t("stop") + " Easy Patch",
                icon="PAUSE",
            )
        else:
            layout.prop(
                context.scene.easy_patch_properties,
                "snap_obj",
                text="",
            )

            layout.row().operator(
                op.EasyPatchModalOperator.bl_idname,
                text=t("start") + " Easy Patch",
                icon="PLAY",
            )

            layout.separator()

            layout.row().operator(
                op.EasyPatchSnapSelectedToSurfaceOperator.bl_idname,
                text=t("snap_selected_to_surface"),
                icon="MOD_SHRINKWRAP",
            )


classes = (EasyPatchMainPanel,)
