delete menu is back DKEY. seperating may be needed to delete_mesh
authorShaul Kedem <shaul_kedem@yahoo.com>
Sat, 31 Jan 2009 02:31:58 +0000 (02:31 +0000)
committerShaul Kedem <shaul_kedem@yahoo.com>
Sat, 31 Jan 2009 02:31:58 +0000 (02:31 +0000)
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c

index d39430f7548f69f1ea10299d88feed8f80f14c63..68d75f640653a227eeb3ad82a96dda95a9237035 100644 (file)
@@ -965,16 +965,15 @@ static void erase_vertices(EditMesh *em, ListBase *l)
        }
 }
 
-void delete_mesh(Object *obedit, EditMesh *em)
+void delete_mesh(Object *obedit, EditMesh *em, int event)
 {
        EditFace *efa, *nextvl;
        EditVert *eve,*nextve;
        EditEdge *eed,*nexted;
-       short event;
        int count;
        char *str="Erase";
 
-       event= pupmenu("Erase %t|Vertices%x10|Edges%x1|Faces%x2|All%x3|Edges & Faces%x4|Only Faces%x5|Edge Loop%x6");
+       
        if(event<1) return;
 
        if(event==10 ) {
@@ -1106,6 +1105,60 @@ void delete_mesh(Object *obedit, EditMesh *em)
        BIF_undo_push(str);
 }
 
+static int delete_mesh_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       
+       delete_mesh(obedit,em,RNA_int_get(op->ptr, "event"));
+       
+       ED_undo_push(C, "Delete Mesh"); // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;
+}
+
+static int delete_mesh_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       int items;
+       char *menu, *p;
+       
+       items = 6;
+       
+       menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
+       
+       p= menu + sprintf(menu, "%s %%t", "Erase");
+       p+= sprintf(p, "|%s %%x%d", "Vertices", 10);
+       p+= sprintf(p, "|%s %%x%d", "Edges", 1);
+       p+= sprintf(p, "|%s %%x%d", "Faces", 2);
+       p+= sprintf(p, "|%s %%x%d", "All", 3);
+       p+= sprintf(p, "|%s %%x%d", "Edges & Faces", 4);
+       p+= sprintf(p, "|%s %%x%d", "Only Faces", 5);
+       p+= sprintf(p, "|%s %%x%d", "Edge Loop", 6);
+       
+       
+       uiPupMenuOperator(C, 20, op, "event", menu);
+       MEM_freeN(menu);
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+
+void MESH_OT_delete_mesh(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "delete mesh";
+       ot->idname= "MESH_OT_delete_mesh";
+       
+       /* api callbacks */
+       ot->invoke= delete_mesh_invoke;
+       ot->exec= delete_mesh_exec;
+       
+       ot->poll= ED_operator_editmesh;
+       
+       /*props */
+       RNA_def_int(ot->srna, "event", 0, 0, INT_MAX, "event", "", 0, 1000);
+}
 
 /* Got this from scanfill.c. You will need to juggle around the
  * callbacks for the scanfill.c code a bit for this to work. */
index eae24b3993e5d0170f9470a98a0a988473a72251..6bcac378b17895bafe3f0fac6a0dd31148df700b 100644 (file)
@@ -232,5 +232,7 @@ void MESH_OT_edge_flip(struct wmOperatorType *ot);
 void MESH_OT_mesh_set_smooth_faces(struct wmOperatorType *ot);
 void MESH_OT_mesh_set_solid_faces(struct wmOperatorType *ot);
 
+void MESH_OT_delete_mesh(struct wmOperatorType *ot);
+
 #endif // MESH_INTERN_H
 
index 6990d5af751f1fc5d92216af2ceb0675c2ef09c1..6f9dd939a41f449e35e6be606b3f4cf9e5d73643 100644 (file)
@@ -137,6 +137,9 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_removedoublesflag);
        WM_operatortype_append(MESH_OT_extrude_mesh);
        WM_operatortype_append(MESH_OT_edit_faces);
+
+       WM_operatortype_append(MESH_OT_delete_mesh);
+
        WM_operatortype_append(MESH_OT_separate);
        WM_operatortype_append(MESH_OT_dupli_extrude_cursor);
        WM_operatortype_append(MESH_OT_loop_select);
@@ -186,6 +189,14 @@ void ED_keymap_mesh(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "MESH_OT_extrude_mesh", EKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_edit_faces", PKEY, KM_PRESS, KM_CTRL, 0);
        
+
+       WM_keymap_add_item(keymap, "MESH_OT_delete_mesh", DKEY, KM_PRESS, 0, 0);
+       
+       
+       
+       
+
+
        /* add */
        WM_keymap_add_item(keymap, "MESH_OT_add_edge_face", FKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);