From eba317dbd731197b22abca4a8121480a05198b63 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 21 Nov 2011 17:14:44 +0000 Subject: Combined BlenderPro Brazil workshop fix + Patch 29302 Loopcut operator now has two extra features: - Pad plus/minus allows to change amount of cuts - typing numerical input works too. (Number input max is set to 32 now. The code doesn't allow editing values or backspace it away, nor does it show in header...) Thanks & congrats Daniel Macedo for his first patch! :) --- source/blender/editors/mesh/loopcut.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/editors/mesh') diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 9bbfea1291f..42728eb7ea1 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -69,6 +69,7 @@ #include "ED_space_api.h" #include "ED_view3d.h" #include "ED_mesh.h" +#include "ED_numinput.h" #include "RNA_access.h" #include "RNA_define.h" @@ -95,6 +96,7 @@ typedef struct tringselOpData { Object *ob; EditMesh *em; EditEdge *eed; + NumInput num; int extend; int do_cut; @@ -345,6 +347,11 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut) lcd->em= BKE_mesh_get_editmesh((Mesh *)lcd->ob->data); lcd->extend = do_cut ? 0 : RNA_boolean_get(op->ptr, "extend"); lcd->do_cut = do_cut; + + initNumInput(&lcd->num); + lcd->num.idx_max = 0; + lcd->num.flag |= NUM_NO_NEGATIVE | NUM_NO_FRACTION; + em_setup_viewcontext(C, &lcd->vc); ED_region_tag_redraw(lcd->ar); @@ -464,6 +471,7 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(lcd->ar); break; case WHEELUPMOUSE: /* change number of cuts */ + case PADPLUSKEY: case PAGEUPKEY: if (event->val == KM_PRESS) { cuts++; @@ -474,6 +482,7 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) } break; case WHEELDOWNMOUSE: /* change number of cuts */ + case PADMINUS: case PAGEDOWNKEY: if (event->val == KM_PRESS) { cuts=MAX2(cuts-1,1); @@ -501,6 +510,23 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event) } } + /* using the keyboard to input the number of cuts */ + if (event->val==KM_PRESS) { + float value; + + if (handleNumInput(&lcd->num, event)) + { + applyNumInput(&lcd->num, &value); + + cuts= CLAMPIS(value, 1, 32); + + RNA_int_set(op->ptr,"number_cuts",cuts); + ringsel_find_edge(lcd, cuts); + + ED_region_tag_redraw(lcd->ar); + } + } + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } -- cgit v1.2.3