diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-01-11 01:31:34 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-01-11 01:31:34 +0300 |
commit | ac4eb52abfafe1ca44dbaa1f20b356e272a3daf9 (patch) | |
tree | cbff57a36ea93e8e267351babde4c5f93e2bc94a /source/blender | |
parent | cf25b10eb5bb61662ce0db6b3ef54a3e3e73a328 (diff) |
- 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.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 3 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 73 | ||||
-rw-r--r-- | source/blender/editors/include/ED_markers.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 14 |
4 files changed, 59 insertions, 35 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 1d54a7e5195..c917797b942 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -86,6 +86,7 @@ #include "BKE_utildefines.h" #include "ED_anim_api.h" +#include "ED_markers.h" /* ************************************************************ */ /* 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 */ ac->scene= scene; if (scene) { - ac->markers= &scene->markers; + ac->markers= ED_context_get_markers(C); ac->obact= (scene->basact)? scene->basact->object : NULL; } ac->sa= sa; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 0a2df6afdcb..37943b26827 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -57,6 +57,7 @@ #include "UI_view2d.h" #include "UI_resources.h" +#include "ED_anim_api.h" #include "ED_markers.h" #include "ED_screen.h" #include "ED_util.h" @@ -66,26 +67,44 @@ /* ************* 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... */ - if (sa->spacetype == SPACE_ACTION) { - SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - - /* local markers can only be shown when there's only a single active action to grab them from - * - flag only takes effect when there's an action, otherwise it can get too confusing? - */ - if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) - { - if (saction->flag & SACTION_POSEMARKERS_SHOW) - return &saction->action->markers; + if (sa) { + if (sa->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction *)sa->spacedata.first; + + /* local markers can only be shown when there's only a single active action to grab them from + * - flag only takes effect when there's an action, otherwise it can get too confusing? + */ + if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) + { + if (saction->flag & SACTION_POSEMARKERS_SHOW) + return &saction->action->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 */ 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); 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 */ 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 */ 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 */ 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; int frame= CTX_data_scene(C)->r.cfra; @@ -527,7 +546,7 @@ typedef struct MarkerMove { /* return 0 if not OK */ 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; TimeMarker *marker; int totmark=0; @@ -811,7 +830,7 @@ callbacks: /* duplicate selected TimeMarkers */ static void ed_marker_duplicate_apply(bContext *C) { - ListBase *markers= context_get_markers(C); + ListBase *markers= ED_context_get_markers(C); TimeMarker *marker, *newmarker; 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) { - ListBase *markers= context_get_markers(C); + ListBase *markers= ED_context_get_markers(C); View2D *v2d= UI_view2d_fromcontext(C); float viewx; int x, y, cfra; @@ -1027,7 +1046,7 @@ callbacks: static int ed_marker_border_select_exec(bContext *C, wmOperator *op) { View2D *v2d= UI_view2d_fromcontext(C); - ListBase *markers= context_get_markers(C); + ListBase *markers= ED_context_get_markers(C); TimeMarker *marker; float xminf, xmaxf, yminf, ymaxf; 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) { - ListBase *markers= context_get_markers(C); + ListBase *markers= ED_context_get_markers(C); TimeMarker *marker; int action = RNA_enum_get(op->ptr, "action"); @@ -1147,7 +1166,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /* remove selected TimeMarkers */ 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; short changed= 0; @@ -1198,7 +1217,7 @@ static void MARKER_OT_delete(wmOperatorType *ot) /* rename first selected TimeMarker */ 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) { 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) { /* 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) 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) { - 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")); 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)) { Scene *scene= CTX_data_scene(C); - ListBase *markers= context_get_markers(C); + ListBase *markers= ED_context_get_markers(C); TimeMarker *marker; short changed= 0; diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index b32fc1a48ef..22c171128bd 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -30,6 +30,7 @@ struct wmKeyConfig; struct bContext; +struct bAnimContext; struct TimeMarker; /* Drawing API ------------------------------ */ @@ -44,6 +45,9 @@ void draw_markers_time(const struct bContext *C, int flag); /* 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); int ED_markers_find_nearest_marker_time(ListBase *markers, float x); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index ea9ef7f8ee6..1ae26421152 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -744,10 +744,10 @@ static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short ked.f1= selx; /* select the nominated keyframe on the given frame */ - if (ale->type == ANIMTYPE_FCURVE) - ANIM_animchannel_keyframes_loop(&ked, ale, ok_cb, select_cb, NULL, ds_filter); - else if (ale->type == ANIMTYPE_GPLAYER) + if (ale->type == ANIMTYPE_GPLAYER) 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) */ @@ -806,14 +806,14 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short } /* Sync marker support */ - // FIXME: this doesn't work for local pose markers! - if ((select_mode==SELECT_ADD) && (ac->spacetype==SPACE_ACTION) && ELEM(leftright, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT)) { + if ((select_mode==SELECT_ADD) && ELEM(leftright, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT)) { 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; - 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)) || ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) { |