Fix T83307: Some modal keys of transform operators don't correspond to the expected effect

The transform modes `shrinkfatten` and `seq_slide` have a special way of
handling events.

They use modal events in a different way than expected.

Therefore, this commit adds special event handles for these modes and
removes the keymodal tips from the status bar.

These effects are already described in the header anyway.
This commit is contained in:
Germano Cavalcante 2020-12-07 17:36:11 -03:00
parent 29fb12da58
commit c822f66bb8
Notes: blender-bot 2023-06-21 19:23:24 +02:00
Referenced by commit 37bf71ad04, Fix T83588: Crash with Shrink/Fatten and Offset Even
Referenced by issue #83307, Statusbar Shortcuts: The 3D View shortcuts are displayed in the Sequencer context when in Transform mode.
3 changed files with 45 additions and 13 deletions

View File

@ -637,6 +637,14 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
}
break;
}
case TFM_MODAL_TRANSLATE:
case TFM_MODAL_ROTATE:
case TFM_MODAL_RESIZE: {
if (!transform_mode_is_changeable(t->mode)) {
return false;
}
break;
}
}
return true;
}
@ -876,11 +884,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
}
else if (t->mode == TFM_SEQ_SLIDE) {
t->flag ^= T_ALT_TRANSFORM;
t->redraw |= TREDRAW_HARD;
handled = true;
}
else if (transform_mode_is_changeable(t->mode)) {
restoreTransObjects(t);
resetTransModal(t);
@ -922,11 +925,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
}
else if (t->mode == TFM_SHRINKFATTEN) {
t->flag ^= T_ALT_TRANSFORM;
t->redraw |= TREDRAW_HARD;
handled = true;
}
else if (transform_mode_is_changeable(t->mode)) {
/* Scale isn't normally very useful after extrude along normals, see T39756 */
if ((t->con.mode & CON_APPLY) && (t->orient[t->orient_curr].type == V3D_ORIENT_NORMAL)) {

View File

@ -32,6 +32,7 @@
#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
@ -45,6 +46,18 @@
/** \name Transform (Sequencer Slide)
* \{ */
static eRedrawFlag seq_slide_handleEvent(struct TransInfo *t, const wmEvent *event)
{
BLI_assert(t->mode == TFM_SEQ_SLIDE);
wmKeyMapItem *kmi = t->custom.mode.data;
if (event->type == kmi->type && event->val == kmi->val) {
/* Allows the 'Expand to fit' effect to be enabled as a toogle. */
t->flag ^= T_ALT_TRANSFORM;
return TREDRAW_HARD;
}
return TREDRAW_NOTHING;
}
static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRAW_STR])
{
char tvec[NUM_STR_REP_LEN * 3];
@ -61,7 +74,7 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[UI_MAX_DRA
str + ofs, UI_MAX_DRAW_STR - ofs, TIP_("Sequence Slide: %s%s, ("), &tvec[0], t->con.text);
if (t->keymap) {
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE);
wmKeyMapItem *kmi = t->custom.mode.data;
if (kmi) {
ofs += WM_keymap_item_to_string(kmi, false, str + ofs, UI_MAX_DRAW_STR - ofs);
}
@ -91,7 +104,7 @@ static void applySeqSlideValue(TransInfo *t, const float val[2])
static void applySeqSlide(TransInfo *t, const int mval[2])
{
char str[UI_MAX_DRAW_STR];
float values_final[2] = {0.0f};
float values_final[3] = {0.0f};
snapSequenceBounds(t, mval);
if (applyNumInput(&t->num, values_final)) {
@ -126,6 +139,7 @@ static void applySeqSlide(TransInfo *t, const int mval[2])
void initSeqSlide(TransInfo *t)
{
t->transform = applySeqSlide;
t->handleEvent = seq_slide_handleEvent;
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
@ -142,5 +156,8 @@ void initSeqSlide(TransInfo *t)
* (supporting frames in addition to "natural" time...). */
t->num.unit_type[0] = B_UNIT_NONE;
t->num.unit_type[1] = B_UNIT_NONE;
/* Workaround to use the same key as the modal keymap. */
t->custom.mode.data = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE);
}
/** \} */

View File

@ -32,6 +32,7 @@
#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
#include "UI_interface.h"
@ -45,6 +46,18 @@
/** \name Transform (Shrink-Fatten)
* \{ */
static eRedrawFlag shrinkfatten_handleEvent(struct TransInfo *t, const wmEvent *event)
{
BLI_assert(t->mode == TFM_SHRINKFATTEN);
wmKeyMapItem *kmi = t->custom.mode.data;
if (event->type == kmi->type && event->val == kmi->val) {
/* Allows the 'Even Thickness' effect to be enabled as a toogle. */
t->flag ^= T_ALT_TRANSFORM;
return TREDRAW_HARD;
}
return TREDRAW_NOTHING;
}
static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
float distance;
@ -78,7 +91,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
ofs += BLI_strncpy_rlen(str + ofs, ", (", sizeof(str) - ofs);
if (t->keymap) {
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
wmKeyMapItem *kmi = t->custom.mode.data;
if (kmi) {
ofs += WM_keymap_item_to_string(kmi, false, str + ofs, sizeof(str) - ofs);
}
@ -121,6 +134,7 @@ void initShrinkFatten(TransInfo *t)
else {
t->mode = TFM_SHRINKFATTEN;
t->transform = applyShrinkFatten;
t->handleEvent = shrinkfatten_handleEvent;
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
@ -134,6 +148,9 @@ void initShrinkFatten(TransInfo *t)
t->num.unit_type[0] = B_UNIT_LENGTH;
t->flag |= T_NO_CONSTRAINT;
/* Workaround to use the same key as the modal keymap. */
t->custom.mode.data = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
}
}
/** \} */