This commit adds some missing features to markers in action editor,

and also fixes some further segfaults.

Now it is possible to 'surf' (jump) to different markers. This is only
possible through the hotkeys for this:
* Page Up - Next Marker
* Page Down - Previous Marker

These hotkeys match the ones in the timeline. In order to do so,
I've had to reassign two (rarely used/obscure) hotkeys:
* 'Ctrl Page Up' is now move selected action channel up (was Page Up)
* 'Ctrl Page Down' is no move selected action channel down (was Page Down)
I should also mention here that
* 'Shift Page Up' is move action channel to top
* 'Shift Page Down' is move action channel to bottom
This commit is contained in:
Joshua Leung 2006-11-16 23:15:06 +00:00
parent f89b052262
commit 9ce143ae25
3 changed files with 120 additions and 44 deletions

@ -85,15 +85,17 @@ void clean_actionchannels(struct bAction *act);
/* Marker Operations */
struct ListBase *get_saction_markers(struct SpaceAction *saction);
struct TimeMarker *find_nearest_saction_marker(struct ListBase *markers);
void get_minmax_saction_markers(struct ListBase *markers, float *first, float *last);
void add_saction_marker(struct ListBase *markers, int frame);
void duplicate_saction_markers(struct ListBase *markers);
void remove_saction_markers(struct ListBase *markers);
void rename_saction_markers(struct ListBase *markers);
void transform_saction_markers(int mode, int smode);
void deselect_saction_markers(struct ListBase *markers, int test, int sel);
void deselect_saction_markers(struct ListBase *markers, short test, short sel);
void borderselect_saction_markers(struct ListBase *markers, float xmin, float xmax, int selectmode);
void selectkeyscolumns_saction_markers(struct ListBase *markers);
void selectkeysbetween_saction_markers(struct ListBase *markers);
void nextprev_saction_markers(ListBase *markers, short dir);
void selectkeys_columns_markers(struct ListBase *markers);
void selectkeys_between_markers(struct ListBase *markers);
/* channel/strip operations */
void up_sel_action(void);

