- Edit mode Mesh undo/redo back
  (undo for editmodes needed recode, todo for curve/lattice/etc)
- Added border select for edit mesh
- Added Akey (de)select all for edit mesh
- Added notifiers for mode changes.

This is also the first trial to dynamically add/remove
keymap handlers, based on modes. For that reason the Object
keymap was split in 2, modal and non-modal. On TABkey, the
view3d listener removes and adds maps.

The view3d keymap still handles generic mouse/border selection.
Internally it will verify modes.

The modes are not  re-implemented still... have to move this
to scene context.
This commit is contained in:
Ton Roosendaal 2009-01-01 13:15:35 +00:00
parent a1c4d1c735
commit e9a3b4f85d
29 changed files with 433 additions and 170 deletions

@ -31,7 +31,12 @@
struct View3D; struct View3D;
struct ARegion; struct ARegion;
struct EditMesh; struct EditMesh;
struct EditVert;
struct EditEdge;
struct EditFace;
struct bContext; struct bContext;
struct wmWindowManager;
struct EditSelection;
// edge and face flag both // edge and face flag both
#define EM_FGON 2 #define EM_FGON 2
@ -67,39 +72,48 @@ typedef struct ViewContext {
/* meshtools.c */ /* meshtools.c */
intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode); intptr_t mesh_octree_table(Object *ob, struct EditMesh *em, float *co, char mode);
EditVert *editmesh_get_x_mirror_vert(Object *ob, EditMesh *em, float *co); struct EditVert *editmesh_get_x_mirror_vert(Object *ob, struct EditMesh *em, float *co);
/* mesh_ops.c */
void ED_operatortypes_mesh(void);
void ED_keymap_mesh(struct wmWindowManager *wm);
/* editmesh.c */ /* editmesh.c */
void ED_spacetypes_init(void);
void ED_keymap_mesh(struct wmWindowManager *wm);
void make_editMesh(Scene *scene, Object *ob); void make_editMesh(Scene *scene, Object *ob);
void load_editMesh(Scene *scene, Object *ob); void load_editMesh(Scene *scene, Object *ob);
void remake_editMesh(Scene *scene, Object *ob); void remake_editMesh(Scene *scene, Object *ob);
void free_editMesh(EditMesh *em); void free_editMesh(struct EditMesh *em);
void EM_init_index_arrays(struct EditMesh *em, int forVert, int forEdge, int forFace); void EM_init_index_arrays(struct EditMesh *em, int forVert, int forEdge, int forFace);
void EM_free_index_arrays(void); void EM_free_index_arrays(void);
EditVert *EM_get_vert_for_index(int index); struct EditVert *EM_get_vert_for_index(int index);
EditEdge *EM_get_edge_for_index(int index); struct EditEdge *EM_get_edge_for_index(int index);
EditFace *EM_get_face_for_index(int index); struct EditFace *EM_get_face_for_index(int index);
int EM_texFaceCheck(struct EditMesh *em); int EM_texFaceCheck(struct EditMesh *em);
int EM_vertColorCheck(struct EditMesh *em); int EM_vertColorCheck(struct EditMesh *em);
void undo_push_mesh(char *name);
void undo_push_mesh(struct bContext *C, char *name);
/* editmesh_lib.c */ /* editmesh_lib.c */
EditFace *EM_get_actFace(struct EditMesh *em, int sloppy); struct EditFace *EM_get_actFace(struct EditMesh *em, int sloppy);
void EM_select_edge(EditEdge *eed, int sel); void EM_select_edge(struct EditEdge *eed, int sel);
void EM_select_face_fgon(struct EditMesh *em, EditFace *efa, int val); void EM_select_face_fgon(struct EditMesh *em, struct EditFace *efa, int val);
void EM_selectmode_flush(struct EditMesh *em); void EM_selectmode_flush(struct EditMesh *em);
void EM_deselect_flush(struct EditMesh *em); void EM_deselect_flush(struct EditMesh *em);
/* exported to transform */ /* exported to transform */
int EM_get_actSelection(EditMesh *em, EditSelection *ese); int EM_get_actSelection(struct EditMesh *em, struct EditSelection *ese);
void EM_editselection_normal(float *normal, EditSelection *ese); void EM_editselection_normal(float *normal, struct EditSelection *ese);
void EM_editselection_plane(float *plane, EditSelection *ese); void EM_editselection_plane(float *plane, struct EditSelection *ese);
/* editmesh_mods.c */ /* editmesh_mods.c */

@ -94,6 +94,9 @@ int ED_operator_node_active(struct bContext *C);
int ED_operator_ipo_active(struct bContext *C); int ED_operator_ipo_active(struct bContext *C);
int ED_operator_sequencer_active(struct bContext *C); int ED_operator_sequencer_active(struct bContext *C);
int ED_operator_object_active(struct bContext *C);
int ED_operator_editmesh(struct bContext *C);
int ED_operator_editcurve(struct bContext *C);
/* default keymaps, bitflags */ /* default keymaps, bitflags */
#define ED_KEYMAP_UI 1 #define ED_KEYMAP_UI 1

