Use Ctrl Snap to seconds w/ play-head drag
D3056 by @alourenco
This commit is contained in:
parent
9c960557a7
commit
f4379f8b91
@ -114,6 +114,8 @@ int BKE_scene_camera_switch_update(struct Scene *scene);
|
||||
char *BKE_scene_find_marker_name(struct Scene *scene, int frame);
|
||||
char *BKE_scene_find_last_marker_name(struct Scene *scene, int frame);
|
||||
|
||||
int BKE_scene_frame_snap_by_seconds(struct Scene *scene, double interval_in_seconds, int cfra);
|
||||
|
||||
/* checks for cycle, returns 1 if it's all OK */
|
||||
bool BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce);
|
||||
|
||||
|
@ -1204,6 +1204,16 @@ char *BKE_scene_find_last_marker_name(Scene *scene, int frame)
|
||||
return best_marker ? best_marker->name : NULL;
|
||||
}
|
||||
|
||||
int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, int cfra)
|
||||
{
|
||||
const int fps = round_db_to_int(FPS * interval_in_seconds);
|
||||
const int second_prev = cfra - mod_i(cfra, fps);
|
||||
const int second_next = second_prev + fps;
|
||||
const int delta_prev = cfra - second_prev;
|
||||
const int delta_next = second_next - cfra;
|
||||
return (delta_prev < delta_next) ? second_prev : second_next;
|
||||
}
|
||||
|
||||
|
||||
Base *BKE_scene_base_add(Scene *sce, Object *ob)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_sound.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "UI_view2d.h"
|
||||
|
||||
@ -98,8 +99,13 @@ static void change_frame_apply(bContext *C, wmOperator *op)
|
||||
float frame = RNA_float_get(op->ptr, "frame");
|
||||
bool do_snap = RNA_boolean_get(op->ptr, "snap");
|
||||
|
||||
if (do_snap && CTX_wm_space_seq(C)) {
|
||||
frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false);
|
||||
if (do_snap) {
|
||||
if (CTX_wm_space_seq(C)) {
|
||||
frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false);
|
||||
}
|
||||
else {
|
||||
frame = BKE_scene_frame_snap_by_seconds(scene, 1.0, frame);
|
||||
}
|
||||
}
|
||||
|
||||
/* set the new frame number */
|
||||
|
Loading…
Reference in New Issue
Block a user