Commit: 2173e88f3b3bb5a28a8520156dd54000993ce11e Author: Hans Goudey Date: Mon Aug 12 17:31:13 2019 -0400 Branches: soc-2019-bevel-profiles https://developer.blender.org/rB2173e88f3b3bb5a28a8520156dd54000993ce11e
Merge branch 'master' into soc-2019-bevel-profiles =================================================================== =================================================================== diff --cc source/blender/blenkernel/intern/scene.c index a653233d260,1ef93427253..17c2417e86d --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@@ -177,12 -176,10 +177,12 @@@ ToolSettings *BKE_toolsettings_copy(Too ts->particle.object = NULL; /* duplicate Grease Pencil interpolation curve */ - ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo); + ts->gp_interpolate.custom_ipo = BKE_curvemapping_copy(ts->gp_interpolate.custom_ipo); /* duplicate Grease Pencil multiframe fallof */ - ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff); - ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_copy(ts->gp_sculpt.cur_falloff); + ts->gp_sculpt.cur_primitive = BKE_curvemapping_copy(ts->gp_sculpt.cur_primitive); + + ts->prwdgt = BKE_profilewidget_copy(ts->prwdgt); return ts; } @@@ -219,16 -216,12 +219,16 @@@ void BKE_toolsettings_free(ToolSetting } /* free Grease Pencil multiframe falloff curve */ if (toolsettings->gp_sculpt.cur_falloff) { - curvemapping_free(toolsettings->gp_sculpt.cur_falloff); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_falloff); } if (toolsettings->gp_sculpt.cur_primitive) { - curvemapping_free(toolsettings->gp_sculpt.cur_primitive); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_primitive); } + if (toolsettings->prwdgt) { + BKE_profilewidget_free(toolsettings->prwdgt); + } + MEM_freeN(toolsettings); } diff --cc source/blender/blenloader/intern/versioning_280.c index 9e532b5fe23,15b4f513050..2ecf65e0aaa --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@@ -3552,30 -3551,22 +3552,47 @@@ void blo_do_versions_280(FileData *fd, { /* Versioning code until next subversion bump goes here. */ + + /* Add custom profile widget to toolsettings for bevel tool */ - if (!DNA_struct_elem_find( - fd->filesdna, "ToolSettings", "ProfileWidget", "prwdgt")) { ++ if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "ProfileWidget", "prwdgt")) { + for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { + ToolSettings *ts = scene->toolsettings; + if ((ts) && (ts->prwdgt == NULL)) { + ts->prwdgt = BKE_profilewidget_add(PROF_PRESET_LINE); + } + } + } + + /* Add custom profile widget to bevel modifier */ + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "ProfileWidget", "prwdgt")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + for (ModifierData *md = object->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + if (!bmd->prwdgt) { + bmd->prwdgt = BKE_profilewidget_add(PROF_PRESET_LINE); + } + } + } + } + } ++ + if (U.view_rotate_sensitivity_turntable == 0) { + U.view_rotate_sensitivity_turntable = DEG2RADF(0.4f); + U.view_rotate_sensitivity_trackball = 1.0f; + } + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_TEXT) { + ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + ARegion *ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI); + if (ar) { + ar->alignment = RGN_ALIGN_RIGHT; + } + } + } + } + } } } diff --cc source/blender/editors/interface/interface_handlers.c index c348743d96f,52933a89045..1bd8ec6510e --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@@ -418,10 -417,7 +418,9 @@@ static uiButMultiState *ui_multibut_loo static ColorBand but_copypaste_coba = {0}; static CurveMapping but_copypaste_curve = {0}; static bool but_copypaste_curve_alive = false; +static ProfileWidget but_copypaste_profile = {0}; +static bool but_copypaste_profile_alive = false; - /** \} */ /* -------------------------------------------------------------------- */ @@@ -2637,8 -2588,7 +2636,8 @@@ static void ui_but_paste(bContext *C, u void ui_but_clipboard_free(void) { - curvemapping_free_data(&but_copypaste_curve); + BKE_curvemapping_free_data(&but_copypaste_curve); + BKE_profilewidget_free_data(&but_copypaste_profile); } /** \} */ @@@ -6743,281 -6689,6 +6742,278 @@@ static int ui_do_but_CURVE return WM_UI_HANDLER_CONTINUE; } +/* Same as ui_numedit_but_CURVE with some smaller changes */ +static bool ui_numedit_but_PROFILE(uiBlock *block, + uiBut *but, + uiHandleButtonData *data, + int evtx, + int evty, + bool snap, + const bool shift) +{ + ProfileWidget *prwdgt = (ProfileWidget *)but->poin; + ProfilePoint *pts = prwdgt->path; + float fx, fy, zoomx, zoomy; + int mx, my, dragx, dragy; + int a; + bool changed = false; + + /* evtx evty and drag coords are absolute mousecoords, + * prevents errors when editing when layout changes */ + mx = evtx; + my = evty; + ui_window_to_block(data->region, block, &mx, &my); + dragx = data->draglastx; + dragy = data->draglasty; + ui_window_to_block(data->region, block, &dragx, &dragy); + + zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&prwdgt->view_rect); + zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&prwdgt->view_rect); + + if (snap) { + float d[2]; + + d[0] = mx - data->dragstartx; + d[1] = my - data->dragstarty; + + if (len_squared_v2(d) < (3.0f * 3.0f)) { + snap = false; + } + } + + fx = (mx - dragx) / zoomx; + fy = (my - dragy) / zoomy; + + if (data->dragsel != -1) { + ProfilePoint *point_last = NULL; + const float mval_factor = ui_mouse_scale_warp_factor(shift); + bool moved_point = false; /* for ctrl grid, can't use orig coords because of sorting */ + + fx *= mval_factor; + fy *= mval_factor; + + /* Move all the points that aren't the last or the first */ + for (a = 1; a < prwdgt->totpoint - 1; a++) { + if (pts[a].flag & PROF_SELECT) { + float origx = pts[a].x, origy = pts[a].y; + pts[a].x += fx; + pts[a].y += fy; + if (snap) { + pts[a].x = 0.125f * roundf(8.0f * pts[a].x); + pts[a].y = 0.125f * roundf(8.0f * pts[a].y); + } + if (!moved_point && (pts[a].x != origx || pts[a].y != origy)) { + moved_point = true; + } + + point_last = &pts[a]; + } + } + + BKE_profilewidget_changed(prwdgt, false); + + if (moved_point) { + data->draglastx = evtx; + data->draglasty = evty; + changed = true; +#ifdef USE_CONT_MOUSE_CORRECT + /* note: using 'cmp_last' is weak since there may be multiple points selected, + * but in practice this isnt really an issue */ + if (ui_but_is_cursor_warp(but)) { + /* OK but can go outside bounds */ + data->ungrab_mval[0] = but->rect.xmin + ((point_last->x - prwdgt->view_rect.xmin) * zoomx); + data->ungrab_mval[1] = but->rect.ymin + ((point_last->y - prwdgt->view_rect.ymin) * zoomy); + BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval); + } +#endif + } + data->dragchange = true; /* mark for selection */ + } + else { + /* clamp for clip */ + if (prwdgt->flag & PROF_USE_CLIP) { + if (prwdgt->view_rect.xmin - fx < prwdgt->clip_rect.xmin) { + fx = prwdgt->view_rect.xmin - prwdgt->clip_rect.xmin; + } + else if (prwdgt->view_rect.xmax - fx > prwdgt->clip_rect.xmax) { + fx = prwdgt->view_rect.xmax - prwdgt->clip_rect.xmax; + } + if (prwdgt->view_rect.ymin - fy < prwdgt->clip_rect.ymin) { + fy = prwdgt->view_rect.ymin - prwdgt->clip_rect.ymin; + } + else if (prwdgt->view_rect.ymax - fy > prwdgt->clip_rect.ymax) { + fy = prwdgt->view_rect.ymax - prwdgt->clip_rect.ymax; + } + } + + prwdgt->view_rect.xmin -= fx; + prwdgt->view_rect.ymin -= fy; + prwdgt->view_rect.xmax -= fx; + prwdgt->view_rect.ymax -= fy; + + data->draglastx = evtx; + data->draglasty = evty; + + changed = true; + } + + return changed; +} + - static int ui_do_but_PROFILE(bContext *C, - uiBlock *block, - uiBut *but, - uiHandleButtonData *data, - const wmEvent *event) ++static int ui_do_but_PROFILE( ++ bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event) +{ + int mx, my, i; + + mx = event->x; + my = event->y; + ui_window_to_block(data->region, block, &mx, &my); + + /* Move selected control points (hardcoded keymap) */ + if (event->type == GKEY && event->val == KM_RELEASE) { + data->dragstartx = mx; + data->dragstarty = my; + data->draglastx = mx; + data->draglasty = my; + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); + return WM_UI_HANDLER_BREAK; + } + + ProfileWidget *prwdgt = (ProfileWidget *)but->poin; + + /* Delete selected control points (hardcoded keymap) */ + if (event->type == XKEY && event->val == KM_RELEASE) { + BKE_profilewidget_remove(prwdgt, PROF_SELECT); + BKE_profilewidget_changed(prwdgt, false); + ED_region_tag_redraw(data->region); + return WM_UI_HANDLER_BREAK; + } + + /* Selecting, adding, and starting point movements */ + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs