From 09015aa8aba073326e5c30060c5f8476bb0d5b24 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 15 Apr 2009 17:53:12 +0000 Subject: 2.5 - Fun for testers: Added "Redo Operator" Panel in view3d 'nkey' region. It's going to be part of tools UI I know, but this will give good tests of what goes on with operators. I had to add small fixes in Transform for it already. :) One important issue to note is that it lists every operator, also from non-3D-window ops. Needs checked or classified somehow. - Fix: removed bad 2.4x hack from how pulldown menus were defined. Made widget code cleaner, and will show menus like SHIFT+A correct now. --- source/blender/editors/include/ED_util.h | 1 + source/blender/editors/interface/interface_panel.c | 8 ++- .../blender/editors/interface/interface_widgets.c | 11 ++-- source/blender/editors/screen/area.c | 2 + .../blender/editors/space_action/action_header.c | 2 - .../blender/editors/space_buttons/buttons_header.c | 3 -- source/blender/editors/space_file/file_header.c | 2 - source/blender/editors/space_graph/graph_header.c | 3 -- source/blender/editors/space_image/image_header.c | 2 - source/blender/editors/space_info/info_header.c | 3 -- source/blender/editors/space_nla/nla_header.c | 3 -- source/blender/editors/space_node/node_header.c | 3 -- .../editors/space_outliner/outliner_header.c | 3 -- .../blender/editors/space_script/script_header.c | 3 -- .../editors/space_sequencer/sequencer_header.c | 3 -- source/blender/editors/space_sound/sound_header.c | 3 -- source/blender/editors/space_time/time_header.c | 3 -- .../blender/editors/space_view3d/view3d_buttons.c | 58 ++++++++++++++++++++++ .../blender/editors/space_view3d/view3d_header.c | 3 -- source/blender/editors/transform/transform.c | 6 ++- source/blender/editors/util/undo.c | 4 ++ 21 files changed, 78 insertions(+), 51 deletions(-) diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 7002524be7e..7ccbf1ff18d 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -45,6 +45,7 @@ void ED_editors_exit (struct bContext *C); void ED_undo_push (struct bContext *C, char *str); void ED_undo_push_op (struct bContext *C, struct wmOperator *op); void ED_undo_pop (struct bContext *C); +void ED_undo_redo (struct bContext *C); void ED_OT_undo (struct wmOperatorType *ot); void ED_OT_redo (struct wmOperatorType *ot); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 261d36cf38e..9e7d13b68cc 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -584,11 +584,15 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, uiBlock *blo panelname= pa->drawname[0]?pa->drawname:pa->panelname; if(pa->active && (pa==panel || pa->paneltab==panel)) { + float col[3]; + + UI_GetThemeColor3fv(TH_TEXT, col); + /* active tab */ if(pa==panel) - UI_ThemeColor(TH_TEXT); + glColor4f(col[0], col[1], col[2], 1.0f); else - UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f); + glColor4f(col[0], col[1], col[2], 0.5f); hrect= *rect; hrect.xmin= rect->xmin+pnl_icons + a*width; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index abaa832957d..3025b1bfc29 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1531,11 +1531,12 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int state, int rou static void widget_disabled(rcti *rect) { - float col[3]; + float col[4]; glEnable(GL_BLEND); - UI_GetThemeColor3fv(TH_BACK, col); + /* can't use theme TH_BACK or TH_PANEL... undefined */ + glGetFloatv(GL_COLOR_CLEAR_VALUE, col); glColor4f(col[0], col[1], col[2], 0.5f); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); @@ -1708,12 +1709,6 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) case SEPR: break; - /* XXX in old code UI_EMBOSSP was set to distinguish these types, fix */ - case PULLDOWN: - case HMENU: - wt= widget_type(UI_WTYPE_PULLDOWN); - break; - default: wt= widget_type(UI_WTYPE_MENU_ITEM); } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 492f1333ff5..54775c4e5ab 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -903,6 +903,8 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) } xco+=XIC; + uiBlockSetEmboss(block, UI_EMBOSS); + return xco; } diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index 68dc9b21e9e..8be90caa86f 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -1606,8 +1606,6 @@ void action_header_buttons(const bContext *C, ARegion *ar) ANIM_animdata_get_context(C, &ac); if ((sa->flag & HEADER_NO_PULLDOWN)==0) { - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); uiDefPulldownBut(block, action_viewmenu, CTX_wm_area(C), diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index a09b7320468..9bec60fcc75 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -143,9 +143,6 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco, xmax-3, 20, ""); diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index ddb890e1f7e..b7276c933e6 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -110,8 +110,6 @@ void file_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_graph/graph_header.c b/source/blender/editors/space_graph/graph_header.c index c20278d4d65..178b4b4562f 100644 --- a/source/blender/editors/space_graph/graph_header.c +++ b/source/blender/editors/space_graph/graph_header.c @@ -162,9 +162,6 @@ void graph_header_buttons(const bContext *C, ARegion *ar) if ((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, graph_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c index 74397e7897d..1ff71bd2225 100644 --- a/source/blender/editors/space_image/image_header.c +++ b/source/blender/editors/space_image/image_header.c @@ -741,8 +741,6 @@ void image_header_buttons(const bContext *C, ARegion *ar) char *menuname; int xmax; - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefMenuBut(block, image_viewmenu, NULL, "View", xco, yco, xmax-3, 20, ""); xco+= xmax; diff --git a/source/blender/editors/space_info/info_header.c b/source/blender/editors/space_info/info_header.c index 2adcd0c6e68..8b940bd6ca8 100644 --- a/source/blender/editors/space_info/info_header.c +++ b/source/blender/editors/space_info/info_header.c @@ -400,9 +400,6 @@ void info_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("File"); uiDefMenuBut(block, info_filemenu, NULL, "File", xco, yco, xmax-3, 20, ""); xco+= xmax; diff --git a/source/blender/editors/space_nla/nla_header.c b/source/blender/editors/space_nla/nla_header.c index 484f466b0e9..0f6b77da6f5 100644 --- a/source/blender/editors/space_nla/nla_header.c +++ b/source/blender/editors/space_nla/nla_header.c @@ -112,9 +112,6 @@ void nla_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 1192eb2b56f..002e4eea681 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -699,9 +699,6 @@ void node_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); xmax= GetButStringLength("View"); uiDefPulldownBut(block, node_viewmenu, NULL, diff --git a/source/blender/editors/space_outliner/outliner_header.c b/source/blender/editors/space_outliner/outliner_header.c index 80ad3d23c94..fe2f054899c 100644 --- a/source/blender/editors/space_outliner/outliner_header.c +++ b/source/blender/editors/space_outliner/outliner_header.c @@ -220,9 +220,6 @@ void outliner_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, outliner_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_script/script_header.c b/source/blender/editors/space_script/script_header.c index 78a19c52206..d9851df4185 100644 --- a/source/blender/editors/space_script/script_header.c +++ b/source/blender/editors/space_script/script_header.c @@ -112,9 +112,6 @@ void script_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_sequencer/sequencer_header.c b/source/blender/editors/space_sequencer/sequencer_header.c index aa633536c30..aee589cb982 100644 --- a/source/blender/editors/space_sequencer/sequencer_header.c +++ b/source/blender/editors/space_sequencer/sequencer_header.c @@ -335,9 +335,6 @@ void sequencer_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); //uiDefMenuBut(block, seq_viewmenu, NULL, "View", xco, 0, xmax-3, 24, ""); // TODO diff --git a/source/blender/editors/space_sound/sound_header.c b/source/blender/editors/space_sound/sound_header.c index 46034d6e7ef..ae3410663c2 100644 --- a/source/blender/editors/space_sound/sound_header.c +++ b/source/blender/editors/space_sound/sound_header.c @@ -112,9 +112,6 @@ void sound_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, 24, ""); diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c index c751fbd8029..f26e632eb87 100644 --- a/source/blender/editors/space_time/time_header.c +++ b/source/blender/editors/space_time/time_header.c @@ -440,9 +440,6 @@ void time_header_buttons(const bContext *C, ARegion *ar) if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - xmax= GetButStringLength("View"); uiDefPulldownBut(block, time_viewmenu, sa, "View", xco, yco, xmax-3, 20, ""); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index a3a8d69f8cb..94d53a64f32 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -31,6 +31,7 @@ #include #include +#include "DNA_ID.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_curve_types.h" @@ -61,6 +62,7 @@ #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_depsgraph.h" +#include "BKE_idprop.h" #include "BKE_object.h" #include "BKE_global.h" #include "BKE_scene.h" @@ -1698,6 +1700,60 @@ static void view3d_panel_bonesketch_spaces(const bContext *C, ARegion *ar, short } } + +/* op->invoke */ +static void redo_cb(bContext *C, void *arg_op, void *arg2) +{ + wmOperator *lastop= arg_op; + + if(lastop) { + int retval; + + printf("operator redo %s\n", lastop->type->name); + ED_undo_pop(C); + retval= WM_operator_repeat(C, lastop); + if((retval & OPERATOR_FINISHED)==0) { + printf("operator redo failed %s\n", lastop->type->name); + ED_undo_redo(C); + } + } +} + +static void view3d_panel_operator_redo(const bContext *C, ARegion *ar, short cntrl) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmOperator *op; + PointerRNA ptr; + uiBlock *block; + int height; + + block= uiBeginBlock(C, ar, "view3d_panel_operator_redo", UI_EMBOSS); + if(uiNewPanel(C, ar, block, "Last Operator", "View3d", 340, 10, 318, height)==0) return; + + /* only for operators that are registered and did an undo push */ + for(op= wm->operators.last; op; op= op->prev) + if((op->type->flag & OPTYPE_REGISTER) && (op->type->flag & OPTYPE_UNDO)) + break; + + if(op==NULL) + return; + + uiBlockSetFunc(block, redo_cb, op, NULL); + + 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); + height= uiDefAutoButsRNA(C, block, &ptr); + + uiNewPanelHeight(block, height); + + uiEndBlock(C, block); +} + + void view3d_buttons_area_defbuts(const bContext *C, ARegion *ar) { uiBeginPanels(C, ar); @@ -1714,6 +1770,8 @@ void view3d_buttons_area_defbuts(const bContext *C, ARegion *ar) view3d_panel_bonesketch_spaces(C, ar, 0); + view3d_panel_operator_redo(C, ar, 0); + uiEndPanels(C, ar); } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 8578024e4ff..57d227f33bf 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -5129,9 +5129,6 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o short xmax, xco= *xcoord; - /* pull down menus */ - uiBlockSetEmboss(block, UI_EMBOSSP); - /* compensate for local mode when setting up the viewing menu/iconrow values */ if(rv3d->view==7) rv3d->viewbut= 1; else if(rv3d->view==1) rv3d->viewbut= 2; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 091b35c7361..d588a73789c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -242,7 +242,8 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy) void projectIntView(TransInfo *t, float *vec, int *adr) { if (t->spacetype==SPACE_VIEW3D) { - project_int_noclip(t->ar, vec, adr); + if(t->ar->regiontype == RGN_TYPE_WINDOW) + project_int_noclip(t->ar, vec, adr); } else if(t->spacetype==SPACE_IMAGE) { float aspx, aspy, v[2]; @@ -272,7 +273,8 @@ void projectIntView(TransInfo *t, float *vec, int *adr) void projectFloatView(TransInfo *t, float *vec, float *adr) { if (t->spacetype==SPACE_VIEW3D) { - project_float_noclip(t->ar, vec, adr); + if(t->ar->regiontype == RGN_TYPE_WINDOW) + project_float_noclip(t->ar, vec, adr); } else if(t->spacetype==SPACE_IMAGE) { int a[2]; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 0b0919ff981..62ce76a7614 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -176,6 +176,10 @@ void ED_undo_pop(bContext *C) { ed_undo_step(C, 1); } +void ED_undo_redo(bContext *C) +{ + ed_undo_step(C, -1); +} static int ed_undo_exec(bContext *C, wmOperator *op) { -- cgit v1.2.3