[Bf-blender-cvs] [9be3ab6] temp-sybren-poselib: Removed loading thumbs from file, drawing with template_icon_view

Sybren A. Stüvel noreply at git.blender.org
Thu Dec 15 16:03:30 CET 2016


Commit: 9be3ab6557da078b6a8a51175076a34f1c31be12
Author: Sybren A. Stüvel
Date:   Thu Dec 15 16:00:57 2016 +0100
Branches: temp-sybren-poselib
https://developer.blender.org/rB9be3ab6557da078b6a8a51175076a34f1c31be12

Removed loading thumbs from file, drawing with template_icon_view

===================================================================

M	release/scripts/startup/bl_ui/__init__.py
M	release/scripts/startup/bl_ui/properties_data_armature.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index f5d544f..5fef813 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -140,31 +140,20 @@ def register():
             options={'ENUM_FLAG'},
             )
 
-    # properties_data_armature.py
-    from . import properties_data_armature
     bpy.types.Action.pose_previews = EnumProperty(
         items=properties_data_armature.pose_preview_items,
         update=properties_data_armature.update_pose)
-    bpy.types.Action.pose_previews_dir = StringProperty(
-        name='Thumbnail Path',
-        subtype='DIR_PATH',
-        default='',
-        # update=filepath_update
-    )
-
 
     # done...
 
 
 def unregister():
-    bpy.utils.unregister_module(__name__)
+    bpy.utils.previews.remove(properties_data_armature.previews)
 
-    from . import properties_data_armature
-
-    # del bpy.types.Object.pose_previews
-    if properties_data_armature.previews:
-        bpy.utils.previews.remove(properties_data_armature.previews)
+    if hasattr(bpy.types.Action, 'pose_previews'):
+        del bpy.types.Action.pose_previews
 
+    bpy.utils.unregister_module(__name__)
 
 # Define a default UIList, when a list does not need any custom drawing...
 # Keep in sync with its #defined name in UI_interface.h
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py
index 4fbc3a7..1288f91 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -166,42 +166,21 @@ previews = None
 
 def pose_preview_items(poselib, context):
     global previews
-    import os.path
 
-    if context is None or not poselib.pose_previews_dir:
+    if context is None or not poselib:
         return []
 
-    directory = bpy.path.abspath(poselib.pose_previews_dir)
-    if not os.path.isdir(directory):
-        return []
-
-    if previews is not None and directory == previews.get('pose_previews_dir', None):
-        return previews.pose_previews
-
     if previews is None:
         previews = bpy.utils.previews.new()
     else:
         previews.clear()
 
-    no_thumbnail = os.path.join(os.path.dirname(__file__),
-                                'thumbnails',
-                                'no_thumbnail.png')
-    no_thumb_thumb = previews.load('NO THUMBNAIL', no_thumbnail, 'IMAGE')
-
     enum_items = []
     for pose_idx, pose_marker in enumerate(poselib.pose_markers):
-        filepath = os.path.join(directory, '%s.png' % pose_marker.name)
-        if os.path.exists(filepath):
-            thumb = previews.load(pose_marker.name, filepath, 'IMAGE')
-        else:
-            print('Warning: "%s" does not exist' % filepath)
-            thumb = no_thumb_thumb
-
         enum_items.append((pose_marker.name, pose_marker.name, pose_marker.name,
-                           thumb.icon_id, pose_idx))
+                           poselib.preview.icon_id, pose_idx))
 
     previews.pose_previews = enum_items
-    previews['pose_previews_dir'] = directory
     return previews.pose_previews
 
 
@@ -230,15 +209,13 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
         if not poselib:
             return
 
-        # layout.template_icon_view(
-        #     poselib, 'pose_markers',
-        #     show_labels=True,
-        # )
         # list of poses in pose library
         row = layout.row()
+        row.template_icon_view(poselib, 'pose_previews', show_labels=True)
         row.template_list("UI_UL_list", "pose_markers", poselib, "pose_markers",
                           poselib.pose_markers, "active_index",
                           rows=5)
+
         # column of operators for active pose
         # - goes beside list
         col = row.column(align=True)
@@ -273,10 +250,6 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
                       icon_value=poselib.preview.icon_id,
                       icon_frame=marker.preview_frame_index)
 
-        #~ layout.template_icon_view(poselib, 'pose_previews', show_labels=True)
-        layout.prop(poselib, "pose_previews_dir")
-        col.operator_context = 'INVOKE_DEFAULT'
-
         row = layout.row(align=True)
         row.operator_context = 'INVOKE_DEFAULT'
         props = row.operator("poselib.render_previews", text='Render OGL all')




More information about the Bf-blender-cvs mailing list