Ejemplo n.º 1
0
/* helper func - set color to draw F-Curve data with */
static void set_fcurve_vertex_color(FCurve *fcu, short sel)
{
	/* Fade the 'intensity' of the vertices based on the selection of the curves too */
	int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255);
	
	/* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */
	if ((fcu->flag & FCURVE_PROTECTED) == 0) {
		/* Curve's points ARE BEING edited */
		if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); 
		else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset);
	}
	else {
		/* Curve's points CANNOT BE edited */
		if (sel) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, alphaOffset);
		else UI_ThemeColorShadeAlpha(TH_TEXT, 0, alphaOffset);
	}
}
Ejemplo n.º 2
0
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
{
	const Editing *ed = BKE_sequencer_editing_get(scene, false);
	const int frame_sta = PSFRA;
	const int frame_end = PEFRA + 1;

	glEnable(GL_BLEND);
	
	/* draw darkened area outside of active timeline 
	 * frame range used is preview range or scene range */
	UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);

	if (frame_sta < frame_end) {
		glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)frame_sta, v2d->cur.ymax);
		glRectf((float)frame_end, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
	}
	else {
		glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
	}

	UI_ThemeColorShade(TH_BACK, -60);
	/* thin lines where the actual frames are */
	fdrawline(frame_sta, v2d->cur.ymin, frame_sta, v2d->cur.ymax);
	fdrawline(frame_end, v2d->cur.ymin, frame_end, v2d->cur.ymax);

	if (ed && !BLI_listbase_is_empty(&ed->metastack)) {
		MetaStack *ms = ed->metastack.last;

		glColor4ub(255, 255, 255, 8);
		glRectf(ms->disp_range[0], v2d->cur.ymin, ms->disp_range[1], v2d->cur.ymax);

		UI_ThemeColorShade(TH_BACK, -40);

		fdrawline(ms->disp_range[0], v2d->cur.ymin, ms->disp_range[0], v2d->cur.ymax);
		fdrawline(ms->disp_range[1], v2d->cur.ymin, ms->disp_range[1], v2d->cur.ymax);
	}

	glDisable(GL_BLEND);
}
Ejemplo n.º 3
0
static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
{	
	glEnable(GL_BLEND);
	
	/* draw darkened area outside of active timeline 
	 * frame range used is preview range or scene range */
	UI_ThemeColorShadeAlpha(TH_BACK, -25, -100);

	if (PSFRA < PEFRA + 1) {
		glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
		glRectf((float)(PEFRA + 1), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
	}
	else {
		glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
	}

	UI_ThemeColorShade(TH_BACK, -60);
	/* thin lines where the actual frames are */
	fdrawline((float)PSFRA, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
	fdrawline((float)(PEFRA + 1), v2d->cur.ymin, (float)(PEFRA + 1), v2d->cur.ymax);
	
	glDisable(GL_BLEND);
}
Ejemplo n.º 4
0
static void draw_keyframe_shape(float x, float y, float xscale, float yscale, short sel, float alpha)
{
	/* coordinates for diamond shape */
	static const float _unit_diamond_shape[4][2] = {
		{0.0f, 1.0f},   /* top vert */
		{1.0f, 0.0f},   /* mid-right */
		{0.0f, -1.0f},  /* bottom vert */
		{-1.0f, 0.0f}   /* mid-left */
	};
	static GLuint displist1 = 0;
	static GLuint displist2 = 0;
	int hsize = STRIP_HEIGHT_HALF;

	/* initialize 2 display lists for diamond shape - one empty, one filled */
	if (displist1 == 0) {
		displist1 = glGenLists(1);
		glNewList(displist1, GL_COMPILE);

		glBegin(GL_LINE_LOOP);
		glVertex2fv(_unit_diamond_shape[0]);
		glVertex2fv(_unit_diamond_shape[1]);
		glVertex2fv(_unit_diamond_shape[2]);
		glVertex2fv(_unit_diamond_shape[3]);
		glEnd();
		glEndList();
	}
	if (displist2 == 0) {
		displist2 = glGenLists(1);
		glNewList(displist2, GL_COMPILE);

		glBegin(GL_QUADS);
		glVertex2fv(_unit_diamond_shape[0]);
		glVertex2fv(_unit_diamond_shape[1]);
		glVertex2fv(_unit_diamond_shape[2]);
		glVertex2fv(_unit_diamond_shape[3]);
		glEnd();
		glEndList();
	}

	glPushMatrix();

	/* adjust view transform before starting */
	glTranslatef(x, y, 0.0f);
	glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);

	/* anti-aliased lines for more consistent appearance */
	glEnable(GL_LINE_SMOOTH);

	if (sel)
		UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha));
	else
		glColor4f(0.91f, 0.91f, 0.91f, alpha);

	glCallList(displist2);

	/* exterior - black frame */
	glColor4f(0.0f, 0.0f, 0.0f, alpha);
	glCallList(displist1);

	glDisable(GL_LINE_SMOOTH);

	/* restore view transform */
	glPopMatrix();
}
Ejemplo n.º 5
0
/* Draw current frame number in a little green box beside the current frame indicator */
static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time)
{
    float xscale, yscale, x, y;
    char str[32];
    short slen;

    /* because the frame number text is subject to the same scaling as the contents of the view */
    UI_view2d_getscale(v2d, &xscale, &yscale);
    glScalef(1.0f/xscale, 1.0f, 1.0f);

    if (time) {
        /* Timecode:
         *	- In general, minutes and seconds should be shown, as most clips will be
         *	  within this length. Hours will only be included if relevant.
         *	- Only show frames when zoomed in enough for them to be relevant
         *	  (using separator of '!' for frames).
         *	  When showing frames, use slightly different display to avoid confusion with mm:ss format
         * TODO: factor into reusable function.
         * Meanwhile keep in sync:
         *	  source/blender/editors/animation/anim_draw.c
         *	  source/blender/editors/interface/view2d.c
         */
        float val= FRA2TIME(CFRA);
        int hours=0, minutes=0, seconds=0, frames=0;
        char neg[2]= "";

        /* get values */
        if (val < 0) {
            /* correction for negative values */
            sprintf(neg, "-");
            val = -val;
        }
        if (val >= 3600) {
            /* hours */
            /* XXX should we only display a single digit for hours since clips are
             * 	   VERY UNLIKELY to be more than 1-2 hours max? However, that would
             *	   go against conventions...
             */
            hours= (int)val / 3600;
            val= (float)fmod(val, 3600);
        }
        if (val >= 60) {
            /* minutes */
            minutes= (int)val / 60;
            val= (float)fmod(val, 60);
        }
        {
            /* seconds + frames
             *	Frames are derived from 'fraction' of second. We need to perform some additional rounding
             *	to cope with 'half' frames, etc., which should be fine in most cases
             */
            seconds= (int)val;
            frames= (int)floor( ((val - seconds) * FPS) + 0.5f );
        }

        /* print timecode to temp string buffer */
        if (hours) sprintf(str, "   %s%02d:%02d:%02d!%02d", neg, hours, minutes, seconds, frames);
        else if (minutes) sprintf(str, "   %s%02d:%02d!%02d", neg, minutes, seconds, frames);
        else sprintf(str, "   %s%d!%02d", neg, seconds, frames);
    }
    else
        sprintf(str, "   %d", CFRA);
    slen= (short)UI_GetStringWidth(str) - 1;

    /* get starting coordinates for drawing */
    x= cfra * xscale;
    y= 18;

    /* draw green box around/behind text */
    UI_ThemeColorShadeAlpha(TH_CFRAME, 0, -100);
    glRectf(x, y,  x+slen,  y+15);

    /* draw current frame number - black text */
    UI_ThemeColor(TH_TEXT);
    UI_DrawString(x-5, y+3, str); // XXX may need to be updated for font stuff

    /* restore view transform */
    glScalef(xscale, 1.0, 1.0);
}