2.5: Lists for vertex groups, shape keys, uvs, vertex colors.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 1 Jul 2009 22:25:49 +0000 (22:25 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 1 Jul 2009 22:25:49 +0000 (22:25 +0000)
RNA
* Added the relevant active_*_index properties, with proper
  get/set/range, updates and notifiers.
* Context.tool_settings.
* ToolSettings.vertex_group_weight.

Operators
* MESH_OT_uv_texture_add/remove
* MESH_OT_vertex_color_add/remove
* MESH_OT_sticky_add/remove
* OBJECT_OT_vertex_group_add/remove/assign/remove_from/
  select/deselect/copy/copy_to_linked
* OBJECT_OT_shape_key_add/remove

UI
* Some updates and cleanups in list template code.

Known issue: when going in & out of editmode, uv textures and vertex
colors dissappear. I thought me->edit_mesh would be NULL when not in
edit mode but it is not?

26 files changed:
release/ui/buttons_data_mesh.py
release/ui/buttons_data_modifier.py
release/ui/buttons_particle.py
source/blender/blenkernel/intern/particle.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_layers.c [new file with mode: 0644]
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/editkey.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_vgroup.c [moved from source/blender/editors/mesh/editdeform.c with 80% similarity]
source/blender/editors/space_buttons/space_buttons.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_screen_types.h
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_context.c
source/blender/makesrna/intern/rna_mesh.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_ui_api.c

index 3360f4c47ad512c0aeb387f1e1dfa4dd1e0e4929..c7e253d5084e5a8174f26959fb0d6932bed46ec6 100644 (file)
@@ -62,30 +62,125 @@ class DATA_PT_materials(DataButtonsPanel):
 
                row = layout.row()
 
-               row.template_list(ob, "materials", "active_material_index")
+               row.template_list(ob, "materials", ob, "active_material_index")
 
                col = row.column(align=True)
                col.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
                col.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
 
-               row = layout.row(align=True)
+               if context.edit_object:
+                       row = layout.row(align=True)
 
-               row.itemO("OBJECT_OT_material_slot_assign", text="Assign");
-               row.itemO("OBJECT_OT_material_slot_select", text="Select");
-               row.itemO("OBJECT_OT_material_slot_deselect", text="Deselect");
+                       row.itemO("OBJECT_OT_material_slot_assign", text="Assign")
+                       row.itemO("OBJECT_OT_material_slot_select", text="Select")
+                       row.itemO("OBJECT_OT_material_slot_deselect", text="Deselect")
 
+               """
                layout.itemS()
 
                box= layout.box()
 
                row = box.row()
-               row.template_list(ob, "materials", "active_material_index", compact=True)
+               row.template_list(ob, "materials", ob, "active_material_index", compact=True)
 
                subrow = row.row(align=True)
                subrow.itemO("OBJECT_OT_material_slot_add", icon="ICON_ZOOMIN", text="")
                subrow.itemO("OBJECT_OT_material_slot_remove", icon="ICON_ZOOMOUT", text="")
+               """
 
+class DATA_PT_vertex_groups(DataButtonsPanel):
+       __idname__ = "DATA_PT_vertex_groups"
+       __label__ = "Vertex Groups"
+       
+       def poll(self, context):
+               return (context.object and context.object.type in ('MESH', 'LATTICE'))
+
+       def draw(self, context):
+               layout = self.layout
+               ob = context.object
+
+               row = layout.row()
+
+               row.template_list(ob, "vertex_groups", ob, "active_vertex_group_index")
+
+               col = row.column(align=True)
+               col.itemO("OBJECT_OT_vertex_group_add", icon="ICON_ZOOMIN", text="")
+               col.itemO("OBJECT_OT_vertex_group_remove", icon="ICON_ZOOMOUT", text="")
+
+               col.itemO("OBJECT_OT_vertex_group_copy", icon="ICON_BLANK1", text="")
+               if ob.data.users > 1:
+                       col.itemO("OBJECT_OT_vertex_group_copy_to_linked", icon="ICON_BLANK1", text="")
+
+               if context.edit_object:
+                       row = layout.row(align=True)
+
+                       row.itemO("OBJECT_OT_vertex_group_assign", text="Assign")
+                       row.itemO("OBJECT_OT_vertex_group_remove_from", text="Remove")
+                       row.itemO("OBJECT_OT_vertex_group_select", text="Select")
+                       row.itemO("OBJECT_OT_vertex_group_deselect", text="Deselect")
+
+                       layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight")
+
+class DATA_PT_shape_keys(DataButtonsPanel):
+       __idname__ = "DATA_PT_shape_keys"
+       __label__ = "Shape Keys"
+       
+       def poll(self, context):
+               return (context.object and context.object.type in ('MESH', 'LATTICE'))
+
+       def draw(self, context):
+               layout = self.layout
+               ob = context.object
+
+               row = layout.row()
+
+               key = ob.data.shape_keys
+
+               row.template_list(key, "keys", ob, "active_shape_key_index")
+
+               col = row.column(align=True)
+               col.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
+               col.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
+
+               if context.edit_object:
+                       layout.enabled = False
+
+class DATA_PT_uv_texture(DataButtonsPanel):
+       __idname__ = "DATA_PT_uv_texture"
+       __label__ = "UV Texture"
+       
+       def draw(self, context):
+               layout = self.layout
+               me = context.mesh
+
+               row = layout.row()
+
+               row.template_list(me, "uv_textures", me, "active_uv_texture_index")
+
+               col = row.column(align=True)
+               col.itemO("MESH_OT_uv_texture_add", icon="ICON_ZOOMIN", text="")
+               col.itemO("MESH_OT_uv_texture_remove", icon="ICON_ZOOMOUT", text="")
+
+class DATA_PT_vertex_colors(DataButtonsPanel):
+       __idname__ = "DATA_PT_vertex_colors"
+       __label__ = "Vertex Colors"
+       
+       def draw(self, context):
+               layout = self.layout
+               me = context.mesh
+
+               row = layout.row()
+
+               row.template_list(me, "vertex_colors", me, "active_vertex_color_index")
+
+               col = row.column(align=True)
+               col.itemO("MESH_OT_vertex_color_add", icon="ICON_ZOOMIN", text="")
+               col.itemO("MESH_OT_vertex_color_remove", icon="ICON_ZOOMOUT", text="")
 
 bpy.types.register(DATA_PT_mesh)
 bpy.types.register(DATA_PT_materials)
+bpy.types.register(DATA_PT_vertex_groups)
+bpy.types.register(DATA_PT_shape_keys)
+bpy.types.register(DATA_PT_uv_texture)
+bpy.types.register(DATA_PT_vertex_colors)
 
index 366f2b8a86b10ae9b3d33853df3cc04b23ed2e1b..953fc1f09742c704d401320d9c6e6bff4b003252 100644 (file)
@@ -350,7 +350,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                sub.itemR(md, "factor")
                sub.itemR(md, "repeat")
                
-               layout.template_pointer(md, "vertex_group", ob, "vertex_groups")
+               layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                
        def softbody(self, layout, ob, md):
                layout.itemL(text="See Softbody panel.")
index 85580c9be69f1fcb43da5fcbcd9f9814618b200d..49ceaf6aae1873ef67bfac4a20918f860abf1709 100644 (file)
@@ -33,7 +33,7 @@ class PARTICLE_PT_particles(ParticleButtonsPanel):
                if ob:
                        row = layout.row()
 
-                       row.template_list(ob, "particle_systems", "active_particle_system_index")
+                       row.template_list(ob, "particle_systems", ob, "active_particle_system_index")
 
                        col = row.column(align=True)
                        col.itemO("OBJECT_OT_particle_system_add", icon="ICON_ZOOMIN", text="")
index 31e60e985d5df021b32111ecfe8216f200d25264..5bf9335d211590cd363201e027f3d6958b77368a 100644 (file)
@@ -230,7 +230,7 @@ void psys_set_current_num(Object *ob, int index)
        if(ob==0) return;
 
        for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) {
-               if(i == index - 1)
+               if(i == index)
                        psys->flag |= PSYS_CURRENT;
                else
                        psys->flag &= ~PSYS_CURRENT;
index 1dd206e6cce42624b9e21e8224033638edade827..c89f515f319859992464e9a6adb6c85bdc61f80f 100644 (file)
@@ -9011,12 +9011,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                 */
                //do_versions_ipos_to_animato(main);
                
-               /* struct audio data moved to renderdata */
+               /* toolsettings */
                for(scene= main->scene.first; scene; scene= scene->id.next) {
                        scene->r.audio = scene->audio;
                        
-                       if(!scene->toolsettings->uv_selectmode)
+                       if(!scene->toolsettings->uv_selectmode) {
                                scene->toolsettings->uv_selectmode= UV_SELECT_VERTEX;
+                               scene->toolsettings->vgroup_weight= 1.0f;
+                       }
                }
                
                /* shader, composit and texture node trees have id.name empty, put something in
index 937f6384f6a1e860f65ca0991cfb19ee28d6e4e0..8952305d6ab30b61ed0c40ba5f839de5cbe97b53 100644 (file)
@@ -110,7 +110,6 @@ void                undo_push_mesh(struct bContext *C, char *name);
 struct EditFace        *EM_get_actFace(struct EditMesh *em, int sloppy);
 void             EM_set_actFace(struct EditMesh *em, struct EditFace *efa);
 float            EM_face_area(struct EditFace *efa);
-void             EM_add_data_layer(struct EditMesh *em, struct CustomData *data, int type);
 
 void           EM_select_edge(struct EditEdge *eed, int sel);
 void           EM_select_face(struct EditFace *efa, int sel);
@@ -134,6 +133,9 @@ struct UvVertMap *EM_make_uv_vert_map(struct EditMesh *em, int selected, int do_
 struct UvMapVert *EM_get_uv_map_vert(struct UvVertMap *vmap, unsigned int v);
 void              EM_free_uv_vert_map(struct UvVertMap *vmap);
 
+void           EM_add_data_layer(struct EditMesh *em, struct CustomData *data, int type);
+void           EM_free_data_layer(struct EditMesh *em, struct CustomData *data, int type);
+
 /* editmesh_mods.c */
 extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs;
 
index 5000dca37431e28009618be87f91e0577decd337..cc8b936b04f2d15626dc8a4bc84f79f13142c67c 100644 (file)
@@ -617,7 +617,7 @@ void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
 void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
-ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *activeprop, int rows, int columns, int compact);
+ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int columns, int compact);
 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
 void uiTemplateOperatorSearch(uiLayout *layout);
 