@ -46,14 +46,19 @@ void ED_OT_undo (struct wmOperatorType *ot);
void ED_OT_redo (struct wmOperatorType *ot); void ED_OT_redo (struct wmOperatorType *ot);
/* undo_editmode.c */ /* undo_editmode.c */
void undo_editmode_push (char *name, void (*freedata)(void *), void undo_editmode_push(struct bContext *C, char *name,
void (*to_editmode)(void *), void *(*from_editmode)(void), void * (*getdata)(struct bContext *C),
int (*validate_undo)(void *)); void (*freedata)(void *),
void (*to_editmode)(void *, void *),
void *(*from_editmode)(void *),
int (*validate_undo)(void *, void *));
void *undo_editmode_get_prev (struct Object *ob); void *undo_editmode_get_prev (struct Object *ob);
struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg_unused); struct uiBlock *editmode_undohistorymenu(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg_unused);
void undo_editmode_menu (void); void undo_editmode_menu (struct bContext *C);
void undo_editmode_clear (void); void undo_editmode_clear (void);
void undo_editmode_step (int step); void undo_editmode_step (struct bContext *C, int step);
/* ************** XXX OLD CRUFT WARNING ************* */ /* ************** XXX OLD CRUFT WARNING ************* */

@ -47,6 +47,7 @@ CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesdna
CPPFLAGS += -I../../makesrna
CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../imbuf
CPPFLAGS += -I../../gpu CPPFLAGS += -I../../gpu
CPPFLAGS += -I../../render/extern/include CPPFLAGS += -I../../render/extern/include

@ -79,7 +79,7 @@
#include "WM_types.h" #include "WM_types.h"
/* own include */ /* own include */
#include "editmesh.h" #include "mesh_intern.h"
/* Pupmenu codes: */ /* Pupmenu codes: */

@ -81,7 +81,7 @@
#include "ED_util.h" #include "ED_util.h"
/* own include */ /* own include */
#include "editmesh.h" #include "mesh_intern.h"
/* /*
editmesh.c: editmesh.c:
@ -1877,10 +1877,10 @@ static void free_undoMesh(void *umv)
MEM_freeN(um); MEM_freeN(um);
} }
static void *editMesh_to_undoMesh(void) static void *editMesh_to_undoMesh(void *emv)
{ {
EditMesh *em= NULL; // XXX EditMesh *em= (EditMesh *)emv;
Scene *scene= NULL; // Scene *scene= NULL;
UndoMesh *um; UndoMesh *um;
EditVert *eve; EditVert *eve;
EditEdge *eed; EditEdge *eed;
@ -1891,7 +1891,7 @@ static void *editMesh_to_undoMesh(void)
EditFaceC *efac=NULL; EditFaceC *efac=NULL;
EditSelectionC *esec=NULL; EditSelectionC *esec=NULL;
int a; int a;
return NULL; // XXX
um= MEM_callocN(sizeof(UndoMesh), "undomesh"); um= MEM_callocN(sizeof(UndoMesh), "undomesh");
um->selectmode = em->selectmode; um->selectmode = em->selectmode;
@ -1972,7 +1972,7 @@ static void *editMesh_to_undoMesh(void)
} }
// XXX um->retopo_paint_data= retopo_paint_data_copy(em->retopo_paint_data); // XXX um->retopo_paint_data= retopo_paint_data_copy(em->retopo_paint_data);
um->retopo_mode= scene->toolsettings->retopo_mode; // um->retopo_mode= scene->toolsettings->retopo_mode;
{ {
Multires *mr= get_mesh(G.obedit)->mr; Multires *mr= get_mesh(G.obedit)->mr;
@ -1996,10 +1996,10 @@ static void *editMesh_to_undoMesh(void)
return um; return um;
} }
static void undoMesh_to_editMesh(void *umv) static void undoMesh_to_editMesh(void *umv, void *emv)
{ {
EditMesh *em= NULL; // XXX EditMesh *em= (EditMesh *)emv;
UndoMesh *um= (UndoMesh*)umv; UndoMesh *um= (UndoMesh *)umv;
EditVert *eve, **evar=NULL; EditVert *eve, **evar=NULL;
EditEdge *eed; EditEdge *eed;
EditFace *efa; EditFace *efa;
@ -2009,7 +2009,7 @@ static void undoMesh_to_editMesh(void *umv)
EditFaceC *efac; EditFaceC *efac;
EditSelectionC *esec; EditSelectionC *esec;
int a=0; int a=0;
return; // XXX
em->selectmode = um->selectmode; em->selectmode = um->selectmode;
free_editMesh(em); free_editMesh(em);
@ -2110,11 +2110,20 @@ static void undoMesh_to_editMesh(void *umv)
} }
} }
static void *getEditMesh(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if(obedit) {
Mesh *me= obedit->data;
return me->edit_mesh;
}
return NULL;
}
/* and this is all the undo system needs to know */ /* and this is all the undo system needs to know */
void undo_push_mesh(char *name) void undo_push_mesh(bContext *C, char *name)
{ {
undo_editmode_push(name, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh, NULL); undo_editmode_push(C, name, getEditMesh, free_undoMesh, undoMesh_to_editMesh, editMesh_to_undoMesh, NULL);
} }

@ -61,7 +61,7 @@
#include "ED_multires.h" #include "ED_multires.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "editmesh.h" #include "mesh_intern.h"
/* bpymenu removed XXX */ /* bpymenu removed XXX */

@ -56,7 +56,7 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data
#include "ED_mesh.h" #include "ED_mesh.h"
#include "editmesh.h" #include "mesh_intern.h"
/* this replaces the active flag used in uv/face mode */ /* this replaces the active flag used in uv/face mode */
void EM_set_actFace(EditMesh *em, EditFace *efa) void EM_set_actFace(EditMesh *em, EditFace *efa)

