forked from bartvdbraak/blender
Fixes for Time Marker support in Action window;
- now draws on correct height - selection is clipped correctly (did entire height) - made showing scene markers default Actually this implementation should have been a patch review... it was done with entirely duplicating the code from timeline.c, whilst re-use and generalizing markers has a preference. That way markers can become supported in any time-based editor. Will send an extensive review to Joshua Leung :)
This commit is contained in:
parent
1ad9d9f370
commit
4923b8e7a2
@ -33,6 +33,7 @@
|
||||
#ifndef BSE_TIME_H
|
||||
#define BSE_TIME_H
|
||||
|
||||
struct SpaceAction;
|
||||
|
||||
/* ******** Markers ********* */
|
||||
void add_timeline_marker(int frame);
|
||||
@ -44,6 +45,7 @@ void timeline_frame_to_center(void);
|
||||
void nextprev_timeline_key(short dir);
|
||||
void nextprev_timeline_marker(short dir);
|
||||
void timeline_grab(int mode, int smode);
|
||||
void draw_markers_action(struct SpaceAction *sact);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -215,93 +215,6 @@ void draw_cfra_action(void)
|
||||
glLineWidth(1.0);
|
||||
}
|
||||
|
||||
/* Aligorith: for now, just draw them as lines (for debugging) */
|
||||
static void draw_marker(TimeMarker *marker)
|
||||
{
|
||||
float xpos, xspace, yspace, xpixels, ypixels;
|
||||
float vec[2];
|
||||
|
||||
|
||||
xpos = marker->frame;
|
||||
/* no time correction for framelen! space is drawn with old values */
|
||||
|
||||
xspace= G.v2d->cur.xmax - G.v2d->cur.xmin;
|
||||
yspace= G.v2d->cur.ymax - G.v2d->cur.ymin;
|
||||
xpixels= G.v2d->mask.xmax-G.v2d->mask.xmin;
|
||||
ypixels= G.v2d->mask.ymax-G.v2d->mask.ymin;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
/* draw line through this point */
|
||||
vec[0]= G.scene->r.framelen * xpos;
|
||||
|
||||
vec[1]= G.v2d->cur.ymin;
|
||||
if (marker->flag & SELECT)
|
||||
glColor3ub(0xFF, 0xFF, 0x99);
|
||||
else
|
||||
glColor3ub(0xAA, 0xAA, 0x55);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2fv(vec);
|
||||
vec[1]= G.v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
|
||||
|
||||
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
|
||||
if(marker->flag & SELECT)
|
||||
BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), (12.0*yspace/ypixels)-CHANNELHEIGHT, ICON_MARKER_HLT);
|
||||
else
|
||||
BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), (12.0*yspace/ypixels)-CHANNELHEIGHT, ICON_MARKER);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
/* and the marker name too, shifted slightly to the top-right */
|
||||
if(marker->name && marker->name[0]) {
|
||||
if(marker->flag & SELECT) {
|
||||
BIF_ThemeColor(TH_TEXT_HI);
|
||||
glRasterPos2f(xpos+(4.0*(xspace/xpixels)),
|
||||
((ypixels<=39.0)?(ypixels-10.0):29.0)*yspace/ypixels);
|
||||
}
|
||||
else {
|
||||
BIF_ThemeColor(TH_TEXT);
|
||||
if((marker->frame <= G.scene->r.cfra) && (marker->frame+5 > G.scene->r.cfra))
|
||||
glRasterPos2f(xpos+(4.0*(xspace/xpixels)),
|
||||
((ypixels<=39.0)?(ypixels-10.0):29.0)*yspace/ypixels);
|
||||
else
|
||||
glRasterPos2f(xpos+(4.0*(xspace/xpixels)), 17.0*yspace/ypixels);
|
||||
}
|
||||
BMF_DrawString(G.font, marker->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_markers_action(SpaceAction *saction)
|
||||
{
|
||||
ListBase *markers;
|
||||
TimeMarker *marker;
|
||||
|
||||
/* try to get markers */
|
||||
markers = get_saction_markers(saction);
|
||||
if (markers == NULL)
|
||||
return;
|
||||
|
||||
/* unselected markers are drawn at the first time */
|
||||
for(marker= markers->first; marker; marker= marker->next) {
|
||||
if(!(marker->flag & SELECT)) draw_marker(marker);
|
||||
}
|
||||
|
||||
/* selected markers are drawn later ... selected markers have to cover unselected
|
||||
* markers laying at the same position as selected markers
|
||||
* (jiri: it is hack, it could be solved better) */
|
||||
for(marker= markers->first; marker; marker= marker->next) {
|
||||
if(marker->flag & SELECT) draw_marker(marker);
|
||||
}
|
||||
}
|
||||
|
||||
/* left hand */
|
||||
static void draw_action_channel_names(bAction *act)
|
||||
|
@ -179,6 +179,36 @@ static void draw_markers_time( void )
|
||||
}
|
||||
}
|
||||
|
||||
void draw_markers_action(SpaceAction *sact)
|
||||
{
|
||||
TimeMarker *marker;
|
||||
float yspace, ypixels;
|
||||
|
||||
/* move ortho view to align with slider in bottom */
|
||||
glTranslatef(0.0f, sact->v2d.cur.ymin, 0.0f);
|
||||
|
||||
/* bad hacks in drawing markers... inverse correct that as well */
|
||||
yspace= sact->v2d.cur.ymax - sact->v2d.cur.ymin;
|
||||
ypixels= sact->v2d.mask.ymax - sact->v2d.mask.ymin;
|
||||
glTranslatef(0.0f, -11.0*yspace/ypixels, 0.0f);
|
||||
|
||||
/* unselected markers are drawn at the first time */
|
||||
for(marker= G.scene->markers.first; marker; marker= marker->next) {
|
||||
if(!(marker->flag & SELECT)) draw_marker(marker);
|
||||
}
|
||||
|
||||
/* selected markers are drawn later ... selected markers have to cover unselected
|
||||
* markers laying at the same position as selected markers */
|
||||
for(marker= G.scene->markers.first; marker; marker= marker->next) {
|
||||
if(marker->flag & SELECT) draw_marker(marker);
|
||||
}
|
||||
|
||||
glTranslatef(0.0f, -sact->v2d.cur.ymin, 0.0f);
|
||||
glTranslatef(0.0f, 11.0*yspace/ypixels, 0.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void draw_sfra_efra()
|
||||
{
|
||||
BIF_ThemeColorShade(TH_BACK, -25);
|
||||
|
@ -2919,12 +2919,12 @@ ListBase *get_saction_markers (SpaceAction *saction)
|
||||
{
|
||||
ListBase *markers;
|
||||
|
||||
if (saction->markert == SACTION_SCMARKERS)
|
||||
// if (saction->markert == SACTION_SCMARKERS)
|
||||
markers = &(G.scene->markers);
|
||||
else if ((saction->markert == SACTION_ACMARKERS) && (saction->action != NULL))
|
||||
markers = &(saction->action->markers);
|
||||
else
|
||||
markers = NULL;
|
||||
// else if ((saction->markert == SACTION_ACMARKERS) && (saction->action != NULL))
|
||||
// markers = &(saction->action->markers);
|
||||
// else
|
||||
// markers = NULL;
|
||||
|
||||
return markers;
|
||||
}
|
||||
@ -3121,7 +3121,11 @@ TimeMarker *find_nearest_saction_marker(ListBase *markers)
|
||||
return NULL;
|
||||
|
||||
getmouseco_areawin (mval);
|
||||
|
||||
|
||||
/* first clip selection in Y */
|
||||
if(mval[1] > 30)
|
||||
return NULL;
|
||||
|
||||
mval[0]-=7;
|
||||
areamouseco_to_ipoco(G.v2d, mval, &rectf.xmin, &rectf.ymin);
|
||||
mval[0]+=14;
|
||||
|
@ -1095,29 +1095,7 @@ void action_buttons(void)
|
||||
from, &(G.saction->actnr), B_ACTALONE,
|
||||
B_ACTLOCAL, B_ACTIONDELETE, 0, 0);
|
||||
|
||||
|
||||
/* Draw marker set selection box */
|
||||
xco+= 8;
|
||||
|
||||
if (G.saction->action != NULL) {
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Markers%t|None%x0|Scene%x1|Action%x2",
|
||||
xco, 0, 80, 20, &(G.saction->markert), 0, 0, 0, 0,
|
||||
"What set of markers to display.");
|
||||
}
|
||||
else {
|
||||
if (G.saction->markert == SACTION_ACMARKERS)
|
||||
G.saction->markert = SACTION_NOMARKERS;
|
||||
|
||||
uiDefButS(block, MENU, B_REDR,
|
||||
"Markers%t|None%x0|Scene%x1",
|
||||
xco, 0, 80, 20, &(G.saction->markert), 0, 0, 0, 0,
|
||||
"What set of markers to display.");
|
||||
}
|
||||
|
||||
xco+=80;
|
||||
|
||||
|
||||
/* Draw action baker */
|
||||
xco+= 8;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user