[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23284] trunk/blender/source/blender: UI: action editor header now also uses template for browsing action

Brecht Van Lommel brecht at blender.org
Wed Sep 16 20:32:11 CEST 2009


Revision: 23284
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23284
Author:   blendix
Date:     2009-09-16 20:32:10 +0200 (Wed, 16 Sep 2009)

Log Message:
-----------
UI: action editor header now also uses template for browsing action
datablocks, was last place using deprecated uiDefIDPoinButs.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/editors/space_action/action_header.c
    trunk/blender/source/blender/editors/space_action/action_intern.h
    trunk/blender/source/blender/editors/space_action/action_ops.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_edit.c	2009-09-16 18:32:03 UTC (rev 23283)
+++ trunk/blender/source/blender/editors/space_action/action_edit.c	2009-09-16 18:32:10 UTC (rev 23284)
@@ -1331,4 +1331,38 @@
 	RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", "");
 }
 
+/* ******************** New Action Operator *********************** */
+
+static int act_new_exec(bContext *C, wmOperator *op)
+{
+	bAction *action;
+
+	// XXX need to restore behaviour to copy old actions...
+	action= add_empty_action("Action");
+
+	/* combined with RNA property, this will assign & increase user,
+	   so decrease here to compensate for that */
+	action->id.us--;
+	
+	/* set notifier that keyframes have changed */
+	WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+	
+	return OPERATOR_FINISHED;
+}
+ 
+void ACT_OT_new (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "New";
+	ot->idname= "ACT_OT_new";
+	ot->description= "Create new action.";
+	
+	/* api callbacks */
+	ot->exec= act_new_exec;
+	ot->poll= ED_operator_action_active;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* ************************************************************************** */

Modified: trunk/blender/source/blender/editors/space_action/action_header.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_header.c	2009-09-16 18:32:03 UTC (rev 23283)
+++ trunk/blender/source/blender/editors/space_action/action_header.c	2009-09-16 18:32:10 UTC (rev 23284)
@@ -260,61 +260,6 @@
 	}
 }
 
-static void saction_idpoin_handle(bContext *C, ID *id, int event)
-{
-	SpaceAction *saction= CTX_wm_space_action(C);
-	Object *obact= CTX_data_active_object(C);
-	
-	printf("actedit do id: \n");
-	
-	switch (event) {
-		case UI_ID_BROWSE:
-			printf("browse \n");
-		case UI_ID_DELETE:
-			printf("browse or delete \n");
-			saction->action= (bAction*)id;
-			
-			/* we must set this action to be the one used by active object (if not pinned) */
-			if (saction->pin == 0) {
-				AnimData *adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */
-				
-				/* set action */
-				printf("\tset action \n");
-				adt->action= saction->action;
-				adt->action->id.us++;
-			}
-			
-			ED_area_tag_redraw(CTX_wm_area(C));
-			ED_undo_push(C, "Assign Action");
-			break;
-		case UI_ID_RENAME:
-			printf("actedit rename \n");
-			break;
-		case UI_ID_ADD_NEW:
-			printf("actedit addnew \n");
-			if (saction->pin == 0) {
-				AnimData *adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */
-				
-				/* set new action */
-				// XXX need to restore behaviour to copy old actions...
-				printf("\tset new action \n");
-				adt->action= saction->action= add_empty_action("Action");
-			}
-			break;
-		case UI_ID_OPEN:
-			printf("actedit open \n");
-			/* XXX not implemented */
-			break;
-		case UI_ID_ALONE:
-			printf("actedit alone \n");
-			/* XXX not implemented */
-			break;
-		case UI_ID_PIN:
-			printf("actedit pin \n");
-			break;
-	}
-}
-
 void action_header_buttons(const bContext *C, ARegion *ar)
 {
 	ScrArea *sa= CTX_wm_area(C);
@@ -409,10 +354,16 @@
 			xco += 30;
 		}
 		else if (saction->mode == SACTCONT_ACTION) {
-			/* NAME ETC  */
-			xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)saction->action, ID_AC, &saction->pin, xco, yco,
-				saction_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_DELETE|UI_ID_FAKE_USER|UI_ID_ALONE|UI_ID_PIN);
+			uiLayout *layout;
+			bScreen *sc= CTX_wm_screen(C);
+			PointerRNA ptr;
+
+			RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, saction, &ptr);
 			
