diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 08:42:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-15 08:42:23 +0300 |
commit | eb8458b064c5a7553a3bd51c214c9669aaf550f9 (patch) | |
tree | 85063dfae53b799f6bceca854ecb4f338458d833 /source/blender/windowmanager | |
parent | acd7b81c2d3fa7828d28c1562fad10663d911783 (diff) |
Centralized operator UI drawing into a new function uiLayoutOperatorButs(),
Operator drawing calls were duplicated in file selector panel, redo panels, redo & dialog popups.
note, uiDefAutoButsRNA's column's argument was misleading, renamed to label_align.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 63 |
1 files changed, 7 insertions, 56 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index d7c84392a12..2b82a772518 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -871,13 +871,11 @@ int WM_operator_winactive(bContext *C) static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) { - wmWindowManager *wm= CTX_wm_manager(C); wmOperator *op= arg_op; - PointerRNA ptr; uiBlock *block; uiLayout *layout; uiStyle *style= U.uistyles.first; - int columns= 2, width= 300; + int width= 300; block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS); @@ -889,30 +887,9 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) assert(op->type->flag & OPTYPE_REGISTER); uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, arg_op); - - if(!op->properties) { - IDPropertyTemplate val = {0}; - op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); - } - - RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, 20, style); - uiItemL(layout, op->type->name, 0); - - /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens - * just fails silently */ - if(!WM_operator_repeat_check(C, op)) { - uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo"); - uiItemL(layout, "* Redo Unsupported *", 0); // XXX, could give some nicer feedback or not show redo panel at all? - } - if(op->type->ui) { - op->layout= layout; - op->type->ui((bContext*)C, op); - op->layout= NULL; - } - else - uiDefAutoButsRNA(layout, &ptr, columns); + uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); @@ -945,38 +922,23 @@ void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) { struct { wmOperator *op; int width; int height; } * data = userData; - wmWindowManager *wm= CTX_wm_manager(C); wmOperator *op= data->op; - PointerRNA ptr; uiBlock *block; uiLayout *layout; uiBut *btn; uiStyle *style= U.uistyles.first; - int columns= 2; block = uiBeginBlock(C, ar, "operator dialog", UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); - if (!op->properties) { - IDPropertyTemplate val = {0}; - op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); - } - - RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); - uiItemL(layout, op->type->name, 0); uiBlockSetFunc(block, dialog_check_cb, op, NULL); - if (op->type->ui) { - op->layout= layout; - op->type->ui((bContext*)C, op); - op->layout= NULL; - } - else - uiDefAutoButsRNA(layout, &ptr, columns); + uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); + /* clear so the OK button is left alone */ uiBlockSetFunc(block, NULL, NULL, NULL); /* Create OK button, the callback of which will execute op */ @@ -993,9 +955,7 @@ static uiBlock *wm_block_create_dialog(bContext *C, ARegion *ar, void *userData) static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) { struct { wmOperator *op; int width; int height; } * data = userData; - wmWindowManager *wm= CTX_wm_manager(C); wmOperator *op= data->op; - PointerRNA ptr; uiBlock *block; uiLayout *layout; uiStyle *style= U.uistyles.first; @@ -1004,19 +964,10 @@ static uiBlock *wm_operator_create_ui(bContext *C, ARegion *ar, void *userData) uiBlockClearFlag(block, UI_BLOCK_LOOP); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); - if(!op->properties) { - IDPropertyTemplate val = {0}; - op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); - } - - RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); - if(op->type->ui) { - op->layout= layout; - op->type->ui((bContext*)C, op); - op->layout= NULL; - } + /* since ui is defined the auto-layout args are not used */ + uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); @@ -1103,7 +1054,7 @@ static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op) op->layout= NULL; } else - uiDefAutoButsRNA(layout, op->ptr, 2); + uiDefAutoButsRNA(layout, op->ptr, NULL, 'H'); uiPopupBoundsBlock(block, 4.0f, 0, 0); uiEndBlock(C, block); |