Fix #20433: make single user doesn't work from menu. Popup menus for
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 22 Dec 2009 11:59:30 +0000 (11:59 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 22 Dec 2009 11:59:30 +0000 (11:59 +0000)
operators were not passing along properties.

source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_layout.c
source/blender/windowmanager/intern/wm_operators.c

index 8e44d7f386e8ddf53259a4c5344abf45acc88980..313791e28cbccda23b75ed3945b943952435ac5c 100644 (file)
@@ -678,6 +678,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
 void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
+void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, struct IDProperty *properties, int context, int flag);
 
 void uiItemL(uiLayout *layout, char *name, int icon); /* label */
 void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *menuname); /* menu */
index b0670be63a22eb7638adc14b0011c4916aeb02b7..9dd5535ea30d21e78daea5c4a66c1976af44e2e6 100644 (file)
@@ -695,7 +695,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro
        uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
 }
 
-void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
+void uiItemsFullEnumO(uiLayout *layout, char *opname, char *propname, IDProperty *properties, int context, int flag)
 {
        wmOperatorType *ot= WM_operatortype_find(opname, 0);
        PointerRNA ptr;
@@ -721,7 +721,21 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
 
                for(i=0; i<totitem; i++) {
                        if(item[i].identifier[0]) {
-                               uiItemEnumO(column, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
+                               if(properties) {
+                                       PointerRNA ptr;
+
+                                       WM_operator_properties_create(&ptr, opname);
+                                       if(ptr.data) {
+                                               IDP_FreeProperty(ptr.data);
+                                               MEM_freeN(ptr.data);
+                                       }
+                                       ptr.data= IDP_CopyProperty(properties);
+                                       RNA_enum_set(&ptr, propname, item[i].value);
+
+                                       uiItemFullO(column, (char*)item[i].name, item[i].icon, opname, ptr.data, context, flag);
+                               }
+                               else
+                                       uiItemEnumO(column, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
                        }
                        else {
                                if(item[i].name) {
@@ -745,6 +759,11 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
        }
 }
 
+void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
+{
+       uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0);
+}
+
 /* for use in cases where we have */
 void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value_str)
 {
index fc5abec1561490d82d379fcdc9cc57a7f0947c3c..d65580681eb4916c3d40c95f5e7f3fb33c64220b 100644 (file)
@@ -621,7 +621,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
        else {
                pup= uiPupMenuBegin(C, op->type->name, 0);
                layout= uiPupMenuLayout(pup);
-               uiItemsEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop));
+               uiItemsFullEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0);
                uiPupMenuEnd(C, pup);
        }
 
@@ -633,10 +633,16 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, char *message)
 {
        uiPopupMenu *pup;
        uiLayout *layout;
+       IDProperty *properties= op->ptr->data;
+
+       if(properties && properties->len)
+               properties= IDP_CopyProperty(op->ptr->data);
+       else
+               properties= NULL;
 
        pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION);
        layout= uiPupMenuLayout(pup);
-       uiItemO(layout, message, 0, op->type->idname);
+       uiItemFullO(layout, message, 0, op->type->idname, properties, WM_OP_EXEC_REGION_WIN, 0);
        uiPupMenuEnd(C, pup);
        
        return OPERATOR_CANCELLED;