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.
This commit is contained in:
2013-02-14 14:01:02 +00:00
parent ceb3624b11
commit 9449866bdc
5 changed files with 53 additions and 16 deletions

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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(