index fcea74cc22bbb22622dbfa7cd8d8f1a126bdcbba..00ec875bd86c3688200c3487e17bd4da67f9c84a 100644 (file)
@@ -2184,7 +2184,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
                                RNA_property_int_range(ptr, prop, &hardmin, &hardmax);
                                RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
 
-                               if(min == max) {
+                               if(type != ROW && min == max) {
                                        min= hardmin;
                                        max= hardmax;
                                }
@@ -2199,7 +2199,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
                                RNA_property_float_range(ptr, prop, &hardmin, &hardmax);
                                RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
 
-                               if(min == max) {
+                               if(type != ROW && min == max) {
                                        min= hardmin;
                                        max= hardmax;
                                }
index 8b3f2bf4100aae508ba4e08fd4f159001c26e89e..8f1d57b28ed3cbcf0ca4ab2c880890970ebfa173 100644 (file)
@@ -1486,93 +1486,63 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname)
 
 /************************* List Template **************************/
 
-#if 0
-typedef struct ListItem {
-       PointerRNA ptr;
-       PropertyRNA *prop;
-       PropertyRNA *activeprop;
-
-       PointerRNA activeptr;
-       int activei;
-
-       int selected;
-} ListItem;
-
-static void list_item_cb(bContext *C, void *arg_item, void *arg_unused)
-{
-       ListItem *item= (ListItem*)arg_item;
-       PropertyType activetype;
-       char *activename;
-
-       if(item->selected) {
-               activetype= RNA_property_type(item->activeprop);
-
-               if(activetype == PROP_POINTER)
-                       RNA_property_pointer_set(&item->ptr, item->activeprop, item->activeptr);
-               else if(activetype == PROP_INT)
-                       RNA_property_int_set(&item->ptr, item->activeprop, item->activei);
-               else if(activetype == PROP_STRING) {
-                       activename= RNA_struct_name_get_alloc(&item->activeptr, NULL, 0);
-                       RNA_property_string_set(&item->ptr, item->activeprop, activename);
-                       MEM_freeN(activename);
-               }
-       }
-}
-#endif
-
-ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char *activepropname, int rows, int columns, int compact)
+ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, PointerRNA *activeptr, char *activepropname, int rows, int columns, int compact)
 {
        CollectionPointerLink *link;
-       PropertyRNA *prop, *activeprop;
+       PropertyRNA *prop= NULL, *activeprop;
        PropertyType type, activetype;
-       PointerRNA activeptr;
        uiLayout *box, *row, *col;
        uiBlock *block;
        uiBut *but;
+       Panel *pa;
        ListBase lb;
-       char *name, *activename= NULL, str[32];
-       int i= 1, activei= 0, len, items, found;
-       static int scroll = 1;
+       char *name, str[32];
+       int i= 0, activei= 0, len, items, found, min, max;
 
        lb.first= lb.last= NULL;
        
        /* validate arguments */
-       if(!ptr->data)
+       block= uiLayoutGetBlock(layout);
+       pa= block->panel;
+
+       if(!pa) {
+               printf("uiTemplateList: only works inside a panel.\n");
                return lb;
-       
-       prop= RNA_struct_find_property(ptr, propname);
-       if(!prop) {
-               printf("uiTemplateList: property not found: %s\n", propname);
+       }
+
+       if(!activeptr->data)
                return lb;
+       
+       if(ptr->data) {
+               prop= RNA_struct_find_property(ptr, propname);
+               if(!prop) {
+                       printf("uiTemplateList: property not found: %s\n", propname);
+                       return lb;
+               }
        }
 
-       activeprop= RNA_struct_find_property(ptr, activepropname);
+       activeprop= RNA_struct_find_property(activeptr, activepropname);
        if(!activeprop) {
                printf("uiTemplateList: property not found: %s\n", activepropname);
                return lb;
        }
 
-       type= RNA_property_type(prop);
-       if(type != PROP_COLLECTION) {
-               printf("uiTemplateList: expected collection property.\n");
-               return lb;
+       if(prop) {
+               type= RNA_property_type(prop);
+               if(type != PROP_COLLECTION) {
+                       printf("uiTemplateList: expected collection property.\n");
+                       return lb;
+               }
        }
 
        activetype= RNA_property_type(activeprop);
-       if(!ELEM3(activetype, PROP_POINTER, PROP_INT, PROP_STRING)) {
-               printf("uiTemplateList: expected pointer, integer or string property.\n");
+       if(activetype != PROP_INT) {
+               printf("uiTemplateList: expected integer property.\n");
                return lb;
        }
 
        /* get active data */
-       if(activetype == PROP_POINTER)
-               activeptr= RNA_property_pointer_get(ptr, activeprop);
-       else if(activetype == PROP_INT)
-               activei= RNA_property_int_get(ptr, activeprop);
-       else if(activetype == PROP_STRING)
-               activename= RNA_property_string_get_alloc(ptr, activeprop, NULL, 0);
-
-       block= uiLayoutGetBlock(layout);
+       activei= RNA_property_int_get(activeptr, activeprop);
 
        if(compact) {
                /* compact layout */
@@ -1580,111 +1550,105 @@ ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char
 
                row= uiLayoutRow(layout, 1);
 
-               RNA_PROP_BEGIN(ptr, itemptr, prop) {
-                       if(activetype == PROP_POINTER)
-                               found= (activeptr.data == itemptr.data);
-                       else if(activetype == PROP_INT)
+               if(ptr->data && prop) {
+                       /* create list items */
+                       RNA_PROP_BEGIN(ptr, itemptr, prop) {
                                found= (activei == i);
-                       else if(activetype == PROP_STRING)
-                               found= (strcmp(activename, name) == 0);
-
-                       if(found) {
-                               name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
-                               if(name) {
-                                       uiItemL(row, name, RNA_struct_ui_icon(itemptr.type));
-                                       MEM_freeN(name);
+
+                               if(found) {
+                                       /* create button */
+                                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+                                       if(name) {
+                                               uiItemL(row, name, RNA_struct_ui_icon(itemptr.type));
+                                               MEM_freeN(name);
+                                       }
+
+                                       /* add to list to return */
+                                       link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
+                                       link->ptr= itemptr;
+                                       BLI_addtail(&lb, link);
                                }
 
-                               link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
-                               link->ptr= itemptr;
-                               BLI_addtail(&lb, link);
+                               i++;
                        }
-
-                       i++;
+                       RNA_PROP_END;
                }
-               RNA_PROP_END;
 
-               if(i == 1)
+               /* if not found, add in dummy button */
+               if(i == 0)
                        uiItemL(row, "", 0);
 
-               sprintf(str, "%d :", i-1);
-               but= uiDefIconTextButR(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, ptr, activepropname, 0, 0, 0, 0, 0, "");
-               if(i == 1)
+               /* next/prev button */
+               sprintf(str, "%d :", i);
+               but= uiDefIconTextButR(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activepropname, 0, 0, 0, 0, 0, "");
+               if(i == 0)
                        uiButSetFlag(but, UI_BUT_DISABLED);
        }
        else {
+               /* default rows/columns */
                if(rows == 0)
                        rows= 5;
                if(columns == 0)
                        columns= 1;
 
-               items= rows*columns;
-
+               /* layout */
                box= uiLayoutBox(layout);
                row= uiLayoutRow(box, 0);
                col = uiLayoutColumn(row, 1);
 
                uiBlockSetEmboss(block, UI_EMBOSSN);
 
-               len= RNA_property_collection_length(ptr, prop);
-               scroll= MIN2(scroll, len-items+1);
-               scroll= MAX2(scroll, 1);
+               /* init numbers */
+               RNA_property_int_range(activeptr, activeprop, &min, &max);
 
-               RNA_PROP_BEGIN(ptr, itemptr, prop) {
-                       if(i >= scroll && i<scroll+items) {
-                               name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+               len= max - min + 1;
+               items= rows*columns;
 
-                               if(name) {
-#if 0
-                                       ListItem *item= MEM_callocN(sizeof(ListItem), "uiTemplateList ListItem");
-
-                                       item->ptr= *ptr;
-                                       item->prop= prop;
-                                       item->activeprop= activeprop;
-                                       item->activeptr= itemptr;
-                                       item->activei= i;
-
-                                       if(activetype == PROP_POINTER)
-                                               item->selected= (activeptr.data == itemptr.data)? i: -1;
-                                       else if(activetype == PROP_INT)
-                                               item->selected= (activei == i)? i: -1;
-                                       else if(activetype == PROP_STRING)
-                                               item->selected= (strcmp(activename, name) == 0)? i: -1;
-#endif
+               pa->list_scroll= MIN2(pa->list_scroll, len-items);
+               pa->list_scroll= MAX2(pa->list_scroll, 0);
 
-                                       //but= uiDefIconTextButI(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, &item->selected, 0, i, 0, 0, "");
-                                       but= uiDefIconTextButR(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, ptr, activepropname, 0/*&item->selected*/, 0, i, 0, 0, "");
-                                       uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
-                                       //uiButSetNFunc(but, list_item_cb, item, NULL);
+               if(ptr->data && prop) {
+                       /* create list items */
+                       RNA_PROP_BEGIN(ptr, itemptr, prop) {
+                               if(i >= pa->list_scroll && i<pa->list_scroll+items) {
+                                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
 
-                                       MEM_freeN(name);
+                                       if(name) {
+                                               /* create button */
+                                               but= uiDefIconTextButR(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
+                                               uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
 
+                                               MEM_freeN(name);
+                                       }
+
+                                       /* add to list to return */
                                        link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
                                        link->ptr= itemptr;
                                        BLI_addtail(&lb, link);
                                }
-                       }
 
-                       i++;
+                               i++;
+                       }
+                       RNA_PROP_END;
                }
-               RNA_PROP_END;
 
-               while(i < scroll+items) {
-                       if(i >= scroll)
+               /* add dummy buttons to fill space */
+               while(i < pa->list_scroll+items) {
+                       if(i >= pa->list_scroll)
                                uiItemL(col, "", 0);
                        i++;
                }
 
                uiBlockSetEmboss(block, UI_EMBOSS);
 
+               /* add scrollbar */
                if(len > items) {
                        col= uiLayoutColumn(row, 0);
-                       uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &scroll, 1, len-items+1, items, 0, "");
+                       uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &pa->list_scroll, 0, len-items, items, 0, "");
                }
-
-               //uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*15,UI_UNIT_Y*0.75, &scroll, 1, 16-5, 5, 0, "");
        }
 
+       /* return items in list */
        return lb;
 }
 
index ddf31c0db6688c38cc166c017a19796bd4ccffb6..ed2d00cb00d6c08baf847080c6f6d203dc7090a3 100644 (file)
@@ -1679,12 +1679,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
        rect1= *rect;
 
        if(horizontal) {
-               fac= (rect->xmax - rect->xmin)/(size-1);
+               fac= (rect->xmax - rect->xmin)/(size);
                rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin));
                rect1.xmax= rect1.xmin + ceil(fac*(but->a1 - but->softmin));
        }
        else {
-               fac= (rect->ymax - rect->ymin)/(size-1);
+               fac= (rect->ymax - rect->ymin)/(size);
                rect1.ymax= rect1.ymax - ceil(fac*(value - but->softmin));
                rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin));
        }
index 83a4211dda1fea122b176933c382ae17d3b8c6dc..22e3b4060a4b69a5afb6faa61d5bc7a9cc0c3b6e 100644 (file)
@@ -234,5 +234,14 @@ void MESH_OT_colors_mirror(struct wmOperatorType *ot);
 void MESH_OT_delete(struct wmOperatorType *ot);
 void MESH_OT_rip(struct wmOperatorType *ot);
 
+/* ******************* mesh_layers.c */
+
+void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
+void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
+void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
+void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
+void MESH_OT_sticky_add(struct wmOperatorType *ot);
+void MESH_OT_sticky_remove(struct wmOperatorType *ot);
+
 #endif // MESH_INTERN_H
 
diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c
new file mode 100644 (file)
index 0000000..99d50d1
--- /dev/null
@@ -0,0 +1,424 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_customdata_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "BKE_context.h"
+#include "BKE_customdata.h"
+#include "BKE_depsgraph.h"
+#include "BKE_displist.h"
+#include "BKE_global.h"
+#include "BKE_mesh.h"
+
+#include "BLI_editVert.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_mesh.h"
+#include "ED_view3d.h"
+
+#include "mesh_intern.h"
+
+static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer)
+{
+       CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
+       void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data;
+       int type= layer->type;
+       int index= CustomData_get_layer_index(data, type);
+       int i, actindex, rndindex, cloneindex, maskindex;
+       
+       /* ok, deleting a non-active layer needs to preserve the active layer indices.
+         to do this, we store a pointer to the .data member of both layer and the active layer,
+         (to detect if we're deleting the active layer or not), then use the active
+         layer data pointer to find where the active layer has ended up.
+         
+         this is necassary because the deletion functions only support deleting the active
+         layer. */
+       actlayerdata = data->layers[CustomData_get_active_layer_index(data, type)].data;
+       rndlayerdata = data->layers[CustomData_get_render_layer_index(data, type)].data;
+       clonelayerdata = data->layers[CustomData_get_clone_layer_index(data, type)].data;
+       masklayerdata = data->layers[CustomData_get_mask_layer_index(data, type)].data;
+       CustomData_set_layer_active(data, type, layer - &data->layers[index]);
+
+       if(me->edit_mesh) {
+               EM_free_data_layer(me->edit_mesh, data, type);
+       }
+       else {
+               CustomData_free_layer_active(data, type, me->totface);
+               mesh_update_customdata_pointers(me);
+       }
+
+       if(!CustomData_has_layer(data, type))
+               if(type == CD_MCOL && (G.f & G_VERTEXPAINT))
+                       G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */
+
+       /* reconstruct active layer */
+       if (actlayerdata != layerdata) {
+               /* find index */
+               actindex = CustomData_get_layer_index(data, type);
+               for (i=actindex; i<data->totlayer; i++) {
+                       if (data->layers[i].data == actlayerdata) {
+                               actindex = i - actindex;
+                               break;
+                       }
+               }
+               
+               /* set index */
+               CustomData_set_layer_active(data, type, actindex);
+       }
+       
+       if (rndlayerdata != layerdata) {
+               /* find index */
+               rndindex = CustomData_get_layer_index(data, type);
+               for (i=rndindex; i<data->totlayer; i++) {
+                       if (data->layers[i].data == rndlayerdata) {
+                               rndindex = i - rndindex;
+                               break;
+                       }
+               }
+               
+               /* set index */
+               CustomData_set_layer_render(data, type, rndindex);
+       }
+       
+       if (clonelayerdata != layerdata) {
+               /* find index */
+               cloneindex = CustomData_get_layer_index(data, type);
+               for (i=cloneindex; i<data->totlayer; i++) {
+                       if (data->layers[i].data == clonelayerdata) {
+                               cloneindex = i - cloneindex;
+                               break;
+                       }
+               }
+               
+               /* set index */
+               CustomData_set_layer_clone(data, type, cloneindex);
+       }
+       
+       if (masklayerdata != layerdata) {
+               /* find index */
+               maskindex = CustomData_get_layer_index(data, type);
+               for (i=maskindex; i<data->totlayer; i++) {
+                       if (data->layers[i].data == masklayerdata) {
+                               maskindex = i - maskindex;
+                               break;
+                       }
+               }
+               
+               /* set index */
+               CustomData_set_layer_mask(data, type, maskindex);
+       }
+}
+
+/*********************** UV texture operators ************************/
+
+static int uv_texture_add_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+       EditMesh *em;
+       int layernum;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+
+       if(scene->obedit == ob) {
+               em= me->edit_mesh;
+
+               layernum= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
+               if(layernum >= MAX_MTFACE)
+                       return OPERATOR_CANCELLED;
+
+               EM_add_data_layer(em, &em->fdata, CD_MTFACE);
+               CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum);
+       }
+       else if(ob) {
+               layernum= CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+               if(layernum >= MAX_MTFACE)
+                       return OPERATOR_CANCELLED;
+
+               if(me->mtface)
+                       CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface);
+               else
+                       CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface);
+
+               CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum);
+               mesh_update_customdata_pointers(me);
+       }
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_uv_texture_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add UV Texture";
+       ot->idname= "MESH_OT_uv_texture_add";
+       
+       /* api callbacks */
+       ot->exec= uv_texture_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int uv_texture_remove_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+       CustomDataLayer *cdl;
+       int index;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+       index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
+       cdl= (index == -1)? NULL: &me->fdata.layers[index];
+
+       if(!cdl)
+               return OPERATOR_CANCELLED;
+
+       delete_customdata_layer(me, cdl);
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_uv_texture_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove UV Texture";
+       ot->idname= "MESH_OT_uv_texture_remove";
+       
+       /* api callbacks */
+       ot->exec= uv_texture_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/*********************** vertex color operators ************************/
+
+static int vertex_color_add_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+       EditMesh *em;
+       MCol *mcol;
+       int layernum;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+
+       if(scene->obedit == ob) {
+               em= me->edit_mesh;
+
+               layernum= CustomData_number_of_layers(&em->fdata, CD_MCOL);
+               if(layernum >= MAX_MCOL)
+                       return OPERATOR_CANCELLED;
+
+               EM_add_data_layer(em, &em->fdata, CD_MCOL);
+               CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum);
+       }
+       else {
+               layernum= CustomData_number_of_layers(&me->fdata, CD_MCOL);
+               if(layernum >= MAX_MCOL)
+                       return OPERATOR_CANCELLED;
+
+               mcol= me->mcol;
+
+               if(me->mcol)
+                       CustomData_add_layer(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface);
+               else
+                       CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface);
+
+               CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
+               mesh_update_customdata_pointers(me);
+
+               if(!mcol)
+                       shadeMeshMCol(scene, ob, me);
+       }
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vertex_color_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Vertex Color";
+       ot->idname= "MESH_OT_vertex_color_add";
+       
+       /* api callbacks */
+       ot->exec= vertex_color_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_color_remove_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+       CustomDataLayer *cdl;
+       int index;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+       index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
+       cdl= (index == -1)? NULL: &me->fdata.layers[index];
+
+       if(!cdl)
+               return OPERATOR_CANCELLED;
+
+       delete_customdata_layer(me, cdl);
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_vertex_color_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove Vertex Color";
+       ot->idname= "MESH_OT_vertex_color_remove";
+       
+       /* api callbacks */
+       ot->exec= vertex_color_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/*********************** sticky operators ************************/
+
+static int sticky_add_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+
+       if(me->msticky)
+               return OPERATOR_CANCELLED;
+
+       // XXX RE_make_sticky();
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_sticky_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Sticky";
+       ot->idname= "MESH_OT_sticky_add";
+       
+       /* api callbacks */
+       ot->exec= sticky_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int sticky_remove_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Mesh *me;
+
+       if(!ob || ob->type!=OB_MESH)
+               return OPERATOR_CANCELLED;
+       
+       me= (Mesh*)ob->data;
+
+       if(!me->msticky)
+               return OPERATOR_CANCELLED;
+
+       CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
+       me->msticky= NULL;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_sticky_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove Sticky";
+       ot->idname= "MESH_OT_sticky_remove";
+       
+       /* api callbacks */
+       ot->exec= sticky_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
index 5a86180a60fb284e28645b0e7daf49b83285aefa..2a9357ed0f0c9e55d67e75c63e683babe078fa94 100644 (file)
@@ -183,6 +183,12 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_knife_cut);
        WM_operatortype_append(MESH_OT_rip);
        
