Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/animation/anim_markers.c8
-rw-r--r--source/blender/editors/include/ED_numinput.h1
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c183
-rw-r--r--source/blender/editors/transform/transform.c101
-rw-r--r--source/blender/editors/util/numinput.c17
5 files changed, 207 insertions, 103 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index ea344e7e332..96044e2408e 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -848,14 +848,14 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
}
if (evt->val == KM_PRESS) {
- float vec[3];
- char str_tx[256];
+ float vec;
+ char str_tx[NUM_STR_REP_LEN];
if (handleNumInput(&mm->num, evt)) {
- applyNumInput(&mm->num, vec);
+ applyNumInput(&mm->num, &vec);
outputNumInput(&mm->num, str_tx);
- RNA_int_set(op->ptr, "frames", vec[0]);
+ RNA_int_set(op->ptr, "frames", vec);
ed_marker_move_apply(op);
// ed_marker_header_update(C, op, str, (int)vec[0]);
// strcat(str, str_tx);
diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h
index 411df88fb28..126ea13f0b2 100644
--- a/source/blender/editors/include/ED_numinput.h
+++ b/source/blender/editors/include/ED_numinput.h
@@ -57,6 +57,7 @@ typedef struct NumInput {
/*********************** NumInput ********************************/
void initNumInput(NumInput *n);
+#define NUM_STR_REP_LEN 20 /* str must be NUM_STR_LEN * (idx_max + 1) length. */
void outputNumInput(NumInput *n, char *str);
short hasNumInput(NumInput *n);
void applyNumInput(NumInput *n, float *vec);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 4c7545fa4fa..29f38342dd2 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -58,6 +58,7 @@
#include "WM_types.h"
#include "ED_mesh.h"
+#include "ED_numinput.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_transform.h"
@@ -4305,23 +4306,31 @@ typedef struct {
int mcenter[2];
float initial_length;
int is_modal;
+ NumInput num_input;
+ float shift_factor; /* The current factor when shift is pressed. Negative when shift not active. */
} BevelData;
#define HEADER_LENGTH 180
static void edbm_bevel_update_header(wmOperator *op, bContext *C)
{
- static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RMB), factor: %f, Use Dist (D): %s: Use Even (E): %s";
+ static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RMB), factor: %s, Use Dist (D): %s: Use Even (E): %s";
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
+ BevelData *opdata = op->customdata;
if (sa) {
+ char factor_str[NUM_STR_REP_LEN];
+ if (hasNumInput(&opdata->num_input))
+ outputNumInput(&opdata->num_input, factor_str);
+ else
+ BLI_snprintf(factor_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "percent"));
BLI_snprintf(msg, HEADER_LENGTH, str,
- RNA_float_get(op->ptr, "percent"),
+ factor_str,
RNA_boolean_get(op->ptr, "use_dist") ? "On" : "Off",
RNA_boolean_get(op->ptr, "use_even") ? "On" : "Off"
- );
+ );
ED_area_headerprint(sa, msg);
}
@@ -4384,7 +4393,11 @@ static int edbm_bevel_init(bContext *C, wmOperator *op, int is_modal)
opdata->li = li;
opdata->weights = NULL;
opdata->is_modal = is_modal;
-
+ opdata->shift_factor = -1.0f;
+
+ initNumInput(&opdata->num_input);
+ opdata->num_input.flag = NUM_NO_NEGATIVE;
+
/* avoid the cost of allocating a bm copy */
if (is_modal)
opdata->mesh_backup = EDBM_redo_state_store(em);
@@ -4523,8 +4536,21 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
{
BevelData *opdata = op->customdata;
-// Scene *scene = CTX_data_scene(C);
+ if (event->val == KM_PRESS) {
+ /* Try to handle numeric inputs... */
+ float factor;
+
+ if (handleNumInput(&opdata->num_input, event)) {
+ applyNumInput(&opdata->num_input, &factor);
+ CLAMP(factor, 0.0f, 1.0f);
+ RNA_float_set(op->ptr, "percent", factor);
+
+ edbm_bevel_calc(C, op);
+ edbm_bevel_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ }
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
@@ -4532,22 +4558,32 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
case MOUSEMOVE:
- {
- float factor;
- float mdiff[2];
+ if (!hasNumInput(&opdata->num_input)) {
+ float factor;
+ float mdiff[2];
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
+ mdiff[0] = opdata->mcenter[0] - event->mval[0];
+ mdiff[1] = opdata->mcenter[1] - event->mval[1];
- factor = len_v2(mdiff) / opdata->initial_length;
- factor = MAX2(1.0f - factor, 0.0f);
+ factor = -len_v2(mdiff) / opdata->initial_length + 1.0f;
- RNA_float_set(op->ptr, "percent", factor);
+ /* Fake shift-transform... */
+ if (event->shift) {
+ if (opdata->shift_factor < 0.0f)
+ opdata->shift_factor = RNA_float_get(op->ptr, "percent");
+ factor = (factor - opdata->shift_factor) * 0.1f + opdata->shift_factor;
+ }
+ else if (opdata->shift_factor >= 0.0f)
+ opdata->shift_factor = -1.0f;
- edbm_bevel_calc(C, op);
- edbm_bevel_update_header(op, C);
+ CLAMP(factor, 0.0f, 1.0f);
+
+ RNA_float_set(op->ptr, "percent", factor);
+
+ edbm_bevel_calc(C, op);
+ edbm_bevel_update_header(op, C);
+ }
return OPERATOR_RUNNING_MODAL;
- }
case LEFTMOUSE:
case PADENTER:
@@ -4598,8 +4634,8 @@ void MESH_OT_bevel(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "percent", 0.0f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f);
-// XXX, disabled for 2.63 release, needs to work much better without overlap before we can give to users.
-// RNA_def_int(ot->srna, "recursion", 1, 1, 50, "Recursion Level", "Recursion Level", 1, 8);
+ /* XXX, disabled for 2.63 release, needs to work much better without overlap before we can give to users. */
+/* RNA_def_int(ot->srna, "recursion", 1, 1, 50, "Recursion Level", "Recursion Level", 1, 8); */
RNA_def_boolean(ot->srna, "use_even", FALSE, "Even", "Calculate evenly spaced bevel");
RNA_def_boolean(ot->srna, "use_dist", FALSE, "Distance", "Interpret the percent in blender units");
@@ -4643,26 +4679,36 @@ typedef struct {
int modify_depth;
int is_modal;
float initial_length;
+ int shift;
+ float shift_amount;
BMBackup backup;
BMEditMesh *em;
+ NumInput num_input;
} InsetData;
static void edbm_inset_update_header(wmOperator *op, bContext *C)
{
InsetData *opdata = op->customdata;
- static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RClick), thickness: %f, depth (Ctrl to tweak): %f (%s), Outset (O): (%s)";
+ static char str[] = "Confirm: Enter/LClick, Cancel: (Esc/RClick), thickness: %s, depth (Ctrl to tweak): %s (%s), Outset (O): (%s)";
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
if (sa) {
+ char flts_str[NUM_STR_REP_LEN * 2];
+ if (hasNumInput(&opdata->num_input))
+ outputNumInput(&opdata->num_input, flts_str);
+ else {
+ BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
+ BLI_snprintf(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "depth"));
+ }
BLI_snprintf(msg, HEADER_LENGTH, str,
- RNA_float_get(op->ptr, "thickness"),
- RNA_float_get(op->ptr, "depth"),
+ flts_str,
+ flts_str + NUM_STR_REP_LEN,
opdata->modify_depth ? "On" : "Off",
RNA_boolean_get(op->ptr, "use_outset") ? "On" : "Off"
- );
+ );
ED_area_headerprint(sa, msg);
}
@@ -4680,9 +4726,14 @@ static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal)
opdata->old_thickness = 0.01;
opdata->old_depth = 0.0;
opdata->modify_depth = FALSE;
+ opdata->shift = FALSE;
+ opdata->shift_amount = 0.0f;
opdata->is_modal = is_modal;
opdata->em = em;
+ initNumInput(&opdata->num_input);
+ opdata->num_input.idx_max = 1; /* Two elements. */
+
if (is_modal)
opdata->backup = EDBM_redo_state_store(em);
@@ -4814,10 +4865,28 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- InsetData *opdata;
+ InsetData *opdata = op->customdata;
- opdata = op->customdata;
+ if (event->val == KM_PRESS) {
+ /* Try to handle numeric inputs... */
+ float amounts[2];
+ if (handleNumInput(&opdata->num_input, event)) {
+ applyNumInput(&opdata->num_input, amounts);
+ amounts[0] = MAX2(amounts[0], 0.0f);
+ RNA_float_set(op->ptr, "thickness", amounts[0]);
+ RNA_float_set(op->ptr, "depth", amounts[1]);
+
+ if (edbm_inset_calc(C, op)) {
+ edbm_inset_update_header(op, C);
+ return OPERATOR_RUNNING_MODAL;
+ }
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
@@ -4825,33 +4894,37 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
case MOUSEMOVE:
- {
- float mdiff[2];
- float amount;
+ if (!hasNumInput(&opdata->num_input)) {
+ float mdiff[2];
+ float amount;
- mdiff[0] = opdata->mcenter[0] - event->mval[0];
- mdiff[1] = opdata->mcenter[1] - event->mval[1];
+ mdiff[0] = opdata->mcenter[0] - event->mval[0];
+ mdiff[1] = opdata->mcenter[1] - event->mval[1];
- if (opdata->modify_depth) {
- amount = opdata->old_depth + (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length;
- RNA_float_set(op->ptr, "depth", amount);
- }
- else {
- amount = opdata->old_thickness - (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length;
- amount = MAX2(amount, 0.0f);
+ if (opdata->modify_depth)
+ amount = opdata->old_depth + len_v2(mdiff) / opdata->initial_length - 1.0f;
+ else
+ amount = opdata->old_thickness - len_v2(mdiff) / opdata->initial_length + 1.0f;
- RNA_float_set(op->ptr, "thickness", amount);
- }
+ /* Fake shift-transform... */
+ if (opdata->shift)
+ amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
- if (edbm_inset_calc(C, op)) {
- edbm_inset_update_header(op, C);
- return OPERATOR_RUNNING_MODAL;
- }
- else {
- edbm_inset_cancel(C, op);
- return OPERATOR_CANCELLED;
+ if (opdata->modify_depth)
+ RNA_float_set(op->ptr, "depth", amount);
+ else {
+ amount = MAX2(amount, 0.0f);
+ RNA_float_set(op->ptr, "thickness", amount);
+ }
+
+ if (edbm_inset_calc(C, op))
+ edbm_inset_update_header(op, C);
+ else {
+ edbm_inset_cancel(C, op);
+ return OPERATOR_CANCELLED;
+ }
}
- }
+ return OPERATOR_RUNNING_MODAL;
case LEFTMOUSE:
case PADENTER:
@@ -4860,6 +4933,20 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
edbm_inset_exit(C, op);
return OPERATOR_FINISHED;
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ if (event->val == KM_PRESS) {
+ if (opdata->modify_depth)
+ opdata->shift_amount = RNA_float_get(op->ptr, "depth");
+ else
+ opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
+ opdata->shift = TRUE;
+ }
+ else {
+ opdata->shift_amount = 0.0f;
+ opdata->shift = FALSE;
+ }
+ return OPERATOR_RUNNING_MODAL;
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
@@ -4871,10 +4958,14 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
if (event->val == KM_PRESS) {
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
+ if (opdata->shift)
+ opdata->shift_amount = opdata->old_thickness;
opdata->modify_depth = TRUE;
}
else {
opdata->old_depth = RNA_float_get(op->ptr, "depth");
+ if (opdata->shift)
+ opdata->shift_amount = opdata->old_depth;
opdata->modify_depth = FALSE;
}
opdata->initial_length = len_v2(mlen);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b355e1ee436..e2752f5e828 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2455,7 +2455,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -2584,7 +2584,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -2670,15 +2670,15 @@ void initResize(TransInfo *t)
static void headerResize(TransInfo *t, float vec[3], char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
char *spos = str;
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
}
else {
- BLI_snprintf(&tvec[0], 20, "%.4f", vec[0]);
- BLI_snprintf(&tvec[20], 20, "%.4f", vec[1]);
- BLI_snprintf(&tvec[40], 20, "%.4f", vec[2]);
+ BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", vec[0]);
+ BLI_snprintf(&tvec[NUM_STR_REP_LEN], NUM_STR_REP_LEN, "%.4f", vec[1]);
+ BLI_snprintf(&tvec[NUM_STR_REP_LEN * 2], NUM_STR_REP_LEN, "%.4f", vec[2]);
}
if (t->con.mode & CON_APPLY) {
@@ -2687,17 +2687,21 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
break;
case 1:
- spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
+ spos += sprintf(spos, "Scale: %s : %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ t->con.text, t->proptext);
break;
case 2:
- spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+ spos += sprintf(spos, "Scale: %s : %s : %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext);
}
}
else {
if (t->flag & T_2D_EDIT)
- spos += sprintf(spos, "Scale X: %s Y: %s%s %s", &tvec[0], &tvec[20], t->con.text, t->proptext);
+ spos += sprintf(spos, "Scale X: %s Y: %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ t->con.text, t->proptext);
else
- spos += sprintf(spos, "Scale X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+ spos += sprintf(spos, "Scale X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext);
}
if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
@@ -3043,7 +3047,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -3389,7 +3393,7 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
applySnapping(t, &final);
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
applyNumInput(&t->num, &final);
@@ -3488,13 +3492,13 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
snapGrid(t, phi);
if (hasNumInput(&t->num)) {
- char c[40];
+ char c[NUM_STR_REP_LEN * 2];
applyNumInput(&t->num, phi);
outputNumInput(&(t->num), c);
- spos += sprintf(spos, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
+ spos += sprintf(spos, "Trackball: %s %s %s", &c[0], &c[NUM_STR_REP_LEN], t->proptext);
phi[0] = DEG2RADF(phi[0]);
phi[1] = DEG2RADF(phi[1]);
@@ -3573,9 +3577,9 @@ void initTranslation(TransInfo *t)
static void headerTranslation(TransInfo *t, float vec[3], char *str)
{
char *spos = str;
- char tvec[60];
- char distvec[20];
- char autoik[20];
+ char tvec[NUM_STR_REP_LEN * 3];
+ char distvec[NUM_STR_REP_LEN];
+ char autoik[NUM_STR_REP_LEN];
float dist;
if (hasNumInput(&t->num)) {
@@ -3593,12 +3597,13 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
int i, do_split = t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1 : 0;
for (i = 0; i < 3; i++)
- bUnit_AsString(&tvec[i * 20], 20, dvec[i] * t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
+ bUnit_AsString(&tvec[i * NUM_STR_REP_LEN], NUM_STR_REP_LEN, dvec[i] * t->scene->unit.scale_length,
+ 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
}
else {
sprintf(&tvec[0], "%.4f", dvec[0]);
- sprintf(&tvec[20], "%.4f", dvec[1]);
- sprintf(&tvec[40], "%.4f", dvec[2]);
+ sprintf(&tvec[NUM_STR_REP_LEN], "%.4f", dvec[1]);
+ sprintf(&tvec[NUM_STR_REP_LEN * 2], "%.4f", dvec[2]);
}
}
@@ -3626,17 +3631,21 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
break;
case 1:
- spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ distvec, t->con.text, t->proptext, &autoik[0]);
break;
case 2:
- spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ &tvec[NUM_STR_REP_LEN * 2], distvec, t->con.text, t->proptext, &autoik[0]);
}
}
else {
if (t->flag & T_2D_EDIT)
- spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext);
+ spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ distvec, t->con.text, t->proptext);
else
- spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]);
+ spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[NUM_STR_REP_LEN],
+ &tvec[NUM_STR_REP_LEN * 2], distvec, t->con.text, t->proptext, &autoik[0]);
}
if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
@@ -3794,7 +3803,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -3863,7 +3872,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
snapGrid(t, &final);
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
applyNumInput(&t->num, &final);
@@ -3935,7 +3944,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
sprintf(str, "Shrink/Fatten: %s", c);
@@ -4003,7 +4012,7 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
sprintf(str, "Shrink/Fatten: %s", c);
@@ -4069,7 +4078,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -4205,7 +4214,7 @@ int Bevel(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -4272,7 +4281,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -4345,7 +4354,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -4405,14 +4414,14 @@ void initBoneSize(TransInfo *t)
static void headerBoneSize(TransInfo *t, float vec[3], char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
}
else {
sprintf(&tvec[0], "%.4f", vec[0]);
- sprintf(&tvec[20], "%.4f", vec[1]);
- sprintf(&tvec[40], "%.4f", vec[2]);
+ sprintf(&tvec[NUM_STR_REP_LEN], "%.4f", vec[1]);
+ sprintf(&tvec[NUM_STR_REP_LEN * 2], "%.4f", vec[2]);
}
/* hmm... perhaps the y-axis values don't need to be shown? */
@@ -4420,10 +4429,12 @@ static void headerBoneSize(TransInfo *t, float vec[3], char *str)
if (t->num.idx_max == 0)
sprintf(str, "ScaleB: %s%s %s", &tvec[0], t->con.text, t->proptext);
else
- sprintf(str, "ScaleB: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+ sprintf(str, "ScaleB: %s : %s : %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2],
+ t->con.text, t->proptext);
}
else {
- sprintf(str, "ScaleB X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
+ sprintf(str, "ScaleB X: %s Y: %s Z: %s%s %s", &tvec[0], &tvec[NUM_STR_REP_LEN], &tvec[NUM_STR_REP_LEN * 2],
+ t->con.text, t->proptext);
}
}
@@ -4536,7 +4547,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
sprintf(str, "Envelope: %s", c);
@@ -5428,7 +5439,7 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
CLAMP(final, -1.0f, 1.0f);
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
applyNumInput(&t->num, &final);
@@ -5494,7 +5505,7 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
snapGrid(t, &final);
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
applyNumInput(&t->num, &final);
@@ -5566,7 +5577,7 @@ int BakeTime(TransInfo *t, const int mval[2])
/* header print for NumInput */
if (hasNumInput(&t->num)) {
- char c[20];
+ char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
@@ -5759,7 +5770,7 @@ void initSeqSlide(TransInfo *t)
static void headerSeqSlide(TransInfo *t, float val[2], char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
@@ -6002,7 +6013,7 @@ void initTimeTranslate(TransInfo *t)
static void headerTimeTranslate(TransInfo *t, char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
/* if numeric input is active, use results from that, otherwise apply snapping to result */
if (hasNumInput(&t->num)) {
@@ -6157,7 +6168,7 @@ void initTimeSlide(TransInfo *t)
static void headerTimeSlide(TransInfo *t, float sval, char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
@@ -6299,7 +6310,7 @@ void initTimeScale(TransInfo *t)
static void headerTimeScale(TransInfo *t, char *str)
{
- char tvec[60];
+ char tvec[NUM_STR_REP_LEN * 3];
if (hasNumInput(&t->num))
outputNumInput(&(t->num), tvec);
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 91290829662..281b682465d 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -66,6 +66,7 @@ void outputNumInput(NumInput *n, char *str)
char cur;
char inv[] = "1/";
short i, j;
+ const int ln = NUM_STR_REP_LEN;
for (j = 0; j <= n->idx_max; j++) {
/* if AFFECTALL and no number typed and cursor not on number, use first number */
@@ -85,34 +86,34 @@ void outputNumInput(NumInput *n, char *str)
inv[0] = 0;
if (n->val[i] > 1e10f || n->val[i] < -1e10f)
- BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.4e%c", inv, n->val[i], cur);
else
switch (n->ctrl[i]) {
case 0:
- BLI_snprintf(&str[j * 20], 20, "%sNONE%c", inv, cur);
+ BLI_snprintf(&str[j * ln], ln, "%sNONE%c", inv, cur);
break;
case 1:
case -1:
- BLI_snprintf(&str[j * 20], 20, "%s%.0f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.0f%c", inv, n->val[i], cur);
break;
case 10:
case -10:
- BLI_snprintf(&str[j * 20], 20, "%s%.f.%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.f.%c", inv, n->val[i], cur);
break;
case 100:
case -100:
- BLI_snprintf(&str[j * 20], 20, "%s%.1f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.1f%c", inv, n->val[i], cur);
break;
case 1000:
case -1000:
- BLI_snprintf(&str[j * 20], 20, "%s%.2f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.2f%c", inv, n->val[i], cur);
break;
case 10000:
case -10000:
- BLI_snprintf(&str[j * 20], 20, "%s%.3f%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.3f%c", inv, n->val[i], cur);
break;
default:
- BLI_snprintf(&str[j * 20], 20, "%s%.4e%c", inv, n->val[i], cur);
+ BLI_snprintf(&str[j * ln], ln, "%s%.4e%c", inv, n->val[i], cur);
}
}
}