- Local Markers are now taken into account correctly for operators
that used markers. I might've missed a few still, but at least a few more cases will work now - Accidentally broke keyframe selection on group channels in gpencil commit, after misreading a call name.
This commit is contained in:
@@ -86,6 +86,7 @@
|
|||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
|
|
||||||
#include "ED_anim_api.h"
|
#include "ED_anim_api.h"
|
||||||
|
#include "ED_markers.h"
|
||||||
|
|
||||||
/* ************************************************************ */
|
/* ************************************************************ */
|
||||||
/* Blender Context <-> Animation Context mapping */
|
/* Blender Context <-> Animation Context mapping */
|
||||||
@@ -306,7 +307,7 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
|
|||||||
/* get useful default context settings from context */
|
/* get useful default context settings from context */
|
||||||
ac->scene= scene;
|
ac->scene= scene;
|
||||||
if (scene) {
|
if (scene) {
|
||||||
ac->markers= &scene->markers;
|
ac->markers= ED_context_get_markers(C);
|
||||||
ac->obact= (scene->basact)? scene->basact->object : NULL;
|
ac->obact= (scene->basact)? scene->basact->object : NULL;
|
||||||
}
|
}
|
||||||
ac->sa= sa;
|
ac->sa= sa;
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
#include "UI_view2d.h"
|
#include "UI_view2d.h"
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
|
#include "ED_anim_api.h"
|
||||||
#include "ED_markers.h"
|
#include "ED_markers.h"
|
||||||
#include "ED_screen.h"
|
#include "ED_screen.h"
|
||||||
#include "ED_util.h"
|
#include "ED_util.h"
|
||||||
@@ -66,11 +67,11 @@
|
|||||||
|
|
||||||
/* ************* Marker API **************** */
|
/* ************* Marker API **************** */
|
||||||
|
|
||||||
static ListBase *context_get_markers(const bContext *C)
|
/* helper function for getting the list of markers to work on */
|
||||||
|
static ListBase *context_get_markers(Scene *scene, ScrArea *sa)
|
||||||
{
|
{
|
||||||
ScrArea *sa = CTX_wm_area(C);
|
|
||||||
|
|
||||||
/* local marker sets... */
|
/* local marker sets... */
|
||||||
|
if (sa) {
|
||||||
if (sa->spacetype == SPACE_ACTION) {
|
if (sa->spacetype == SPACE_ACTION) {
|
||||||
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
|
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
|
||||||
|
|
||||||
@@ -83,9 +84,27 @@ static ListBase *context_get_markers(const bContext *C)
|
|||||||
return &saction->action->markers;
|
return &saction->action->markers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* default to using the scene's markers */
|
/* default to using the scene's markers */
|
||||||
return &CTX_data_scene(C)->markers;
|
return &scene->markers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ............. */
|
||||||
|
|
||||||
|
/* public API for getting markers from context */
|
||||||
|
ListBase *ED_context_get_markers(const bContext *C)
|
||||||
|
{
|
||||||
|
return context_get_markers(CTX_data_scene(C), CTX_wm_area(C));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* public API for getting markers from "animation" context */
|
||||||
|
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
|
||||||
|
{
|
||||||
|
if (ac)
|
||||||
|
return context_get_markers(ac->scene, ac->sa);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------- */
|
/* --------------------------------- */
|
||||||
@@ -341,7 +360,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
|
|||||||
/* Draw Scene-Markers in time window */
|
/* Draw Scene-Markers in time window */
|
||||||
void draw_markers_time(const bContext *C, int flag)
|
void draw_markers_time(const bContext *C, int flag)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
View2D *v2d= UI_view2d_fromcontext(C);
|
View2D *v2d= UI_view2d_fromcontext(C);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
|
|
||||||
@@ -375,7 +394,7 @@ void draw_markers_time(const bContext *C, int flag)
|
|||||||
/* special poll() which checks if there are selected markers first */
|
/* special poll() which checks if there are selected markers first */
|
||||||
static int ed_markers_poll_selected_markers(bContext *C)
|
static int ed_markers_poll_selected_markers(bContext *C)
|
||||||
{
|
{
|
||||||
ListBase *markers = context_get_markers(C);
|
ListBase *markers = ED_context_get_markers(C);
|
||||||
|
|
||||||
/* first things first: markers can only exist in timeline views */
|
/* first things first: markers can only exist in timeline views */
|
||||||
if (ED_operator_animview_active(C) == 0)
|
if (ED_operator_animview_active(C) == 0)
|
||||||
@@ -444,7 +463,7 @@ static int ed_markers_opwrap_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
|||||||
/* add TimeMarker at curent frame */
|
/* add TimeMarker at curent frame */
|
||||||
static int ed_marker_add(bContext *C, wmOperator *UNUSED(op))
|
static int ed_marker_add(bContext *C, wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
int frame= CTX_data_scene(C)->r.cfra;
|
int frame= CTX_data_scene(C)->r.cfra;
|
||||||
|
|
||||||
@@ -527,7 +546,7 @@ typedef struct MarkerMove {
|
|||||||
/* return 0 if not OK */
|
/* return 0 if not OK */
|
||||||
static int ed_marker_move_init(bContext *C, wmOperator *op)
|
static int ed_marker_move_init(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
MarkerMove *mm;
|
MarkerMove *mm;
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
int totmark=0;
|
int totmark=0;
|
||||||
@@ -811,7 +830,7 @@ callbacks:
|
|||||||
/* duplicate selected TimeMarkers */
|
/* duplicate selected TimeMarkers */
|
||||||
static void ed_marker_duplicate_apply(bContext *C)
|
static void ed_marker_duplicate_apply(bContext *C)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker, *newmarker;
|
TimeMarker *marker, *newmarker;
|
||||||
|
|
||||||
if (markers == NULL)
|
if (markers == NULL)
|
||||||
@@ -906,7 +925,7 @@ static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned
|
|||||||
|
|
||||||
static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera)
|
static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
View2D *v2d= UI_view2d_fromcontext(C);
|
View2D *v2d= UI_view2d_fromcontext(C);
|
||||||
float viewx;
|
float viewx;
|
||||||
int x, y, cfra;
|
int x, y, cfra;
|
||||||
@@ -1027,7 +1046,7 @@ callbacks:
|
|||||||
static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
|
static int ed_marker_border_select_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
View2D *v2d= UI_view2d_fromcontext(C);
|
View2D *v2d= UI_view2d_fromcontext(C);
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
float xminf, xmaxf, yminf, ymaxf;
|
float xminf, xmaxf, yminf, ymaxf;
|
||||||
int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
|
int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
|
||||||
@@ -1092,7 +1111,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
|
static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
int action = RNA_enum_get(op->ptr, "action");
|
int action = RNA_enum_get(op->ptr, "action");
|
||||||
|
|
||||||
@@ -1147,7 +1166,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot)
|
|||||||
/* remove selected TimeMarkers */
|
/* remove selected TimeMarkers */
|
||||||
static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker, *nmarker;
|
TimeMarker *marker, *nmarker;
|
||||||
short changed= 0;
|
short changed= 0;
|
||||||
|
|
||||||
@@ -1198,7 +1217,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
|
|||||||
/* rename first selected TimeMarker */
|
/* rename first selected TimeMarker */
|
||||||
static int ed_marker_rename_exec(bContext *C, wmOperator *op)
|
static int ed_marker_rename_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
TimeMarker *marker= ED_markers_get_first_selected(context_get_markers(C));
|
TimeMarker *marker= ED_markers_get_first_selected(ED_context_get_markers(C));
|
||||||
|
|
||||||
if(marker) {
|
if(marker) {
|
||||||
RNA_string_get(op->ptr, "name", marker->name);
|
RNA_string_get(op->ptr, "name", marker->name);
|
||||||
@@ -1216,7 +1235,7 @@ static int ed_marker_rename_exec(bContext *C, wmOperator *op)
|
|||||||
static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt)
|
static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt)
|
||||||
{
|
{
|
||||||
/* must initialise the marker name first if there is a marker selected */
|
/* must initialise the marker name first if there is a marker selected */
|
||||||
TimeMarker *marker = ED_markers_get_first_selected(context_get_markers(C));
|
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
|
||||||
if (marker)
|
if (marker)
|
||||||
RNA_string_set(op->ptr, "name", marker->name);
|
RNA_string_set(op->ptr, "name", marker->name);
|
||||||
|
|
||||||
@@ -1248,7 +1267,7 @@ static void MARKER_OT_rename(wmOperatorType *ot)
|
|||||||
|
|
||||||
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
|
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
|
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
|
||||||
TimeMarker *marker, *marker_new;
|
TimeMarker *marker, *marker_new;
|
||||||
|
|
||||||
@@ -1306,7 +1325,7 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot)
|
|||||||
static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op))
|
static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
{
|
{
|
||||||
Scene *scene= CTX_data_scene(C);
|
Scene *scene= CTX_data_scene(C);
|
||||||
ListBase *markers= context_get_markers(C);
|
ListBase *markers= ED_context_get_markers(C);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
short changed= 0;
|
short changed= 0;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
struct wmKeyConfig;
|
struct wmKeyConfig;
|
||||||
struct bContext;
|
struct bContext;
|
||||||
|
struct bAnimContext;
|
||||||
struct TimeMarker;
|
struct TimeMarker;
|
||||||
|
|
||||||
/* Drawing API ------------------------------ */
|
/* Drawing API ------------------------------ */
|
||||||
@@ -44,6 +45,9 @@ void draw_markers_time(const struct bContext *C, int flag);
|
|||||||
|
|
||||||
/* Backend API ----------------------------- */
|
/* Backend API ----------------------------- */
|
||||||
|
|
||||||
|
ListBase *ED_context_get_markers(const struct bContext *C);
|
||||||
|
ListBase *ED_animcontext_get_markers(const struct bAnimContext *ac);
|
||||||
|
|
||||||
struct TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x);
|
struct TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x);
|
||||||
int ED_markers_find_nearest_marker_time(ListBase *markers, float x);
|
int ED_markers_find_nearest_marker_time(ListBase *markers, float x);
|
||||||
|
|
||||||
|
|||||||
@@ -744,10 +744,10 @@ static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short
|
|||||||
ked.f1= selx;
|
ked.f1= selx;
|
||||||
|
|
||||||
/* select the nominated keyframe on the given frame */
|
/* select the nominated keyframe on the given frame */
|
||||||
if (ale->type == ANIMTYPE_FCURVE)
|
if (ale->type == ANIMTYPE_GPLAYER)
|
||||||
ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, ds_filter);
|
|
||||||
else if (ale->type == ANIMTYPE_GPLAYER)
|
|
||||||
select_gpencil_frame(ale->data, selx, select_mode);
|
select_gpencil_frame(ale->data, selx, select_mode);
|
||||||
|
else
|
||||||
|
ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, ds_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
|
/* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */
|
||||||
@@ -806,14 +806,14 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sync marker support */
|
/* Sync marker support */
|
||||||
// FIXME: this doesn't work for local pose markers!
|
if ((select_mode==SELECT_ADD) && ELEM(leftright, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT)) {
|
||||||
if ((select_mode==SELECT_ADD) && (ac->spacetype==SPACE_ACTION) && ELEM(leftright, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT)) {
|
|
||||||
SpaceAction *saction= ac->sa->spacedata.first;
|
SpaceAction *saction= ac->sa->spacedata.first;
|
||||||
|
|
||||||
if (saction && (saction->flag & SACTION_MARKERS_MOVE)) {
|
if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) {
|
||||||
|
ListBase *markers = ED_animcontext_get_markers(ac);
|
||||||
TimeMarker *marker;
|
TimeMarker *marker;
|
||||||
|
|
||||||
for (marker= scene->markers.first; marker; marker= marker->next) {
|
for (marker= markers->first; marker; marker= marker->next) {
|
||||||
if( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) ||
|
if( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) ||
|
||||||
((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) )
|
((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user