diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-01-22 00:58:40 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-01-22 00:58:40 +0300 |
commit | b400703403dd87c482824a1b10f40923c67412e4 (patch) | |
tree | ea6a6f97b09936ae6a4e60c789077e84105d7868 /source | |
parent | 0d4583365a84078fac8351925b5caa663d64a108 (diff) |
Macro operator properties using property groups in groups (initial code by brecht).
Works correctly with menu, keymap definitions and keymap export/import.
Properties set in the macro definition overwrite those set by the user (there's no way to see that in the UI at this point).
MISSING: Python operator calling code to fill in the properties hierarchy.
Also contains some keymap export changes by Imran Syed (freakabcd on irc): the exported configuration will use the name of the file and the exported script will select the added configuration when ran.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 21 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 40 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 16 |
3 files changed, 61 insertions, 16 deletions
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index a08413293a5..eb292b4bccc 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -159,6 +159,19 @@ static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa) else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } +static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOperator *op) +{ + if(op->type->flag & OPTYPE_MACRO) { + for(op= op->macro.first; op; op= op->next) { + uiItemL(pa->layout, op->idname, 0); + view3d_panel_operator_redo_operator(C, pa, op); + } + } + else { + view3d_panel_operator_redo_buts(C, pa, op); + } +} + static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { wmOperator *op= view3d_last_operator(C); @@ -173,13 +186,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) uiBlockSetFunc(block, redo_cb, op, NULL); - if(op->macro.first) { - for(op= op->macro.first; op; op= op->next) - view3d_panel_operator_redo_buts(C, pa, op); - } - else { - view3d_panel_operator_redo_buts(C, pa, op); - } + view3d_panel_operator_redo_operator(C, pa, op); } /* ******************* */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 15adb33d527..7fa5f9b61c0 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -391,15 +391,41 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P motherop = op; root = 1; } + - for(otmacro= ot->macro.first; otmacro; otmacro= otmacro->next) { - wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0); - wmOperator *opm= wm_operator_create(wm, otm, otmacro->ptr, NULL); - - IDP_ReplaceGroupInGroup(opm->properties, motherop->properties); + /* if properties exist, it will contain everything needed */ + if (properties) { + otmacro= ot->macro.first; + + RNA_STRUCT_BEGIN(properties, prop) { + + if (otmacro == NULL) + break; + + /* skip invalid properties */ + if (strcmp(RNA_property_identifier(prop), otmacro->idname) == 0) + { + wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0); + PointerRNA someptr = RNA_property_pointer_get(properties, prop); + wmOperator *opm= wm_operator_create(wm, otm, &someptr, NULL); - BLI_addtail(&motherop->macro, opm); - opm->opm= motherop; /* pointer to mom, for modal() */ + IDP_ReplaceGroupInGroup(opm->properties, otmacro->properties); + + BLI_addtail(&motherop->macro, opm); + opm->opm= motherop; /* pointer to mom, for modal() */ + + otmacro= otmacro->next; + } + } + RNA_STRUCT_END; + } else { + for (otmacro = ot->macro.first; otmacro; otmacro = otmacro->next) { + wmOperatorType *otm= WM_operatortype_find(otmacro->idname, 0); + wmOperator *opm= wm_operator_create(wm, otm, otmacro->ptr, NULL); + + BLI_addtail(&motherop->macro, opm); + opm->opm= motherop; /* pointer to mom, for modal() */ + } } if (root) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 79f36ca0513..40b9714a6e1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -347,8 +347,11 @@ wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag) ot->modal= wm_macro_modal; ot->cancel= wm_macro_cancel; ot->poll= NULL; + + if(!ot->description) + ot->description= "(undocumented operator)"; - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:"(undocumented operator)"); // XXX All ops should have a description but for now allow them not to. + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); // XXX All ops should have a description but for now allow them not to. RNA_def_struct_identifier(ot->srna, ot->idname); BLI_addtail(&global_ops, ot); @@ -370,9 +373,12 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType*, void*), vo ot->cancel= wm_macro_cancel; ot->poll= NULL; + if(!ot->description) + ot->description= "(undocumented operator)"; + opfunc(ot, userdata); - RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description:"(undocumented operator)"); + RNA_def_struct_ui_text(ot->srna, ot->name, ot->description); RNA_def_struct_identifier(ot->srna, ot->idname); BLI_addtail(&global_ops, ot); @@ -388,6 +394,12 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname); BLI_addtail(&ot->macro, otmacro); + + { + wmOperatorType *otsub = WM_operatortype_find(idname, 0); + RNA_def_pointer_runtime(ot->srna, otsub->idname, otsub->srna, + otsub->name, otsub->description); + } return otmacro; } |