diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-10-13 04:32:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-10-13 04:32:31 +0400 |
commit | eabf7ab3351ade8415cd38d6faf2cfba79ba7400 (patch) | |
tree | de69cec6b43dcbf8bf08529f09c8bba90c508deb /source/blender | |
parent | 3a63adb5ff7e52084d279d64a0afc0f8067c0499 (diff) |
code cleanup: utility function for getting a bool as a string.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/mesh/editmesh_inset.c | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 20 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_keymap.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 5 |
5 files changed, 22 insertions, 21 deletions
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 71822868026..eb66cf50a1e 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -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); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 9d8b283fe1a..b0dc30d73f7 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -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); } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b08f66d0454..ba7bdebd5bf 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -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]) diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 121e5e401fa..eab27286709 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -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 diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 43a98a4600b..f6ba3a29344 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -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"); +} |