[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34238] trunk/blender/source/blender/ editors: - Local Markers are now taken into account correctly for operators

Joshua Leung aligorith at gmail.com
Mon Jan 10 23:31:34 CET 2011


Revision: 34238
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34238
Author:   aligorith
Date:     2011-01-10 22:31:34 +0000 (Mon, 10 Jan 2011)
Log Message:
-----------
- 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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/animation/anim_markers.c
    trunk/blender/source/blender/editors/include/ED_markers.h
    trunk/blender/source/blender/editors/space_action/action_select.c

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c	2011-01-10 22:25:57 UTC (rev 34237)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c	2011-01-10 22:31:34 UTC (rev 34238)
@@ -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 @@
 	/* 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;

Modified: trunk/blender/source/blender/editors/animation/anim_markers.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_markers.c	2011-01-10 22:25:57 UTC (rev 34237)
+++ trunk/blender/source/blender/editors/animation/anim_markers.c	2011-01-10 22:31:34 UTC (rev 34238)
@@ -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,28 +67,46 @@
 
 /* ************* 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;
+}
+
 /* --------------------------------- */
 
 /* Get the marker that is closest to this point */
@@ -341,7 +360,7 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 @@
 /* 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 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 @@
 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 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 @@
 /* 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 @@
 /* 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_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 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 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;
 

Modified: trunk/blender/source/blender/editors/include/ED_markers.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_markers.h	2011-01-10 22:25:57 UTC (rev 34237)
+++ trunk/blender/source/blender/editors/include/ED_markers.h	2011-01-10 22:31:34 UTC (rev 34238)
@@ -30,6 +30,7 @@
 
 struct wmKeyConfig;
 struct bContext;
+struct bAnimContext;
 struct TimeMarker;
 
 /* Drawing API ------------------------------ */
@@ -44,6 +45,9 @@
 
 /* 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);
 

Modified: trunk/blender/source/blender/editors/space_action/action_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_select.c	2011-01-10 22:25:57 UTC (rev 34237)
+++ trunk/blender/source/blender/editors/space_action/action_select.c	2011-01-10 22:31:34 UTC (rev 34238)
@@ -744,10 +744,10 @@
 	ked.f1= selx;
 	
 	/* select the nominated keyframe on the given frame */
-	if (ale->type == ANIMTYPE_FCURVE)
+	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);
-	else if (ale->type == ANIMTYPE_GPLAYER)
-		select_gpencil_frame(ale->data, selx, select_mode);
 }
 
 /* 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 @@
 	}
 	
 	/* 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)) ) 
 				{




More information about the Bf-blender-cvs mailing list