Paint mode (VPaint WPaint) was too easy to enter, I made the
operators having a more designated poll() to check stuff.

Now CTRL+TAB hotkeys will work in editmode for select type,
and outside editmode for wpaint or posemode.

Also fixed select type operator to so it works for facemode.
This commit is contained in:
Ton Roosendaal 2009-02-01 13:24:19 +00:00
parent dce3c08b2c
commit 6aab3e7267
3 changed files with 26 additions and 20 deletions

@ -3652,34 +3652,28 @@ void editmesh_deselect_by_material(EditMesh *em, int index)
EM_selectmode_flush(em);
}
static void mesh_selection_type(EditMesh *em, int val)
static void mesh_selection_type(Scene *scene, EditMesh *em, int val)
{
int ctrl= 0; // XXX
// if(em->selectmode & SCE_SELECT_VERTEX) pupmenu_set_active(1);
// else if(em->selectmode & SCE_SELECT_EDGE) pupmenu_set_active(2);
// else pupmenu_set_active(3);
// val= pupmenu("Select Mode%t|Vertices|Edges|Faces");
if(val>0) {
if(val==1){
if(val==1) {
em->selectmode= SCE_SELECT_VERTEX;
EM_selectmode_set(em);
}
else if(val==2){
if(ctrl) EM_convertsel(em, em->selectmode, SCE_SELECT_EDGE);
}
else if(val==2) {
//if(ctrl) EM_convertsel(em, em->selectmode, SCE_SELECT_EDGE);
em->selectmode= SCE_SELECT_EDGE;
EM_selectmode_set(em);
}
else{
if((ctrl)) EM_convertsel(em, em->selectmode, SCE_SELECT_FACE);
//if((ctrl)) EM_convertsel(em, em->selectmode, SCE_SELECT_FACE);
em->selectmode= SCE_SELECT_FACE;
EM_selectmode_set(em);
}
/* note, em stores selectmode to be able to pass it on everywhere without scene,
this is only until all select modes and toolsettings are settled more */
scene->selectmode= em->selectmode;
// if (EM_texFaceCheck())
}
}
@ -3697,9 +3691,9 @@ static int mesh_selection_type_exec(bContext *C, wmOperator *op)
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
mesh_selection_type(em, RNA_enum_get(op->ptr,"type"));
mesh_selection_type(CTX_data_scene(C), em, RNA_enum_get(op->ptr,"type"));
WM_event_add_notifier(C, NC_WINDOW, obedit);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
return OPERATOR_FINISHED;
}

@ -204,7 +204,7 @@ void ED_keymap_mesh(wmWindowManager *wm)
/* selection mode */
WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, KM_CTRL, 0);
/* transform keymap already defined, so no tweaks for select */

@ -1192,6 +1192,18 @@ static int set_wpaint(bContext *C, wmOperator *op) /* toggle */
return OPERATOR_FINISHED;
}
/* for switching to/from mode */
static int paint_poll_test(bContext *C)
{
if(ED_operator_view3d_active(C)==0)
return 0;
if(CTX_data_edit_object(C))
return 0;
if(CTX_data_active_object(C)==NULL)
return 0;
return 1;
}
void VIEW3D_OT_wpaint_toggle(wmOperatorType *ot)
{
@ -1201,7 +1213,7 @@ void VIEW3D_OT_wpaint_toggle(wmOperatorType *ot)
/* api callbacks */
ot->exec= set_wpaint;
ot->poll= ED_operator_object_active;
ot->poll= paint_poll_test;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1708,7 +1720,7 @@ void VIEW3D_OT_vpaint_toggle(wmOperatorType *ot)
/* api callbacks */
ot->exec= set_vpaint;
ot->poll= ED_operator_object_active;
ot->poll= paint_poll_test;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;