Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNutti <nutti.metro@gmail.com>2018-11-17 15:11:55 +0300
committerNutti <nutti.metro@gmail.com>2018-11-17 15:11:55 +0300
commit2532b96844c121b710e1a1973d2a5ff824ab3be4 (patch)
treec1f7682a77310f53ed4c2682b0788f73aa677d69 /uv_magic_uv/preferences.py
parent92ebf635ee2a9ddbc7fbf4a0c06b9732ee555b27 (diff)
Magic UV: Release v5.2
* Bulit-in menu preferences * Add-on updater * Copy/Paste UV * Add option "[New]" for pasting to newly allocated UV map * Add option "[All]" for pasting all UV maps at once * Align UV * Add option "Mesh Influence" * World Scale UV * Add mode option "Manual" to allow the user specify the density manually * Improve UI * Cleanup documents * Fix bugs
Diffstat (limited to 'uv_magic_uv/preferences.py')
-rw-r--r--uv_magic_uv/preferences.py508
1 files changed, 378 insertions, 130 deletions
diff --git a/uv_magic_uv/preferences.py b/uv_magic_uv/preferences.py
index d8cdf86b..376258d0 100644
--- a/uv_magic_uv/preferences.py
+++ b/uv_magic_uv/preferences.py
@@ -20,23 +20,165 @@
__author__ = "Nutti <nutti.metro@gmail.com>"
__status__ = "production"
-__version__ = "5.1"
-__date__ = "24 Feb 2018"
+__version__ = "5.2"
+__date__ = "17 Nov 2018"
+import bpy
from bpy.props import (
FloatProperty,
FloatVectorProperty,
+ BoolProperty,
+ EnumProperty,
+ IntProperty,
)
from bpy.types import AddonPreferences
+from . import ui
+from . import op
+from . import addon_updater_ops
-class MUV_Preferences(AddonPreferences):
+
+__all__ = [
+ 'add_builtin_menu',
+ 'remove_builtin_menu',
+ 'Preferences'
+]
+
+
+def view3d_uvmap_menu_fn(self, context):
+ layout = self.layout
+ sc = context.scene
+
+ layout.separator()
+ layout.label("Copy/Paste UV", icon='IMAGE_COL')
+ # Copy/Paste UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuCopyPasteUV.bl_idname,
+ text="Copy/Paste UV")
+ # Transfer UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuTransferUV.bl_idname,
+ text="Transfer UV")
+
+ layout.separator()
+ layout.label("UV Manipulation", icon='IMAGE_COL')
+ # Flip/Rotate UV
+ ops = layout.operator(op.flip_rotate_uv.Operator.bl_idname,
+ text="Flip/Rotate UV")
+ ops.seams = sc.muv_flip_rotate_uv_seams
+ # Mirror UV
+ ops = layout.operator(op.mirror_uv.Operator.bl_idname, text="Mirror UV")
+ ops.axis = sc.muv_mirror_uv_axis
+ # Move UV
+ layout.operator(op.move_uv.Operator.bl_idname, text="Move UV")
+ # World Scale UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuWorldScaleUV.bl_idname,
+ text="World Scale UV")
+ # Preserve UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuPreserveUVAspect.bl_idname,
+ text="Preserve UV")
+ # Texture Lock
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuTextureLock.bl_idname,
+ text="Texture Lock")
+ # Texture Wrap
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuTextureWrap.bl_idname,
+ text="Texture Wrap")
+ # UV Sculpt
+ layout.prop(sc, "muv_uv_sculpt_enable", text="UV Sculpt")
+
+ layout.separator()
+ layout.label("UV Mapping", icon='IMAGE_COL')
+ # Unwrap Constraint
+ ops = layout.operator(op.unwrap_constraint.Operator.bl_idname,
+ text="Unwrap Constraint")
+ ops.u_const = sc.muv_unwrap_constraint_u_const
+ ops.v_const = sc.muv_unwrap_constraint_v_const
+ # Texture Projection
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuTextureProjection.bl_idname,
+ text="Texture Projection")
+ # UVW
+ layout.menu(ui.VIEW3D_MT_uv_map.MenuUVW.bl_idname, text="UVW")
+
+
+def view3d_object_menu_fn(self, _):
+ layout = self.layout
+
+ layout.separator()
+ # Copy/Paste UV (Among Objecct)
+ layout.menu(ui.VIEW3D_MT_object.MenuCopyPasteUVObject.bl_idname,
+ text="Copy/Paste UV")
+ layout.label("Copy/Paste UV", icon='IMAGE_COL')
+
+
+def image_uvs_menu_fn(self, context):
+ layout = self.layout
+ sc = context.scene
+
+ layout.separator()
+ # Align UV Cursor
+ layout.menu(ui.IMAGE_MT_uvs.MenuAlignUVCursor.bl_idname,
+ text="Align UV Cursor")
+ # UV Bounding Box
+ layout.prop(sc, "muv_uv_bounding_box_show", text="UV Bounding Box")
+ # UV Inspection
+ layout.menu(ui.IMAGE_MT_uvs.MenuUVInspection.bl_idname,
+ text="UV Inspection")
+ layout.label("Editor Enhancement", icon='IMAGE_COL')
+
+ layout.separator()
+ # Align UV
+ layout.menu(ui.IMAGE_MT_uvs.MenuAlignUV.bl_idname, text="Align UV")
+ # Smooth UV
+ ops = layout.operator(op.smooth_uv.Operator.bl_idname, text="Smooth")
+ ops.transmission = sc.muv_smooth_uv_transmission
+ ops.select = sc.muv_smooth_uv_select
+ ops.mesh_infl = sc.muv_smooth_uv_mesh_infl
+ # Select UV
+ layout.menu(ui.IMAGE_MT_uvs.MenuSelectUV.bl_idname, text="Select UV")
+ # Pack UV
+ ops = layout.operator(op.pack_uv.Operator.bl_idname, text="Pack UV")
+ ops.allowable_center_deviation = sc.muv_pack_uv_allowable_center_deviation
+ ops.allowable_size_deviation = sc.muv_pack_uv_allowable_size_deviation
+ layout.label("UV Manipulation", icon='IMAGE_COL')
+
+ layout.separator()
+ # Copy/Paste UV (on UV/Image Editor)
+ layout.menu(ui.IMAGE_MT_uvs.MenuCopyPasteUVUVEdit.bl_idname,
+ text="Copy/Paste UV")
+ layout.label("Copy/Paste UV", icon='IMAGE_COL')
+
+
+def add_builtin_menu():
+ bpy.types.VIEW3D_MT_uv_map.append(view3d_uvmap_menu_fn)
+ bpy.types.VIEW3D_MT_object.append(view3d_object_menu_fn)
+ bpy.types.IMAGE_MT_uvs.append(image_uvs_menu_fn)
+
+
+def remove_builtin_menu():
+ bpy.types.IMAGE_MT_uvs.remove(image_uvs_menu_fn)
+ bpy.types.VIEW3D_MT_object.remove(view3d_object_menu_fn)
+ bpy.types.VIEW3D_MT_uv_map.remove(view3d_uvmap_menu_fn)
+
+
+class Preferences(AddonPreferences):
"""Preferences class: Preferences for this add-on"""
bl_idname = __package__
+ def update_enable_builtin_menu(self, _):
+ if self['enable_builtin_menu']:
+ add_builtin_menu()
+ else:
+ remove_builtin_menu()
+
+ # enable to add features to built-in menu
+ enable_builtin_menu = BoolProperty(
+ name="Built-in Menu",
+ description="Enable built-in menu",
+ default=True,
+ update=update_enable_builtin_menu
+ )
+
# for UV Sculpt
- uvsculpt_brush_color = FloatVectorProperty(
+ uv_sculpt_brush_color = FloatVectorProperty(
name="Color",
description="Color",
default=(1.0, 0.4, 0.4, 1.0),
@@ -47,7 +189,7 @@ class MUV_Preferences(AddonPreferences):
)
# for Overlapped UV
- uvinsp_overlapped_color = FloatVectorProperty(
+ uv_inspection_overlapped_color = FloatVectorProperty(
name="Color",
description="Color",
default=(0.0, 0.0, 1.0, 0.3),
@@ -58,7 +200,7 @@ class MUV_Preferences(AddonPreferences):
)
# for Flipped UV
- uvinsp_flipped_color = FloatVectorProperty(
+ uv_inspection_flipped_color = FloatVectorProperty(
name="Color",
description="Color",
default=(1.0, 0.0, 0.0, 0.3),
@@ -69,7 +211,7 @@ class MUV_Preferences(AddonPreferences):
)
# for Texture Projection
- texproj_canvas_padding = FloatVectorProperty(
+ texture_projection_canvas_padding = FloatVectorProperty(
name="Canvas Padding",
description="Canvas Padding",
size=2,
@@ -78,139 +220,245 @@ class MUV_Preferences(AddonPreferences):
default=(20.0, 20.0))
# for UV Bounding Box
- uvbb_cp_size = FloatProperty(
+ uv_bounding_box_cp_size = FloatProperty(
name="Size",
description="Control Point Size",
default=6.0,
min=3.0,
max=100.0)
- uvbb_cp_react_size = FloatProperty(
+ uv_bounding_box_cp_react_size = FloatProperty(
name="React Size",
description="Size event fired",
default=10.0,
min=3.0,
max=100.0)
- def draw(self, _):
+ # for UI
+ category = EnumProperty(
+ name="Category",
+ description="Preferences Category",
+ items=[
+ ('INFO', "Information", "Information about this add-on"),
+ ('CONFIG', "Configuration", "Configuration about this add-on"),
+ ('UPDATE', "Update", "Update this add-on"),
+ ],
+ default='INFO'
+ )
+ info_desc_expanded = BoolProperty(
+ name="Description",
+ description="Description",
+ default=False
+ )
+ info_loc_expanded = BoolProperty(
+ name="Location",
+ description="Location",
+ default=False
+ )
+ conf_uv_sculpt_expanded = BoolProperty(
+ name="UV Sculpt",
+ description="UV Sculpt",
+ default=False
+ )
+ conf_uv_inspection_expanded = BoolProperty(
+ name="UV Inspection",
+ description="UV Inspection",
+ default=False
+ )
+ conf_texture_projection_expanded = BoolProperty(
+ name="Texture Projection",
+ description="Texture Projection",
+ default=False
+ )
+ conf_uv_bounding_box_expanded = BoolProperty(
+ name="UV Bounding Box",
+ description="UV Bounding Box",
+ default=False
+ )
+
+ # for add-on updater
+ auto_check_update = BoolProperty(
+ name="Auto-check for Update",
+ description="If enabled, auto-check for updates using an interval",
+ default=False
+ )
+ updater_intrval_months = IntProperty(
+ name='Months',
+ description="Number of months between checking for updates",
+ default=0,
+ min=0
+ )
+ updater_intrval_days = IntProperty(
+ name='Days',
+ description="Number of days between checking for updates",
+ default=7,
+ min=0
+ )
+ updater_intrval_hours = IntProperty(
+ name='Hours',
+ description="Number of hours between checking for updates",
+ default=0,
+ min=0,
+ max=23
+ )
+ updater_intrval_minutes = IntProperty(
+ name='Minutes',
+ description="Number of minutes between checking for updates",
+ default=0,
+ min=0,
+ max=59
+ )
+
+ def draw(self, context):
layout = self.layout
- layout.label("[Configuration]")
-
- layout.label("UV Sculpt:")
- sp = layout.split(percentage=0.05)
- col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
- col = sp.column()
- col.label("Brush Color:")
- col.prop(self, "uvsculpt_brush_color", text="")
-
- layout.separator()
-
- layout.label("UV Inspection:")
- sp = layout.split(percentage=0.05)
- col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
- col = sp.column()
- col.label("Overlapped UV Color:")
- col.prop(self, "uvinsp_overlapped_color", text="")
- sp = sp.split(percentage=0.45)
- col = sp.column()
- col.label("Flipped UV Color:")
- col.prop(self, "uvinsp_flipped_color", text="")
-
- layout.separator()
-
- layout.label("Texture Projection:")
- sp = layout.split(percentage=0.05)
- col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
- col = sp.column()
- col.prop(self, "texproj_canvas_padding")
-
- layout.separator()
-
- layout.label("UV Bounding Box:")
- sp = layout.split(percentage=0.05)
- col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
- col = sp.column()
- col.label("Control Point:")
- col.prop(self, "uvbb_cp_size")
- col.prop(self, "uvbb_cp_react_size")
-
- layout.label("--------------------------------------")
-
- layout.label("[Description]")
- column = layout.column(align=True)
- column.label("Magic UV is composed of many UV editing features.")
- column.label("See tutorial page if you are new to this add-on.")
- column.label("https://github.com/nutti/Magic-UV/wiki/Tutorial")
-
- layout.label("--------------------------------------")
-
- layout.label("[Location]")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("3D View > Tool shelf > Copy/Paste UV (Object mode)")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Copy/Paste UV (Among objects)")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("3D View > Tool shelf > Copy/Paste UV (Edit mode)")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Copy/Paste UV (Among faces in 3D View)")
- col.label("Transfer UV")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("3D View > Tool shelf > UV Manipulation (Edit mode)")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Flip/Rotate UV")
- col.label("Mirror UV")
- col.label("Move UV")
- col.label("World Scale UV")
- col.label("Preserve UV Aspect")
- col.label("Texture Lock")
- col.label("Texture Wrap")
- col.label("UV Sculpt")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("3D View > Tool shelf > UV Manipulation (Edit mode)")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Unwrap Constraint")
- col.label("Texture Projection")
- col.label("UVW")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("UV/Image Editor > Tool shelf > Copy/Paste UV")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Copy/Paste UV (Among faces in UV/Image Editor)")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("UV/Image Editor > Tool shelf > UV Manipulation")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Align UV")
- col.label("Smooth UV")
- col.label("Select UV")
- col.label("Pack UV (Extension)")
-
- row = layout.row(align=True)
- sp = row.split(percentage=0.5)
- sp.label("UV/Image Editor > Tool shelf > Editor Enhancement")
- sp = sp.split(percentage=1.0)
- col = sp.column(align=True)
- col.label("Align UV Cursor")
- col.label("UV Cursor Location")
- col.label("UV Bounding Box")
- col.label("UV Inspection")
+ layout.row().prop(self, "category", expand=True)
+
+ if self.category == 'INFO':
+ layout.prop(
+ self, "info_desc_expanded", text="Description",
+ icon='DISCLOSURE_TRI_DOWN' if self.info_desc_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.info_desc_expanded:
+ column = layout.column(align=True)
+ column.label("Magic UV is composed of many UV editing" +
+ " features.")
+ column.label("See tutorial page if you are new to this" +
+ " add-on.")
+ column.label("https://github.com/nutti/Magic-UV/wiki/Tutorial")
+
+ layout.prop(
+ self, "info_loc_expanded", text="Location",
+ icon='DISCLOSURE_TRI_DOWN' if self.info_loc_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.info_loc_expanded:
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("3D View > Tool shelf > Copy/Paste UV (Object mode)")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Copy/Paste UV (Among objects)")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("3D View > Tool shelf > Copy/Paste UV (Edit mode)")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Copy/Paste UV (Among faces in 3D View)")
+ col.label("Transfer UV")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("3D View > Tool shelf > UV Manipulation (Edit mode)")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Flip/Rotate UV")
+ col.label("Mirror UV")
+ col.label("Move UV")
+ col.label("World Scale UV")
+ col.label("Preserve UV Aspect")
+ col.label("Texture Lock")
+ col.label("Texture Wrap")
+ col.label("UV Sculpt")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("3D View > Tool shelf > UV Manipulation (Edit mode)")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Unwrap Constraint")
+ col.label("Texture Projection")
+ col.label("UVW")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("UV/Image Editor > Tool shelf > Copy/Paste UV")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Copy/Paste UV (Among faces in UV/Image Editor)")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("UV/Image Editor > Tool shelf > UV Manipulation")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Align UV")
+ col.label("Smooth UV")
+ col.label("Select UV")
+ col.label("Pack UV (Extension)")
+
+ row = layout.row(align=True)
+ sp = row.split(percentage=0.5)
+ sp.label("UV/Image Editor > Tool shelf > Editor Enhancement")
+ sp = sp.split(percentage=1.0)
+ col = sp.column(align=True)
+ col.label("Align UV Cursor")
+ col.label("UV Cursor Location")
+ col.label("UV Bounding Box")
+ col.label("UV Inspection")
+
+ elif self.category == 'CONFIG':
+ layout.prop(self, "enable_builtin_menu", text="Built-in Menu")
+
+ layout.separator()
+
+ layout.prop(
+ self, "conf_uv_sculpt_expanded", text="UV Sculpt",
+ icon='DISCLOSURE_TRI_DOWN' if self.conf_uv_sculpt_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.conf_uv_sculpt_expanded:
+ sp = layout.split(percentage=0.05)
+ col = sp.column() # spacer
+ sp = sp.split(percentage=0.3)
+ col = sp.column()
+ col.label("Brush Color:")
+ col.prop(self, "uv_sculpt_brush_color", text="")
+ layout.separator()
+
+ layout.prop(
+ self, "conf_uv_inspection_expanded", text="UV Inspection",
+ icon='DISCLOSURE_TRI_DOWN' if self.conf_uv_inspection_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.conf_uv_inspection_expanded:
+ sp = layout.split(percentage=0.05)
+ col = sp.column() # spacer
+ sp = sp.split(percentage=0.3)
+ col = sp.column()
+ col.label("Overlapped UV Color:")
+ col.prop(self, "uv_inspection_overlapped_color", text="")
+ sp = sp.split(percentage=0.45)
+ col = sp.column()
+ col.label("Flipped UV Color:")
+ col.prop(self, "uv_inspection_flipped_color", text="")
+ layout.separator()
+
+ layout.prop(
+ self, "conf_texture_projection_expanded",
+ text="Texture Projection",
+ icon='DISCLOSURE_TRI_DOWN'
+ if self.conf_texture_projection_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.conf_texture_projection_expanded:
+ sp = layout.split(percentage=0.05)
+ col = sp.column() # spacer
+ sp = sp.split(percentage=0.3)
+ col = sp.column()
+ col.prop(self, "texture_projection_canvas_padding")
+ layout.separator()
+
+ layout.prop(
+ self, "conf_uv_bounding_box_expanded", text="UV Bounding Box",
+ icon='DISCLOSURE_TRI_DOWN'
+ if self.conf_uv_bounding_box_expanded
+ else 'DISCLOSURE_TRI_RIGHT')
+ if self.conf_uv_bounding_box_expanded:
+ sp = layout.split(percentage=0.05)
+ col = sp.column() # spacer
+ sp = sp.split(percentage=0.3)
+ col = sp.column()
+ col.label("Control Point:")
+ col.prop(self, "uv_bounding_box_cp_size")
+ col.prop(self, "uv_bounding_box_cp_react_size")
+ layout.separator()
+
+ elif self.category == 'UPDATE':
+ addon_updater_ops.update_settings_ui(self, context)