2.5
authorTon Roosendaal <ton@blender.org>
Wed, 15 Apr 2009 17:53:12 +0000 (17:53 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 15 Apr 2009 17:53:12 +0000 (17:53 +0000)
- 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.

21 files changed:
source/blender/editors/include/ED_util.h
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/screen/area.c
source/blender/editors/space_action/action_header.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_file/file_header.c
source/blender/editors/space_graph/graph_header.c
source/blender/editors/space_image/image_header.c
source/blender/editors/space_info/info_header.c
source/blender/editors/space_nla/nla_header.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_outliner/outliner_header.c
source/blender/editors/space_script/script_header.c
source/blender/editors/space_sequencer/sequencer_header.c
source/blender/editors/space_sound/sound_header.c
source/blender/editors/space_time/time_header.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/transform/transform.c
source/blender/editors/util/undo.c

index 7002524be7e27e03d21bfb92fed268c4f6b0c18b..7ccbf1ff18dae160c2e031347782fea9eae17041 100644 (file)
@@ -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);
 
index 261d36cf38e5c372fffbd1c2936a5e284cccc6c8..9e7d13b68cc75bfbd0fb35a8262e30c613b8b391 100644 (file)
@@ -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;
index abaa832957db0f532353f6caf9e4dc1859dadb4d..3025b1bfc2975680881280e6f9886bfd2819b4c5 100644 (file)
@@ -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);
                }
index 492f1333ff57ea849ef07dd673ff0d26d1e58db8..54775c4e5ab1d6da6189ee47cafe844c090a96bc 100644 (file)
@@ -903,6 +903,8 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
        }
        xco+=XIC;
        
+       uiBlockSetEmboss(block, UI_EMBOSS);
+       
        return xco;
 }
 
index 68dc9b21e9e5c35a5c7eba52957c646aec8ca430..8be90caa86fb1ec4b0c65a881b669bfd163ad70d 100644 (file)
@@ -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), 
index a09b73204683a0b376b9d4ef5451a10f76ef1e98..9bec60fcc75340b4cc1481fcd00b07dccbdee4e0 100644 (file)
@@ -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, "");
index ddb890e1f7ed67cb1c8951912dd3d227e96b7b65..b7276c933e6a770ca62d6cddb9ffd60a3f66ba0b 100644 (file)
@@ -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, "");
index c20278d4d65dd2ad7de8d22035891561957551c8..178b4b4562f36d7daf62197c6dafd180f62020e8 100644 (file)
@@ -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, "");
index 74397e7897d3b8468816454092d6039c61f3236f..1ff71bd2225aadeb403ba2277232017324750da9 100644 (file)
@@ -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;
index 2adcd0c6e6844cb8de50f9287fb5b55d646069f5..8b940bd6ca854e8536a9f21ebe71a233b6bca4d8 100644 (file)
@@ -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;
index 484f466b0e93b2b457c352575d8f7eba54c936f1..0f6b77da6f54a3eaf6d2d97af9f5c13aeb3c8f76 100644 (file)
@@ -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, "");
index 1192eb2b56fbb5f401adde5ef7e004204b115370..002e4eea68131645397bcb1ecfc4b664407d1716 100644 (file)
@@ -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, 
index 80ad3d23c9410694cf095019541a2a981096d8f9..fe2f054899c857d9205c610f19a9e488788a81b1 100644 (file)
@@ -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, ""); 
index 78a19c5220678e1e7195230134feb04ef1706624..d9851df418542e4c1b462d6cc1c343a9e838143c 100644 (file)
@@ -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, "");
index aa633536c3083ef9b578641b85382b3a010180ff..aee589cb982816269941760284f51f5904d2f29b 100644 (file)
@@ -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
index 46034d6e7ef26f936bd4ca1c0a32859d8c45738b..ae3410663c28b1219d84e33758d65a8205dd607f 100644 (file)
@@ -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, "");
index c751fbd8029d69110635769ab57c712552de4351..f26e632eb872e9ad3685309ba5893549f3ada18b 100644 (file)
@@ -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, "");
index a3a8d69f8cbcbbf4623fad5ee81c1cd411f39888..94d53a64f32aa61263539896c19b9aef0506039c 100644 (file)
@@ -31,6 +31,7 @@
 #include <math.h>
 #include <float.h>
 
+#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);
 }
 
index 8578024e4fff6c259dcd1b4e27df15213f619779..57d227f33bff917ab19fa7db38bef485644a7933 100644 (file)
@@ -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;
index 091b35c7361f77de3a5304ea6869201f6f274f4c..d588a73789c263807f6b2e0d9bf3761c8c22d39f 100644 (file)
@@ -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];
index 0b0919ff981c7df96ed1259fba5123b1bacb3674..62ce76a7614cce8549e2bc7c5a52d932438bc149 100644 (file)
@@ -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)
 {