def draw_item(self, context, layout, data, item, icon, active_data, active_propname, filter_flg):
        ob = data
        self.use_filter_sort_alpha = True

        coll = active_propname.strip("active_index")

        collection = getattr(bpy.data, coll)
        obj = collection.get(item.name) 
               
        icon = get_icon(obj.type) if hasattr(obj, "type") else icon_from_bpy_datapath(repr(obj))
        
        if self.layout_type in {'DEFAULT', 'COMPACT'}:
           layout.label("  %s" % (item.name), icon=icon)
        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label(text="", icon=icon)

        return
        col.label(item.name)
        return
Пример #2
0
    def draw_item(self, context, layout, data, item, icon, active_data,
                  active_propname, filter_flg):
        ob = data
        self.use_filter_sort_alpha = True

        coll = active_propname.strip("active_index")

        collection = getattr(bpy.data, coll)
        obj = collection.get(item.name)

        icon = get_icon(obj.type) if hasattr(
            obj, "type") else icon_from_bpy_datapath(repr(obj))

        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            layout.label("  %s" % (item.name), icon=icon)
        elif self.layout_type in {'GRID'}:
            layout.alignment = 'CENTER'
            layout.label(text="", icon=icon)

        return
        col.label(item.name)
        return
Пример #3
0
    def draw(self, context):
        layout = self.layout

        collection = self.collection
        scene = context.scene
        wm = context.window_manager
        dm = context.driver_manager
        search = getattr(scene.driver_objects, "search_%s" % self.collection,
                         False)
        index = getattr(scene.driver_objects,
                        "active_%s_index" % self.collection, -1)
        coll = getattr(scene.driver_objects, collection)
        layout.prop(scene.driver_objects, "search_%s" % self.collection)
        if getattr(scene.driver_objects, "search_%s" % self.collection):
            ui = layout.template_list("SD_%s_ui_list" % self.collection, "",
                                      scene.driver_objects, self.collection,
                                      scene.driver_objects,
                                      "active_%s_index" % self.collection,
                                      self.collection)

        # get_driven_scene_objects(scene)
        if self.collection.startswith("ob"):
            #dic = dm.get_driven_scene_objects(scene)
            ob = coll[index] if search else context.object

            keys = [ob.name] if ob is not None else []
        elif self.collection.startswith("sce"):
            ob = context.scene
            keys = [ob.name]
        elif self.collection.startswith("mat"):
            ob = context.object.active_material
            keys = [ob.name] if ob is not None else []
        elif self.collection.startswith("shape_keys"):
            ob = getattr(context.object.data, "shape_keys", None)
            keys = [ob.name] if ob is not None else []
        else:
            #dic = dm.get_collection_dic(type(self).collection)
            ob = coll[index]
            keys = [ob.name]
            #keys = sorted(dic.keys())

        if ob is None:
            layout.label("NO CONTEXT OBJECT")
            return None
        dm.check_deleted_drivers()
        dic = dm.get_object_dic(collection, ob.name)

        obj = getattr(bpy.data, collection).get(ob.name)

        #  TO BE REFACTORED
        col = layout.column(align=True)
        icon = get_icon(obj.type) if hasattr(
            obj, "type") else icon_from_bpy_datapath(repr(obj))
        row = col.row()
        row.alignment = 'LEFT'
        row.label(icon='DISCLOSURE_TRI_RIGHT', text="")
        if not search and collection.startswith("obj"):
            row.template_ID(context.scene.objects, "active")
        else:
            row.label(icon=icon, text=ob.name)
        #obj = dm.find(dic[m][0][0]).driven_object.id_data            '''
        dm.draw_layout(col, context, dic)
        #dm.check_added_drivers(ob)
        return None
    def draw(self, context):
        layout = self.layout

        collection = self.collection
        scene = context.scene
        wm = context.window_manager
        dm = context.driver_manager
        search = getattr(scene.driver_objects, "search_%s" % self.collection, False)
        index = getattr(scene.driver_objects, "active_%s_index" % self.collection, -1)
        coll = getattr(scene.driver_objects, collection)
        layout.prop(scene.driver_objects, "search_%s" % self.collection)
        if getattr(scene.driver_objects, "search_%s" % self.collection):
            ui = layout.template_list("SD_%s_ui_list" % self.collection,
                                      "", scene.driver_objects,
                                      self.collection, scene.driver_objects,
                                      "active_%s_index" % self.collection, self.collection)

        # get_driven_scene_objects(scene)
        if self.collection.startswith("ob"):
            #dic = dm.get_driven_scene_objects(scene)
            ob = coll[index] if search else context.object
            
            keys = [ob.name] if ob is not None else []
        elif self.collection.startswith("sce"):
            ob = context.scene
            keys = [ob.name]
        elif self.collection.startswith("mat"):
            ob = context.object.active_material
            keys = [ob.name] if ob is not None else []
        elif self.collection.startswith("shape_keys"):
            ob = getattr(context.object.data, "shape_keys", None)
            keys = [ob.name] if ob is not None else []
        else:
            #dic = dm.get_collection_dic(type(self).collection)
            ob = coll[index]
            keys = [ob.name]
            #keys = sorted(dic.keys())
        
        if ob is None:
            layout.label("NO CONTEXT OBJECT")
            return None
        dm.check_deleted_drivers()
        dic = dm.get_object_dic(collection, ob.name)
        

        obj = getattr(bpy.data, collection).get(ob.name)

     #  TO BE REFACTORED
        col = layout.column(align=True)
        icon = get_icon(obj.type) if hasattr(obj, "type") else icon_from_bpy_datapath(repr(obj))
        row = col.row()
        row.alignment = 'LEFT'
        row.label(icon='DISCLOSURE_TRI_RIGHT', text="")
        if not search and collection.startswith("obj"):
            row.template_ID(context.scene.objects, "active")
        else:
            row.label(icon=icon, text=ob.name)
        #obj = dm.find(dic[m][0][0]).driven_object.id_data            '''
        dm.draw_layout(col, context, dic)
        #dm.check_added_drivers(ob)
        return None