+			layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first);
+			uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACT_OT_new", NULL, NULL);
+			uiBlockLayoutResolve(C, block, &xco, NULL);
+			
 			xco += 8;
 		}
 		

Modified: trunk/blender/source/blender/editors/space_action/action_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_intern.h	2009-09-16 18:32:03 UTC (rev 23283)
+++ trunk/blender/source/blender/editors/space_action/action_intern.h	2009-09-16 18:32:10 UTC (rev 23284)
@@ -99,6 +99,8 @@
 void ACT_OT_snap(struct wmOperatorType *ot);
 void ACT_OT_mirror(struct wmOperatorType *ot);
 
+void ACT_OT_new(struct wmOperatorType *ot);
+
 /* defines for snap keyframes 
  * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h)
  */

Modified: trunk/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_ops.c	2009-09-16 18:32:03 UTC (rev 23283)
+++ trunk/blender/source/blender/editors/space_action/action_ops.c	2009-09-16 18:32:10 UTC (rev 23284)
@@ -83,6 +83,7 @@
 	WM_operatortype_append(ACT_OT_insert_keyframe);
 	WM_operatortype_append(ACT_OT_copy);
 	WM_operatortype_append(ACT_OT_paste);
+	WM_operatortype_append(ACT_OT_new);
 	
 	WM_operatortype_append(ACT_OT_previewrange_set);
 	WM_operatortype_append(ACT_OT_view_all);

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-09-16 18:32:03 UTC (rev 23283)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-09-16 18:32:10 UTC (rev 23284)
@@ -38,8 +38,7 @@
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
 
-#include "BKE_paint.h"
-
+#include "WM_api.h"
 #include "WM_types.h"
 
 EnumPropertyItem space_type_items[] = {
@@ -80,11 +79,15 @@
 
 #ifdef RNA_RUNTIME
 
+#include "DNA_anim_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 
+#include "BKE_animsys.h"
 #include "BKE_brush.h"
+#include "BKE_colortools.h"
 #include "BKE_context.h"
+#include "BKE_paint.h"
 
 #include "ED_image.h"
 #include "ED_screen.h"
@@ -227,13 +230,6 @@
 	st->top= 0;
 }
 
-static void rna_SpaceFileBrowser_params_set(PointerRNA *ptr, PointerRNA value)
-{
-	SpaceFile *sfile= (SpaceFile*)(ptr->data);
-
-	sfile->params= value.data;
-}
-
 /* Space Properties */
 
 static StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr)
@@ -311,12 +307,36 @@
 }
 
 /* Space Time */
+
 static void rna_SpaceTime_redraw_update(bContext *C, PointerRNA *ptr)
 {
 	SpaceTime *st= (SpaceTime*)ptr->data;
 	ED_screen_animation_timer_update(C, st->redraws);
 }
 
+/* Space Dopesheet */
+
+static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA value)
+{
+	SpaceAction *saction= (SpaceAction*)(ptr->data);
+	saction->action= value.data;
+}
+
+static void rna_SpaceDopeSheetEditor_action_update(bContext *C, PointerRNA *ptr)
+{
+	SpaceAction *saction= (SpaceAction*)(ptr->data);
+	Object *obact= CTX_data_active_object(C);
+
+	/* we must set this action to be the one used by active object (if not pinned) */
+	if(obact && saction->pin == 0) {
+		AnimData *adt= BKE_id_add_animdata(&obact->id); /* this only adds if non-existant */
+		
+		/* set action */
+		adt->action= saction->action;
+		id_us_plus(&adt->action->id);
+	}
+}
+
 #else
 
 static void rna_def_space(BlenderRNA *brna)
@@ -1039,6 +1059,13 @@
 	srna= RNA_def_struct(brna, "SpaceDopeSheetEditor", "Space");
 	RNA_def_struct_sdna(srna, "SpaceAction");
 	RNA_def_struct_ui_text(srna, "Space DopeSheet Editor", "DopeSheet space data.");
+
+	/* data */
+	prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceDopeSheetEditor_action_set", NULL);
+	RNA_def_property_ui_text(prop, "Action", "Action displayed and edited in this space.");
+	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_DOPESHEET, "rna_SpaceDopeSheetEditor_action_update");
 	
 	/* mode */
 	prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
@@ -1425,7 +1452,6 @@
 
 	prop= RNA_def_property(srna, "params", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "params");
-	RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceFileBrowser_params_set", NULL);
 	RNA_def_property_ui_text(prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser.");
 }
 





More information about the Bf-blender-cvs mailing list