+       WM_operatortype_append(MESH_OT_uv_texture_add);
+       WM_operatortype_append(MESH_OT_uv_texture_remove);
+       WM_operatortype_append(MESH_OT_vertex_color_add);
+       WM_operatortype_append(MESH_OT_vertex_color_remove);
+       WM_operatortype_append(MESH_OT_sticky_add);
+       WM_operatortype_append(MESH_OT_sticky_remove);
 }
 
 /* note mesh keymap also for other space? */
index 913046c5ab80b02fc0cef036000d5d0f665fa25a..1c31c7c765356a134dd9f92cf4a089b37eeec5be 100644 (file)
@@ -55,6 +55,7 @@
 
 #include "BKE_action.h"
 #include "BKE_anim.h"
+#include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
 #include "BKE_global.h"
 
 #include "ED_object.h"
 
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "object_intern.h"
 
 /* XXX */
 static void BIF_undo_push() {}
-static void error() {}
 /* XXX */
 
 #if 0 // XXX old animation system
@@ -394,25 +399,6 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
 
 /* ******************** */
 
-void insert_shapekey(Scene *scene, Object *ob)
-{
-       if(get_mesh(ob) && get_mesh(ob)->mr) {
-               error("Cannot create shape keys on a multires mesh.");
-       }
-       else {
-               Key *key;
-       
-               if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
-               else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
-               else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
-       
-               key= ob_get_key(ob);
-               ob->shapenr= BLI_countlist(&key->block);
-       
-               BIF_undo_push("Add Shapekey");
-       }
-}
-
 void delete_key(Scene *scene, Object *ob)
 {
        KeyBlock *kb, *rkb;
@@ -473,6 +459,123 @@ void delete_key(Scene *scene, Object *ob)
        BIF_undo_push("Delete Shapekey");
 }
 
