forked from bartvdbraak/blender
- split objet group add/link into 2 operators
- link now brings up a search box so when there are 100's of groups its less annoying. - utility functions for id-enums so only local objects can be displayed in a search list (used for group_link) - renamed operator properties from typle to scene, group, action etc.
This commit is contained in:
parent
575dce788a
commit
12cf8ac1d6
@ -155,13 +155,11 @@ class OBJECT_PT_groups(ObjectButtonsPanel):
|
||||
ob = context.object
|
||||
wide_ui = context.region.width > narrowui
|
||||
|
||||
if wide_ui:
|
||||
split = layout.split()
|
||||
split.operator_menu_enum("object.group_add", "group")
|
||||
split.label()
|
||||
else:
|
||||
layout.operator_menu_enum("object.group_add", "group")
|
||||
split = layout.split(percentage=0.8, align=True)
|
||||
split.operator("object.group_link", text="Link to Group")
|
||||
split.operator("object.group_add", text="", icon='ZOOMIN')
|
||||
|
||||
# XXX, this is bad practice, yes, I wrote it :( - campbell
|
||||
index = 0
|
||||
value = str(tuple(context.scene.cursor_location))
|
||||
for group in bpy.data.groups:
|
||||
|
@ -844,6 +844,7 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert)
|
||||
for(x = 1; x < edgeSize - 1; x++, i++) {
|
||||
vd= ccgSubSurf_getEdgeData(ss, e, x);
|
||||
copy_v3_v3(mvert[i].co, vd->co);
|
||||
/* XXX, This gives errors with -fpe, the normals dont seem to be unit length - campbell */
|
||||
normal_float_to_short_v3(mvert[i].no, vd->no);
|
||||
}
|
||||
}
|
||||
|
@ -1069,7 +1069,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
|
||||
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ListBase *markers= context_get_markers(C);
|
||||
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type"));
|
||||
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
|
||||
TimeMarker *marker, *marker_new;
|
||||
|
||||
if(scene_to==NULL) {
|
||||
@ -1110,7 +1110,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
|
||||
prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
|
||||
RNA_def_enum_funcs(prop, RNA_scene_itemf);
|
||||
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
|
||||
|
||||
static int group_instance_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "type"));
|
||||
Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
|
||||
|
||||
int enter_editmode;
|
||||
unsigned int layer;
|
||||
@ -895,7 +895,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
|
||||
prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
|
||||
RNA_def_enum_funcs(prop, RNA_group_itemf);
|
||||
ot->prop= prop;
|
||||
ED_object_add_generic_props(ot, FALSE);
|
||||
|
@ -52,6 +52,7 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "object_intern.h"
|
||||
|
||||
@ -224,84 +225,71 @@ void GROUP_OT_create(wmOperatorType *ot)
|
||||
|
||||
static int group_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
||||
Base *base;
|
||||
Group *group;
|
||||
int value= RNA_enum_get(op->ptr, "group");
|
||||
|
||||
if(!ob)
|
||||
if(ob == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
base= object_in_scene(ob, scene);
|
||||
if(!base)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(value == -1)
|
||||
group= add_group( "Group" );
|
||||
else
|
||||
group= BLI_findlink(&bmain->group, value);
|
||||
|
||||
if(group) {
|
||||
add_to_group(group, ob, scene, NULL); /* base will be used if found */
|
||||
}
|
||||
group= add_group("Group");
|
||||
add_to_group(group, ob, scene, NULL);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static EnumPropertyItem group_items[]= {
|
||||
{-1, "ADD_NEW", 0, "Add New Group", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Group *group;
|
||||
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
||||
EnumPropertyItem *item= NULL;
|
||||
int a, totitem= 0;
|
||||
|
||||
RNA_enum_items_add_value(&item, &totitem, group_items, -1);
|
||||
|
||||
if (bmain) {
|
||||
if(bmain->group.first)
|
||||
RNA_enum_item_add_separator(&item, &totitem);
|
||||
|
||||
for(a=0, group=bmain->group.first; group; group=group->id.next, a++) {
|
||||
tmp.value= a;
|
||||
tmp.identifier= group->id.name+2;
|
||||
tmp.name= group->id.name+2;
|
||||
RNA_enum_item_add(&item, &totitem, &tmp);
|
||||
}
|
||||
}
|
||||
|
||||
RNA_enum_item_end(&item, &totitem);
|
||||
*free= 1;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void OBJECT_OT_group_add(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Add to Group";
|
||||
ot->idname= "OBJECT_OT_group_add";
|
||||
ot->description = "Add an object to an existing group, or create new";
|
||||
ot->description = "Add an object to a new group";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= group_add_exec;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int group_link_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
||||
Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
|
||||
|
||||
if(ELEM(NULL, ob, group))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
add_to_group(group, ob, scene, NULL);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_group_link(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Link to Group";
|
||||
ot->idname= "OBJECT_OT_group_link";
|
||||
ot->description = "Add an object to an existing group";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= group_link_exec;
|
||||
ot->invoke= WM_enum_search_invoke;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop= RNA_def_enum(ot->srna, "group", group_items, -1, "Group", "Group to add object to.");
|
||||
RNA_def_enum_funcs(prop, group_itemf);
|
||||
prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
|
||||
RNA_def_enum_funcs(prop, RNA_group_local_itemf);
|
||||
ot->prop= prop;
|
||||
}
|
||||
|
||||
static int group_remove_exec(bContext *C, wmOperator *op)
|
||||
|
@ -212,6 +212,7 @@ void OBJECT_OT_shape_key_move(struct wmOperatorType *ot);
|
||||
|
||||
/* object_group.c */
|
||||
void OBJECT_OT_group_add(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_group_link(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_group_remove(struct wmOperatorType *ot);
|
||||
|
||||
/* object_bake.c */
|
||||
|
@ -193,6 +193,7 @@ void ED_operatortypes_object(void)
|
||||
WM_operatortype_append(LATTICE_OT_make_regular);
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_group_add);
|
||||
WM_operatortype_append(OBJECT_OT_group_link);
|
||||
WM_operatortype_append(OBJECT_OT_group_remove);
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_hook_add_selobj);
|
||||
|
@ -1146,7 +1146,7 @@ void link_to_scene(unsigned short nr)
|
||||
|
||||
static int make_links_scene_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type"));
|
||||
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
|
||||
|
||||
if(scene_to==NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Scene not found");
|
||||
@ -1264,8 +1264,8 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
|
||||
RNA_def_enum_funcs(prop, RNA_scene_itemf);
|
||||
prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
|
||||
RNA_def_enum_funcs(prop, RNA_scene_local_itemf);
|
||||
}
|
||||
|
||||
void OBJECT_OT_make_links_data(wmOperatorType *ot)
|
||||
|
@ -260,7 +260,7 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op)
|
||||
cfra= (float)CFRA;
|
||||
|
||||
/* get action to use */
|
||||
act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "type"));
|
||||
act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action"));
|
||||
|
||||
if (act == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No valid Action to add.");
|
||||
@ -336,7 +336,7 @@ void NLA_OT_actionclip_add (wmOperatorType *ot)
|
||||
|
||||
/* props */
|
||||
// TODO: this would be nicer as an ID-pointer...
|
||||
prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
|
||||
prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", "");
|
||||
RNA_def_enum_funcs(prop, RNA_action_itemf);
|
||||
ot->prop= prop;
|
||||
}
|
||||
|
@ -101,9 +101,13 @@ EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct Poin
|
||||
/* Generic functions, return an enum from library data, index is the position
|
||||
* in the linked list can add more for different types as needed */
|
||||
EnumPropertyItem *RNA_action_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_action_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_group_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
|
||||
|
||||
#endif /* RNA_ENUM_TYPES */
|
||||
|
||||
|
@ -3252,7 +3252,7 @@ void wm_window_keymap(wmKeyConfig *keyconf)
|
||||
}
|
||||
|
||||
/* Generic itemf's for operators that take library args */
|
||||
static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, ID *id)
|
||||
static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, ID *id, int local)
|
||||
{
|
||||
EnumPropertyItem *item= NULL, item_tmp;
|
||||
int totitem= 0;
|
||||
@ -3261,9 +3261,11 @@ static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, I
|
||||
memset(&item_tmp, 0, sizeof(item_tmp));
|
||||
|
||||
for( ; id; id= id->next) {
|
||||
item_tmp.identifier= item_tmp.name= id->name+2;
|
||||
item_tmp.value= i++;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
if(local==FALSE || id->lib==NULL) {
|
||||
item_tmp.identifier= item_tmp.name= id->name+2;
|
||||
item_tmp.value= i++;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
RNA_enum_item_end(&item, &totitem);
|
||||
@ -3275,17 +3277,36 @@ static EnumPropertyItem *rna_id_itemf(bContext *C, PointerRNA *ptr, int *free, I
|
||||
/* can add more as needed */
|
||||
EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->action.first : NULL);
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->action.first : NULL, FALSE);
|
||||
}
|
||||
EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->action.first : NULL, TRUE);
|
||||
}
|
||||
|
||||
EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->group.first : NULL);
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->group.first : NULL, FALSE);
|
||||
}
|
||||
EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->group.first : NULL, TRUE);
|
||||
}
|
||||
|
||||
EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->image.first : NULL);
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->image.first : NULL, FALSE);
|
||||
}
|
||||
EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->image.first : NULL, TRUE);
|
||||
}
|
||||
|
||||
EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->scene.first : NULL);
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, FALSE);
|
||||
}
|
||||
EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, int *free)
|
||||
{
|
||||
return rna_id_itemf(C, ptr, free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, TRUE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user