2.5/Paint modes:
authorNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 15:47:32 +0000 (15:47 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Fri, 14 Aug 2009 15:47:32 +0000 (15:47 +0000)
* Fixed one of the items from Brecht's TODO mail. Exiting edit mode now restores any paint mode you might have been in, rather than going to object mode.

source/blender/editors/include/ED_view3d.h
source/blender/editors/object/object_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesdna/DNA_object_types.h

index b576299c1d07f511ae7b0ab21a5328f28b535a83..aecf8976fa1a2a7247aa5de6043115123a528755 100644 (file)
@@ -131,7 +131,8 @@ int lasso_inside(short mcords[][2], short moves, short sx, short sy);
 int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1);
 
 /* modes */
-void ED_view3d_exit_paint_modes(struct bContext *C);
+int ED_view3d_exit_paint_modes(struct bContext *C);
+void ED_view3d_restore_paint_modes(struct bContext *C, int);
 /* get 3d region from context, also if mouse is in header or toolbar */
 struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C);
 
index a6bd38752ae5cd96582b0c709af6db8328f817e5..4cc3f22d5f8bd8b3ea29330887105fc556695eee 100644 (file)
@@ -3724,7 +3724,7 @@ void ED_object_exit_editmode(bContext *C, int flag)
                load_editMball(obedit);
                if(freedata) free_editMball(obedit);
        }
-       
+
        /* freedata only 0 now on file saves */
        if(freedata) {
                /* for example; displist make is different in editmode */
@@ -3739,6 +3739,8 @@ void ED_object_exit_editmode(bContext *C, int flag)
        
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene);
        }
+
+       ED_view3d_restore_paint_modes(C, obedit->restore_mode);
 }
 
 
@@ -3772,7 +3774,7 @@ void ED_object_enter_editmode(bContext *C, int flag)
        
        if(flag & EM_WAITCURSOR) waitcursor(1);
 
-       ED_view3d_exit_paint_modes(C);
+       ob->restore_mode = ED_view3d_exit_paint_modes(C);
        
        if(ob->type==OB_MESH) {
                Mesh *me= ob->data;
index 2e0172f4238c7d261926d7d51f987174dcb2c524..d40b3ad46005ea33e49abc7d152a44fb03f13035 100644 (file)
@@ -134,28 +134,37 @@ static int retopo_mesh_paint_check() {return 0;}
 
 /* end XXX ************* */
 
-
-/* well... in this file a lot of view mode manipulation happens, so let's have it defined here */
-void ED_view3d_exit_paint_modes(bContext *C)
+static int ED_toggle_paint_modes(bContext *C, int mode)
 {
-       if(G.f & G_TEXTUREPAINT)
+       if(mode & G_TEXTUREPAINT)
                WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if(G.f & G_VERTEXPAINT)
+       if(mode & G_VERTEXPAINT)
                WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       else if(G.f & G_WEIGHTPAINT)
+       else if(mode & G_WEIGHTPAINT)
                WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
 
-       if(G.f & G_SCULPTMODE)
+       if(mode & G_SCULPTMODE)
                WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       if(G.f & G_PARTICLEEDIT)
+       if(mode & G_PARTICLEEDIT)
                WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
-       
-       G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT);
 }
 
+/* well... in this file a lot of view mode manipulation happens, so let's have it defined here */
+int ED_view3d_exit_paint_modes(bContext *C)
+{
+       int restore = G.f;
 
+       ED_toggle_paint_modes(C, G.f);
+       
+       G.f &= ~(G_VERTEXPAINT+G_TEXTUREPAINT+G_WEIGHTPAINT+G_SCULPTMODE+G_PARTICLEEDIT);
 
+       return restore;
+}
 
+void ED_view3d_restore_paint_modes(struct bContext *C, int mode)
+{
+       ED_toggle_paint_modes(C, mode);
+}
 
 static void do_view3d_header_buttons(bContext *C, void *arg, int event);
 
index ae9d775a74aee6f31f3eb1d5693221140846fc2e..35fd4a28cc3a0c1d9e984687d4df902006db3c16 100644 (file)
@@ -227,7 +227,8 @@ typedef struct Object {
        int lastDataMask;                       /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
        unsigned int state;                     /* bit masks of game controllers that are active */
        unsigned int init_state;        /* bit masks of initial state as recorded by the users */
-       int pad2;
+
+       int restore_mode;               /* Keep track of what mode to return to after edit mode exits */
 
        ListBase gpulamp;               /* runtime, for lamps only */
 } Object;