Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-16 22:32:10 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-16 22:32:10 +0400
commitde59f34be0a2da17a90950aef1c87a0bb6c74052 (patch)
treebbf151a8041f8cf004324c63ab5e2a0c2684d9f6 /source/blender/editors
parent6b5ce9366d176a753348fcf1f2753f76cd164a2f (diff)
UI: action editor header now also uses template for browsing action
datablocks, was last place using deprecated uiDefIDPoinButs.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_action/action_edit.c34
-rw-r--r--source/blender/editors/space_action/action_header.c67
-rw-r--r--source/blender/editors/space_action/action_intern.h2
-rw-r--r--source/blender/editors/space_action/action_ops.c1
4 files changed, 46 insertions, 58 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 89633d0cdfe..9e05c482ecb 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1331,4 +1331,38 @@ void ACT_OT_mirror (wmOperatorType *ot)
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;
+}
+
/* ************************************************************************** */
diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c
index 8674f481a18..57546d440b0 100644
--- a/source/blender/editors/space_action/action_header.c
+++ b/source/blender/editors/space_action/action_header.c
@@ -260,61 +260,6 @@ static void do_action_buttons(bContext *C, void *arg, int event)
}
}
-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,9 +354,15 @@ void action_header_buttons(const bContext *C, ARegion *ar)
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;
}
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index e5f0ab8994e..4326bed62d3 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -99,6 +99,8 @@ void ACT_OT_frame_jump(struct wmOperatorType *ot);
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)
*/
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 42b033040b1..cd4a7b30eff 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -83,6 +83,7 @@ void action_operatortypes(void)
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);