Fix #105009: AnimAll: Error when inserting key on string attribute
[blender-addons.git] / magic_uv / ui / view3d_uv_mapping.py
blobf6928f8ea872d585e86953a0b0eed5131d0bf0d2
1 # SPDX-FileCopyrightText: 2018-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 __author__ = "Nutti <nutti.metro@gmail.com>"
6 __status__ = "production"
7 __version__ = "6.6"
8 __date__ = "22 Apr 2022"
10 import bpy
12 from ..op.uvw import (
13 MUV_OT_UVW_BoxMap,
14 MUV_OT_UVW_BestPlanerMap,
16 from ..op.texture_projection import (
17 MUV_OT_TextureProjection,
18 MUV_OT_TextureProjection_Project,
20 from ..op.unwrap_constraint import MUV_OT_UnwrapConstraint
21 from ..utils.bl_class_registry import BlClassRegistry
22 from ..utils import compatibility as compat
25 @BlClassRegistry()
26 @compat.ChangeRegionType(region_type='TOOLS')
27 class MUV_PT_View3D_UVMapping(bpy.types.Panel):
28 """
29 Panel class: UV Mapping on Property Panel on View3D
30 """
32 bl_space_type = 'VIEW_3D'
33 bl_region_type = 'UI'
34 bl_label = "UV Mapping"
35 bl_category = "Edit"
36 bl_context = 'mesh_edit'
37 bl_options = {'DEFAULT_CLOSED'}
39 def draw_header(self, _):
40 layout = self.layout
41 layout.label(text="", icon=compat.icon('IMAGE'))
43 def draw(self, context):
44 sc = context.scene
45 layout = self.layout
47 box = layout.box()
48 box.prop(sc, "muv_unwrap_constraint_enabled", text="Unwrap Constraint")
49 if sc.muv_unwrap_constraint_enabled:
50 ops = box.operator(MUV_OT_UnwrapConstraint.bl_idname,
51 text="Unwrap")
52 ops.u_const = sc.muv_unwrap_constraint_u_const
53 ops.v_const = sc.muv_unwrap_constraint_v_const
54 row = box.row(align=True)
55 row.prop(sc, "muv_unwrap_constraint_u_const", text="U-Constraint")
56 row.prop(sc, "muv_unwrap_constraint_v_const", text="V-Constraint")
58 box = layout.box()
59 box.prop(sc, "muv_texture_projection_enabled",
60 text="Texture Projection")
61 if sc.muv_texture_projection_enabled:
62 row = box.row()
63 row.prop(
64 sc, "muv_texture_projection_enable",
65 text="Disable"
66 if MUV_OT_TextureProjection.is_running(context)
67 else "Enable",
68 icon='RESTRICT_VIEW_OFF'
69 if MUV_OT_TextureProjection.is_running(context)
70 else 'RESTRICT_VIEW_ON')
71 row.prop(sc, "muv_texture_projection_tex_image", text="")
72 box.prop(sc, "muv_texture_projection_tex_transparency",
73 text="Transparency")
74 col = box.column(align=True)
75 row = col.row()
76 row.prop(sc, "muv_texture_projection_adjust_window",
77 text="Adjust Window")
78 if not sc.muv_texture_projection_adjust_window:
79 sp = compat.layout_split(col, factor=0.5)
80 sub = sp.column()
81 sub.prop(sc, "muv_texture_projection_tex_scaling",
82 text="Scaling")
83 sp = compat.layout_split(sp, factor=1.0)
84 sub = sp.column()
85 sub.prop(sc, "muv_texture_projection_tex_translation",
86 text="Translation")
87 row = col.row()
88 row.label(text="Rotation:")
89 row.prop(sc, "muv_texture_projection_tex_rotation", text="")
90 col.separator()
91 col.prop(sc, "muv_texture_projection_apply_tex_aspect",
92 text="Texture Aspect Ratio")
93 col.prop(sc, "muv_texture_projection_assign_uvmap",
94 text="Assign UVMap")
95 box.operator(
96 MUV_OT_TextureProjection_Project.bl_idname,
97 text="Project")
99 box = layout.box()
100 box.prop(sc, "muv_uvw_enabled", text="UVW")
101 if sc.muv_uvw_enabled:
102 row = box.row(align=True)
103 ops = row.operator(MUV_OT_UVW_BoxMap.bl_idname, text="Box")
104 ops.assign_uvmap = sc.muv_uvw_assign_uvmap
105 ops = row.operator(MUV_OT_UVW_BestPlanerMap.bl_idname,
106 text="Best Planner")
107 ops.assign_uvmap = sc.muv_uvw_assign_uvmap
108 box.prop(sc, "muv_uvw_assign_uvmap", text="Assign UVMap")