From df7e7660325611847721768fb7d082e7d5f2736c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Feb 2009 11:52:16 +0000 Subject: UI * Changed uiPupMenuOperator usage to uiPupMenuBegin/End (simpler, no need to build a string). Also made transform orientation and subdiv type enums instead of ints for this. * Added an icon argument to many of the uiMenu calls, and added a uiMenuItemIntO. * Move auto rna button creation out of outliner code, now is uiDefAutoButR for individual buttons and uiDefAutoButsRNA for a whole block. * Implemented uiPupBlock(O). Pressing F6 gives a menu with the properties of the last operator to test. I tried to make a redo last operator out of this but couldn't get the context correct for the operator to repeat in. Further the popup block also has some issues getting closed while editing buttons. * Fix uiAfterFunc memory leak on Ctrl+Q quit. * Fix handling of RNA number button dragging and sliding for RNA buttons with range -inf/inf. --- source/blender/windowmanager/intern/wm_operators.c | 74 ++++++++-------------- 1 file changed, 27 insertions(+), 47 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5c286e06324..f5e9520c702 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -201,9 +201,7 @@ void WM_operator_properties_free(PointerRNA *ptr) int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) { PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type"); - const EnumPropertyItem *item; - int totitem, i, len= strlen(op->type->name) + 8; - char *menu, *p; + uiMenuItem *head; if(prop==NULL) { printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname); @@ -212,34 +210,24 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) printf("WM_menu_invoke: %s \"type\" is not an enum property\n", op->type->idname); } else { - RNA_property_enum_items(op->ptr, prop, &item, &totitem); - - for (i=0; itype->name); - for (i=0; itype->name, 0); + uiMenuItemsEnumO(head, op->type->idname, "type"); + uiPupMenuEnd(C, head); } + return OPERATOR_CANCELLED; } /* op->invoke */ int WM_operator_confirm(bContext *C, wmOperator *op, wmEvent *event) { - char buf[512]; - - sprintf(buf, "OK? %%i%d%%t|%s", ICON_HELP, op->type->name); - uiPupMenuOperator(C, 0, op, NULL, buf); + uiMenuItem *head; + + head= uiPupMenuBegin("OK?", ICON_HELP); + uiMenuItemO(head, 0, op->type->idname); + uiPupMenuEnd(C, head); - return OPERATOR_RUNNING_MODAL; + return OPERATOR_CANCELLED; } /* op->invoke, opens fileselect if filename property not set, otherwise executes */ @@ -293,26 +281,6 @@ static void WM_OT_save_homefile(wmOperatorType *ot) /* ********* recent file *********** */ -static void recent_filelist(char *pup) -{ - struct RecentFile *recent; - int i, ofs= 0; - char *p; - - p= pup + sprintf(pup, "Open Recent%%t"); - - if (G.sce[0]) { - p+= sprintf(p, "|%s %%x%d", G.sce, 1); - ofs = 1; - } - - for (recent = G.recent_files.first, i=0; (inext, i++) { - if (strcmp(recent->filename, G.sce)) { - p+= sprintf(p, "|%s %%x%d", recent->filename, i+ofs+1); - } - } -} - static int recentfile_exec(bContext *C, wmOperator *op) { int event= RNA_enum_get(op->ptr, "nr"); @@ -338,12 +306,24 @@ static int recentfile_exec(bContext *C, wmOperator *op) static int wm_recentfile_invoke(bContext *C, wmOperator *op, wmEvent *event) { - char pup[2048]; + struct RecentFile *recent; + uiMenuItem *head; + int i, ofs= 0; + + head= uiPupMenuBegin("Open Recent", 0); + + if(G.sce[0]) { + uiMenuItemIntO(head, G.sce, 0, op->type->idname, "nr", 1); + ofs = 1; + } - recent_filelist(pup); - uiPupMenuOperator(C, 0, op, "nr", pup); + for(recent = G.recent_files.first, i=0; (inext, i++) + if(strcmp(recent->filename, G.sce)) + uiMenuItemIntO(head, recent->filename, 0, op->type->idname, "nr", i+ofs+1); + + uiPupMenuEnd(C, head); - return OPERATOR_RUNNING_MODAL; + return OPERATOR_CANCELLED; } static void WM_OT_open_recentfile(wmOperatorType *ot) -- cgit v1.2.3