Fix T48372: missing OS X trackpad scroll support for increasing loop cut / bevel segments.
This commit is contained in:
parent
2d8db0de79
commit
5fde5616e0
@ -69,6 +69,7 @@ typedef struct {
|
|||||||
BMBackup mesh_backup;
|
BMBackup mesh_backup;
|
||||||
void *draw_handle_pixel;
|
void *draw_handle_pixel;
|
||||||
short twtype;
|
short twtype;
|
||||||
|
float segments; /* Segments as float so smooth mouse pan works in small increments */
|
||||||
} BevelData;
|
} BevelData;
|
||||||
|
|
||||||
#define HEADER_LENGTH 180
|
#define HEADER_LENGTH 180
|
||||||
@ -332,7 +333,6 @@ static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event)
|
|||||||
static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
BevelData *opdata = op->customdata;
|
BevelData *opdata = op->customdata;
|
||||||
int segments = RNA_int_get(op->ptr, "segments");
|
|
||||||
const bool has_numinput = hasNumInput(&opdata->num_input);
|
const bool has_numinput = hasNumInput(&opdata->num_input);
|
||||||
|
|
||||||
/* Modal numinput active, try to handle numeric inputs first... */
|
/* Modal numinput active, try to handle numeric inputs first... */
|
||||||
@ -373,6 +373,19 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MOUSEPAN: {
|
||||||
|
float delta = 0.02f * (event->y - event->prevy);
|
||||||
|
if (opdata->segments >= 1 && opdata->segments + delta < 1)
|
||||||
|
opdata->segments = 1;
|
||||||
|
else
|
||||||
|
opdata->segments += delta;
|
||||||
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
||||||
|
edbm_bevel_calc(op);
|
||||||
|
edbm_bevel_update_header(C, op);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Note this will prevent padplus and padminus to ever activate modal numinput.
|
/* Note this will prevent padplus and padminus to ever activate modal numinput.
|
||||||
* This is not really an issue though, as we only expect positive values here...
|
* This is not really an issue though, as we only expect positive values here...
|
||||||
* Else we could force them to only modify segments number when shift is pressed, or so.
|
* Else we could force them to only modify segments number when shift is pressed, or so.
|
||||||
@ -383,8 +396,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
if (event->val == KM_RELEASE)
|
if (event->val == KM_RELEASE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
segments++;
|
opdata->segments = opdata->segments + 1;
|
||||||
RNA_int_set(op->ptr, "segments", segments);
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
||||||
edbm_bevel_calc(op);
|
edbm_bevel_calc(op);
|
||||||
edbm_bevel_update_header(C, op);
|
edbm_bevel_update_header(C, op);
|
||||||
handled = true;
|
handled = true;
|
||||||
@ -395,8 +408,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
if (event->val == KM_RELEASE)
|
if (event->val == KM_RELEASE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
segments = max_ii(segments - 1, 1);
|
opdata->segments = max_ff(opdata->segments - 1, 1);
|
||||||
RNA_int_set(op->ptr, "segments", segments);
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
||||||
edbm_bevel_calc(op);
|
edbm_bevel_calc(op);
|
||||||
edbm_bevel_update_header(C, op);
|
edbm_bevel_update_header(C, op);
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -87,6 +87,9 @@ typedef struct RingSelOpData {
|
|||||||
|
|
||||||
bool extend;
|
bool extend;
|
||||||
bool do_cut;
|
bool do_cut;
|
||||||
|
|
||||||
|
float cuts; /* cuts as float so smooth mouse pan works in small increments */
|
||||||
|
float smoothness;
|
||||||
} RingSelOpData;
|
} RingSelOpData;
|
||||||
|
|
||||||
/* modal loop selection drawing callback */
|
/* modal loop selection drawing callback */
|
||||||
@ -501,6 +504,8 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
|
|||||||
lcd->em = BKE_editmesh_from_object(lcd->ob);
|
lcd->em = BKE_editmesh_from_object(lcd->ob);
|
||||||
lcd->extend = do_cut ? false : RNA_boolean_get(op->ptr, "extend");
|
lcd->extend = do_cut ? false : RNA_boolean_get(op->ptr, "extend");
|
||||||
lcd->do_cut = do_cut;
|
lcd->do_cut = do_cut;
|
||||||
|
lcd->cuts = RNA_int_get(op->ptr, "number_cuts");
|
||||||
|
lcd->smoothness = RNA_float_get(op->ptr, "smoothness");
|
||||||
|
|
||||||
initNumInput(&lcd->num);
|
initNumInput(&lcd->num);
|
||||||
lcd->num.idx_max = 1;
|
lcd->num.idx_max = 1;
|
||||||
@ -648,9 +653,9 @@ static int loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
float smoothness = RNA_float_get(op->ptr, "smoothness");
|
|
||||||
int cuts = RNA_int_get(op->ptr, "number_cuts");
|
|
||||||
RingSelOpData *lcd = op->customdata;
|
RingSelOpData *lcd = op->customdata;
|
||||||
|
float cuts = lcd->cuts;
|
||||||
|
float smoothness = lcd->smoothness;
|
||||||
bool show_cuts = false;
|
bool show_cuts = false;
|
||||||
const bool has_numinput = hasNumInput(&lcd->num);
|
const bool has_numinput = hasNumInput(&lcd->num);
|
||||||
|
|
||||||
@ -662,20 +667,10 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
/* using the keyboard to input the number of cuts */
|
/* using the keyboard to input the number of cuts */
|
||||||
/* Modal numinput active, try to handle numeric inputs first... */
|
/* Modal numinput active, try to handle numeric inputs first... */
|
||||||
if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &lcd->num, event)) {
|
if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &lcd->num, event)) {
|
||||||
float values[2] = {(float)cuts, smoothness};
|
float values[2] = {cuts, smoothness};
|
||||||
applyNumInput(&lcd->num, values);
|
applyNumInput(&lcd->num, values);
|
||||||
|
cuts = values[0];
|
||||||
/* allow zero so you can backspace and type in a value
|
smoothness = values[1];
|
||||||
* otherwise 1 as minimum would make more sense */
|
|
||||||
cuts = CLAMPIS(values[0], 0, SUBD_CUTS_MAX);
|
|
||||||
smoothness = CLAMPIS(values[1], -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
|
|
||||||
|
|
||||||
RNA_int_set(op->ptr, "number_cuts", cuts);
|
|
||||||
ringsel_find_edge(lcd, cuts);
|
|
||||||
show_cuts = true;
|
|
||||||
RNA_float_set(op->ptr, "smoothness", smoothness);
|
|
||||||
|
|
||||||
ED_region_tag_redraw(lcd->ar);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
@ -708,25 +703,28 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
ED_region_tag_redraw(lcd->ar);
|
ED_region_tag_redraw(lcd->ar);
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
case MOUSEPAN:
|
||||||
|
if (event->alt == 0) {
|
||||||
|
cuts += 0.02f * (event->y - event->prevy);
|
||||||
|
if (cuts < 1 && lcd->cuts >= 1)
|
||||||
|
cuts = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
smoothness += 0.002f * (event->y - event->prevy);
|
||||||
|
}
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
case PADPLUSKEY:
|
case PADPLUSKEY:
|
||||||
case PAGEUPKEY:
|
case PAGEUPKEY:
|
||||||
case WHEELUPMOUSE: /* change number of cuts */
|
case WHEELUPMOUSE: /* change number of cuts */
|
||||||
if (event->val == KM_RELEASE)
|
if (event->val == KM_RELEASE)
|
||||||
break;
|
break;
|
||||||
if (event->alt == 0) {
|
if (event->alt == 0) {
|
||||||
cuts++;
|
cuts += 1;
|
||||||
cuts = CLAMPIS(cuts, 0, SUBD_CUTS_MAX);
|
|
||||||
RNA_int_set(op->ptr, "number_cuts", cuts);
|
|
||||||
ringsel_find_edge(lcd, cuts);
|
|
||||||
show_cuts = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
smoothness = min_ff(smoothness + 0.05f, SUBD_SMOOTH_MAX);
|
smoothness += 0.05f;
|
||||||
RNA_float_set(op->ptr, "smoothness", smoothness);
|
|
||||||
show_cuts = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_region_tag_redraw(lcd->ar);
|
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case PADMINUS:
|
case PADMINUS:
|
||||||
@ -734,27 +732,19 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
case WHEELDOWNMOUSE: /* change number of cuts */
|
case WHEELDOWNMOUSE: /* change number of cuts */
|
||||||
if (event->val == KM_RELEASE)
|
if (event->val == KM_RELEASE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (event->alt == 0) {
|
if (event->alt == 0) {
|
||||||
cuts = max_ii(cuts - 1, 1);
|
cuts = max_ff(cuts - 1, 1);
|
||||||
RNA_int_set(op->ptr, "number_cuts", cuts);
|
|
||||||
ringsel_find_edge(lcd, cuts);
|
|
||||||
show_cuts = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
smoothness = max_ff(smoothness - 0.05f, -SUBD_SMOOTH_MAX);
|
smoothness -= 0.05f;
|
||||||
RNA_float_set(op->ptr, "smoothness", smoothness);
|
|
||||||
show_cuts = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ED_region_tag_redraw(lcd->ar);
|
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case MOUSEMOVE: /* mouse moved somewhere to select another loop */
|
case MOUSEMOVE: /* mouse moved somewhere to select another loop */
|
||||||
if (!has_numinput) {
|
if (!has_numinput) {
|
||||||
lcd->vc.mval[0] = event->mval[0];
|
lcd->vc.mval[0] = event->mval[0];
|
||||||
lcd->vc.mval[1] = event->mval[1];
|
lcd->vc.mval[1] = event->mval[1];
|
||||||
loopcut_mouse_move(lcd, cuts);
|
loopcut_mouse_move(lcd, (int)lcd->cuts);
|
||||||
|
|
||||||
ED_region_tag_redraw(lcd->ar);
|
ED_region_tag_redraw(lcd->ar);
|
||||||
handled = true;
|
handled = true;
|
||||||
@ -764,23 +754,30 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
|
|
||||||
/* Modal numinput inactive, try to handle numeric inputs last... */
|
/* Modal numinput inactive, try to handle numeric inputs last... */
|
||||||
if (!handled && event->val == KM_PRESS && handleNumInput(C, &lcd->num, event)) {
|
if (!handled && event->val == KM_PRESS && handleNumInput(C, &lcd->num, event)) {
|
||||||
float values[2] = {(float)cuts, smoothness};
|
float values[2] = {cuts, smoothness};
|
||||||
applyNumInput(&lcd->num, values);
|
applyNumInput(&lcd->num, values);
|
||||||
|
cuts = values[0];
|
||||||
/* allow zero so you can backspace and type in a value
|
smoothness = values[1];
|
||||||
* otherwise 1 as minimum would make more sense */
|
|
||||||
cuts = CLAMPIS(values[0], 0, SUBD_CUTS_MAX);
|
|
||||||
smoothness = CLAMPIS(values[1], -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
|
|
||||||
|
|
||||||
RNA_int_set(op->ptr, "number_cuts", cuts);
|
|
||||||
ringsel_find_edge(lcd, cuts);
|
|
||||||
show_cuts = true;
|
|
||||||
RNA_float_set(op->ptr, "smoothness", smoothness);
|
|
||||||
|
|
||||||
ED_region_tag_redraw(lcd->ar);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cuts != lcd->cuts) {
|
||||||
|
/* allow zero so you can backspace and type in a value
|
||||||
|
* otherwise 1 as minimum would make more sense */
|
||||||
|
lcd->cuts = CLAMPIS(cuts, 0, SUBD_CUTS_MAX);
|
||||||
|
RNA_int_set(op->ptr, "number_cuts", (int)lcd->cuts);
|
||||||
|
ringsel_find_edge(lcd, (int)lcd->cuts);
|
||||||
|
show_cuts = true;
|
||||||
|
ED_region_tag_redraw(lcd->ar);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smoothness != lcd->smoothness) {
|
||||||
|
lcd->smoothness = CLAMPIS(smoothness, -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
|
||||||
|
RNA_float_set(op->ptr, "smoothness", lcd->smoothness);
|
||||||
|
show_cuts = true;
|
||||||
|
ED_region_tag_redraw(lcd->ar);
|
||||||
|
}
|
||||||
|
|
||||||
if (show_cuts) {
|
if (show_cuts) {
|
||||||
Scene *sce = CTX_data_scene(C);
|
Scene *sce = CTX_data_scene(C);
|
||||||
char buf[64 + NUM_STR_REP_LEN * 2];
|
char buf[64 + NUM_STR_REP_LEN * 2];
|
||||||
@ -789,7 +786,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
outputNumInput(&lcd->num, str_rep, &sce->unit);
|
outputNumInput(&lcd->num, str_rep, &sce->unit);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", cuts);
|
BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", (int)lcd->cuts);
|
||||||
BLI_snprintf(str_rep + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%.2f", smoothness);
|
BLI_snprintf(str_rep + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%.2f", smoothness);
|
||||||
}
|
}
|
||||||
BLI_snprintf(buf, sizeof(buf), IFACE_("Number of Cuts: %s, Smooth: %s (Alt)"),
|
BLI_snprintf(buf, sizeof(buf), IFACE_("Number of Cuts: %s, Smooth: %s (Alt)"),
|
||||||
|
Loading…
Reference in New Issue
Block a user