subdivides are now grouped in a menu - WKEY

This commit is contained in:
2009-01-19 18:36:54 +00:00
parent 1c590a4d06
commit 33ab2636df
3 changed files with 73 additions and 3 deletions

View File

@@ -6407,3 +6407,69 @@ void MESH_OT_subdivide_smooth(wmOperatorType *ot)
/* props */
RNA_def_float(ot->srna, "smoothness", 5.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
}
static int subdivs_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *lastop;
int items;
char *menu, *p;
items = 4;
menu= MEM_callocN(items * OP_MAX_TYPENAME, "string");
p= menu + sprintf(menu, "%s %%t", "subdiv");
p+= sprintf(p, "|%s %%x%d", "simple", 3);
p+= sprintf(p, "|%s %%x%d", "multi", 2);
p+= sprintf(p, "|%s %%x%d", "fractal", 1);
p+= sprintf(p, "|%s %%x%d", "smooth", 0);
uiPupmenuOperator(C, 20, op, "index", menu);
MEM_freeN(menu);
return OPERATOR_RUNNING_MODAL;
}
static int subdivs_exec(bContext *C, wmOperator *op)
{
switch(RNA_int_get(op->ptr, "index"))
{
case 3: // simple
subdivide_exec(C,op);
break;
case 2: // multi
subdivide_multi_exec(C,op);
break;
case 1: // fractal;
subdivide_multi_fractal_exec(C,op);
break;
case 0: //smooth
subdivide_smooth_exec(C,op);
break;
}
return OPERATOR_FINISHED;
}
void MESH_OT_subdivs(wmOperatorType *ot)
{
/* identifiers */
ot->name= "subdivs";
ot->idname= "MESH_OT_subdivs";
/* api callbacks */
ot->invoke= subdivs_invoke;
ot->exec= subdivs_exec;
ot->poll= ED_operator_editmesh;
/*props */
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
/* this is temp, the ops are different, but they are called from subdivs, so all the possible props should be here as well*/
RNA_def_int(ot->srna, "number_cuts", 4, 0, 100, "Number of Cuts", "", 0, INT_MAX);
RNA_def_float(ot->srna, "random_factor", 5.0, 0.0f, FLT_MAX, "Random Factor", "", 0.0f, 1000.0f);
RNA_def_float(ot->srna, "smoothness", 5.0f, 0.0f, 1000.0f, "Smoothness", "", 0.0f, FLT_MAX);
}

View File

@@ -210,6 +210,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit);
void esubdivideflag(Object *obedit, EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype);
int EdgeSlide(EditMesh *em, short immediate, float imperc);
void MESH_OT_subdivs(struct wmOperatorType *ot);
void MESH_OT_subdivide(struct wmOperatorType *ot);
void MESH_OT_subdivide_multi(struct wmOperatorType *ot);
void MESH_OT_subdivide_multi_fractal(struct wmOperatorType *ot);

View File

@@ -117,6 +117,7 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_subdivide_multi);
WM_operatortype_append(MESH_OT_subdivide_multi_fractal);
WM_operatortype_append(MESH_OT_subdivide_smooth);
WM_operatortype_append(MESH_OT_subdivs);
WM_operatortype_append(MESH_OT_select_linked_flat_faces);
WM_operatortype_append(MESH_OT_select_sharp_edges);
WM_operatortype_append(MESH_OT_add_primitive_plane);
@@ -161,10 +162,12 @@ void ED_keymap_mesh(wmWindowManager *wm)
RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "select", 2);
RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL, 0)->ptr, "select", 1);
WM_keymap_add_item(keymap, "MESH_OT_subdivide", WKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
WM_keymap_add_item(keymap, "MESH_OT_subdivs", WKEY, KM_PRESS, 0, 0); // this is the menu
/*WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi_fractal", WKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_subdivide_smooth", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_subdivide_smooth", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);*/
/* add */
WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);