code cleanup: utility function for getting a bool as a string.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 13 Oct 2013 00:32:31 +0000 (00:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 13 Oct 2013 00:32:31 +0000 (00:32 +0000)
source/blender/editors/mesh/editmesh_inset.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/transform/transform.c
source/blender/windowmanager/WM_keymap.h
source/blender/windowmanager/intern/wm_keymap.c

index 718228680268ee4e8b6c3ef54ff6694c88cf937d..eb66cf50a1eed23efe37bec01588fb036390b492 100644 (file)
@@ -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);
index 9d8b283fe1a9b69c5edbb5e9299dd9019caeee8b..b0dc30d73f71c1e92d4b68f2c9be481cae9b2bed 100644 (file)
@@ -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);
 }
index b08f66d045455c538fc5c50ed1578f2c95269227..ba7bdebd5bf911f7de467a1cea7d23193f63be4a 100644 (file)
@@ -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])
index 121e5e401fac03fcd96af5aa3b4eaf07f1a01b84..eab27286709451268c5894f21feea63ff079c720 100644 (file)
@@ -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
index 43a98a4600bfeb019472174a23c7324ad25cf864..f6ba3a29344c1e974680484120e6d6a3ee2d7d2c 100644 (file)
@@ -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");
+}