[Bf-blender-cvs] [1dd702b] temp-sybren-poselib: Revert "Removed now-unused code of old poselib-previews addon."
Sybren A. Stüvel
noreply at git.blender.org
Thu Dec 15 16:03:29 CET 2016
Commit: 1dd702bf8c12dd9902f25c80f9b11f5e85f2ab8f
Author: Sybren A. Stüvel
Date: Thu Dec 15 15:21:00 2016 +0100
Branches: temp-sybren-poselib
https://developer.blender.org/rB1dd702bf8c12dd9902f25c80f9b11f5e85f2ab8f
Revert "Removed now-unused code of old poselib-previews addon."
This reverts commit 94527ed77c65bda18915216121c7c27cd5b9d2a1.
===================================================================
M release/scripts/startup/bl_operators/poselib.py
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_operators/poselib.py b/release/scripts/startup/bl_operators/poselib.py
index fca0365..8e9d4b1 100644
--- a/release/scripts/startup/bl_operators/poselib.py
+++ b/release/scripts/startup/bl_operators/poselib.py
@@ -104,6 +104,9 @@ class POSELIB_OT_render_previews(Operator):
return {'RUNNING_MODAL'}
def render_pose(self, context, plib, plib_index):
+ import tempfile
+ import os.path
+
marker = plib.pose_markers[plib_index]
marker.preview_frame_index = plib_index
self.log.info('Rendering pose %s at frame %i', marker.name, marker.frame)
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 3938584..f5d544f 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -140,12 +140,31 @@ 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__)
+ from . import properties_data_armature
+
+ # del bpy.types.Object.pose_previews
+ if properties_data_armature.previews:
+ bpy.utils.previews.remove(properties_data_armature.previews)
+
# 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 74ba937..4fbc3a7 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -161,6 +161,56 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
sub.operator("pose.group_deselect", text="Deselect")
+previews = None
+
+
+def pose_preview_items(poselib, context):
+ global previews
+ import os.path
+
+ if context is None or not poselib.pose_previews_dir:
+ 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))
+
+ previews.pose_previews = enum_items
+ previews['pose_previews_dir'] = directory
+ return previews.pose_previews
+
+
+def update_pose(poselib_action, context):
+ pose_name = poselib_action.pose_previews
+ poselib_action.pose_markers.active = poselib_action.pose_markers[pose_name]
+ bpy.ops.poselib.apply_pose(pose_index=poselib_action.pose_markers.active_index)
+
+
class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
bl_label = "Pose Library"
bl_options = {'DEFAULT_CLOSED'}
@@ -180,6 +230,10 @@ 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_list("UI_UL_list", "pose_markers", poselib, "pose_markers",
@@ -219,6 +273,10 @@ 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