[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4113] trunk/py/scripts/addons/ render_copy_settings: Update to render_copy_settings: use new template_list (and now we can have two lists in one panel!)

Bastien Montagne montagne29 at wanadoo.fr
Fri Dec 28 12:19:27 CET 2012


Revision: 4113
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4113
Author:   mont29
Date:     2012-12-28 11:19:26 +0000 (Fri, 28 Dec 2012)
Log Message:
-----------
Update to render_copy_settings: use new template_list (and now we can have two lists in one panel!)

Yet there is some work to be done on the 'GRID' mode of lists, current layout code is stupid (and nearly unusable)...

Modified Paths:
--------------
    trunk/py/scripts/addons/render_copy_settings/__init__.py
    trunk/py/scripts/addons/render_copy_settings/operator.py
    trunk/py/scripts/addons/render_copy_settings/panel.py
    trunk/py/scripts/addons/render_copy_settings/presets.py

Modified: trunk/py/scripts/addons/render_copy_settings/__init__.py
===================================================================
--- trunk/py/scripts/addons/render_copy_settings/__init__.py	2012-12-28 10:48:12 UTC (rev 4112)
+++ trunk/py/scripts/addons/render_copy_settings/__init__.py	2012-12-28 11:19:26 UTC (rev 4113)
@@ -21,15 +21,12 @@
 bl_info = {
     "name": "Copy Settings",
     "author": "Bastien Montagne",
-    "version": (0, 1, 4),
-    "blender": (2, 61, 0),
+    "version": (0, 1, 5),
+    "blender": (2, 65, 0),
     "location": "Render buttons (Properties window)",
-    "description": "Allows to copy a selection of render settings from "
-                   "current scene to others.",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-                "Scripts/Render/Copy Settings",
-    "tracker_url": "http://projects.blender.org/tracker/index.php?"
-                   "func=detail&aid=25832",
+    "description": "Allows to copy a selection of render settings from current scene to others.",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Copy Settings",
+    "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25832",
     "category": "Render"}
 
 
@@ -50,53 +47,38 @@
                        PointerProperty)
 
 
-###############################################################################
-# Global properties for the script, for UI (as there’s no way to let them in
-# the operator…).
-###############################################################################
+########################################################################################################################
+# Global properties for the script, for UI (as there’s no way to let them in the operator…).
+########################################################################################################################
 
 class RenderCopySettingsScene(bpy.types.PropertyGroup):
     allowed = BoolProperty(default=True)
 
-    # A string of identifiers (colon delimited) which property’s controls
-    # should be displayed in a template_list.
-    template_list_controls = StringProperty(default="allowed",
-                                            options={'HIDDEN'})
 
-
 class RenderCopySettingsSetting(bpy.types.PropertyGroup):
     strid = StringProperty(default="")
     copy = BoolProperty(default=False)
 
-    # A string of identifiers (colon delimited) which property’s controls
-    # should be displayed in a template_list.
-    template_list_controls = StringProperty(default="copy",
-                                            options={'HIDDEN'})
 
-
 class RenderCopySettings(bpy.types.PropertyGroup):
     # XXX: The consistency of this collection is delegated to the UI code.
     #      It should only contain one element for each render setting.
     affected_settings = CollectionProperty(type=RenderCopySettingsSetting,
                                            name="Affected Settings",
-                                           description="The list of all "
-                                                       "available render "
-                                                       "settings")
+                                           description="The list of all available render settings")
     # XXX Unused, but needed for template_list…
-    aff_sett_idx = IntProperty()
+    affected_settings_idx = IntProperty()
 
     # XXX: The consistency of this collection is delegated to the UI code.
     #      It should only contain one element for each scene.
     allowed_scenes = CollectionProperty(type=RenderCopySettingsScene,
                                         name="Allowed Scenes",
-                                        description="The list all scenes "
-                                                    "in the file")
+                                        description="The list all scenes in the file")
     # XXX Unused, but needed for template_list…
-    allw_scenes_idx = IntProperty()
+    allowed_scenes_idx = IntProperty()
 
     filter_scene = StringProperty(name="Filter Scene",
-                                  description="Regex to only affect scenes "
-                                              "which name matches it",
+                                  description="Regex to only affect scenes which name matches it",
                                   default="")
 
 
@@ -105,8 +87,7 @@
     bpy.utils.register_class(RenderCopySettingsScene)
     bpy.utils.register_class(RenderCopySettingsSetting)
     bpy.utils.register_class(RenderCopySettings)
-    bpy.types.Scene.render_copy_settings = \
-        PointerProperty(type=RenderCopySettings)
+    bpy.types.Scene.render_copy_settings = PointerProperty(type=RenderCopySettings)
 
     bpy.utils.register_module(__name__)
 

Modified: trunk/py/scripts/addons/render_copy_settings/operator.py
===================================================================
--- trunk/py/scripts/addons/render_copy_settings/operator.py	2012-12-28 10:48:12 UTC (rev 4112)
+++ trunk/py/scripts/addons/render_copy_settings/operator.py	2012-12-28 11:19:26 UTC (rev 4113)
@@ -21,14 +21,12 @@
 import bpy
 from . import presets
 
