Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/view2d_edge_pan.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if (!UI_view2d_edge_pan_poll(C)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Set pointers to owners. */ | /* Set pointers to owners. */ | ||||
| vpd->screen = CTX_wm_screen(C); | vpd->screen = CTX_wm_screen(C); | ||||
| vpd->area = CTX_wm_area(C); | vpd->area = CTX_wm_area(C); | ||||
| vpd->region = CTX_wm_region(C); | vpd->region = CTX_wm_region(C); | ||||
| vpd->v2d = &vpd->region->v2d; | vpd->v2d = &vpd->region->v2d; | ||||
| BLI_rctf_init(&vpd->limit, -FLT_MAX, FLT_MAX, -FLT_MAX, FLT_MAX); | |||||
| BLI_assert(speed_ramp > 0.0f); | BLI_assert(speed_ramp > 0.0f); | ||||
| vpd->inside_pad = inside_pad; | vpd->inside_pad = inside_pad; | ||||
| vpd->outside_pad = outside_pad; | vpd->outside_pad = outside_pad; | ||||
| vpd->speed_ramp = speed_ramp; | vpd->speed_ramp = speed_ramp; | ||||
| vpd->max_speed = max_speed; | vpd->max_speed = max_speed; | ||||
| vpd->delay = delay; | vpd->delay = delay; | ||||
| vpd->zoom_influence = zoom_influence; | vpd->zoom_influence = zoom_influence; | ||||
| vpd->enabled = false; | vpd->enabled = false; | ||||
| /* Calculate translation factor, based on size of view. */ | /* Calculate translation factor, based on size of view. */ | ||||
| const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1); | const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1); | ||||
| const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1); | const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1); | ||||
| vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx; | vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx; | ||||
| vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy; | vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy; | ||||
| UI_view2d_edge_pan_reset(vpd); | UI_view2d_edge_pan_reset(vpd); | ||||
| } | } | ||||
| void UI_view2d_edge_pan_set_limits( | |||||
| View2DEdgePanData *vpd, float xmin, float xmax, float ymin, float ymax) | |||||
| { | |||||
| BLI_rctf_init(&vpd->limit, xmin, xmax, ymin, ymax); | |||||
| } | |||||
| void UI_view2d_edge_pan_reset(View2DEdgePanData *vpd) | void UI_view2d_edge_pan_reset(View2DEdgePanData *vpd) | ||||
| { | { | ||||
| vpd->edge_pan_start_time_x = 0.0; | vpd->edge_pan_start_time_x = 0.0; | ||||
| vpd->edge_pan_start_time_y = 0.0; | vpd->edge_pan_start_time_y = 0.0; | ||||
| vpd->edge_pan_last_time = PIL_check_seconds_timer(); | vpd->edge_pan_last_time = PIL_check_seconds_timer(); | ||||
| vpd->initial_rect = vpd->region->v2d.cur; | vpd->initial_rect = vpd->region->v2d.cur; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[2]) | ||||
| /* Check if we can actually start the edge pan (e.g. adding nodes outside the view will start | /* Check if we can actually start the edge pan (e.g. adding nodes outside the view will start | ||||
| * disabled). */ | * disabled). */ | ||||
| if (BLI_rcti_isect_pt_v(&inside_rect, xy)) { | if (BLI_rcti_isect_pt_v(&inside_rect, xy)) { | ||||
| /* We are inside once, can start. */ | /* We are inside once, can start. */ | ||||
| vpd->enabled = true; | vpd->enabled = true; | ||||
| } | } | ||||
| rctf *cur = &vpd->v2d->cur; | |||||
| rctf *limit = &vpd->limit; | |||||
| int pan_dir_x = 0; | int pan_dir_x = 0; | ||||
| int pan_dir_y = 0; | int pan_dir_y = 0; | ||||
| if (vpd->enabled && ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy))) { | if (vpd->enabled && ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy))) { | ||||
| /* Find whether the mouse is beyond X and Y edges. */ | /* Find whether the mouse is beyond X and Y edges. */ | ||||
| if (xy[0] > inside_rect.xmax) { | if (xy[0] > inside_rect.xmax && cur->xmax < limit->xmax) { | ||||
| pan_dir_x = 1; | pan_dir_x = 1; | ||||
| } | } | ||||
| else if (xy[0] < inside_rect.xmin) { | else if (xy[0] < inside_rect.xmin && cur->xmin > limit->xmin) { | ||||
| pan_dir_x = -1; | pan_dir_x = -1; | ||||
| } | } | ||||
| if (xy[1] > inside_rect.ymax) { | if (xy[1] > inside_rect.ymax && cur->ymax < limit->ymax) { | ||||
| pan_dir_y = 1; | pan_dir_y = 1; | ||||
| } | } | ||||
| else if (xy[1] < inside_rect.ymin) { | else if (xy[1] < inside_rect.ymin && cur->ymin > limit->ymin) { | ||||
| pan_dir_y = -1; | pan_dir_y = -1; | ||||
| } | } | ||||
| } | } | ||||
| const double current_time = PIL_check_seconds_timer(); | const double current_time = PIL_check_seconds_timer(); | ||||
| edge_pan_manage_delay_timers(vpd, pan_dir_x, pan_dir_y, current_time); | edge_pan_manage_delay_timers(vpd, pan_dir_x, pan_dir_y, current_time); | ||||
| /* Calculate the delta since the last time the operator was called. */ | /* Calculate the delta since the last time the operator was called. */ | ||||
| ▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines | |||||