@ -69,7 +69,7 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
#include "ED_mesh.h" #include "ED_mesh.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "editmesh.h" #include "mesh_intern.h"
/* **** XXX ******** */ /* **** XXX ******** */
static void BIF_undo_push() {} static void BIF_undo_push() {}

@ -76,14 +76,18 @@ editmesh_mods.c, UI level access, no geometry changes
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "ED_multires.h" #include "ED_multires.h"
#include "ED_mesh.h" #include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "BIF_gl.h" #include "BIF_gl.h"
#include "BIF_glutil.h" #include "BIF_glutil.h"
#include "editmesh.h" #include "mesh_intern.h"
#include "BLO_sys_types.h" // for intptr_t support #include "BLO_sys_types.h" // for intptr_t support
@ -2174,6 +2178,7 @@ static void mouse_mesh_loop(ViewContext *vc)
/* here actual select happens */ /* here actual select happens */
/* gets called via generic mouse select operator */
void mouse_mesh(bContext *C, short mval[2], short extend) void mouse_mesh(bContext *C, short mval[2], short extend)
{ {
ViewContext vc; ViewContext vc;
@ -3225,22 +3230,41 @@ void selectswap_mesh(EditMesh *em) /* UI level */
} }
void deselectall_mesh(EditMesh *em) /* this toggles!!!, UI level */ /* ******************** (de)select all operator **************** */
{
if( EM_nvertices_selected(em) ) { static int toggle_select_all_exec(bContext *C, wmOperator *op)
EM_clear_flag_all(em, SELECT); {
BIF_undo_push("Deselect All"); Object *obedit= CTX_data_edit_object(C);
} EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
else {
EM_set_flag_all(em, SELECT); if( EM_nvertices_selected(em) ) {
BIF_undo_push("Select All"); EM_clear_flag_all(em, SELECT);
} BIF_undo_push("Deselect All");
}
else {
EM_set_flag_all(em, SELECT);
BIF_undo_push("Select All");
}
// if (EM_texFaceCheck()) // if (EM_texFaceCheck())
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
return OPERATOR_FINISHED;
} }
void MESH_OT_de_select_all(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Select or Deselect All";
ot->idname= "MESH_OT_de_select_all";
/* api callbacks */
ot->exec= toggle_select_all_exec;
ot->poll= ED_operator_editmesh;
}
/* ******************** **************** */
void EM_select_more(EditMesh *em) void EM_select_more(EditMesh *em)
{ {
EditVert *eve; EditVert *eve;

@ -82,7 +82,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
#include "ED_mesh.h" #include "ED_mesh.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "editmesh.h" #include "mesh_intern.h"
/* XXX */ /* XXX */
static void BIF_undo_push() {} static void BIF_undo_push() {}

@ -29,10 +29,11 @@
/* Internal for editmesh_xxxx.c functions */ /* Internal for editmesh_xxxx.c functions */
#ifndef EDITMESH_H #ifndef MESH_INTERN_H
#define EDITMESH_H #define MESH_INTERN_H
struct bContext; struct bContext;
struct wmOperatorType;
#define TEST_EDITMESH if(G.obedit==0) return; /* layer test XXX */ #define TEST_EDITMESH if(G.obedit==0) return; /* layer test XXX */
@ -164,6 +165,9 @@ extern struct EditFace *EM_face_from_faces(EditMesh *em, struct EditFace *efa1,
/* ******************* editmesh_mods.c */ /* ******************* editmesh_mods.c */
void MESH_OT_de_select_all(struct wmOperatorType *ot);
extern EditEdge *findnearestedge(ViewContext *vc, int *dist); extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
extern void EM_automerge(int update); extern void EM_automerge(int update);
void editmesh_select_by_material(EditMesh *em, int index); void editmesh_select_by_material(EditMesh *em, int index);
@ -195,5 +199,5 @@ void esubdivideflag(EditMesh *em, int flag, float rad, int beauty, int numcuts,
int EdgeSlide(EditMesh *em, short immediate, float imperc); int EdgeSlide(EditMesh *em, short immediate, float imperc);
#endif #endif // MESH_INTERN_H

@ -0,0 +1,78 @@
/**
* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BLI_editVert.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_mesh.h"
#include "mesh_intern.h"
/* ************************** registration **********************************/
void ED_operatortypes_mesh(void)
{
WM_operatortype_append(MESH_OT_de_select_all);
}
/* note mesh keymap also for other space? */
void ED_keymap_mesh(wmWindowManager *wm)
{
ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
// RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
}

@ -84,7 +84,7 @@
#include "ED_object.h" #include "ED_object.h"
/* own include */ /* own include */
#include "editmesh.h" #include "mesh_intern.h"
/* from rendercode.c */ /* from rendercode.c */

@ -2061,7 +2061,7 @@ static void exit_editmode(bContext *C, wmOperator *op, int flag) /* freedata==0
// if(flag & EM_WAITCURSOR) waitcursor(0); // if(flag & EM_WAITCURSOR) waitcursor(0);
WM_event_add_notifier(C, NC_SCENE|ND_OB_EDIT, scene); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob);
} }
@ -2097,9 +2097,7 @@ static void enter_editmode(bContext *C, wmOperator *op)
make_editMesh(scene, ob); make_editMesh(scene, ob);
// XXX if (EM_texFaceCheck()) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, ob);
// allqueue(REDRAWIMAGE, 0);
} }
if (ob->type==OB_ARMATURE){ if (ob->type==OB_ARMATURE){
bArmature *arm= base->object->data; bArmature *arm= base->object->data;
@ -2122,7 +2120,7 @@ static void enter_editmode(bContext *C, wmOperator *op)
/* to ensure all goes in restposition and without striding */ /* to ensure all goes in restposition and without striding */
DAG_object_flush_update(scene, G.obedit, OB_RECALC); DAG_object_flush_update(scene, G.obedit, OB_RECALC);
allqueue (REDRAWVIEW3D,0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, ob);
} }
else if(ob->type==OB_FONT) { else if(ob->type==OB_FONT) {
G.obedit= ob; G.obedit= ob;
@ -2144,19 +2142,16 @@ static void enter_editmode(bContext *C, wmOperator *op)
G.obedit= ob; G.obedit= ob;
// XXX make_editNurb(); // XXX make_editNurb();
} }
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWOOPS, 0);
if(ok) { if(ok) {
allqueue(REDRAWVIEW3D, 1);
DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA); DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA);
} }
else G.obedit= NULL; else {
G.obedit= NULL;
// if(wc) waitcursor(0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob);
WM_event_add_notifier(C, NC_SCENE|ND_OB_EDIT, scene); }
} }

