forked from bartvdbraak/blender
Move increment value into numinput structure.
Easier for transform to have different values per transform then (also different from gears values). (Based on a bug reported by Jonathan Smith)
This commit is contained in:
parent
8a31fab304
commit
a8d364ce4a
@ -436,6 +436,7 @@ static int ed_marker_move_init(bContext *C, wmOperator *op)
|
||||
initNumInput(&mm->num);
|
||||
mm->num.idx_max = 0; /* one axis */
|
||||
mm->num.flag |= NUM_NO_FRACTION;
|
||||
mm->num.increment = 1.0f;
|
||||
|
||||
for (a=0, marker= markers->first; marker; marker= marker->next) {
|
||||
if (marker->flag & SELECT) {
|
||||
@ -617,7 +618,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
float vec[3];
|
||||
char str_tx[256];
|
||||
|
||||
if (handleNumInput(&mm->num, evt, 1.0))
|
||||
if (handleNumInput(&mm->num, evt))
|
||||
{
|
||||
applyNumInput(&mm->num, vec);
|
||||
outputNumInput(&mm->num, str_tx);
|
||||
|
@ -33,6 +33,7 @@ typedef struct NumInput {
|
||||
char inv[3]; /* If the value is inverted or not */
|
||||
float val[3]; /* Direct value of the input */
|
||||
int ctrl[3]; /* Control to indicate what to do with the numbers that are typed */
|
||||
float increment;
|
||||
} NumInput ;
|
||||
|
||||
/* NUMINPUT FLAGS */
|
||||
@ -48,7 +49,7 @@ void initNumInput(NumInput *n);
|
||||
void outputNumInput(NumInput *n, char *str);
|
||||
short hasNumInput(NumInput *n);
|
||||
void applyNumInput(NumInput *n, float *vec);
|
||||
char handleNumInput(NumInput *n, struct wmEvent *event, float increment);
|
||||
char handleNumInput(NumInput *n, struct wmEvent *event);
|
||||
|
||||
#define NUM_MODAL_INCREMENT_UP 18
|
||||
#define NUM_MODAL_INCREMENT_DOWN 19
|
||||
|
@ -721,7 +721,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
|
||||
}
|
||||
|
||||
// Modal numinput events
|
||||
t->redraw |= handleNumInput(&(t->num), event, t->snap[1]);
|
||||
t->redraw |= handleNumInput(&(t->num), event);
|
||||
}
|
||||
/* else do non-mapped events */
|
||||
else if (event->val==KM_PRESS) {
|
||||
@ -974,7 +974,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
|
||||
}
|
||||
|
||||
// Numerical input events
|
||||
t->redraw |= handleNumInput(&(t->num), event, t->snap[1]);
|
||||
t->redraw |= handleNumInput(&(t->num), event);
|
||||
|
||||
// NDof input events
|
||||
switch(handleNDofInput(&(t->ndof), event))
|
||||
@ -2081,6 +2081,8 @@ void initWarp(TransInfo *t)
|
||||
t->snap[1] = 5.0f;
|
||||
t->snap[2] = 1.0f;
|
||||
|
||||
t->num.increment = 1.0f;
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
|
||||
/* we need min/max in view space */
|
||||
@ -2237,6 +2239,8 @@ void initShear(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = 0.1f;
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -2363,6 +2367,8 @@ void initResize(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerResize(TransInfo *t, float vec[3], char *str) {
|
||||
@ -2614,6 +2620,8 @@ void initToSphere(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->num.flag |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
|
||||
@ -2705,6 +2713,8 @@ void initRotation(TransInfo *t)
|
||||
t->snap[1] = (float)((5.0/180)*M_PI);
|
||||
t->snap[2] = t->snap[1] * 0.2f;
|
||||
|
||||
t->num.increment = 1.0f;
|
||||
|
||||
if (t->flag & T_2D_EDIT)
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
|
||||
@ -3032,6 +3042,8 @@ void initTrackball(TransInfo *t)
|
||||
t->snap[1] = (float)((5.0/180)*M_PI);
|
||||
t->snap[2] = t->snap[1] * 0.2f;
|
||||
|
||||
t->num.increment = 1.0f;
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -3149,6 +3161,8 @@ void initTranslation(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = t->snap[2] = 1.0f;
|
||||
}
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerTranslation(TransInfo *t, float vec[3], char *str) {
|
||||
@ -3339,6 +3353,8 @@ void initShrinkFatten(TransInfo *t)
|
||||
t->snap[1] = 1.0f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
}
|
||||
@ -3413,6 +3429,8 @@ void initTilt(TransInfo *t)
|
||||
t->snap[1] = (float)((5.0/180)*M_PI);
|
||||
t->snap[2] = t->snap[1] * 0.2f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -3482,6 +3500,8 @@ void initCurveShrinkFatten(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_ZERO;
|
||||
t->num.flag |= NUM_NO_ZERO;
|
||||
|
||||
@ -3551,6 +3571,8 @@ void initPushPull(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = 1.0f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
|
||||
@ -3639,6 +3661,8 @@ void initBevel(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
/* DON'T KNOW WHY THIS IS NEEDED */
|
||||
if (G.editBMesh->imval[0] == 0 && G.editBMesh->imval[1] == 0) {
|
||||
/* save the initial mouse co */
|
||||
@ -3748,6 +3772,8 @@ void initBevelWeight(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -3819,6 +3845,8 @@ void initCrease(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -3893,6 +3921,8 @@ void initBoneSize(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
|
||||
@ -4009,6 +4039,8 @@ void initBoneEnvelope(TransInfo *t)
|
||||
t->snap[1] = 0.1f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -4586,6 +4618,8 @@ void initEdgeSlide(TransInfo *t)
|
||||
t->snap[1] = (float)((5.0/180)*M_PI);
|
||||
t->snap[2] = t->snap[1] * 0.2f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -4754,6 +4788,8 @@ void initBoneRoll(TransInfo *t)
|
||||
t->snap[1] = (float)((5.0/180)*M_PI);
|
||||
t->snap[2] = t->snap[1] * 0.2f;
|
||||
|
||||
t->num.increment = 1.0f;
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
@ -4814,6 +4850,8 @@ void initBakeTime(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = 1.0f;
|
||||
t->snap[2] = t->snap[1] * 0.1f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
int BakeTime(TransInfo *t, short mval[2])
|
||||
@ -5031,6 +5069,8 @@ void initSeqSlide(TransInfo *t)
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = floor(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
|
||||
t->snap[2] = 10.0f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerSeqSlide(TransInfo *t, float val[2], char *str)
|
||||
@ -5246,6 +5286,8 @@ void initTimeTranslate(TransInfo *t)
|
||||
/* initialise snap like for everything else */
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = t->snap[2] = 1.0f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerTimeTranslate(TransInfo *t, char *str)
|
||||
@ -5392,6 +5434,8 @@ void initTimeSlide(TransInfo *t)
|
||||
/* initialise snap like for everything else */
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = t->snap[2] = 1.0f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerTimeSlide(TransInfo *t, float sval, char *str)
|
||||
@ -5524,6 +5568,8 @@ void initTimeScale(TransInfo *t)
|
||||
/* initialise snap like for everything else */
|
||||
t->snap[0] = 0.0f;
|
||||
t->snap[1] = t->snap[2] = 1.0f;
|
||||
|
||||
t->num.increment = t->snap[1];
|
||||
}
|
||||
|
||||
static void headerTimeScale(TransInfo *t, char *str) {
|
||||
|
@ -859,7 +859,8 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
|
||||
setlinestyle(0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v2);
|
||||
glVertex3fv(center);
|
||||
// glVertex3fv(v2);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
@ -159,7 +159,7 @@ void applyNumInput(NumInput *n, float *vec)
|
||||
}
|
||||
}
|
||||
|
||||
char handleNumInput(NumInput *n, wmEvent *event, float increment)
|
||||
char handleNumInput(NumInput *n, wmEvent *event)
|
||||
{
|
||||
float Val = 0;
|
||||
short idx = n->idx, idx_max = n->idx_max;
|
||||
@ -170,13 +170,13 @@ char handleNumInput(NumInput *n, wmEvent *event, float increment)
|
||||
if (!n->ctrl[idx])
|
||||
n->ctrl[idx] = 1;
|
||||
|
||||
n->val[idx] += increment;
|
||||
n->val[idx] += n->increment;
|
||||
break;
|
||||
case NUM_MODAL_INCREMENT_DOWN:
|
||||
if (!n->ctrl[idx])
|
||||
n->ctrl[idx] = 1;
|
||||
|
||||
n->val[idx] -= increment;
|
||||
n->val[idx] -= n->increment;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -300,6 +300,8 @@ char handleNumInput(NumInput *n, wmEvent *event, float increment)
|
||||
}
|
||||
}
|
||||
|
||||
printf("%f\n", n->val[idx]);
|
||||
|
||||
/* REDRAW SINCE NUMBERS HAVE CHANGED */
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user