disable undo for hard coded interface buttons:
authorCampbell Barton <ideasman42@gmail.com>
Thu, 18 Aug 2011 17:09:23 +0000 (17:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 18 Aug 2011 17:09:23 +0000 (17:09 +0000)
- space type switcher.
- header menu toggle.
- properties window header buttons.
- various view3d manipulator buttons.

source/blender/editors/screen/area.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/editors/space_view3d/view3d_header.c

index 82986dfbcc4b82b5a462aaa2321f549ee33cbc88..bc97cd9d3ff0297d12763a5e4a7fe0c0d1318090 100644 (file)
@@ -1406,6 +1406,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
                                                   "Displays current editor type. "
                                                   "Click for menu of available types");
        uiButSetFunc(but, spacefunc, NULL, NULL);
+       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
        
        return xco + UI_UNIT_X + 14;
 }
@@ -1414,6 +1415,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
 {
        ScrArea *sa= CTX_wm_area(C);
        int xco= 8;
+       uiBut *but;
        
        if (!sa->full)
                xco= ED_area_header_switchbutton(C, block, yco);
@@ -1421,20 +1423,22 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
        uiBlockSetEmboss(block, UI_EMBOSSN);
 
        if (sa->flag & HEADER_NO_PULLDOWN) {
-               uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
+               but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
                                                 ICON_DISCLOSURE_TRI_RIGHT,
                                                 xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
                                                 &(sa->flag), 0, 0, 0, 0, 
                                                 "Show pulldown menus");
        }
        else {
-               uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
+               but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
                                                 ICON_DISCLOSURE_TRI_DOWN,
                                                 xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
                                                 &(sa->flag), 0, 0, 0, 0, 
                                                 "Hide pulldown menus");
        }
 
+       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
+
        uiBlockSetEmboss(block, UI_EMBOSS);
        
        return xco + UI_UNIT_X;
index 19c600be93761516e07317a8110a9ac8c4a50b98..e631718b0cbd5b26a9a1908e10a93f5ea25ff339 100644 (file)
@@ -104,6 +104,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
 {
        SpaceButs *sbuts= CTX_wm_space_buts(C);
        uiBlock *block;
+       uiBut *but;
        int xco, yco= 2;
 
        buttons_context_compute(C, sbuts);
@@ -118,33 +119,32 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
        xco -= UI_UNIT_X;
        
        // Default panels
+
        uiBlockBeginAlign(block);
-       if(sbuts->pathflag & (1<<BCONTEXT_RENDER))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SCENE,                     xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render");
-       if(sbuts->pathflag & (1<<BCONTEXT_SCENE))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_SCENE_DATA,                        xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene");
-       if(sbuts->pathflag & (1<<BCONTEXT_WORLD))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_WORLD,             xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World");
-       if(sbuts->pathflag & (1<<BCONTEXT_OBJECT))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_OBJECT_DATA,       xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object");
-       if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_CONSTRAINT,        xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints");
-       if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_MODIFIER,  xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers");
-       if(sbuts->pathflag & (1<<BCONTEXT_DATA))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     sbuts->dataicon,        xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data");
-       if(sbuts->pathflag & (1<<BCONTEXT_BONE))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_BONE_DATA, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone");
-       if(sbuts->pathflag & (1<<BCONTEXT_BONE_CONSTRAINT))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_CONSTRAINT_BONE,   xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints");
-       if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_MATERIAL,  xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material");
-       if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE))
-               uiDefIconButS(block, ROW, B_BUTSPREVIEW,        ICON_TEXTURE,   xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_TEXTURE, 0, 0, "Texture");
-       if(sbuts->pathflag & (1<<BCONTEXT_PARTICLE))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PARTICLES, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PARTICLE, 0, 0, "Particles");
-       if(sbuts->pathflag & (1<<BCONTEXT_PHYSICS))
-               uiDefIconButS(block, ROW, B_CONTEXT_SWITCH,     ICON_PHYSICS,   xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)BCONTEXT_PHYSICS, 0, 0, "Physics");
+
+#define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \
+       if(sbuts->pathflag & (1<<_ctx)) { \
+               but= uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, _tip); \
+               uiButClearFlag(but, UI_BUT_UNDO); \
+       } \
+
+
+       BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, "Render")
+       BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, "Scene");
+       BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, "World");
+       BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, "Object");
+       BUTTON_HEADER_CTX(BCONTEXT_CONSTRAINT, ICON_CONSTRAINT, "Object Constraints");
+       BUTTON_HEADER_CTX(BCONTEXT_MODIFIER, ICON_MODIFIER, "Object Modifiers");
+       BUTTON_HEADER_CTX(BCONTEXT_DATA, sbuts->dataicon, "Object Data");
+       BUTTON_HEADER_CTX(BCONTEXT_BONE, ICON_BONE_DATA, "Bone");
+       BUTTON_HEADER_CTX(BCONTEXT_BONE_CONSTRAINT, ICON_CONSTRAINT_BONE, "Bone Constraints");
+       BUTTON_HEADER_CTX(BCONTEXT_MATERIAL, ICON_MATERIAL, "Material");
+       BUTTON_HEADER_CTX(BCONTEXT_TEXTURE, ICON_TEXTURE, "Textures");
+       BUTTON_HEADER_CTX(BCONTEXT_PARTICLE, ICON_PARTICLES, "Particles");
+       BUTTON_HEADER_CTX(BCONTEXT_PHYSICS, ICON_PHYSICS, "Physics");
+
+#undef BUTTON_HEADER_CTX
+
        xco+= BUT_UNIT_X;
        
        uiBlockEndAlign(block);
index 70b2a3d36282fc9ce51856c119eb694e867229b4..78dcf6c9a5c265e39cab3b24eb1c9440fa236577 100644 (file)
@@ -466,6 +466,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        Object *ob= OBACT;
        Object *obedit = CTX_data_edit_object(C);
        uiBlock *block;
+       uiBut *but;
        uiLayout *row;
        const float dpi_fac= UI_DPI_FAC;
        
@@ -513,9 +514,12 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                block= uiLayoutGetBlock(row);
                
                if(v3d->twflag & V3D_USE_MANIPULATOR) {
-                       uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode");
-                       uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode");
-                       uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode");
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode");
+                       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode");
+                       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode");
+                       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
                }
                        
                if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
@@ -523,7 +527,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                }
                        
                str_menu = BIF_menustringTransformOrientation(C, "Orientation");
-               uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation");
+               but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation");
+               uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
                MEM_freeN((void *)str_menu);
        }