@ -75,12 +75,16 @@ void ED_operatortypes_object(void)
} }
/* note object keymap also for other space? */
void ED_keymap_object(wmWindowManager *wm) void ED_keymap_object(wmWindowManager *wm)
{ {
ListBase *keymap= WM_keymap_listbase(wm, "View3D Object", SPACE_VIEW3D, 0); ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0);
/* Note: this keymap works disregarding mode */
WM_keymap_add_item(keymap, "OBJECT_OT_toggle_editmode", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_toggle_editmode", TABKEY, KM_PRESS, 0, 0);
/* Note: this keymap gets disabled in non-objectmode, */
keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0);

@ -35,6 +35,9 @@
#include "BKE_screen.h" #include "BKE_screen.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_curve_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "WM_api.h" #include "WM_api.h"
@ -134,6 +137,26 @@ int ED_operator_sequencer_active(bContext *C)
return ed_spacetype_test(C, SPACE_SEQ); return ed_spacetype_test(C, SPACE_SEQ);
} }
int ED_operator_object_active(bContext *C)
{
return NULL != CTX_data_active_object(C);
}
int ED_operator_editmesh(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if(obedit && obedit->type==OB_MESH)
return NULL != ((Mesh *)obedit->data)->edit_mesh;
return 0;
}
int ED_operator_editcurve(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if(obedit && obedit->type==OB_CURVE)
return NULL != ((Mesh *)obedit->data)->edit_mesh;
return 0;
}
/* *************************** action zone operator ************************** */ /* *************************** action zone operator ************************** */

@ -27,6 +27,8 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_windowmanager_types.h" #include "DNA_windowmanager_types.h"
#include "BKE_context.h" #include "BKE_context.h"
@ -39,6 +41,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_object.h" #include "ED_object.h"
#include "ED_mesh.h"
#include "ED_space_api.h" #include "ED_space_api.h"
#include "ED_anim_api.h" #include "ED_anim_api.h"
@ -85,6 +88,7 @@ void ED_spacetypes_init(void)
ED_operatortypes_anim(); ED_operatortypes_anim();
ED_operatortypes_animchannels(); // XXX have this as part of anim() ones instead? ED_operatortypes_animchannels(); // XXX have this as part of anim() ones instead?
ED_operatortypes_object(); ED_operatortypes_object();
ED_operatortypes_mesh();
ui_view2d_operatortypes(); ui_view2d_operatortypes();
spacetypes = BKE_spacetypes_list(); spacetypes = BKE_spacetypes_list();
@ -105,6 +109,7 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
ED_keymap_anim(wm); ED_keymap_anim(wm);
ED_keymap_animchannels(wm); ED_keymap_animchannels(wm);
ED_keymap_object(wm); ED_keymap_object(wm);
ED_keymap_mesh(wm);
UI_view2d_keymap(wm); UI_view2d_keymap(wm);
spacetypes = BKE_spacetypes_list(); spacetypes = BKE_spacetypes_list();

@ -117,8 +117,8 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
case NC_SCENE: case NC_SCENE:
switch(wmn->data) { switch(wmn->data) {
case ND_OB_ACTIVE: case ND_OB_ACTIVE:
case ND_OB_EDIT:
case ND_OB_SELECT: case ND_OB_SELECT:
case ND_MODE:
ED_region_tag_redraw(ar); ED_region_tag_redraw(ar);
break; break;
} }

