diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-14 18:01:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-14 18:01:02 +0400 |
commit | 9449866bdca7736155b1d8a42bfb230ec3084d51 (patch) | |
tree | 4287cbbe7bee19d0d01bd6bdf52313a484449e0c /source/blender | |
parent | ceb3624b115848d96f11f1507474ee5a61f9e0d0 (diff) |
fix (for one case of...) [#33949] T_ALT_TRANSFORM conflicts with "emulate 3 button mouse"
ShrinkFatten operator now uses scale key to toggle 'Even thickness' option.
With the default keymap this is Alt+S,S.
Added functionality so the header print can get the key used for the modal keymap, some other operators should make use of this too.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/metaball/mball_ops.c | 7 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 34 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_keymap.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 24 |
5 files changed, 53 insertions, 16 deletions
diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index e98654f589a..f91d57424a1 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -28,10 +28,6 @@ * \ingroup edmeta */ - -#include "WM_api.h" -#include "WM_types.h" - #include "RNA_access.h" #include "ED_mball.h" @@ -40,6 +36,9 @@ #include "BLI_utildefines.h" +#include "WM_api.h" +#include "WM_types.h" + #include "mball_intern.h" void ED_operatortypes_metaball(void) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index a76fd4a8746..ae7e3eeba28 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -958,6 +958,10 @@ int transformEvent(TransInfo *t, wmEvent *event) initSnapping(t, NULL); // need to reinit after mode change t->redraw |= TREDRAW_HARD; } + else if (t->mode == TFM_SHRINKFATTEN) { + t->flag ^= T_ALT_TRANSFORM; + t->redraw |= TREDRAW_HARD; + } else if (t->mode == TFM_RESIZE) { if (t->options & CTX_MOVIECLIP) { restoreTransObjects(t); @@ -1920,6 +1924,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int } + t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); + initSnapping(t, op); // Initialize snapping data AFTER mode flags /* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */ @@ -4054,7 +4060,8 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { float distance; int i; - char str[64]; + char str[128]; + char *str_p; TransData *td = t->data; distance = -t->values[0]; @@ -4064,18 +4071,30 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) applyNumInput(&t->num, &distance); /* header print for NumInput */ + str_p = str; + str_p += BLI_snprintf(str_p, sizeof(str), "Shrink/Fatten:"); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; - outputNumInput(&(t->num), c); - - sprintf(str, "Shrink/Fatten: %s %s", c, t->proptext); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s", c); } else { /* default header print */ - sprintf(str, "Shrink/Fatten: %.4f %s", distance, t->proptext); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %.4f", distance); } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), " %s, (", t->proptext); + { + wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE); + if (kmi) { + str_p += WM_keymap_item_to_string(kmi, str_p, sizeof(str) - (str_p - str)); + } + } + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), ") Even Thickness %s", + (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF"); + /* done with header string */ + + t->values[0] = -distance; for (i = 0; i < t->total; i++, td++) { @@ -6398,14 +6417,15 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2])) /* header string */ str_p = str; + str_p += BLI_snprintf(str_p, sizeof(str), "Vert Slide: "); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; applyNumInput(&t->num, &final); outputNumInput(&(t->num), c); - str_p += BLI_snprintf(str, sizeof(str), "Vert Slide: %s", &c[0]); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "%s", &c[0]); } else { - str_p += BLI_snprintf(str_p, sizeof(str), "Vert Slide: %.4f ", final); + str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "%.4f ", final); } str_p += BLI_snprintf(str_p, sizeof(str) - (str_p - str), "(E)ven: %s, ", !is_proportional ? "ON" : "OFF"); if (!is_proportional) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 55b7e9fae60..78f346be2aa 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -352,6 +352,7 @@ typedef struct TransInfo { struct Scene *scene; struct ToolSettings *settings; struct wmTimer *animtimer; + struct wmKeyMap *keymap; /* so we can do lookups for header text */ int mval[2]; /* current mouse position */ struct Object *obedit; void *draw_handle_apply; diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h index 43369154dbb..49ee759bbf2 100644 --- a/source/blender/windowmanager/WM_keymap.h +++ b/source/blender/windowmanager/WM_keymap.h @@ -64,7 +64,7 @@ wmKeyMapItem *WM_keymap_add_menu(struct wmKeyMap *keymap, const char *idname, in int val, int modifier, int keymodifier); int WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); -char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len); +int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len); wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid); @@ -81,6 +81,7 @@ wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, st wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname); wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value); wmKeyMapItem *WM_modalkeymap_add_item_str(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, const char *value); +wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue); void WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname); /* Keymap Editor */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index a296c742e5c..92a310ac34e 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -737,6 +737,24 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, int type, int val, int m return kmi; } +wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue) +{ + + if (km->flag & KEYMAP_MODAL) { + wmKeyMapItem *kmi; + for (kmi = km->items.first; kmi; kmi = kmi->next) { + if (kmi->propvalue == propvalue) { + return kmi; + } + } + } + else { + BLI_assert(!"called with non modal keymap"); + } + + return NULL; +} + void WM_modalkeymap_assign(wmKeyMap *km, const char *opname) { wmOperatorType *ot = WM_operatortype_find(opname, 0); @@ -785,7 +803,7 @@ const char *WM_key_event_string(short type) return ""; } -char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) +int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) { char buf[128]; @@ -818,9 +836,7 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len) } strcat(buf, WM_key_event_string(kmi->type)); - BLI_strncpy(str, buf, len); - - return str; + return BLI_snprintf(str, len, "%s", buf); } static wmKeyMapItem *wm_keymap_item_find_handlers( |