Fix T50904: Imprecise timeline frame selection using mouse

The changes introduced in rB3e628eefa9f55fac7b0faaec4fd4392c2de6b20e
made the non-subframe frame change behaviour less intuitive, by always
truncating downwards, instead of rounding to the nearest frame instead.
This made the UI a lot less forgiving of pointing precision errors
(for example, as a result of hand shake, or using a tablet on a highres scren)

This commit restores the old behaviour in this case only (subframe inspection
isn't affected by these changes)
This commit is contained in:
Joshua Leung 2017-03-10 13:38:02 +13:00
parent 62cc226101
commit 17689f8bb6
Notes: blender-bot 2023-02-14 08:33:26 +01:00
Referenced by issue #50911, Broken user interface in render result window when image size matches screen resolution
Referenced by issue #50904, Imprecise timeline frame selection using mouse
1 changed files with 4 additions and 6 deletions

View File

@ -103,11 +103,12 @@ static void change_frame_apply(bContext *C, wmOperator *op)
}
/* set the new frame number */
CFRA = (int)frame;
if (scene->r.flag & SCER_SHOW_SUBFRAME) {
CFRA = (int)frame;
SUBFRA = frame - (int)frame;
}
else {
CFRA = iroundf(frame);
SUBFRA = 0.0f;
}
FRAMENUMBER_MIN_CLAMP(CFRA);
@ -134,15 +135,12 @@ static float frame_from_event(bContext *C, const wmEvent *event)
{
ARegion *region = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
float viewx;
float frame;
/* convert from region coordinates to View2D 'tot' space */
viewx = UI_view2d_region_to_view_x(&region->v2d, event->mval[0]);
/* round result to nearest int (frames are ints!) */
frame = viewx;
frame = UI_view2d_region_to_view_x(&region->v2d, event->mval[0]);
/* respect preview range restrictions (if only allowed to move around within that range) */
if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
CLAMP(frame, PSFRA, PEFRA);
}