@ -197,10 +197,34 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
/* own keymap */ /* own keymap */
keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0); keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL); WM_event_add_keymap_handler(&ar->handlers, keymap);
/* object ops, modal later... */
keymap= WM_keymap_listbase(wm, "View3D Object", SPACE_VIEW3D, 0); /* object ops. */
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL); keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
/* object modal ops default */
keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
static void view3d_modal_keymaps(wmWindowManager *wm, ARegion *ar, int stype)
{
ListBase *keymap;
keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
if(stype==NS_MODE_OBJECT)
WM_event_add_keymap_handler(&ar->handlers, keymap);
else
WM_event_remove_keymap_handler(&ar->handlers, keymap);
keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
if(stype==NS_EDITMODE_MESH)
WM_event_add_keymap_handler(&ar->handlers, keymap);
else
WM_event_remove_keymap_handler(&ar->handlers, keymap);
} }
@ -212,10 +236,13 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->data) { switch(wmn->data) {
case ND_FRAME: case ND_FRAME:
case ND_OB_ACTIVE: case ND_OB_ACTIVE:
case ND_OB_EDIT:
case ND_OB_SELECT: case ND_OB_SELECT:
ED_region_tag_redraw(ar); ED_region_tag_redraw(ar);
break; break;
case ND_MODE:
view3d_modal_keymaps(wmn->wm, ar, wmn->subtype);
ED_region_tag_redraw(ar);
break;
} }
break; break;
case NC_OBJECT: case NC_OBJECT:
@ -258,6 +285,24 @@ static void view3d_header_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C); UI_view2d_view_restore(C);
} }
static void view3d_header_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
case NC_SCENE:
switch(wmn->data) {
case ND_FRAME:
case ND_OB_ACTIVE:
case ND_OB_SELECT:
case ND_MODE:
ED_region_tag_redraw(ar);
break;
}
break;
}
}
static int view3d_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result) static int view3d_context(const bContext *C, const bContextDataMember *member, bContextDataResult *result)
{ {
View3D *v3d= (View3D*)CTX_wm_space_data(C); View3D *v3d= (View3D*)CTX_wm_space_data(C);
@ -343,7 +388,7 @@ void ED_spacetype_view3d(void)
art->regionid = RGN_TYPE_HEADER; art->regionid = RGN_TYPE_HEADER;
art->minsizey= HEADERY; art->minsizey= HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
art->listener= view3d_main_area_listener; art->listener= view3d_header_area_listener;
art->init= view3d_header_area_init; art->init= view3d_header_area_init;
art->draw= view3d_header_area_draw; art->draw= view3d_header_area_draw;

@ -1228,7 +1228,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
vc.scene= scene; vc.scene= scene;
vc.v3d= v3d; vc.v3d= v3d;
vc.obact= OBACT; vc.obact= OBACT;
vc.obedit= G.obedit;
val= RNA_int_get(op->ptr, "event_type"); val= RNA_int_get(op->ptr, "event_type");
rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.xmin= RNA_int_get(op->ptr, "xmin");
@ -1247,10 +1247,11 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
if(G.obedit) { if(G.obedit) {
if(G.obedit->type==OB_MESH) { if(G.obedit->type==OB_MESH) {
Mesh *me= G.obedit->data;
vc.em= me->edit_mesh;
do_mesh_box_select(&vc, &rect, (val==LEFTMOUSE)); do_mesh_box_select(&vc, &rect, (val==LEFTMOUSE));
// allqueue(REDRAWVIEW3D, 0);
// if (EM_texFaceCheck()) // if (EM_texFaceCheck())
// allqueue(REDRAWIMAGE, 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit);
} }
else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) { else if(ELEM(G.obedit->type, OB_CURVE, OB_SURF)) {
@ -1412,17 +1413,21 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
MEM_freeN(vbuffer); MEM_freeN(vbuffer);
} }
BIF_undo_push("Border select");
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
/* *****************Selection Operators******************* */ /* *****************Selection Operators******************* */
static EnumPropertyItem prop_select_types[] = {
{0, "EXCLUSIVE", "Exclusive", ""},
{1, "EXTEND", "Extend", ""},
{0, NULL, NULL, NULL}
};
/* ****** Border Select ****** */ /* ****** Border Select ****** */
void VIEW3D_OT_borderselect(wmOperatorType *ot) void VIEW3D_OT_borderselect(wmOperatorType *ot)
{ {
PropertyRNA *prop;
/* identifiers */ /* identifiers */
ot->name= "Border Select"; ot->name= "Border Select";
@ -1441,15 +1446,13 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot)
RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE); RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE); RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE); RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_select_types);
} }
/* ****** Mouse Select ****** */ /* ****** Mouse Select ****** */
static EnumPropertyItem prop_select_types[] = {
{0, "EXCLUSIVE", "Exclusive", ""},
{1, "EXTEND", "Extend", ""},
{0, NULL, NULL, NULL}
};
static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{ {

@ -52,6 +52,9 @@
void ED_editors_exit(bContext *C) void ED_editors_exit(bContext *C)
{ {
/* frees all editmode undos */
undo_editmode_clear();
if(CTX_data_edit_object(C)) { if(CTX_data_edit_object(C)) {
Object *ob= CTX_data_edit_object(C); Object *ob= CTX_data_edit_object(C);

@ -61,16 +61,17 @@
Add this in your local code: Add this in your local code:
void undo_editmode_push(char *name, void undo_editmode_push(bContext *C, char *name,
void * (*getdata)(bContext *C), // use context to retrieve current editdata
void (*freedata)(void *), // pointer to function freeing data void (*freedata)(void *), // pointer to function freeing data
void (*to_editmode)(void *), // data to editmode conversion void (*to_editmode)(void *, void *), // data to editmode conversion
void * (*from_editmode)(void)) // editmode to data conversion void * (*from_editmode)(void *)) // editmode to data conversion
int (*validate_undo)(void *)) // check if undo data is still valid int (*validate_undo)(void *, void *)) // check if undo data is still valid
Further exported for UI is: Further exported for UI is:
void undo_editmode_step(int step); // undo and redo void undo_editmode_step(bContext *C, int step); // undo and redo
void undo_editmode_clear(void) // free & clear all data void undo_editmode_clear(void) // free & clear all data
void undo_editmode_menu(void) // history menu void undo_editmode_menu(void) // history menu
@ -92,10 +93,11 @@ typedef struct UndoElem {
void *undodata; void *undodata;
uintptr_t undosize; uintptr_t undosize;
char name[MAXUNDONAME]; char name[MAXUNDONAME];
void * (*getdata)(bContext *C);
void (*freedata)(void *); void (*freedata)(void *);
void (*to_editmode)(void *); void (*to_editmode)(void *, void *);
void * (*from_editmode)(void); void * (*from_editmode)(void *);
int (*validate_undo)(void *); int (*validate_undo)(void *, void *);
} UndoElem; } UndoElem;
static ListBase undobase={NULL, NULL}; static ListBase undobase={NULL, NULL};
@ -104,19 +106,23 @@ static UndoElem *curundo= NULL;
/* ********************* xtern api calls ************* */ /* ********************* xtern api calls ************* */
static void undo_restore(UndoElem *undo) static void undo_restore(UndoElem *undo, void *editdata)
{ {
if(undo) { if(undo) {
undo->to_editmode(undo->undodata); undo->to_editmode(undo->undodata, editdata);
} }
} }
/* name can be a dynamic string */ /* name can be a dynamic string */
void undo_editmode_push(char *name, void (*freedata)(void *), void undo_editmode_push(bContext *C, char *name,
void (*to_editmode)(void *), void *(*from_editmode)(void), void * (*getdata)(bContext *C),
int (*validate_undo)(void *)) void (*freedata)(void *),
void (*to_editmode)(void *, void *),
void *(*from_editmode)(void *),
int (*validate_undo)(void *, void *))
{ {
UndoElem *uel; UndoElem *uel;
void *editdata;
int nr; int nr;
uintptr_t memused, totmem, maxmem; uintptr_t memused, totmem, maxmem;
@ -131,10 +137,11 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
} }
/* make new */ /* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file"); curundo= uel= MEM_callocN(sizeof(UndoElem), "undo editmode");
strncpy(uel->name, name, MAXUNDONAME-1); strncpy(uel->name, name, MAXUNDONAME-1);
BLI_addtail(&undobase, uel); BLI_addtail(&undobase, uel);
uel->getdata= getdata;
uel->freedata= freedata; uel->freedata= freedata;
uel->to_editmode= to_editmode; uel->to_editmode= to_editmode;
uel->from_editmode= from_editmode; uel->from_editmode= from_editmode;
@ -158,7 +165,8 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
/* copy */ /* copy */
memused= MEM_get_memory_in_use(); memused= MEM_get_memory_in_use();
curundo->undodata= curundo->from_editmode(); editdata= getdata(C);
curundo->undodata= curundo->from_editmode(editdata);
curundo->undosize= MEM_get_memory_in_use() - memused; curundo->undosize= MEM_get_memory_in_use() - memused;
curundo->ob= G.obedit; curundo->ob= G.obedit;
curundo->id= G.obedit->id; curundo->id= G.obedit->id;
@ -190,7 +198,7 @@ void undo_editmode_push(char *name, void (*freedata)(void *),
} }
/* helper to remove clean other objects from undo stack */ /* helper to remove clean other objects from undo stack */
static void undo_clean_stack(void) static void undo_clean_stack(bContext *C)
{ {
UndoElem *uel, *next; UndoElem *uel, *next;
int mixed= 0; int mixed= 0;
@ -200,13 +208,21 @@ static void undo_clean_stack(void)
uel= undobase.first; uel= undobase.first;
while(uel) { while(uel) {
void *editdata= uel->getdata(C);
int isvalid= 0;
next= uel->next; next= uel->next;
/* for when objects are converted, renamed, or global undo changes pointers... */ /* for when objects are converted, renamed, or global undo changes pointers... */
if(uel->type==G.obedit->type && strcmp(uel->id.name, G.obedit->id.name)==0 && if(uel->type==G.obedit->type) {
(!uel->validate_undo || uel->validate_undo(uel->undodata))) { if(strcmp(uel->id.name, G.obedit->id.name)==0) {
uel->ob= G.obedit; if(uel->validate_undo==NULL)
isvalid= 1;
else if(uel->validate_undo(uel->undodata, editdata))
isvalid= 1;
}
} }
if(isvalid)
uel->ob= G.obedit;
else { else {
mixed= 1; mixed= 1;
uel->freedata(uel->undodata); uel->freedata(uel->undodata);
@ -220,14 +236,14 @@ static void undo_clean_stack(void)
} }
/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */
void undo_editmode_step(int step) void undo_editmode_step(bContext *C, int step)
{ {
/* prevent undo to happen on wrong object, stack can be a mix */ /* prevent undo to happen on wrong object, stack can be a mix */
undo_clean_stack(); undo_clean_stack(C);
if(step==0) { if(step==0) {
undo_restore(curundo); undo_restore(curundo, curundo->getdata(C));
} }
else if(step==1) { else if(step==1) {
@ -235,7 +251,7 @@ void undo_editmode_step(int step)
else { else {
if(G.f & G_DEBUG) printf("undo %s\n", curundo->name); if(G.f & G_DEBUG) printf("undo %s\n", curundo->name);
curundo= curundo->prev; curundo= curundo->prev;
undo_restore(curundo); undo_restore(curundo, curundo->getdata(C));
} }
} }
else { else {
@ -243,7 +259,7 @@ void undo_editmode_step(int step)
if(curundo==NULL || curundo->next==NULL) error("No more steps to redo"); if(curundo==NULL || curundo->next==NULL) error("No more steps to redo");
else { else {
undo_restore(curundo->next); undo_restore(curundo->next, curundo->getdata(C));
curundo= curundo->next; curundo= curundo->next;
if(G.f & G_DEBUG) printf("redo %s\n", curundo->name); if(G.f & G_DEBUG) printf("redo %s\n", curundo->name);
} }
@ -267,7 +283,7 @@ void undo_editmode_clear(void)
} }
/* based on index nr it does a restore */ /* based on index nr it does a restore */
static void undo_number(int nr) static void undo_number(bContext *C, int nr)
{ {
UndoElem *uel; UndoElem *uel;
int a=1; int a=1;
@ -276,19 +292,19 @@ static void undo_number(int nr)
if(a==nr) break; if(a==nr) break;
} }
curundo= uel; curundo= uel;
undo_editmode_step(0); undo_editmode_step(C, 0);
} }
/* ************** for interaction with menu/pullown */ /* ************** for interaction with menu/pullown */
void undo_editmode_menu(void) void undo_editmode_menu(bContext *C)
{ {
UndoElem *uel; UndoElem *uel;
DynStr *ds= BLI_dynstr_new(); DynStr *ds= BLI_dynstr_new();
short event; short event;
char *menu; char *menu;
undo_clean_stack(); // removes other objects from it undo_clean_stack(C); // removes other objects from it
BLI_dynstr_append(ds, "Editmode Undo History %t"); BLI_dynstr_append(ds, "Editmode Undo History %t");
@ -303,7 +319,7 @@ void undo_editmode_menu(void)
// XXX event= pupmenu_col(menu, 20); // XXX event= pupmenu_col(menu, 20);
MEM_freeN(menu); MEM_freeN(menu);
if(event>0) undo_number(event); if(event>0) undo_number(C, event);
} }
static void do_editmode_undohistorymenu(bContext *C, void *arg, int event) static void do_editmode_undohistorymenu(bContext *C, void *arg, int event)
@ -311,7 +327,7 @@ static void do_editmode_undohistorymenu(bContext *C, void *arg, int event)
if(G.obedit==NULL || event<1) return; if(G.obedit==NULL || event<1) return;
undo_number(event-1); undo_number(C, event-1);
} }
@ -322,7 +338,7 @@ uiBlock *editmode_undohistorymenu(bContext *C, uiMenuBlockHandle *handle, void *
short yco = 20, menuwidth = 120; short yco = 20, menuwidth = 120;
short item= 1; short item= 1;
undo_clean_stack(); // removes other objects from it undo_clean_stack(C); // removes other objects from it
block= uiBeginBlock(C, handle->region, "view3d_edit_mesh_undohistorymenu", UI_EMBOSSP, UI_HELV); block= uiBeginBlock(C, handle->region, "view3d_edit_mesh_undohistorymenu", UI_EMBOSSP, UI_HELV);
uiBlockSetButmFunc(block, do_editmode_undohistorymenu, NULL); uiBlockSetButmFunc(block, do_editmode_undohistorymenu, NULL);

@ -86,7 +86,7 @@ void ED_undo_push(bContext *C, char *str)
if (U.undosteps == 0) return; if (U.undosteps == 0) return;
if(G.obedit->type==OB_MESH) if(G.obedit->type==OB_MESH)
undo_push_mesh(str); undo_push_mesh(C, str);
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
undo_push_curve(str); undo_push_curve(str);
else if (G.obedit->type==OB_FONT) else if (G.obedit->type==OB_FONT)
@ -109,40 +109,45 @@ void ED_undo_push(bContext *C, char *str)
} }
} }
static void undo_do(bContext *C) static int ed_undo_step(bContext *C, wmOperator *op, int step)
{
if(U.uiflag & USER_GLOBALUNDO) {
#ifndef DISABLE_PYTHON
// XXX BPY_scripts_clear_pyobjects();
#endif
BKE_undo_step(C, 1);
sound_initialize_sounds();
}
}
static int ed_undo_exec(bContext *C, wmOperator *op)
{ {
ScrArea *sa= CTX_wm_area(C); ScrArea *sa= CTX_wm_area(C);
if(G.obedit) { if(G.obedit) {
if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
undo_editmode_step(1); undo_editmode_step(C, step);
} }
else { else {
int do_glob_undo= 0;
if(G.f & G_TEXTUREPAINT) if(G.f & G_TEXTUREPAINT)
undo_imagepaint_step(1); undo_imagepaint_step(step);
else if(sa->spacetype==SPACE_IMAGE) { else if(sa->spacetype==SPACE_IMAGE) {
SpaceImage *sima= (SpaceImage *)sa->spacedata.first; SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
if(sima->flag & SI_DRAWTOOL) if(sima->flag & SI_DRAWTOOL)
undo_imagepaint_step(1); undo_imagepaint_step(step);
else else
undo_do(C); do_glob_undo= 1;
}
else if(G.f & G_PARTICLEEDIT) {
if(step==1)
PE_undo();
else
PE_redo();
} }
else if(G.f & G_PARTICLEEDIT)
PE_undo();
else { else {
undo_do(C); do_glob_undo= 1;
}
if(do_glob_undo) {
if(U.uiflag & USER_GLOBALUNDO) {
#ifndef DISABLE_PYTHON
// XXX BPY_scripts_clear_pyobjects();
#endif
BKE_undo_step(C, step);
sound_initialize_sounds();
}
} }
} }
@ -151,39 +156,13 @@ static int ed_undo_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
static int ed_undo_exec(bContext *C, wmOperator *op)
{
return ed_undo_step(C, op, 1);
}
static int ed_redo_exec(bContext *C, wmOperator *op) static int ed_redo_exec(bContext *C, wmOperator *op)
{ {
ScrArea *sa= CTX_wm_area(C); return ed_undo_step(C, op, -1);
if(G.obedit) {
//if ELEM7(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)
// undo_editmode_step(-1);
}
else {
if(G.f & G_TEXTUREPAINT)
undo_imagepaint_step(-1);
else if(sa->spacetype==SPACE_IMAGE) {
SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
if(sima->flag & SI_DRAWTOOL)
undo_imagepaint_step(-1);
else {
BKE_undo_step(C, -1);
sound_initialize_sounds();
}
}
else if(G.f & G_PARTICLEEDIT)
PE_redo();
else {
/* includes faceselect now */
if(U.uiflag & USER_GLOBALUNDO) {
BKE_undo_step(C, -1);
sound_initialize_sounds();
}
}
}
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
} }
void ED_undo_menu(bContext *C) void ED_undo_menu(bContext *C)

@ -0,0 +1,38 @@
/**
* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef ED_UTIL_INTERN_H
#define ED_UTIL_INTERN_H
/* internal exports only */
/* editmode_undo.c */
void undo_editmode_clear(void);
#endif /* ED_UTIL_INTERN_H */

@ -30,6 +30,7 @@
struct bContext; struct bContext;
struct wmEvent; struct wmEvent;
struct wmWindowManager;
/* exported types for WM */ /* exported types for WM */
@ -114,6 +115,7 @@ typedef void (*wmUIHandlerRemoveFunc)(struct bContext *C, void *userdata);
typedef struct wmNotifier { typedef struct wmNotifier {
struct wmNotifier *prev, *next; struct wmNotifier *prev, *next;
struct wmWindowManager *wm;
struct wmWindow *window; struct wmWindow *window;
int swinid; int swinid;
@ -152,7 +154,7 @@ typedef struct wmNotifier {
#define ND_SEQUENCER (6<<16) #define ND_SEQUENCER (6<<16)
#define ND_OB_ACTIVE (7<<16) #define ND_OB_ACTIVE (7<<16)
#define ND_OB_SELECT (8<<16) #define ND_OB_SELECT (8<<16)
#define ND_OB_EDIT (9<<16) #define ND_MODE (9<<16)
/* Object */ /* Object */
#define ND_TRANSFORM (16<<16) #define ND_TRANSFORM (16<<16)
@ -165,6 +167,18 @@ typedef struct wmNotifier {
/* subtype, 256 entries too */ /* subtype, 256 entries too */
#define NOTE_SUBTYPE 0x0000FF00 #define NOTE_SUBTYPE 0x0000FF00
/* subtype scene mode */
#define NS_MODE_OBJECT (1<<8)
#define NS_EDITMODE_MESH (2<<8)
#define NS_EDITMODE_CURVE (3<<8)
#define NS_EDITMODE_SURFACE (4<<8)
#define NS_EDITMODE_TEXT (5<<8)
#define NS_EDITMODE_MBALL (6<<8)
#define NS_EDITMODE_LATTICE (7<<8)
#define NS_EDITMODE_ARMATURE (8<<8)
/* action classification */ /* action classification */
#define NOTE_ACTION (0x000000FF) #define NOTE_ACTION (0x000000FF)
#define NA_EDITED 1 #define NA_EDITED 1

@ -104,9 +104,11 @@ void WM_event_add_notifier(bContext *C, unsigned int type, void *reference)
{ {
wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier"); wmNotifier *note= MEM_callocN(sizeof(wmNotifier), "notifier");
BLI_addtail(&CTX_wm_manager(C)->queue, note); note->wm= CTX_wm_manager(C);
BLI_addtail(&note->wm->queue, note);
note->window= CTX_wm_window(C); note->window= CTX_wm_window(C);
if(CTX_wm_region(C)) if(CTX_wm_region(C))
note->swinid= CTX_wm_region(C)->swinid; note->swinid= CTX_wm_region(C)->swinid;

@ -79,6 +79,7 @@
#include "ED_datafiles.h" #include "ED_datafiles.h"
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_util.h"
#include "UI_interface.h" #include "UI_interface.h"

@ -257,9 +257,6 @@ void WM_exit(bContext *C)
// if (copybuf) MEM_freeN(copybuf); // if (copybuf) MEM_freeN(copybuf);
// if (copybufinfo) MEM_freeN(copybufinfo); // if (copybufinfo) MEM_freeN(copybufinfo);
/* undo free stuff */
// undo_editmode_clear();
BKE_undo_save_quit(); // saves quit.blend if global undo is on BKE_undo_save_quit(); // saves quit.blend if global undo is on
BKE_reset_undo(); BKE_reset_undo();