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:
Diffstat (limited to 'uv_magic_uv/preferences.py')
-rw-r--r--uv_magic_uv/preferences.py360
1 files changed, 241 insertions, 119 deletions
diff --git a/uv_magic_uv/preferences.py b/uv_magic_uv/preferences.py
index 3ba94376..a58d08d4 100644
--- a/uv_magic_uv/preferences.py
+++ b/uv_magic_uv/preferences.py
@@ -29,19 +29,14 @@ from bpy.props import (
FloatVectorProperty,
BoolProperty,
EnumProperty,
- IntProperty,
+ StringProperty,
)
from bpy.types import AddonPreferences
from . import op
from . import ui
-from . import addon_updater_ops
-
-__all__ = [
- 'add_builtin_menu',
- 'remove_builtin_menu',
- 'Preferences'
-]
+from .utils.bl_class_registry import BlClassRegistry
+from .utils.addon_updator import AddonUpdatorManager
def view3d_uvmap_menu_fn(self, context):
@@ -69,8 +64,32 @@ def view3d_uvmap_menu_fn(self, context):
ops.axis = sc.muv_mirror_uv_axis
# Move UV
layout.operator(op.move_uv.MUV_OT_MoveUV.bl_idname, text="Move UV")
+ # World Scale UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MUV_MT_WorldScaleUV.bl_idname,
+ text="World Scale UV")
+ # Preserve UV
+ layout.menu(ui.VIEW3D_MT_uv_map.MUV_MT_PreserveUVAspect.bl_idname,
+ text="Preserve UV")
+ # Texture Lock
+ layout.menu(ui.VIEW3D_MT_uv_map.MUV_MT_TextureLock.bl_idname,
+ text="Texture Lock")
+ # Texture Wrap
+ layout.menu(ui.VIEW3D_MT_uv_map.MUV_MT_TextureWrap.bl_idname,
+ text="Texture Wrap")
+ # UV Sculpt
+ layout.prop(sc, "muv_uv_sculpt_enable", text="UV Sculpt")
layout.separator()
+ layout.label(text="UV Mapping", icon='IMAGE')
+ # Unwrap Constraint
+ ops = layout.operator(
+ op.unwrap_constraint.MUV_OT_UnwrapConstraint.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.MUV_MT_TextureProjection.bl_idname,
+ text="Texture Projection")
# UVW
layout.menu(ui.VIEW3D_MT_uv_map.MUV_MT_UVW.bl_idname, text="UVW")
@@ -80,13 +99,14 @@ def view3d_object_menu_fn(self, _):
layout.separator()
layout.label(text="Copy/Paste UV", icon='IMAGE')
- # Copy/Paste UV (Among Objecct)
+ # Copy/Paste UV (Among Object)
layout.menu(ui.VIEW3D_MT_object.MUV_MT_CopyPasteUV_Object.bl_idname,
text="Copy/Paste UV")
-def image_uvs_menu_fn(self, _):
+def image_uvs_menu_fn(self, context):
layout = self.layout
+ sc = context.scene
layout.separator()
# Copy/Paste UV (on UV/Image Editor)
@@ -94,6 +114,34 @@ def image_uvs_menu_fn(self, _):
layout.menu(ui.IMAGE_MT_uvs.MUV_MT_CopyPasteUV_UVEdit.bl_idname,
text="Copy/Paste UV")
+ layout.separator()
+ # Pack UV
+ layout.label(text="UV Manipulation", icon='IMAGE')
+ ops = layout.operator(op.pack_uv.MUV_OT_PackUV.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
+ # Select UV
+ layout.menu(ui.IMAGE_MT_uvs.MUV_MT_SelectUV.bl_idname, text="Select UV")
+ # Smooth UV
+ ops = layout.operator(op.smooth_uv.MUV_OT_SmoothUV.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
+ # Align UV
+ layout.menu(ui.IMAGE_MT_uvs.MUV_MT_AlignUV.bl_idname, text="Align UV")
+
+ layout.separator()
+ # Align UV Cursor
+ layout.label(text="Editor Enhancement", icon='IMAGE')
+ layout.menu(ui.IMAGE_MT_uvs.MUV_MT_AlignUVCursor.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.MUV_MT_UVInspection.bl_idname,
+ text="UV Inspection")
+
def add_builtin_menu():
bpy.types.VIEW3D_MT_uv_map.append(view3d_uvmap_menu_fn)
@@ -107,6 +155,49 @@ def remove_builtin_menu():
bpy.types.VIEW3D_MT_uv_map.remove(view3d_uvmap_menu_fn)
+@BlClassRegistry()
+class MUV_OT_CheckAddonUpdate(bpy.types.Operator):
+ bl_idname = "uv.muv_check_addon_update"
+ bl_label = "Check Update"
+ bl_description = "Check Add-on Update"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ updater = AddonUpdatorManager.get_instance()
+ updater.check_update_candidate()
+
+ return {'FINISHED'}
+
+
+@BlClassRegistry()
+class MUV_OT_UpdateAddon(bpy.types.Operator):
+ bl_idname = "uv.muv_update_addon"
+ bl_label = "Update"
+ bl_description = "Update Add-on"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ branch_name: StringProperty(
+ name="Branch Name",
+ description="Branch name to update",
+ default="",
+ )
+
+ def execute(self, context):
+ updater = AddonUpdatorManager.get_instance()
+ updater.update(self.branch_name)
+
+ return {'FINISHED'}
+
+
+def get_update_candidate_branches(_, __):
+ updater = AddonUpdatorManager.get_instance()
+ if not updater.candidate_checked():
+ return []
+
+ return [(name, name, "") for name in updater.get_candidate_branch_names()]
+
+
+@BlClassRegistry()
class Preferences(AddonPreferences):
"""Preferences class: Preferences for this add-on"""
@@ -119,15 +210,15 @@ class Preferences(AddonPreferences):
remove_builtin_menu()
# enable to add features to built-in menu
- enable_builtin_menu = BoolProperty(
+ enable_builtin_menu: BoolProperty(
name="Built-in Menu",
description="Enable built-in menu",
default=True,
- update=update_enable_builtin_menu
+ update=update_enable_builtin_menu,
)
# for UV Sculpt
- uv_sculpt_brush_color = FloatVectorProperty(
+ uv_sculpt_brush_color: FloatVectorProperty(
name="Color",
description="Color",
default=(1.0, 0.4, 0.4, 1.0),
@@ -138,7 +229,7 @@ class Preferences(AddonPreferences):
)
# for Overlapped UV
- uv_inspection_overlapped_color = FloatVectorProperty(
+ uv_inspection_overlapped_color: FloatVectorProperty(
name="Color",
description="Color",
default=(0.0, 0.0, 1.0, 0.3),
@@ -149,7 +240,7 @@ class Preferences(AddonPreferences):
)
# for Flipped UV
- uv_inspection_flipped_color = FloatVectorProperty(
+ uv_inspection_flipped_color: FloatVectorProperty(
name="Color",
description="Color",
default=(1.0, 0.0, 0.0, 0.3),
@@ -160,7 +251,7 @@ class Preferences(AddonPreferences):
)
# for Texture Projection
- texture_projection_canvas_padding = FloatVectorProperty(
+ texture_projection_canvas_padding: FloatVectorProperty(
name="Canvas Padding",
description="Canvas Padding",
size=2,
@@ -169,13 +260,13 @@ class Preferences(AddonPreferences):
default=(20.0, 20.0))
# for UV Bounding Box
- uv_bounding_box_cp_size = FloatProperty(
+ uv_bounding_box_cp_size: FloatProperty(
name="Size",
description="Control Point Size",
default=6.0,
min=3.0,
max=100.0)
- uv_bounding_box_cp_react_size = FloatProperty(
+ uv_bounding_box_cp_react_size: FloatProperty(
name="React Size",
description="Size event fired",
default=10.0,
@@ -183,7 +274,7 @@ class Preferences(AddonPreferences):
max=100.0)
# for UI
- category = EnumProperty(
+ category: EnumProperty(
name="Category",
description="Preferences Category",
items=[
@@ -193,68 +284,42 @@ class Preferences(AddonPreferences):
],
default='INFO'
)
- info_desc_expanded = BoolProperty(
+ info_desc_expanded: BoolProperty(
name="Description",
description="Description",
default=False
)
- info_loc_expanded = BoolProperty(
+ info_loc_expanded: BoolProperty(
name="Location",
description="Location",
default=False
)
- conf_uv_sculpt_expanded = BoolProperty(
+ conf_uv_sculpt_expanded: BoolProperty(
name="UV Sculpt",
description="UV Sculpt",
default=False
)
- conf_uv_inspection_expanded = BoolProperty(
+ conf_uv_inspection_expanded: BoolProperty(
name="UV Inspection",
description="UV Inspection",
default=False
)
- conf_texture_projection_expanded = BoolProperty(
+ conf_texture_projection_expanded: BoolProperty(
name="Texture Projection",
description="Texture Projection",
default=False
)
- conf_uv_bounding_box_expanded = BoolProperty(
+ 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
+ updater_branch_to_update: EnumProperty(
+ name="branch",
+ description="Target branch to update add-on",
+ items=get_update_candidate_branches
)
def draw(self, context):
@@ -263,17 +328,20 @@ class Preferences(AddonPreferences):
layout.row().prop(self, "category", expand=True)
if self.category == 'INFO':
+ layout.separator()
+
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")
+ col = layout.column(align=True)
+ col.label(text="Magic UV is composed of many UV editing" +
+ " features.")
+ col.label(text="See tutorial page if you are new to this" +
+ " add-on.")
+ col.label(text="https://github.com/nutti/Magic-UV" +
+ "/wiki/Tutorial")
layout.prop(
self, "info_loc_expanded", text="Location",
@@ -281,71 +349,78 @@ class Preferences(AddonPreferences):
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)
+ sp = row.split(factor=0.5)
+ sp.label(text="3D View > Tool shelf > " +
+ "Copy/Paste UV (Object mode)")
+ sp = sp.split(factor=1.0)
col = sp.column(align=True)
- col.label("Copy/Paste UV (Among objects)")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="3D View > Tool shelf > " +
+ "Copy/Paste UV (Edit mode)")
+ sp = sp.split(factor=1.0)
col = sp.column(align=True)
- col.label("Copy/Paste UV (Among faces in 3D View)")
- col.label("Transfer UV")
+ col.label(text="Copy/Paste UV (Among faces in 3D View)")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="3D View > Tool shelf > " +
+ "UV Manipulation (Edit mode)")
+ sp = sp.split(factor=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")
+ col.label(text="Flip/Rotate UV")
+ col.label(text="Mirror UV")
+ col.label(text="Move UV")
+ col.label(text="World Scale UV")
+ col.label(text="Preserve UV Aspect")
+ col.label(text="Texture Lock")
+ col.label(text="Texture Wrap")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="3D View > Tool shelf > " +
+ "UV Manipulation (Edit mode)")
+ sp = sp.split(factor=1.0)
col = sp.column(align=True)
- col.label("Unwrap Constraint")
- col.label("Texture Projection")
- col.label("UVW")
+ col.label(text="Unwrap Constraint")
+ col.label(text="Texture Projection")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="UV/Image Editor > Tool shelf > Copy/Paste UV")
+ sp = sp.split(factor=1.0)
col = sp.column(align=True)
- col.label("Copy/Paste UV (Among faces in UV/Image Editor)")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="UV/Image Editor > Tool shelf > UV Manipulation")
+ sp = sp.split(factor=1.0)
col = sp.column(align=True)
- col.label("Align UV")
- col.label("Smooth UV")
- col.label("Select UV")
- col.label("Pack UV (Extension)")
+ col.label(text="Align UV")
+ col.label(text="Smooth UV")
+ col.label(text="Select UV")
+ col.label(text="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)
+ sp = row.split(factor=0.5)
+ sp.label(text="UV/Image Editor > Tool shelf > " +
+ "Editor Enhancement")
+ sp = sp.split(factor=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")
+ col.label(text="Align UV Cursor")
+ col.label(text="UV Cursor Location")
+ col.label(text="UV Bounding Box")
+ col.label(text="UV Inspection")
elif self.category == 'CONFIG':
+ layout.separator()
+
layout.prop(self, "enable_builtin_menu", text="Built-in Menu")
layout.separator()
@@ -355,11 +430,11 @@ class Preferences(AddonPreferences):
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)
+ sp = layout.split(factor=0.05)
col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
+ sp = sp.split(factor=0.3)
col = sp.column()
- col.label("Brush Color:")
+ col.label(text="Brush Color:")
col.prop(self, "uv_sculpt_brush_color", text="")
layout.separator()
@@ -368,15 +443,15 @@ class Preferences(AddonPreferences):
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)
+ sp = layout.split(factor=0.05)
col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
+ sp = sp.split(factor=0.3)
col = sp.column()
- col.label("Overlapped UV Color:")
+ col.label(text="Overlapped UV Color:")
col.prop(self, "uv_inspection_overlapped_color", text="")
- sp = sp.split(percentage=0.45)
+ sp = sp.split(factor=0.45)
col = sp.column()
- col.label("Flipped UV Color:")
+ col.label(text="Flipped UV Color:")
col.prop(self, "uv_inspection_flipped_color", text="")
layout.separator()
@@ -387,9 +462,9 @@ class Preferences(AddonPreferences):
if self.conf_texture_projection_expanded
else 'DISCLOSURE_TRI_RIGHT')
if self.conf_texture_projection_expanded:
- sp = layout.split(percentage=0.05)
+ sp = layout.split(factor=0.05)
col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
+ sp = sp.split(factor=0.3)
col = sp.column()
col.prop(self, "texture_projection_canvas_padding")
layout.separator()
@@ -400,14 +475,61 @@ class Preferences(AddonPreferences):
if self.conf_uv_bounding_box_expanded
else 'DISCLOSURE_TRI_RIGHT')
if self.conf_uv_bounding_box_expanded:
- sp = layout.split(percentage=0.05)
+ sp = layout.split(factor=0.05)
col = sp.column() # spacer
- sp = sp.split(percentage=0.3)
+ sp = sp.split(factor=0.3)
col = sp.column()
- col.label("Control Point:")
+ col.label(text="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)
+ updater = AddonUpdatorManager.get_instance()
+
+ layout.separator()
+
+ if not updater.candidate_checked():
+ col = layout.column()
+ col.scale_y = 2
+ row = col.row()
+ row.operator(MUV_OT_CheckAddonUpdate.bl_idname,
+ text="Check 'Magic UV' add-on update",
+ icon='FILE_REFRESH')
+ else:
+ row = layout.row(align=True)
+ row.scale_y = 2
+ col = row.column()
+ col.operator(MUV_OT_CheckAddonUpdate.bl_idname,
+ text="Check 'Magic UV' add-on update",
+ icon='FILE_REFRESH')
+ col = row.column()
+ if updater.latest_version() != "":
+ col.enabled = True
+ ops = col.operator(
+ MUV_OT_UpdateAddon.bl_idname,
+ text="Update to the latest release version (version: {})"
+ .format(updater.latest_version()),
+ icon='TRIA_DOWN_BAR')
+ ops.branch_name = updater.latest_version()
+ else:
+ col.enabled = False
+ col.operator(MUV_OT_UpdateAddon.bl_idname,
+ text="No updates are available.")
+
+ layout.separator()
+ layout.label(text="Manual Update:")
+ row = layout.row(align=True)
+ row.prop(self, "updater_branch_to_update", text="Target")
+ ops = row.operator(
+ MUV_OT_UpdateAddon.bl_idname, text="Update",
+ icon='TRIA_DOWN_BAR')
+ ops.branch_name = self.updater_branch_to_update
+
+ layout.separator()
+ if updater.has_error():
+ box = layout.box()
+ box.label(text=updater.error(), icon='CANCEL')
+ elif updater.has_info():
+ box = layout.box()
+ box.label(text=updater.info(), icon='ERROR')