Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/view2d_edge_pan.c
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | void UI_view2d_edge_pan_init(bContext *C, | ||||
| 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; | |||||
| /* 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); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[2]) | ||||
| inside_rect = region->winrct; | inside_rect = region->winrct; | ||||
| outside_rect = region->winrct; | outside_rect = region->winrct; | ||||
| BLI_rcti_pad(&inside_rect, -vpd->inside_pad * U.widget_unit, -vpd->inside_pad * U.widget_unit); | BLI_rcti_pad(&inside_rect, -vpd->inside_pad * U.widget_unit, -vpd->inside_pad * U.widget_unit); | ||||
| BLI_rcti_pad(&outside_rect, vpd->outside_pad * U.widget_unit, vpd->outside_pad * U.widget_unit); | BLI_rcti_pad(&outside_rect, vpd->outside_pad * U.widget_unit, vpd->outside_pad * U.widget_unit); | ||||
| int pan_dir_x = 0; | int pan_dir_x = 0; | ||||
| int pan_dir_y = 0; | int pan_dir_y = 0; | ||||
| if ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy)) { | if ((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, also check if we can actually start the edge | ||||
| * pan (e.g. adding nodes outside the view will start disabled). */ | |||||
| if (xy[0] > inside_rect.xmax) { | if (xy[0] > inside_rect.xmax) { | ||||
| pan_dir_x = 1; | pan_dir_x = vpd->enabled ? 1 : 0; | ||||
| } | } | ||||
| else if (xy[0] < inside_rect.xmin) { | else if (xy[0] < inside_rect.xmin) { | ||||
| pan_dir_x = -1; | pan_dir_x = vpd->enabled ? -1 : 0; | ||||
| } | } | ||||
| if (xy[1] > inside_rect.ymax) { | if (xy[1] > inside_rect.ymax) { | ||||
| pan_dir_y = 1; | pan_dir_y = vpd->enabled ? 1 : 0; | ||||
| } | } | ||||
| else if (xy[1] < inside_rect.ymin) { | else if (xy[1] < inside_rect.ymin) { | ||||
| pan_dir_y = -1; | pan_dir_y = vpd->enabled ? -1 : 0; | ||||
HooglyBoogly: These could be replaced with a check later:
```
if (!vpd->enabled) {
return;
} | |||||
lichtwerkAuthorUnsubmitted Done Inline ActionsThink we cannot return right away due to the timers? (but havent checked in full depth), committed with slightly different approach lichtwerk: Think we cannot return right away due to the timers? (but havent checked in full depth)… | |||||
HooglyBooglyUnsubmitted Not Done Inline ActionsAh, you're right, sorry. What you committed looks good. HooglyBoogly: Ah, you're right, sorry. What you committed looks good. | |||||
| } | |||||
| else { | |||||
| /* We are inside once, can start. */ | |||||
| vpd->enabled = true; | |||||
| } | } | ||||
| } | } | ||||
| 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. */ | ||||
| const float dtime = (float)(current_time - vpd->edge_pan_last_time); | const float dtime = (float)(current_time - vpd->edge_pan_last_time); | ||||
| ▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines | |||||
These could be replaced with a check later:
if (!vpd->enabled) { return; }