code cleanup: utility function for getting a bool as a string.
This commit is contained in:
@@ -96,10 +96,10 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
|
||||
BLI_snprintf(msg, HEADER_LENGTH, str,
|
||||
flts_str,
|
||||
flts_str + NUM_STR_REP_LEN,
|
||||
opdata->modify_depth ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "use_outset") ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "use_boundary") ? IFACE_("On") : IFACE_("Off"),
|
||||
RNA_boolean_get(op->ptr, "use_individual") ? IFACE_("On") : IFACE_("Off")
|
||||
WM_bool_as_string(opdata->modify_depth),
|
||||
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")),
|
||||
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")),
|
||||
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))
|
||||
);
|
||||
|
||||
ED_area_headerprint(sa, msg);
|
||||
|
@@ -230,10 +230,10 @@ static void knife_update_header(bContext *C, KnifeTool_OpData *kcd)
|
||||
BLI_snprintf(header, HEADER_LENGTH, IFACE_("LMB: define cut lines, Return/Spacebar: confirm, Esc or RMB: cancel, "
|
||||
"E: new cut, Ctrl: midpoint snap (%s), Shift: ignore snap (%s), "
|
||||
"C: angle constrain (%s), Z: cut through (%s)"),
|
||||
kcd->snap_midpoints ? IFACE_("On") : IFACE_("Off"),
|
||||
kcd->ignore_edge_snapping ? IFACE_("On") : IFACE_("Off"),
|
||||
kcd->angle_snapping ? IFACE_("On") : IFACE_("Off"),
|
||||
kcd->cut_through ? IFACE_("On") : IFACE_("Off"));
|
||||
WM_bool_as_string(kcd->snap_midpoints),
|
||||
WM_bool_as_string(kcd->ignore_edge_snapping),
|
||||
WM_bool_as_string(kcd->angle_snapping),
|
||||
WM_bool_as_string(kcd->cut_through));
|
||||
|
||||
ED_area_headerprint(CTX_wm_area(C), header);
|
||||
}
|
||||
|
@@ -4107,7 +4107,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
||||
}
|
||||
}
|
||||
BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"),
|
||||
(t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF"));
|
||||
WM_bool_as_string(t->flag & T_ALT_TRANSFORM));
|
||||
/* done with header string */
|
||||
|
||||
|
||||
@@ -5875,9 +5875,6 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||
bool flipped = sld->flipped_vtx;
|
||||
bool is_proportional = sld->is_proportional;
|
||||
|
||||
const char *on_str = IFACE_("ON");
|
||||
const char *off_str = IFACE_("OFF");
|
||||
|
||||
final = t->values[0];
|
||||
|
||||
snapGrid(t, &final);
|
||||
@@ -5893,11 +5890,11 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||
outputNumInput(&(t->num), c);
|
||||
|
||||
BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s, (F)lipped: %s"),
|
||||
&c[0], !is_proportional ? on_str : off_str, flipped ? on_str : off_str);
|
||||
&c[0], WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped));
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %.4f (E)ven: %s, (F)lipped: %s"),
|
||||
final, !is_proportional ? on_str : off_str, flipped ? on_str : off_str);
|
||||
final, WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped));
|
||||
}
|
||||
|
||||
CLAMP(final, -1.0f, 1.0f);
|
||||
@@ -6382,9 +6379,6 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||
const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
|
||||
const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
|
||||
|
||||
const char *on_str = IFACE_("ON");
|
||||
const char *off_str = IFACE_("OFF");
|
||||
|
||||
final = t->values[0];
|
||||
|
||||
snapGrid(t, &final);
|
||||
@@ -6405,11 +6399,11 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
|
||||
else {
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%.4f ", final);
|
||||
}
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), !is_proportional ? on_str : off_str);
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), WM_bool_as_string(!is_proportional));
|
||||
if (!is_proportional) {
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), flipped ? on_str : off_str);
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), WM_bool_as_string(flipped));
|
||||
}
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), is_clamp ? on_str : off_str);
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp));
|
||||
/* done with header string */
|
||||
|
||||
/* do stuff here */
|
||||
@@ -6741,7 +6735,7 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str)
|
||||
}
|
||||
}
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"),
|
||||
(t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF"));
|
||||
WM_bool_as_string(t->flag & T_ALT_TRANSFORM));
|
||||
}
|
||||
|
||||
static void applySeqSlide(TransInfo *t, const float val[2])
|
||||
|
@@ -98,6 +98,8 @@ const char *WM_key_event_string(short type);
|
||||
int WM_key_event_operator_id(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, int hotkey, struct wmKeyMap **keymap_r);
|
||||
char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, struct IDProperty *properties, const bool strict, char *str, int len);
|
||||
|
||||
const char *WM_bool_as_string(bool test);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "BLF_translation.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_enum_types.h"
|
||||
@@ -1479,3 +1480,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
return km;
|
||||
}
|
||||
|
||||
const char *WM_bool_as_string(bool test)
|
||||
{
|
||||
return test ? IFACE_("ON") : IFACE_("OFF");
|
||||
}
|
||||
|
Reference in New Issue
Block a user