forked from bartvdbraak/blender
View All/Selected tools for NLA Editor
This commit is contained in:
parent
ddbfcacfa0
commit
57fe73b3ac
@ -73,6 +73,10 @@ class NLA_MT_view(bpy.types.Menu):
|
||||
layout.operator("anim.previewrange_set")
|
||||
layout.operator("anim.previewrange_clear")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("nla.view_all")
|
||||
layout.operator("nla.view_selected")
|
||||
|
||||
layout.separator()
|
||||
layout.operator("screen.area_dupli")
|
||||
layout.operator("screen.screen_full_area")
|
||||
|
@ -234,6 +234,7 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons
|
||||
int filter;
|
||||
|
||||
/* get data to filter, from Action or Dopesheet */
|
||||
// XXX: what is sel doing here?!
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
|
@ -68,6 +68,7 @@
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "nla_intern.h" // own include
|
||||
#include "nla_private.h" // FIXME... maybe this shouldn't be included?
|
||||
@ -235,6 +236,136 @@ void NLA_OT_tweakmode_exit (wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
/* NLA Strips Range Stuff */
|
||||
|
||||
/* *************************** Calculate Range ************************** */
|
||||
|
||||
/* Get the min/max strip extents */
|
||||
static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, const short onlySel)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* get data to filter */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* set large values to try to override */
|
||||
*min= 999999999.0f;
|
||||
*max= -999999999.0f;
|
||||
|
||||
/* check if any channels to set range with */
|
||||
if (anim_data.first) {
|
||||
/* go through channels, finding max extents */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
NlaTrack *nlt = (NlaTrack *)ale->data;
|
||||
NlaStrip *strip;
|
||||
|
||||
for (strip = nlt->strips.first; strip; strip = strip->next) {
|
||||
/* only consider selected strips? */
|
||||
if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
|
||||
/* extend range if appropriate */
|
||||
*min = MIN2(*min, strip->start);
|
||||
*max = MAX2(*max, strip->end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* free memory */
|
||||
BLI_freelistN(&anim_data);
|
||||
}
|
||||
else {
|
||||
/* set default range */
|
||||
if (ac->scene) {
|
||||
*min= (float)ac->scene->r.sfra;
|
||||
*max= (float)ac->scene->r.efra;
|
||||
}
|
||||
else {
|
||||
*min= -5;
|
||||
*max= 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ****************** View-All Operator ****************** */
|
||||
|
||||
static int nlaedit_viewall(bContext *C, const short onlySel)
|
||||
{
|
||||
bAnimContext ac;
|
||||
View2D *v2d;
|
||||
float extra;
|
||||
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
v2d= &ac.ar->v2d;
|
||||
|
||||
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
|
||||
get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
|
||||
|
||||
extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
/* set vertical range */
|
||||
v2d->cur.ymax= 0.0f;
|
||||
v2d->cur.ymin= (float)-(v2d->mask.ymax - v2d->mask.ymin);
|
||||
|
||||
/* do View2D syncing */
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
|
||||
/* just redraw this view */
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* ......... */
|
||||
|
||||
static int nlaedit_viewall_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
/* whole range */
|
||||
return nlaedit_viewall(C, FALSE);
|
||||
}
|
||||
|
||||
static int nlaedit_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
/* only selected */
|
||||
return nlaedit_viewall(C, TRUE);
|
||||
}
|
||||
|
||||
void NLA_OT_view_all (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "View All";
|
||||
ot->idname= "NLA_OT_view_all";
|
||||
ot->description= "Reset viewable area to show full strips range";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= nlaedit_viewall_exec;
|
||||
ot->poll= ED_operator_nla_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void NLA_OT_view_selected (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "View Selected";
|
||||
ot->idname= "NLA_OT_view_selected";
|
||||
ot->description= "Reset viewable area to show selected strips range";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= nlaedit_viewsel_exec;
|
||||
ot->poll= ED_operator_nla_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* *********************************************** */
|
||||
/* NLA Editing Operations (Constructive/Destructive) */
|
||||
|
||||
|
@ -94,6 +94,9 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot);
|
||||
|
||||
/* --- */
|
||||
|
||||
void NLA_OT_view_all(wmOperatorType *ot);
|
||||
void NLA_OT_view_selected(wmOperatorType *ot);
|
||||
|
||||
void NLA_OT_actionclip_add(wmOperatorType *ot);
|
||||
void NLA_OT_transition_add(wmOperatorType *ot);
|
||||
|
||||
|
@ -130,6 +130,10 @@ void nla_operatortypes(void)
|
||||
WM_operatortype_append(NLA_OT_select_all_toggle);
|
||||
WM_operatortype_append(NLA_OT_select_leftright);
|
||||
|
||||
/* view */
|
||||
WM_operatortype_append(NLA_OT_view_all);
|
||||
WM_operatortype_append(NLA_OT_view_selected);
|
||||
|
||||
/* edit */
|
||||
WM_operatortype_append(NLA_OT_tweakmode_enter);
|
||||
WM_operatortype_append(NLA_OT_tweakmode_exit);
|
||||
@ -212,6 +216,11 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
|
||||
|
||||
/* view*/
|
||||
/* auto-set range */
|
||||
//WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
||||
|
||||
/* editing */
|
||||
/* tweakmode
|
||||
|
Loading…
Reference in New Issue
Block a user