@ -2636,23 +2636,25 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case MKEY:
/* marker operations */
if (G.qual == 0)
add_saction_marker(markers, CFRA);
else if (G.qual == LR_ALTKEY) {
if( okee("Erase selected markers")==0 )
if (markers != NULL) {
if (G.qual == 0)
add_saction_marker(markers, CFRA);
else if (G.qual == LR_ALTKEY) {
if( okee("Erase selected markers")==0 )
break;
remove_saction_markers(markers);
}
else if (G.qual == LR_CTRLKEY)
rename_saction_markers(markers);
else if (G.qual == LR_SHIFTKEY)
transform_saction_markers('g', 0);
else if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY))
duplicate_saction_markers(markers);
else
break;
remove_saction_markers(markers);
allqueue(REDRAWACTION, 0);
allqueue(REDRAWTIME, 0);
}
else if (G.qual == LR_CTRLKEY)
rename_saction_markers(markers);
else if (G.qual == LR_SHIFTKEY)
transform_saction_markers('g', 0);
else if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY))
duplicate_saction_markers(markers);
else
break;
allqueue(REDRAWACTION, 0);
allqueue(REDRAWTIME, 0);
break;
case NKEY:
@ -2710,30 +2712,30 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
case PAGEUPKEY:
if (key) {
/* to do */
/* only jump to markers possible (key channels can't be moved yet) */
nextprev_saction_markers(markers, 1);
}
else {
if(G.qual & LR_SHIFTKEY) {
if(G.qual & LR_SHIFTKEY)
top_sel_action();
}
else
{
else if (G.qual & LR_CTRLKEY)
up_sel_action();
}
else
nextprev_saction_markers(markers, 1);
}
break;
case PAGEDOWNKEY:
if (key) {
/* to do */
/* only jump to markers possible (key channels can't be moved yet) */
nextprev_saction_markers(markers, -1);
}
else {
if(G.qual & LR_SHIFTKEY) {
if(G.qual & LR_SHIFTKEY)
bottom_sel_action();
}
else if (G.qual & LR_CTRLKEY)
down_sel_action();
else
down_sel_action();
nextprev_saction_markers(markers, -1);
}
break;
case DELKEY:
@ -2955,6 +2957,9 @@ void remove_saction_markers(ListBase *markers)
{
TimeMarker *marker;
if (markers == NULL)
return;
for(marker= markers->first; marker; marker= marker->next) {
if(marker->flag & SELECT){
BLI_freelinkN(markers, marker);
@ -2970,6 +2975,9 @@ void rename_saction_markers(ListBase *markers)
TimeMarker *marker;
char name[64];
if (markers == NULL)
return;
for(marker= markers->first; marker; marker= marker->next) {
if(marker->flag & SELECT) {
sprintf(name, marker->name);
@ -3131,11 +3139,51 @@ TimeMarker *find_nearest_saction_marker(ListBase *markers)
return NULL;
}
/* select next/previous marker */
void nextprev_saction_markers(ListBase *markers, short dir)
{
TimeMarker *marker, *cur=NULL, *first, *last;
int mindist= MAXFRAME, dist;
if (markers == NULL)
return;
first= last= markers->first;
for(marker= markers->first; marker; marker= marker->next) {
/* find closest to current frame first */
dist= (marker->frame/G.scene->r.framelen) - CFRA;
if(dir==1 && dist>0 && dist<mindist) {
mindist= dist;
cur= marker;
}
else if(dir==-1 && dist<0 && -dist<mindist) {
mindist= -dist;
cur= marker;
}
/* find first/last */
if(marker->frame > last->frame) last= marker;
if(marker->frame < first->frame) first= marker;
}
if(cur==NULL) {
if(dir==1) cur= first;
else cur= last;
}
if(cur) {
CFRA= cur->frame/G.scene->r.framelen;
update_for_newframe();
allqueue(REDRAWALL, 0);
}
}
/* select/deselect all TimeMarkers */
void deselect_saction_markers(ListBase *markers, int test, int sel)
void deselect_saction_markers(ListBase *markers, short test, short sel)
{
TimeMarker *marker;
if (markers == NULL)
return;
/* check if need to find out whether to how to select markers */
if (test) {
/* dependant on existing selection */
@ -3179,6 +3227,9 @@ void borderselect_saction_markers(ListBase *markers, float xmin, float xmax, int
{
TimeMarker *marker;
if (markers == NULL)
return;
for(marker= markers->first; marker; marker= marker->next) {
if ((marker->frame > xmin) && (marker->frame <= xmax)) {
switch (selectmode) {
@ -3195,6 +3246,28 @@ void borderselect_saction_markers(ListBase *markers, float xmin, float xmax, int
}
}
void get_minmax_saction_markers(ListBase *markers, float *first, float *last)
{
TimeMarker *marker;
float min, max;
if (!markers)
return;
min= ((TimeMarker *)markers->first)->frame;
max= ((TimeMarker *)markers->last)->frame;
for (marker= markers->first; marker; marker= marker->next) {
if (marker->frame < min)
min= marker->frame;
else if (marker->frame > max)
max= marker->frame;
}
*first= min;
*last= max;
}
/* ************************************* Action Channel Ordering *********************************** */
void top_sel_action()

@ -439,8 +439,8 @@ static uiBlock *action_selectmenu(void *arg_unused)
"Select Keys Column|K", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
ACTMENU_SEL_COLUMN, "");
/*
/*
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
"Select Keys At Markers|CTRL K", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
@ -450,7 +450,7 @@ static uiBlock *action_selectmenu(void *arg_unused)
"Select Keys Between Markers|SHIFT K", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
ACTMENU_SEL_MARKERS_KEYSBETWEEN, "");
*/
*/
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
@ -774,11 +774,11 @@ static uiBlock *action_keymenu_chanposmenu(void *arg_unused)
uiBlockSetButmFunc(block, do_action_keymenu_chanposmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
"Move Up|Page Up", 0, yco-=20,
"Move Up|Ctrl Page Up", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
ACTMENU_KEY_CHANPOS_MOVE_CHANNEL_UP, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1,
"Move Down|Page Down", 0, yco-=20,
"Move Down|Ctrl Page Down", 0, yco-=20,
menuwidth, 19, NULL, 0.0, 0.0, 0,
ACTMENU_KEY_CHANPOS_MOVE_CHANNEL_DOWN, "");
@ -927,30 +927,30 @@ static uiBlock *action_keymenu(void *arg_unused)
static void do_action_markermenu(void *arg, int event)
{
SpaceAction *saction;
ListBase *lb = NULL;
ListBase *markers = NULL;
saction= curarea->spacedata.first;
if (!saction)
return;
/* get set of markers */
lb= get_saction_markers(saction);
if (lb == NULL)
markers= get_saction_markers(saction);
if (markers == NULL)
return;
switch(event)
{
case ACTMENU_MARKERS_ADD:
add_saction_marker(lb, CFRA);
add_saction_marker(markers, CFRA);
break;
case ACTMENU_MARKERS_DUPLICATE:
duplicate_saction_markers(lb);
duplicate_saction_markers(markers);
break;
case ACTMENU_MARKERS_DELETE:
remove_saction_markers(lb);
remove_saction_markers(markers);
break;
case ACTMENU_MARKERS_NAME:
rename_saction_markers(lb);
rename_saction_markers(markers);
break;
case ACTMENU_MARKERS_MOVE:
transform_saction_markers('g', 0);
@ -1075,7 +1075,8 @@ void action_buttons(void)
"Key", xco, -2, xmax-3, 24, "");
xco+= xmax;
if (G.saction->markert != SACTION_NOMARKERS) {
if ((G.saction->markert != SACTION_NOMARKERS) &&
(G.saction->action != NULL)) {
xmax= GetButStringLength("Marker");
uiDefPulldownBut(block, action_markermenu, NULL,
"Marker", xco, -2, xmax-3, 24, "");