diff options
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r-- | source/blender/editors/space_action/action_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 51 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_header.c | 104 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_ops.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_select.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_action/space_action.c | 9 |
7 files changed, 119 insertions, 110 deletions
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 4288cc10a26..7181a6b5aa1 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -260,6 +260,13 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { switch (ale->type) { + case ANIMTYPE_SUMMARY: + { + // FIXME: hardcoded colours - reddish color from NLA + glColor4f(0.8f, 0.2f, 0.0f, 0.4f); + } + break; + case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: { @@ -351,6 +358,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { + case ALE_ALL: + draw_summary_channel(v2d, ale->data, y); + break; case ALE_SCE: draw_scene_channel(v2d, ads, ale->key_data, y); break; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 89633d0cdfe..0bcf4b037cb 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -86,9 +86,60 @@ #include "WM_api.h" #include "WM_types.h" +#include "UI_interface.h" + #include "action_intern.h" /* ************************************************************************** */ +/* ACTION MANAGEMENT */ + +/* ******************** New Action Operator *********************** */ + +static int act_new_exec(bContext *C, wmOperator *op) +{ + bAction *action; + PointerRNA ptr, idptr; + PropertyRNA *prop; + + // XXX need to restore behaviour to copy old actions... + action= add_empty_action("Action"); + + /* hook into UI */ + uiIDContextProperty(C, &ptr, &prop); + + if(prop) { + /* when creating new ID blocks, use is already 1, but RNA + * pointer se also increases user, so this compensates it */ + action->id.us--; + + RNA_id_pointer_create(&action->id, &idptr); + RNA_property_pointer_set(&ptr, prop, idptr); + RNA_property_update(C, &ptr, prop); + } + + /* 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; + // NOTE: this is used in the NLA too... + //ot->poll= ED_operator_action_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* ************************************************************************** */ /* KEYFRAME-RANGE STUFF */ /* *************************** Calculate Range ************************** */ diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c index 8674f481a18..ba5fc0893ec 100644 --- a/source/blender/editors/space_action/action_header.c +++ b/source/blender/editors/space_action/action_header.c @@ -68,7 +68,7 @@ #include "action_intern.h" enum { - B_REDR= 0, + B_REDR= 1, } eActHeader_Events; /* ********************************************************* */ @@ -189,6 +189,7 @@ static void act_edit_keytypesmenu(bContext *C, uiLayout *layout, void *arg_unuse uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); uiItemEnumO(layout, NULL, 0, "ACT_OT_keyframe_type", "type", BEZT_KEYTYPE_KEYFRAME); uiItemEnumO(layout, NULL, 0, "ACT_OT_keyframe_type", "type", BEZT_KEYTYPE_BREAKDOWN); + uiItemEnumO(layout, NULL, 0, "ACT_OT_keyframe_type", "type", BEZT_KEYTYPE_EXTREME); } static void act_edit_handlesmenu(bContext *C, uiLayout *layout, void *arg_unused) @@ -253,66 +254,8 @@ static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) static void do_action_buttons(bContext *C, void *arg, int event) { - switch (event) { - case B_REDR: - ED_area_tag_redraw(CTX_wm_area(C)); - break; - } -} - -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; - } + ED_area_tag_refresh(CTX_wm_area(C)); + ED_area_tag_redraw(CTX_wm_area(C)); } void action_header_buttons(const bContext *C, ARegion *ar) @@ -383,35 +326,28 @@ void action_header_buttons(const bContext *C, ARegion *ar) xco += (90 + 8); + /* SUMMARY CHANNEL */ + uiDefIconTextButBitI(block, TOG, ADS_FILTER_SUMMARY, B_REDR, ICON_BORDERMOVE, "Summary", xco,yco,XIC*4,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Include DopeSheet summary row"); // TODO: needs a better icon + xco += (XIC*4.5); + /*if (ac.data)*/ { /* MODE-DEPENDENT DRAWING */ if (saction->mode == SACTCONT_DOPESHEET) { /* FILTERING OPTIONS */ - xco -= 10; - - //uiBlockBeginAlign(block); - uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Only display selected Objects"); - //uiBlockEndAlign(block); - xco += 5; - - uiBlockBeginAlign(block); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Scene Animation"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display World Animation"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display ShapeKeys"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Materials"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Lamps"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Cameras"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Curves"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display MetaBalls"); - uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Display Particles"); - uiBlockEndAlign(block); - xco += 30; + xco -= XIC; // XXX first button incurs this offset... + xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco); } 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(block, &xco, NULL); xco += 8; } @@ -443,7 +379,7 @@ void action_header_buttons(const bContext *C, ARegion *ar) xco += (XIC + 8); } - /* always as last */ + /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); uiEndBlock(C, block); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index e5f0ab8994e..c436475b537 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) */ @@ -122,7 +124,7 @@ enum { /* ***************************************** */ /* action_ops.c */ void action_operatortypes(void); -void action_keymap(struct wmWindowManager *wm); +void action_keymap(struct wmKeyConfig *keyconf); #endif /* ED_ACTION_INTERN_H */ diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 42b033040b1..ba504fa8a69 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); @@ -90,9 +91,9 @@ void action_operatortypes(void) /* ************************** registration - keymaps **********************************/ -static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) +static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) { - wmKeymapItem *kmi; + wmKeyMapItem *kmi; /* action_select.c - selection tools */ /* click-select */ @@ -155,7 +156,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) WM_keymap_add_item(keymap, "ACT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); /* transform system */ - transform_keymap_for_space(wm, keymap, SPACE_ACTION); + transform_keymap_for_space(keyconf, keymap, SPACE_ACTION); /* test */ /* WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0); */ @@ -163,9 +164,9 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap) /* --------------- */ -void action_keymap(wmWindowManager *wm) +void action_keymap(wmKeyConfig *keyconf) { - ListBase *keymap; + wmKeyMap *keymap; /* channels */ /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. @@ -174,7 +175,7 @@ void action_keymap(wmWindowManager *wm) */ /* keyframes */ - keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0); - action_keymap_keyframes(wm, keymap); + keymap= WM_keymap_find(keyconf, "Action_Keys", SPACE_ACTION, 0); + action_keymap_keyframes(keyconf, keymap); } diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index e358f559b14..c945f41bc55 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -219,7 +219,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; + int filter, filterflag; BeztEditData bed; BeztEditFunc ok_cb, select_cb; @@ -235,6 +235,14 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + /* get filtering flag for dopesheet data (if applicable) */ + if (ac->datatype == ANIMCONT_DOPESHEET) { + bDopeSheet *ads= (bDopeSheet *)ac->data; + filterflag= ads->filterflag; + } + else + filterflag= 0; + /* get beztriple editing/validation funcs */ select_cb= ANIM_editkeyframes_select(selectmode); @@ -271,20 +279,10 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting */ - if (ale->key_data) { - if (ale->datatype == ALE_FCURVE) - ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL); - } - else if (ale->type == ANIMTYPE_GROUP) { - bActionGroup *agrp= ale->data; - FCurve *fcu; - - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) - ANIM_fcurve_keys_bezier_loop(&bed, fcu, ok_cb, select_cb, NULL); - } - //else if (ale->type == ANIMTYPE_GPLAYER) { + //if (ale->type == ANIMTYPE_GPLAYER) // borderselect_gplayer_frames(ale->data, rectf.xmin, rectf.xmax, selectmode); - //} + //else + ANIM_animchannel_keys_bezier_loop(&bed, ale, ok_cb, select_cb, NULL, filterflag); } /* set minimum extent to be the maximum of the next channel */ @@ -792,6 +790,12 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode, if (ale->key_data) { switch (ale->datatype) { + case ALE_SCE: + { + Scene *scene= (Scene *)ale->key_data; + scene_to_keylist(ads, scene, &anim_keys, NULL); + } + break; case ALE_OB: { Object *ob= (Object *)ale->key_data; @@ -812,6 +816,10 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode, break; } } + else if (ale->type == ANIMTYPE_SUMMARY) { + /* dopesheet summary covers everything */ + summary_to_keylist(ac, &anim_keys, NULL); + } else if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp= (bActionGroup *)ale->data; agroup_to_keylist(adt, agrp, &anim_keys, NULL); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index b7a3df563ea..07de15a26b4 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -153,12 +153,12 @@ static SpaceLink *action_duplicate(SpaceLink *sl) /* add handlers, stuff you only do once or on area/region changes */ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0); /* XXX weak? */ + keymap= WM_keymap_find(wm->defaultconf, "Action_Keys", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -216,12 +216,12 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void action_channel_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - keymap= WM_keymap_listbase(wm, "Animation_Channels", 0, 0); /* XXX weak? */ + keymap= WM_keymap_find(wm->defaultconf, "Animation_Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -323,6 +323,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCENE: switch(wmn->data) { + case ND_RENDER_OPTIONS: case ND_OB_ACTIVE: case ND_FRAME: case ND_MARKERS: |