+/********************** shape key operators *********************/
+
+static int shape_key_add_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Key *key;
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
+       else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
+       else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
+
+       key= ob_get_key(ob);
+       ob->shapenr= BLI_countlist(&key->block);
+
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_shape_key_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Shape Key";
+       ot->idname= "OBJECT_OT_shape_key_add";
+       
+       /* api callbacks */
+       ot->exec= shape_key_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int shape_key_remove_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Scene *scene= CTX_data_scene(C);
+       Main *bmain= CTX_data_main(C);
+       KeyBlock *kb, *rkb;
+       Key *key;
+       //IpoCurve *icu;
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+       
+       key= ob_get_key(ob);
+       if(key==NULL)
+               return OPERATOR_CANCELLED;
+       
+       kb= BLI_findlink(&key->block, ob->shapenr-1);
+
+       if(kb) {
+               for(rkb= key->block.first; rkb; rkb= rkb->next)
+                       if(rkb->relative == ob->shapenr-1)
+                               rkb->relative= 0;
+
+               BLI_remlink(&key->block, kb);
+               key->totkey--;
+               if(key->refkey== kb)
+                       key->refkey= key->block.first;
+                       
+               if(kb->data) MEM_freeN(kb->data);
+               MEM_freeN(kb);
+               
+               for(kb= key->block.first; kb; kb= kb->next)
+                       if(kb->adrcode>=ob->shapenr)
+                               kb->adrcode--;
+               
+#if 0 // XXX old animation system
+               if(key->ipo) {
+                       
+                       for(icu= key->ipo->curve.first; icu; icu= icu->next) {
+                               if(icu->adrcode==ob->shapenr-1) {
+                                       BLI_remlink(&key->ipo->curve, icu);
+                                       free_ipo_curve(icu);
+                                       break;
+                               }
+                       }
+                       for(icu= key->ipo->curve.first; icu; icu= icu->next) 
+                               if(icu->adrcode>=ob->shapenr)
+                                       icu->adrcode--;
+               }
+#endif // XXX old animation system             
+               
+               if(ob->shapenr>1) ob->shapenr--;
+       }
+       
+       if(key->totkey==0) {
+               if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL;
+               else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
+               else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
+
+               free_libblock_us(&(bmain->key), key);
+       }
+       
+       DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove Shape Key";
+       ot->idname= "OBJECT_OT_shape_key_remove";
+       
+       /* api callbacks */
+       ot->exec= shape_key_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 void move_keys(Object *ob)
 {
 #if 0
@@ -560,3 +663,4 @@ void move_keys(Object *ob)
        BIF_undo_push("Move Shapekey(s)");
 #endif
 }
