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:
authorJoshua Leung <aligorith@gmail.com>2015-02-28 02:42:10 +0300
committerJoshua Leung <aligorith@gmail.com>2015-02-28 16:34:48 +0300
commit7c611e22049bb92f6efbbc1e2337fbfe22f841c4 (patch)
tree508d49f4266b54e75dbf2082ac303216f74cf3f3 /source/blender/editors/space_action
parent2b51eab69dff5bc97a1621c87b6c79be78fcdb84 (diff)
Code Cleanup: Deduplicate logic for getting AnimData block associated with Action Editor modes
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r--source/blender/editors/space_action/action_edit.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 4607d6e528d..c4ed44c91f5 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -83,6 +83,26 @@
/* ************************************************************************** */
/* ACTION MANAGEMENT */
+/* Helper function to find the active AnimData block from the Action Editor context */
+static AnimData *actedit_animdata_from_context(bContext *C)
+{
+ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
+ Object *ob = CTX_data_active_object(C);
+ AnimData *adt = NULL;
+
+ /* Get AnimData block to use */
+ if (saction->mode == SACTCONT_ACTION) {
+ /* Currently, "Action Editor" means object-level only... */
+ adt = ob->adt;
+ }
+ else if (saction->mode == SACTCONT_SHAPEKEY) {
+ Key *key = BKE_key_from_object(ob);
+ adt = key->adt;
+ }
+
+ return adt;
+}
+
/* Create new action */
static bAction *action_create_new(bContext *C, bAction *oldact)
{
@@ -230,18 +250,7 @@ static int action_pushdown_poll(bContext *C)
static int action_pushdown_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Object *ob = CTX_data_active_object(C);
- AnimData *adt = NULL;
-
- /* Get AnimData block to use */
- if (saction->mode == SACTCONT_ACTION) {
- /* Currently, "Action Editor" means object-level only... */
- adt = ob->adt;
- }
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
- adt = key->adt;
- }
+ AnimData *adt = actedit_animdata_from_context(C);
/* Do the deed... */
if (adt) {
@@ -289,18 +298,7 @@ void ACTION_OT_push_down(wmOperatorType *ot)
static int action_stash_exec(bContext *C, wmOperator *op)
{
SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C);
- Object *ob = CTX_data_active_object(C);
- AnimData *adt = NULL;
-
- /* Get AnimData block to use */
- if (saction->mode == SACTCONT_ACTION) {
- /* Currently, "Action Editor" means object-level only... */
- adt = ob->adt;
- }
- else if (saction->mode == SACTCONT_SHAPEKEY) {
- Key *key = BKE_key_from_object(ob);
- adt = key->adt;
- }
+ AnimData *adt = actedit_animdata_from_context(C);
/* Perform stashing operation */
if (adt) {