Beispiel #1
0
    def execute(self, context):
        listAttr = LibUtils.GetPropGroup(self.list_parent, self.list_attr)
        if listAttr.list_item_selected <= 0:
            return {'CANCELLED'}

        listAttr.list_items.move(listAttr.list_item_selected,
                                 listAttr.list_item_selected - 1)
        listAttr.list_item_selected -= 1

        return {'FINISHED'}
Beispiel #2
0
def DrawListWidget(layout,
                   parentID,
                   propGroupPath,
                   listType,
                   defItemName,
                   itemAddOp='DEFAULT',
                   itemRenderFunc=None):
    listPropGroup = LibUtils.GetPropGroup(parentID, propGroupPath)

    row = layout.row()
    row.template_list(listType,
                      "",
                      listPropGroup,
                      'list_items',
                      listPropGroup,
                      'list_item_selected',
                      rows=5)

    col = row.column()
    sub = col.row()
    subsub = sub.column(align=True)
    if itemAddOp in {'DEFAULT'}:
        op = subsub.operator('vray.ui_list_item_add', icon="ZOOMIN", text="")
        op.list_parent = parentID
        op.list_attr = propGroupPath
        op.def_item_name = defItemName
    else:
        subsub.operator(itemAddOp, icon="ZOOMIN", text="")

    sub = col.row()
    op = subsub.operator('vray.ui_list_item_del', icon="ZOOMOUT", text="")
    op.list_parent = parentID
    op.list_attr = propGroupPath
    subsub = sub.column(align=True)
    op = subsub.operator("vray.ui_list_item_up", icon='MOVE_UP_VEC', text="")
    op.list_parent = parentID
    op.list_attr = propGroupPath
    op = subsub.operator("vray.ui_list_item_down",
                         icon='MOVE_DOWN_VEC',
                         text="")
    op.list_parent = parentID
    op.list_attr = propGroupPath

    if itemRenderFunc:
        if listPropGroup.list_item_selected >= 0 and len(
                listPropGroup.list_items) > 0:
            listItem = listPropGroup.list_items[
                listPropGroup.list_item_selected]

            layout.separator()
            itemRenderFunc(layout, listItem)
Beispiel #3
0
    def execute(self, context):
        listAttr = LibUtils.GetPropGroup(self.list_parent, self.list_attr)

        if listAttr.list_item_selected >= 0:
            listAttr.list_items.remove(listAttr.list_item_selected)
            listAttr.list_item_selected -= 1

        if len(listAttr.list_items):
            if listAttr.list_item_selected < 0:
                listAttr.list_item_selected = 0
        else:
            listAttr.list_item_selected = -1

        return {'FINISHED'}
Beispiel #4
0
 def execute(self, context):
     listAttr = LibUtils.GetPropGroup(self.list_parent, self.list_attr)
     listAttr.list_items.add()
     listAttr.list_items[-1].name = self.def_item_name
     listAttr.list_item_selected = len(listAttr.list_items) - 1
     return {'FINISHED'}