+
index 1eb867e19a059f091109de348158d925a6a56896..a52acdd4e1e89780f1ef23e819b097a6dca2ece2 100644 (file)
@@ -92,5 +92,19 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
 /* editconstraint.c */
 void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
 
+/* object_vgroup.c */
+void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_remove(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_assign(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_remove_from(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_copy_to_linked(struct wmOperatorType *ot);
+void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot);
+
+/* editkey.c */
+void OBJECT_OT_shape_key_add(struct wmOperatorType *ot);
+void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot);
+
 #endif /* ED_OBJECT_INTERN_H */
 
index cfee6a551527187cd4d428c0825b729685e67064..6fa78a538401b5311416e012e4030778dc7581ab 100644 (file)
@@ -104,6 +104,18 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(OBJECT_OT_modifier_mdef_bind);
 
        WM_operatortype_append(OBJECT_OT_constraint_add);
+
+       WM_operatortype_append(OBJECT_OT_vertex_group_add);
+       WM_operatortype_append(OBJECT_OT_vertex_group_remove);
+       WM_operatortype_append(OBJECT_OT_vertex_group_assign);
+       WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
+       WM_operatortype_append(OBJECT_OT_vertex_group_select);
+       WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
+       WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
+       WM_operatortype_append(OBJECT_OT_vertex_group_copy);
+
+       WM_operatortype_append(OBJECT_OT_shape_key_add);
+       WM_operatortype_append(OBJECT_OT_shape_key_remove);
 }
 
 void ED_keymap_object(wmWindowManager *wm)
similarity index 80%
rename from source/blender/editors/mesh/editdeform.c
rename to source/blender/editors/object/object_vgroup.c
index 3ccd4d56ece7b5daec9b1e515b466308dc8b2885..fb71fc091086ec3d4148d381b7885d83c4773cdb 100644 (file)
 #include "BLI_blenlib.h"
 #include "BLI_editVert.h"
 
+#include "BKE_context.h"
 #include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_depsgraph.h"
 #include "BKE_deform.h"
+#include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
 #include "BKE_lattice.h"
 #include "BKE_mesh.h"
 #include "BKE_utildefines.h"
 
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
 #include "ED_mesh.h"
 #include "ED_view3d.h"
-#include "mesh_intern.h"
+
+#include "object_intern.h"
 
 /* XXX */
 static void BIF_undo_push() {}
@@ -719,18 +726,13 @@ void add_vert_to_defgroup (Object *ob, bDeformGroup *dg, int vertnum,
 }
 
 /* Only available in editmode */