-# These operators are only defined because it seems impossible to directly
-# edit properties from UI code…
+# These operators are only defined because it seems impossible to directly edit properties from UI code…
 
 
 # A sorting func for collections (working in-place).
 # XXX Not optimized at all…
-# XXX If some items in the collection do not have the sortkey property,
-#     they are just ignored…
+# XXX If some items in the collection do not have the sortkey property, they are just ignored…
 def collection_property_sort(collection, sortkey, start_idx=0):
     while start_idx + 1 < len(collection):
         while not hasattr(collection[start_idx], sortkey):
@@ -49,8 +47,7 @@
 
 
 class RenderCopySettingsPrepare(bpy.types.Operator):
-    """Prepare internal data for render_copy_settings (gathering all """ \
-    """existingrender settings, and scenes)"""
+    """Prepare internal data for render_copy_settings (gathering all existingrender settings, and scenes)"""
     bl_idname = "scene.render_copy_settings_prepare"
     bl_label = "Render: Copy Settings Prepare"
     bl_option = {'REGISTER'}
@@ -62,8 +59,7 @@
     def execute(self, context):
         cp_sett = context.scene.render_copy_settings
 
-        # Get all available render settings, and update accordingly
-        # affected_settings…
+        # Get all available render settings, and update accordingly affected_settings…
         props = {}
         for prop in context.scene.render.bl_rna.properties:
             if prop.identifier in {'rna_type'}:
@@ -92,13 +88,11 @@
                 try:
                     regex = re.compile(cp_sett.filter_scene)
                 except Exception as e:
-                    self.report({'ERROR_INVALID_INPUT'}, "The filter-scene "
-                                "regex did not compile:\n    (%s)." % str(e))
+                    self.report({'ERROR_INVALID_INPUT'}, "The filter-scene regex did not compile:\n    (%s)." % str(e))
                     return {'CANCELLED'}
             except:
                 regex = None
-                self.report({'WARNING'}, "Unable to import the re module. "
-                            "Regex scene filtering will be disabled!")
+                self.report({'WARNING'}, "Unable to import the re module, regex scene filtering will be disabled!")
         scenes = set()
         for scene in bpy.data.scenes:
             if scene == bpy.context.scene:  # Exclude current scene!
@@ -190,12 +184,9 @@
     def execute(self, context):
         regex = None
         cp_sett = context.scene.render_copy_settings
-        affected_settings = {sett.strid for sett in cp_sett.affected_settings
-                                                 if sett.copy}
-        allowed_scenes = {sce.name for sce in cp_sett.allowed_scenes
-                                           if sce.allowed}
-        do_copy(context, affected_settings=affected_settings,
-                allowed_scenes=allowed_scenes)
+        affected_settings = {sett.strid for sett in cp_sett.affected_settings if sett.copy}
+        allowed_scenes = {sce.name for sce in cp_sett.allowed_scenes if sce.allowed}
+        do_copy(context, affected_settings=affected_settings, allowed_scenes=allowed_scenes)
         return {'FINISHED'}
 
 

Modified: trunk/py/scripts/addons/render_copy_settings/panel.py
===================================================================
--- trunk/py/scripts/addons/render_copy_settings/panel.py	2012-12-28 10:48:12 UTC (rev 4112)
+++ trunk/py/scripts/addons/render_copy_settings/panel.py	2012-12-28 11:19:26 UTC (rev 4113)
@@ -22,6 +22,24 @@
 from . import presets
 
 
+class RENDER_UL_copy_settings(bpy.types.UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        #assert(isinstance(item, (bpy.types.RenderCopySettingsScene, bpy.types.RenderCopySettingsSetting)))
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            if isinstance(item, bpy.types.RenderCopySettingsSetting):
+                layout.label(item.name, icon_value=icon)
+                layout.prop(item, "copy", text="")
+            else: #elif isinstance(item, bpy.types.RenderCopySettingsScene):
+                layout.prop(item, "allowed", text=item.name, toggle=True)
+        elif self.layout_type in {'GRID'}:
+            layout.alignment = 'CENTER'
+            if isinstance(item, bpy.types.RenderCopySettingsSetting):
+                layout.label(item.name, icon_value=icon)
+                layout.prop(item, "copy", text="")
+            else: #elif isinstance(item, bpy.types.RenderCopySettingsScene):
+                layout.prop(item, "allowed", text=item.name, toggle=True)
+
+
 class RENDER_PT_copy_settings(bpy.types.Panel):
     bl_label = "Copy Settings"
     bl_space_type = "PROPERTIES"
@@ -34,8 +52,7 @@
         layout = self.layout
         cp_sett = context.scene.render_copy_settings
 
-        layout.operator("scene.render_copy_settings",
-                        text="Copy Render Settings")
+        layout.operator("scene.render_copy_settings", text="Copy Render Settings")
 

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list