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:
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r--source/blender/editors/space_action/action_edit.c86
1 files changed, 76 insertions, 10 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 6e040371037..92e727fc2d7 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -42,7 +42,6 @@
#include "DNA_anim_types.h"
#include "DNA_gpencil_types.h"
-#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_mask_types.h"
@@ -65,7 +64,6 @@
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
#include "ED_screen.h"
-#include "ED_transform.h"
#include "ED_markers.h"
#include "ED_mask.h"
@@ -122,7 +120,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op))
}
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -364,7 +362,60 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot)
/* ****************** View-All Operator ****************** */
-static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xaxis)
+/* Find the extents of the active channel
+ * > min: (float) bottom y-extent of channel
+ * > max: (float) top y-extent of channel
+ * > returns: success of finding a selected channel
+ */
+static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, float *max)
+{
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */
+ float y;
+
+ /* get all items - we need to do it this way */
+ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+
+ /* loop through all channels, finding the first one that's selected */
+ y = (float)ACHANNEL_FIRST;
+
+ for (ale = anim_data.first; ale; ale = ale->next) {
+ bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
+
+ /* must be selected... */
+ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
+ ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT))
+ {
+ /* update best estimate */
+ *min = (float)(y - ACHANNEL_HEIGHT_HALF);
+ *max = (float)(y + ACHANNEL_HEIGHT_HALF);
+
+ /* is this high enough priority yet? */
+ found = acf->channel_role;
+
+ /* only stop our search when we've found an actual channel
+ * - datablock expanders get less priority so that we don't abort prematurely
+ */
+ if (found == ACHANNEL_ROLE_CHANNEL) {
+ break;
+ }
+ }
+
+ /* adjust y-position for next one */
+ y -= ACHANNEL_STEP;
+ }
+
+ /* free all temp data */
+ BLI_freelistN(&anim_data);
+
+ return (found != 0);
+}
+
+static int actkeys_viewall(bContext *C, const bool only_sel)
{
bAnimContext ac;
View2D *v2d;
@@ -390,10 +441,25 @@ static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xax
v2d->cur.xmax += extra;
/* set vertical range */
- if (only_xaxis == false) {
+ if (only_sel == false) {
+ /* view all -> the summary channel is usually the shows everything, and resides right at the top... */
v2d->cur.ymax = 0.0f;
v2d->cur.ymin = (float)-BLI_rcti_size_y(&v2d->mask);
}
+ else {
+ /* locate first selected channel (or the active one), and frame those */
+ float ymin = v2d->cur.ymin;
+ float ymax = v2d->cur.ymax;
+
+ if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) {
+ /* recenter the view so that this range is in the middle */
+ float ymid = (ymax - ymin) / 2.0f + ymin;
+ float x_center;
+
+ UI_view2d_center_get(v2d, &x_center, NULL);
+ UI_view2d_center_set(v2d, x_center, ymid);
+ }
+ }
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
@@ -409,13 +475,13 @@ static int actkeys_viewall(bContext *C, const bool only_sel, const bool only_xax
static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op))
{
/* whole range */
- return actkeys_viewall(C, false, false);
+ return actkeys_viewall(C, false);
}
static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
{
/* only selected */
- return actkeys_viewall(C, true, true);
+ return actkeys_viewall(C, true);
}
void ACTION_OT_view_all(wmOperatorType *ot)
@@ -680,7 +746,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -753,7 +819,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -843,7 +909,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
- WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
return OPERATOR_FINISHED;
}