-void assign_verts_defgroup (Object *obedit, float weight)
+void assign_verts_defgroup (Object *ob, float weight)
 {
-       Object *ob;
        EditVert *eve;
        bDeformGroup *dg, *eg;
        MDeformWeight *newdw;
        MDeformVert *dvert;
        int     i, done;
-       
-// XXX if(multires_level1_test()) return;
-
-       ob= obedit;
 
        if (!ob)
                return;
@@ -883,18 +885,13 @@ float get_vert_defgroup (Object *ob, bDeformGroup *dg, int vertnum)
 
 /* Only available in editmode */
 /* removes from active defgroup, if allverts==0 only selected vertices */
-void remove_verts_defgroup (Object *obedit, int allverts)
+void remove_verts_defgroup (Object *ob, int allverts)
 {
-       Object *ob;
        EditVert *eve;
        MDeformVert *dvert;
        MDeformWeight *newdw;
        bDeformGroup *dg, *eg;
        int     i;
-       
-// XXX if(multires_level1_test()) return;
-
-       ob= obedit;
 
        if (!ob)
                return;
@@ -966,14 +963,10 @@ void remove_verts_defgroup (Object *obedit, int allverts)
 
 /* Only available in editmode */
 /* removes from all defgroup, if allverts==0 only selected vertices */
-void remove_verts_defgroups(Object *obedit, int allverts)
+void remove_verts_defgroups(Object *ob, int allverts)
 {
-       Object *ob;
        int actdef, defCount;
-       
-//  XXX        if (multires_level1_test()) return;
 
-       ob= obedit;
        if (ob == NULL) return;
        
        actdef= ob->actdef;
@@ -1107,4 +1100,245 @@ void vgroup_operation_with_menu(Object *ob)
        }
 }
 
+/********************** vertex group operators *********************/
+
+static int vertex_group_add_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Scene *scene= CTX_data_scene(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       add_defgroup(ob);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_add";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_add_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_remove_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+       Scene *scene= CTX_data_scene(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       if(scene->obedit == ob) {
+               del_defgroup(ob);
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       }
+       else {
+               del_defgroup_in_object_mode(ob);
+               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_remove";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_remove_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_assign_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       ToolSettings *ts= CTX_data_tool_settings(C);
+       Object *ob= CTX_data_edit_object(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       assign_verts_defgroup(ob, ts->vgroup_weight);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Assign Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_assign";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_assign_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_edit_object(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       remove_verts_defgroup(ob, 0);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Remove from Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_remove_from";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_remove_from_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_select_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_edit_object(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       sel_verts_defgroup(ob, 1); /* runs countall() */
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_select(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_select";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_select_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_deselect_exec(bContext *C, wmOperator *op)
+{
+       Object *ob= CTX_data_edit_object(C);
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       sel_verts_defgroup(ob, 0); /* runs countall() */
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Deselect Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_deselect";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_deselect_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_copy_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+
+       if(!ob)
+               return OPERATOR_CANCELLED;
+
+       duplicate_defgroup(ob);
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_vertex_group_copy(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Copy Vertex Group";
+       ot->idname= "OBJECT_OT_vertex_group_copy";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_copy_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+    Base *base;
+       int retval= OPERATOR_CANCELLED;
+
+       if(!ob)
+               return retval;
+
+    for(base=scene->base.first; base; base= base->next) {
+        if(base->object->type==ob->type) {
+            if(base->object!=ob && base->object->data==ob->data) {
+                BLI_freelistN(&base->object->defbase);
+                BLI_duplicatelist(&base->object->defbase, &ob->defbase);
+                base->object->actdef= ob->actdef;
+
+                DAG_object_flush_update(scene, base->object, OB_RECALC_DATA);
+                               WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, base->object);
+
+                               retval = OPERATOR_FINISHED;
+            }
+        }
+    }
+       
+       return retval;
+}
+
+void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Copy Vertex Group to Linked";
+       ot->idname= "OBJECT_OT_vertex_group_copy_to_linked";
+       
+       /* api callbacks */
+       ot->exec= vertex_group_copy_to_linked_exec;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
 
index f9732551545aff28dea156bc643a44bcea8a0071..b89a13ce218ee95dac7e5d1e33ed33fc03499107 100644 (file)
@@ -331,6 +331,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
                case NC_SCENE:
                        switch(wmn->data) {
                                case ND_FRAME:
+                               case ND_MODE:
                                        ED_area_tag_redraw(sa);
                                        break;
                                        
index 828721f0abb3bd261b1d71e37add066dd4cc52c4..31724bb5665fde1b38b1cf54c766460def86b600 100644 (file)
@@ -439,6 +439,9 @@ typedef struct ToolSettings {
        VPaint *wpaint;         /* weight paint */
        Sculpt *sculpt;
        
+       /* Vertex groups */
+       float vgroup_weight;
+
        /* Subdivide Settings */
        short cornertype;
        short editbutflag;
@@ -470,7 +473,6 @@ typedef struct ToolSettings {
        float uvcalc_radius;
        float uvcalc_cubesize;
        float uvcalc_margin;
-       float pad;
        short uvcalc_mapdir;
        short uvcalc_mapalign;
        short uvcalc_flag;
@@ -537,7 +539,7 @@ typedef struct ToolSettings {
        /* Alt+RMB option */
        char edge_mode;
 
-       /* transform */
+       /* Transform */
        short snap_mode, snap_flag, snap_target;
        short proportional, prop_mode;
 } ToolSettings;
index 7bc941952045eb646997393775a55cfdebbbe682..d9d68490425933120c3153648b74902149186723 100644 (file)
@@ -105,6 +105,9 @@ typedef struct Panel {              /* the part from uiBlock that needs saved in file */
        int sortorder;                  /* panels are aligned according to increasing sortorder */
        struct Panel *paneltab;         /* this panel is tabbed in *paneltab */
        void *activedata;                       /* runtime for panel manipulation */
+
+       int list_scroll, list_size;
+       char list_search[64];
 } Panel;
 
 typedef struct Header {
index 8200a21f4accd4f4bfad500c0952bf24ed12a25b..5c4b6a955240d624d43e0cb5c9ae4be67bd4e00a 100644 (file)
@@ -535,10 +535,8 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna)
        srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint");
        RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target.");
 
-       RNA_def_struct_sdna(srna, "bConstraint");
-
        prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_PERCENTAGE);
-       RNA_def_property_float_sdna(prop, NULL, "headtail");
+       RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
        RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1.");
        RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
 
index 378498c8e0ad763ac8197e91d1b493ed754d1f2f..7fa2734800291028df423db61959fa53b7f3b6b7 100644 (file)
@@ -96,6 +96,12 @@ static PointerRNA rna_Context_scene_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_Scene, CTX_data_scene(C));
 }
 
+static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
+{
+       bContext *C= (bContext*)ptr->data;
+       return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C));
+}
+
 #else
 
 void RNA_def_context(BlenderRNA *brna)
@@ -153,6 +159,12 @@ void RNA_def_context(BlenderRNA *brna)
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_struct_type(prop, "Scene");
        RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL);
+
+       prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_struct_type(prop, "ToolSettings");
+       RNA_def_property_pointer_funcs(prop, "rna_Context_tool_settings_get", NULL, NULL);
+
 }
 
 #endif
index 41d64a8dbb95b73bf05cd098d17fd9c9cc478241..39fa6f36f23f87125e942f13c80a2e8897366e79 100644 (file)
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 
-#include "BKE_customdata.h"
-
 #ifdef RNA_RUNTIME
 
+#include "DNA_scene_types.h"
+
+#include "BLI_editVert.h"
+
+#include "BKE_customdata.h"
+#include "BKE_depsgraph.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_utildefines.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+static void rna_Mesh_update_data(bContext *C, PointerRNA *ptr)
+{
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
+       ID *id= ptr->id.data;
+       Object *ob;
+
+       for(ob=bmain->object.first; ob; ob= ob->id.next) {
+               if(ob->data == id) {
+                       /* XXX this will loop over all objects again (slow) */
+                       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+                       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+               }
+       }
+}
+
 static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
 {
        MVert *mvert= (MVert*)ptr->data;
@@ -183,13 +210,19 @@ static void rna_MeshFace_material_index_range(PointerRNA *ptr, int *min, int *ma
        *max= me->totcol-1;
 }
 
+static CustomData *rna_mesh_fdata(Mesh *me)
+{
+       return (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
+}
+
 static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
 {
        Mesh *me= (Mesh*)ptr->id.data;
+       CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *layer;
        int i, length= 0;
 
-       for(layer=me->fdata.layers, i=0; i<me->fdata.totlayer; layer++, i++)
+       for(layer=fdata->layers, i=0; i<fdata->totlayer; layer++, i++)
                if(layer->type == type)
                        length++;
 
@@ -199,64 +232,96 @@ static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
 static int rna_CustomDataLayer_active_get(PointerRNA *ptr, int type, int render)
 {
        Mesh *me= (Mesh*)ptr->id.data;
-       int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
+       CustomData *fdata= rna_mesh_fdata(me);
+       int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
 
-       if(render) return (n == CustomData_get_render_layer_index(&me->fdata, type));
-       else return (n == CustomData_get_active_layer_index(&me->fdata, type));
+       if(render) return (n == CustomData_get_render_layer_index(fdata, type));
+       else return (n == CustomData_get_active_layer_index(fdata, type));
 }
 
 static void rna_CustomDataLayer_active_set(PointerRNA *ptr, int value, int type, int render)
 {
        Mesh *me= (Mesh*)ptr->id.data;
-       int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
+       CustomData *fdata= rna_mesh_fdata(me);
+       int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
 
        if(value == 0)
                return;
 
-       if(render) CustomData_set_layer_render_index(&me->fdata, type, n);
-       else CustomData_set_layer_active_index(&me->fdata, type, n);
+       if(render) CustomData_set_layer_render_index(fdata, type, n);
+       else CustomData_set_layer_active_index(fdata, type, n);
 }
 
-static int rna_uv_layer_check(CollectionPropertyIterator *iter, void *data)
+static int rna_uv_texture_check(CollectionPropertyIterator *iter, void *data)
 {
        CustomDataLayer *layer= (CustomDataLayer*)data;
        return (layer->type != CD_MTFACE);
 }
 
-static void rna_Mesh_uv_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Mesh_uv_textures_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_uv_layer_check);
+       CustomData *fdata= rna_mesh_fdata(me);
+       rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_uv_texture_check);
 }
 
-static int rna_Mesh_uv_layers_length(PointerRNA *ptr)
+static int rna_Mesh_uv_textures_length(PointerRNA *ptr)
 {
        return rna_CustomDataLayer_length(ptr, CD_MTFACE);
 }
 
-static PointerRNA rna_Mesh_active_uv_layer_get(PointerRNA *ptr)
+static PointerRNA rna_Mesh_active_uv_texture_get(PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       int index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
-       CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+       CustomData *fdata= rna_mesh_fdata(me);
+       int index= CustomData_get_active_layer_index(fdata, CD_MTFACE);
+       CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
 
        return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
 }
 
-static void rna_Mesh_active_uv_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Mesh_active_uv_texture_set(PointerRNA *ptr, PointerRNA value)
 {
        Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *cdl;
        int a;
 
-       for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+       for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
                if(value.data == cdl) {
-                       CustomData_set_layer_active_index(&me->fdata, CD_MTFACE, a);
+                       CustomData_set_layer_active_index(fdata, CD_MTFACE, a);
+                       mesh_update_customdata_pointers(me);
                        return;
                }
        }
 }
 
