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! :)
This commit is contained in:
Ton Roosendaal
2011-11-21 17:14:44 +00:00
parent 697e4d2ca7
commit eba317dbd7

View File

@@ -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;
}