diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_bevel.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_bevel.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 5eaac72590b..242cbf79a83 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -44,6 +44,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "UI_interface.h" + #include "ED_mesh.h" #include "ED_numinput.h" #include "ED_screen.h" @@ -69,16 +71,15 @@ typedef struct { BMBackup mesh_backup; void *draw_handle_pixel; short twtype; + float segments; /* Segments as float so smooth mouse pan works in small increments */ } BevelData; -#define HEADER_LENGTH 180 - static void edbm_bevel_update_header(bContext *C, wmOperator *op) { const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), " "Vertex Only: %s (V), Offset: %s, Segments: %d"); - char msg[HEADER_LENGTH]; + char msg[UI_MAX_DRAW_STR]; ScrArea *sa = CTX_wm_area(C); Scene *sce = CTX_data_scene(C); @@ -97,7 +98,7 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op) RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str); - BLI_snprintf(msg, HEADER_LENGTH, str, type_str, + BLI_snprintf(msg, sizeof(msg), str, type_str, WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")), offset_str, RNA_int_get(op->ptr, "segments")); @@ -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) { BevelData *opdata = op->customdata; - int segments = RNA_int_get(op->ptr, "segments"); const bool has_numinput = hasNumInput(&opdata->num_input); /* 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; + 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. * 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. @@ -383,8 +396,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_RELEASE) break; - segments++; - RNA_int_set(op->ptr, "segments", segments); + opdata->segments = opdata->segments + 1; + RNA_int_set(op->ptr, "segments", (int)opdata->segments); edbm_bevel_calc(op); edbm_bevel_update_header(C, op); handled = true; @@ -395,8 +408,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_RELEASE) break; - segments = max_ii(segments - 1, 1); - RNA_int_set(op->ptr, "segments", segments); + opdata->segments = max_ff(opdata->segments - 1, 1); + RNA_int_set(op->ptr, "segments", (int)opdata->segments); edbm_bevel_calc(op); edbm_bevel_update_header(C, op); handled = true; |