+static int rna_Mesh_active_uv_texture_index_get(PointerRNA *ptr)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+       return CustomData_get_active_layer(fdata, CD_MTFACE);
+}
+
+static void rna_Mesh_active_uv_texture_index_set(PointerRNA *ptr, int value)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+
+       CustomData_set_layer_active(fdata, CD_MTFACE, value);
+       mesh_update_customdata_pointers(me);
+}
+
+static void rna_Mesh_active_uv_texture_index_range(PointerRNA *ptr, int *min, int *max)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+
+       *min= 0;
+       *max= CustomData_number_of_layers(fdata, CD_MTFACE)-1;
+       *max= MAX2(0, *max);
+}
+
 static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
 {
        MTFace *mtface= (MTFace*)ptr->data;
@@ -354,46 +419,84 @@ static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value)
        rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 0);
 }
 
-static int rna_vcol_layer_check(CollectionPropertyIterator *iter, void *data)
+static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value)
+{
+       Mesh *me= (Mesh*)ptr->id.data;
+       CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
+       BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+       CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers);
+}
+
+static int rna_vertex_color_check(CollectionPropertyIterator *iter, void *data)
 {
        CustomDataLayer *layer= (CustomDataLayer*)data;
        return (layer->type != CD_MCOL);
 }
 
-static void rna_Mesh_vcol_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Mesh_vertex_colors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_vcol_layer_check);
+       CustomData *fdata= rna_mesh_fdata(me);
+       rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_vertex_color_check);
 }
 
-static int rna_Mesh_vcol_layers_length(PointerRNA *ptr)
+static int rna_Mesh_vertex_colors_length(PointerRNA *ptr)
 {
        return rna_CustomDataLayer_length(ptr, CD_MCOL);
 }
 
-static PointerRNA rna_Mesh_active_vcol_layer_get(PointerRNA *ptr)
+static PointerRNA rna_Mesh_active_vertex_color_get(PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       int index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
-       CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+       CustomData *fdata= rna_mesh_fdata(me);
+       int index= CustomData_get_active_layer_index(fdata, CD_MCOL);
+       CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
 
        return rna_pointer_inherit_refine(ptr, &RNA_MeshColorLayer, cdl);
 }
 
-static void rna_Mesh_active_vcol_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Mesh_active_vertex_color_set(PointerRNA *ptr, PointerRNA value)
 {
        Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *cdl;
        int a;
 
-       for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+       for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
                if(value.data == cdl) {
-                       CustomData_set_layer_active_index(&me->fdata, CD_MCOL, a);
+                       CustomData_set_layer_active_index(fdata, CD_MCOL, a);
+                       mesh_update_customdata_pointers(me);
                        return;
                }
        }
 }
 
+static int rna_Mesh_active_vertex_color_index_get(PointerRNA *ptr)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+       return CustomData_get_active_layer(fdata, CD_MCOL);
+}
+
+static void rna_Mesh_active_vertex_color_index_set(PointerRNA *ptr, int value)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+
+       CustomData_set_layer_active(fdata, CD_MCOL, value);
+       mesh_update_customdata_pointers(me);
+}
+
+static void rna_Mesh_active_vertex_color_index_range(PointerRNA *ptr, int *min, int *max)
+{
+       Mesh *me= (Mesh*)ptr->data;
+       CustomData *fdata= rna_mesh_fdata(me);
+
+       *min= 0;
+       *max= CustomData_number_of_layers(fdata, CD_MCOL)-1;
+       *max= MAX2(0, *max);
+}
+
 static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->id.data;
@@ -427,6 +530,14 @@ static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value)
        rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 0);
 }
 
+static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value)
+{
+       Mesh *me= (Mesh*)ptr->id.data;
+       CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
+       BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+       CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers);
+}
+
 static void rna_MeshFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->id.data;
@@ -449,7 +560,8 @@ static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data)
 static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_float_layer_check);
+       CustomData *fdata= rna_mesh_fdata(me);
+       rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_float_layer_check);
 }
 
 static int rna_Mesh_float_layers_length(PointerRNA *ptr)
@@ -479,7 +591,8 @@ static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr)
 static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_int_layer_check);
+       CustomData *fdata= rna_mesh_fdata(me);
+       rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_int_layer_check);
 }
 
 static int rna_Mesh_int_layers_length(PointerRNA *ptr)
@@ -509,7 +622,8 @@ static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr)
 static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        Mesh *me= (Mesh*)ptr->data;
-       rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_string_layer_check);
+       CustomData *fdata= rna_mesh_fdata(me);
+       rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_string_layer_check);
 }
 
 static int rna_Mesh_string_layers_length(PointerRNA *ptr)
@@ -568,17 +682,18 @@ static char *rna_MeshVertex_path(PointerRNA *ptr)
 
 static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("uv_layers[%s]", ((CustomDataLayer*)ptr->data)->name);
+       return BLI_sprintfN("uv_textures[%s]", ((CustomDataLayer*)ptr->data)->name);
 }
 
 static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type)
 {
        Mesh *me= (Mesh*)ptr->id.data;
+       CustomData *fdata= rna_mesh_fdata(me);
        CustomDataLayer *cdl;
        int a;
        size_t b;
 
-       for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+       for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
                if(cdl->type == type) {
                        b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type);
                        if(b >= 0 && b < me->totface)
@@ -591,17 +706,17 @@ static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type
 
 static char *rna_MeshTextureFace_path(PointerRNA *ptr)
 {
-       return rna_CustomDataData_path(ptr, "uv_layers", CD_MTFACE);
+       return rna_CustomDataData_path(ptr, "uv_textures", CD_MTFACE);
 }
 
 static char *rna_MeshColorLayer_path(PointerRNA *ptr)
 {
-       return BLI_sprintfN("vcol_layers[%s]", ((CustomDataLayer*)ptr->data)->name);
+       return BLI_sprintfN("vertex_colors[%s]", ((CustomDataLayer*)ptr->data)->name);
 }
 
 static char *rna_MeshColor_path(PointerRNA *ptr)
 {
-       return rna_CustomDataData_path(ptr, "vcol_layers", CD_MCOL);
+       return rna_CustomDataData_path(ptr, "vertex_colors", CD_MCOL);
 }
 
 static char *rna_MeshSticky_path(PointerRNA *ptr)
@@ -798,6 +913,7 @@ static void rna_def_mtface(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
        RNA_def_struct_name_property(srna, prop);
+       RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set");
        RNA_def_property_ui_text(prop, "Name", "");
 
        prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
@@ -935,6 +1051,7 @@ static void rna_def_mcol(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
        RNA_def_struct_name_property(srna, prop);
+       RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshColorLayer_name_set");
        RNA_def_property_ui_text(prop, "Name", "");
 
        prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
@@ -1120,33 +1237,45 @@ static void rna_def_mesh(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "MeshSticky");
        RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates.");
 
-       /* UV layers */
+       /* UV textures */
 
-       prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
+       prop= RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
-       RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0);
+       RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0, 0, 0);
        RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
-       RNA_def_property_ui_text(prop, "UV Layers", "");
+       RNA_def_property_ui_text(prop, "UV Textures", "");
 
-       prop= RNA_def_property(srna, "active_uv_layer", PROP_POINTER, PROP_UNSIGNED);
+       prop= RNA_def_property(srna, "active_uv_texture", PROP_POINTER, PROP_UNSIGNED);
        RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
-       RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_layer_get", "rna_Mesh_active_uv_layer_set", NULL);
+       RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL);
        RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Active UV Layer", "Active UV layer.");
+       RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture.");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+       prop= RNA_def_property(srna, "active_uv_texture_index", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get", "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range");
+       RNA_def_property_ui_text(prop, "Active UV Texture Index", "Active UV texture index.");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 
-       /* VCol layers */
+       /* Vertex colors */
 
-       prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE);
+       prop= RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
-       RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0);
+       RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0, 0, 0);
        RNA_def_property_struct_type(prop, "MeshColorLayer");
-       RNA_def_property_ui_text(prop, "Vertex Color Layers", "");
+       RNA_def_property_ui_text(prop, "Vertex Colors", "");
 
-       prop= RNA_def_property(srna, "active_vcol_layer", PROP_POINTER, PROP_UNSIGNED);
+       prop= RNA_def_property(srna, "active_vertex_color", PROP_POINTER, PROP_UNSIGNED);
        RNA_def_property_struct_type(prop, "MeshColorLayer");
-       RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vcol_layer_get", "rna_Mesh_active_vcol_layer_set", NULL);
+       RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL);
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer.");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+       prop= RNA_def_property(srna, "active_vertex_color_index", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_int_funcs(prop, "rna_Mesh_active_vertex_color_index_get", "rna_Mesh_active_vertex_color_index_set", "rna_Mesh_active_vertex_color_index_range");
+       RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index.");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 
        prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
@@ -1182,6 +1311,7 @@ static void rna_def_mesh(BlenderRNA *brna)
        prop= RNA_def_property(srna, "double_sided", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
        RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
 
        prop= RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
index 9b3100c733bde43fa68514fcd5d7de3f681c71a0..947846f8d8d409727c7ba64a8f60abf6e80e5643 100644 (file)
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_key_types.h"
+
 #include "BKE_armature.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_depsgraph.h"
+#include "BKE_key.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
 #include "BKE_particle.h"
@@ -131,6 +134,27 @@ static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef));
 }
 
+static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
+{
+       Object *ob= (Object*)ptr->id.data;
+       return MAX2(ob->actdef-1, 0);
+}
+
+static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
+{
+       Object *ob= (Object*)ptr->id.data;
+       ob->actdef= value+1;
+}
+
+static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max)
+{
+       Object *ob= (Object*)ptr->id.data;
+
+       *min= 0;
+       *max= BLI_countlist(&ob->defbase)-1;
+       *max= MAX2(0, *max);
+}
+
 void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
 {
        Object *ob= (Object*)ptr->id.data;
@@ -228,11 +252,23 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res
        BLI_strncpy(result, "", maxlen);
 }
 
+static int rna_Object_active_material_index_get(PointerRNA *ptr)
+{
+       Object *ob= (Object*)ptr->id.data;
+       return MAX2(ob->actcol-1, 0);
+}
+
+static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
+{
+       Object *ob= (Object*)ptr->id.data;
+       ob->actcol= value+1;
+}
+
 static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max)
 {
        Object *ob= (Object*)ptr->id.data;
-       *min= 1;
-       *max= ob->totcol;
+       *min= 0;
+       *max= MAX2(ob->totcol-1, 0);
 }
 
 static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
@@ -244,14 +280,15 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
 static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max)
 {
        Object *ob= (Object*)ptr->id.data;
-       *min= 1;
-       *max= BLI_countlist(&ob->particlesystem);
+       *min= 0;
+       *max= BLI_countlist(&ob->particlesystem)-1;
+       *max= MAX2(0, *max);
 }
 
 static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
 {
        Object *ob= (Object*)ptr->id.data;
-       return psys_get_current_num(ob) + 1;
+       return psys_get_current_num(ob);
 }
 
 static void rna_Object_active_particle_system_index_set(struct PointerRNA *ptr, int value)
@@ -384,6 +421,41 @@ static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
        }
 }
 
+static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max)
+{
+       Object *ob= (Object*)ptr->id.data;
+       Key *key= ob_get_key(ob);
+
+       *min= 0;
+       *max= (key)? BLI_countlist(&key->block)-1: 0;
+       *max= MAX2(0, *max);
+}
+
+static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
+{
+       Object *ob= (Object*)ptr->id.data;
+
+       return MAX2(ob->shapenr-1, 0);
+}
+
+static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
+{
+       Object *ob= (Object*)ptr->id.data;
+
+       ob->shapenr= value+1;
+       ob->shapeflag |= OB_SHAPE_TEMPLOCK;
+}
+
+static void rna_Object_shape_key_lock_set(PointerRNA *ptr, int value)
+{
+       Object *ob= (Object*)ptr->id.data;
+
+       if(value) ob->shapeflag |= OB_SHAPE_LOCK;
+       else ob->shapeflag &= ~OB_SHAPE_LOCK;
+
+       ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+}
+
 #else
 
 static void rna_def_vertex_group(BlenderRNA *brna)
@@ -814,7 +886,7 @@ static void rna_def_object(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "actcol");
-       RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Object_active_material_index_range");
+       RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range");
        RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot.");
 
        /* transform */
@@ -895,8 +967,15 @@ static void rna_def_object(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE);
        RNA_def_property_struct_type(prop, "VertexGroup");
-       RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL, NULL);
+       RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL);
        RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
+
+       prop= RNA_def_property(srna, "active_vertex_group_index", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "actdef");
+       RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range");
+       RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
 
        /* empty */
 
@@ -1171,13 +1250,15 @@ static void rna_def_object(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_shape_key_lock_set");
        RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
 
-       prop= RNA_def_property(srna, "active_shape_key", PROP_INT, PROP_NONE);
+       prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "shapenr");
-       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key index.");
+       RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range");
+       RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
 
        RNA_api_object(srna);
 }
index 47c9025149ab84a7493e00ca23a9c08f88f04d32..5f03b7167f44cf8965f51146604624b88c515240 100644 (file)
@@ -245,6 +245,11 @@ void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_enum_items(prop, mesh_select_mode_items);
        RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Mesh selection and display mode.");
 
+       prop= RNA_def_property(srna, "vertex_group_weight", PROP_FLOAT, PROP_PERCENTAGE);
+       RNA_def_property_float_sdna(prop, NULL, "vgroup_weight");
+       RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups.");
+
+       /* Sculpt */
        rna_def_sculpt(brna);
 }
 
index b70112eebed36b7f2b18cf99a6d5c775e17156e8..3df3fad3f15c5bcf371531895c7ea790cf729693 100644 (file)
@@ -259,6 +259,8 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        func= RNA_def_function(srna, "template_list", "uiTemplateList");
        api_ui_item_rna_common(func);
+       parm= RNA_def_pointer(func, "active_data", "AnyType", "", "Data from which to take property for the active element.");
+       RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
        parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX);