Esempio n. 1
0
/* helper func - draw keyframe vertices only for an F-Curve */
static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
{
	FPoint *first, *last;
	float hsize, xscale, yscale;
	
	/* get view settings */
	hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
	UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
	
	/* set vertex color */
	if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
	else UI_ThemeColor(TH_TEXT);
	
	/* get verts */
	first = fcu->fpt;
	last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
	
	/* draw */
	if (first && last) {
		/* anti-aliased lines for more consistent appearance */
		if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
		glEnable(GL_BLEND);
		
		draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
		draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
		
		glDisable(GL_BLEND);
		if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
	}
}
/* draw keyframe lines for timeline */
static void time_draw_keyframes(const bContext *C, ARegion *ar)
{
	Scene *scene = CTX_data_scene(C);
	Object *ob = CTX_data_active_object(C);
	View2D *v2d = &ar->v2d;
	bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
	
	/* set this for all keyframe lines once and for all */
	glLineWidth(1.0);
	
	/* draw grease pencil keyframes (if available) */	
	UI_ThemeColor(TH_TIME_GP_KEYFRAME);
	if (scene->gpd) {
		time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel);
	}
	if (ob && ob->gpd) {
		time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel);
	}
	
	/* draw scene keyframes first 
	 *	- don't try to do this when only drawing active/selected data keyframes,
	 *	  since this can become quite slow
	 */
	if (onlysel == 0) {
		/* set draw color */
		UI_ThemeColorShade(TH_TIME_KEYFRAME, -50);
		time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
	}
	
	/* draw keyframes from selected objects 
	 *  - only do the active object if in posemode (i.e. showing only keyframes for the bones)
	 *    OR the onlysel flag was set, which means that only active object's keyframes should
	 *    be considered
	 */
	UI_ThemeColor(TH_TIME_KEYFRAME);
	
	if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
		/* draw keyframes for active object only */
		time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel);
	}
	else {
		bool active_done = false;
		
		/* draw keyframes from all selected objects */
		CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
		{
			/* last arg is 0, since onlysel doesn't apply here... */
			time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
			
			/* if this object is the active one, set flag so that we don't draw again */
			if (obsel == ob)
				active_done = true;
		}
		CTX_DATA_END;
		
		/* if active object hasn't been done yet, draw it... */
		if (ob && (active_done == 0))
			time_draw_idblock_keyframes(v2d, (ID *)ob, 0);
	}
Esempio n. 3
0
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */
static void mat_livedb_draw_content_count_icons(ListBase *lb, int xmax, int *offsx, int ys)
{
    int cat_cnt = 0, mat_cnt = 0, string_width;
    LiveDbTreeElement   *te;
    char                cnt_str[16];
    float               ufac = UI_UNIT_X / 20.0f;

    if ((*offsx) - UI_UNIT_X > xmax) return;

    for (te = lb->first; te; te = te->next) {
        if (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY) ++cat_cnt;
        else ++mat_cnt;
    }
    if (cat_cnt > 0) {
        snprintf(cnt_str, 16, "%d", cat_cnt);
        string_width = UI_fontstyle_string_width(UI_FSTYLE_WIDGET, cnt_str);

        UI_draw_roundbox_corner_set(UI_CNR_ALL);
        glColor4ub(220, 220, 255, 100);
        UI_draw_roundbox((float) *offsx - 4.0f * ufac,
                   (float)ys + 1.0f * ufac,
                   (float)*offsx + UI_UNIT_X + string_width,
                   (float)ys + UI_UNIT_Y - ufac,
                   (float)UI_UNIT_Y / 2.0f - ufac);
        glEnable(GL_BLEND); /* roundbox disables */

        UI_icon_draw((float)*offsx, (float)ys + 2 * ufac, ICON_FILE_FOLDER);

        (*offsx) += UI_UNIT_X;
        UI_ThemeColor(TH_TEXT);
        UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, (float)*offsx - 2 * ufac, (float)ys + 5 * ufac, cnt_str);

        offsx += (int)(UI_UNIT_X + string_width);
    }
    if (mat_cnt > 0) {
        snprintf(cnt_str, 16, "%d", mat_cnt);
        string_width = UI_fontstyle_string_width(UI_FSTYLE_WIDGET, cnt_str);

        UI_draw_roundbox_corner_set(UI_CNR_ALL);
        glColor4ub(220, 220, 255, 100);
        UI_draw_roundbox((float) *offsx - 4.0f * ufac,
                   (float)ys + 1.0f * ufac,
                   (float)*offsx + UI_UNIT_X + string_width,
                   (float)ys + UI_UNIT_Y - ufac,
                   (float)UI_UNIT_Y / 2.0f - ufac);
        glEnable(GL_BLEND); /* roundbox disables */

        UI_icon_draw((float)*offsx, (float)ys + 2 * ufac, ICON_MATERIAL);

        (*offsx) += UI_UNIT_X;
        UI_ThemeColor(TH_TEXT);
        UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, (float)*offsx - 2 * ufac, (float)ys + 5 * ufac, cnt_str);

        offsx += (int)(UI_UNIT_X + string_width);
    }
} /* mat_livedb_draw_content_count_icons() */
Esempio n. 4
0
/* Sets the current drawing color based on the format character specified */
static void format_draw_color(char formatchar)
{
	switch (formatchar) {
		case FMT_TYPE_WHITESPACE:
			break;
		case FMT_TYPE_SYMBOL:
			UI_ThemeColor(TH_SYNTAX_S);
			break;
		case FMT_TYPE_COMMENT:
			UI_ThemeColor(TH_SYNTAX_C);
			break;
		case FMT_TYPE_NUMERAL:
			UI_ThemeColor(TH_SYNTAX_N);
			break;
		case FMT_TYPE_STRING:
			UI_ThemeColor(TH_SYNTAX_L);
			break;
		case FMT_TYPE_DIRECTIVE:
			UI_ThemeColor(TH_SYNTAX_D);
			break;
		case FMT_TYPE_SPECIAL:
			UI_ThemeColor(TH_SYNTAX_V);
			break;
		case FMT_TYPE_RESERVED:
			UI_ThemeColor(TH_SYNTAX_R);
			break;
		case FMT_TYPE_KEYWORD:
			UI_ThemeColor(TH_SYNTAX_B);
			break;
		case FMT_TYPE_DEFAULT:
		default:
			UI_ThemeColor(TH_TEXT);
			break;
	}
}
Esempio n. 5
0
static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
	RenderResult *rr;
	rcti rect;
	float colf[3];
	
	rr= BKE_image_acquire_renderresult(scene, ima);

	if(rr && rr->text) {
		rect= ar->winrct;
		rect.xmin= 0;
		rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT;
		rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
		rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
		
		/* clear header rect */
		UI_GetThemeColor3fv(TH_BACK, colf);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f);
		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1);
		glDisable(GL_BLEND);
		
		UI_ThemeColor(TH_TEXT_HI);

		UI_DrawString(12, rect.ymin + 5, rr->text);
	}

	BKE_image_release_renderresult(scene, ima);
}
Esempio n. 6
0
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *rect, char dir)
{
	Panel *panel= block->panel;
	rcti hrect;
	int  pnl_icons;
	char *activename= panel->drawname[0]?panel->drawname:panel->panelname;
	
	/* + 0.001f to avoid flirting with float inaccuracy */
	if(panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f;
	else pnl_icons= (panel->labelofs+PNL_ICON+5)/block->aspect + 0.001f;
	
	/* active tab */
	/* draw text label */
	UI_ThemeColor(TH_TITLE);
	
	hrect= *rect;
	if(dir == 'h') {
		hrect.xmin= rect->xmin+pnl_icons;
		uiStyleFontDraw(&style->paneltitle, &hrect, activename);
	}
	else {
		/* ignore 'pnl_icons', otherwise the text gets offset horizontally 
		 * + 0.001f to avoid flirting with float inaccuracy
		 */
		hrect.xmin= rect->xmin + (PNL_ICON+5)/block->aspect + 0.001f;
		uiStyleFontDrawRotated(&style->paneltitle, &hrect, activename);
	}
}
Esempio n. 7
0
/* General call for drawing current frame indicator in animation editor */
void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
{
	Scene *scene = CTX_data_scene(C);
	float vec[2];
	
	/* Draw a light green line to indicate current frame */
	vec[0] = (float)(scene->r.cfra * scene->r.framelen);
	
	UI_ThemeColor(TH_CFRAME);
	if (flag & DRAWCFRA_WIDE)
		glLineWidth(3.0);
	else
		glLineWidth(2.0);
	
	glBegin(GL_LINE_STRIP);
	vec[1] = v2d->cur.ymin - 500.0f;    /* XXX arbitrary... want it go to bottom */
	glVertex2fv(vec);
		
	vec[1] = v2d->cur.ymax;
	glVertex2fv(vec);
	glEnd();
	
	glLineWidth(1.0);
	
	/* Draw current frame number in a little box */
	if (flag & DRAWCFRA_SHOW_NUMBOX) {
		UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
		draw_cfra_number(scene, v2d, vec[0], (flag & DRAWCFRA_UNIT_SECONDS) != 0);
	}
}
Esempio n. 8
0
void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
{
	View2D *v2d = &ar->v2d;
	float xscale, yscale;
	float vec[2];

	/* Draw a light green line to indicate current frame */
	vec[0] = (float)(sc->user.framenr * scene->r.framelen);

	UI_ThemeColor(TH_CFRAME);
	glLineWidth(2.0);

	glBegin(GL_LINE_STRIP);
	vec[1] = v2d->cur.ymin;
	glVertex2fv(vec);

	vec[1] = v2d->cur.ymax;
	glVertex2fv(vec);
	glEnd();

	glLineWidth(1.0);

	UI_view2d_view_orthoSpecial(ar, v2d, 1);

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

	ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18);

	/* restore view transform */
	glScalef(xscale, 1.0, 1.0);
}
Esempio n. 9
0
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only, float units_scale)
{
	BezTriple *bezt = fcu->bezt;
	BezTriple *prevbezt = NULL;
	float hsize, xscale, yscale;
	int i;
	
	/* get view settings */
	hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
	UI_view2d_getscale(v2d, &xscale, &yscale);

	/* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
	yscale *= units_scale;
	
	/* set handle color */
	if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
	else UI_ThemeColor(TH_HANDLE_VERTEX);
	
	/* anti-aliased lines for more consistent appearance */
	if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
	glEnable(GL_BLEND);
	
	for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) {
		/* Draw the editmode handles for a bezier curve (others don't have handles) 
		 * if their selection status matches the selection status we're drawing for
		 *	- first handle only if previous beztriple was bezier-mode
		 *	- second handle only if current beztriple is bezier-mode
		 *
		 * Also, need to take into account whether the keyframe was selected
		 * if a Graph Editor option to only show handles of selected keys is on.
		 */
		if (!sel_handle_only || BEZSELECTED(bezt)) {
			if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
				if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
					draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
			}
			
			if (bezt->ipo == BEZT_IPO_BEZ) {
				if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
					draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
			}
		}
	}
	
	if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
	glDisable(GL_BLEND);
}
Esempio n. 10
0
static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
{
	float gridsize, gridstep= 1.0f/32.0f;
	float fac, blendfac;
	int x1, y1, x2, y2;
	
	/* the image is located inside (0,0),(1, 1) as set by view2d */
	UI_ThemeColorShade(TH_BACK, 20);

	UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
	UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
	glRectf(x1, y1, x2, y2);

	/* gridsize adapted to zoom level */
	gridsize= 0.5f*(zoomx+zoomy);
	if(gridsize<=0.0f) return;
	
	if(gridsize<1.0f) {
		while(gridsize<1.0f) {
			gridsize*= 4.0f;
			gridstep*= 4.0f;
		}
	}
	else {
		while(gridsize>=4.0f) {
			gridsize/= 4.0f;
			gridstep/= 4.0f;
		}
	}
	
	/* the fine resolution level */
	blendfac= 0.25f*gridsize - floorf(0.25f*gridsize);
	CLAMP(blendfac, 0.0f, 1.0f);
	UI_ThemeColorShade(TH_BACK, (int)(20.0f*(1.0f-blendfac)));
	
	fac= 0.0f;
	glBegin(GL_LINES);
	while(fac<1.0f) {
		glVertex2f(x1, y1*(1.0f-fac) + y2*fac);
		glVertex2f(x2, y1*(1.0f-fac) + y2*fac);
		glVertex2f(x1*(1.0f-fac) + x2*fac, y1);
		glVertex2f(x1*(1.0f-fac) + x2*fac, y2);
		fac+= gridstep;
	}
	
	/* the large resolution level */
	UI_ThemeColor(TH_BACK);
	
	fac= 0.0f;
	while(fac<1.0f) {
		glVertex2f(x1, y1*(1.0f-fac) + y2*fac);
		glVertex2f(x2, y1*(1.0f-fac) + y2*fac);
		glVertex2f(x1*(1.0f-fac) + x2*fac, y1);
		glVertex2f(x1*(1.0f-fac) + x2*fac, y2);
		fac+= 4.0f*gridstep;
	}
	glEnd();
}
Esempio n. 11
0
static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
{
	FlyInfo *fly = arg;
	rctf viewborder;
	int xoff, yoff;
	float x1, x2, y1, y2;

	if (fly->scene->camera) {
		ED_view3d_calc_camera_border(fly->scene, fly->ar, fly->v3d, fly->rv3d, &viewborder, false);
		xoff = viewborder.xmin;
		yoff = viewborder.ymin;
	}
	else {
		xoff = 0;
		yoff = 0;
	}

	/* draws 4 edge brackets that frame the safe area where the
	 * mouse can move during fly mode without spinning the view */

	x1 = xoff + 0.45f * fly->width;
	y1 = yoff + 0.45f * fly->height;
	x2 = xoff + 0.55f * fly->width;
	y2 = yoff + 0.55f * fly->height;

	UI_ThemeColor(TH_VIEW_OVERLAY);
	glBegin(GL_LINES);
	/* bottom left */
	glVertex2f(x1, y1);
	glVertex2f(x1, y1 + 5);

	glVertex2f(x1, y1);
	glVertex2f(x1 + 5, y1);

	/* top right */
	glVertex2f(x2, y2);
	glVertex2f(x2, y2 - 5);

	glVertex2f(x2, y2);
	glVertex2f(x2 - 5, y2);

	/* top left */
	glVertex2f(x1, y2);
	glVertex2f(x1, y2 - 5);

	glVertex2f(x1, y2);
	glVertex2f(x1 + 5, y2);

	/* bottom right */
	glVertex2f(x2, y1);
	glVertex2f(x2, y1 + 5);

	glVertex2f(x2, y1);
	glVertex2f(x2 - 5, y1);
	glEnd();
}
Esempio n. 12
0
static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track,
			MovieTrackingMarker *marker, int coord, float val)
{
	struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata;
	int sel= 0, sel_flag;

	if(track!=data->act_track)
		return;

	sel_flag= coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
	sel= (marker->flag & sel_flag) ? 1 : 0;

	if(sel == data->sel) {
		if(sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT);
		else UI_ThemeColor(TH_HANDLE_VERTEX);

		draw_curve_knot(marker->framenr, val, data->xscale, data->yscale, data->hsize);
	}
}
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
	if (t->flag & T_PROP_EDIT) {
		RegionView3D *rv3d = CTX_wm_region_view3d(C);
		float tmat[4][4], imat[4][4];
		float center[3];
		int depth_test_enabled;

		UI_ThemeColor(TH_GRID);

		if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
			copy_m4_m4(tmat, rv3d->viewmat);
			invert_m4_m4(imat, tmat);
		}
		else {
			unit_m4(tmat);
			unit_m4(imat);
		}

		glPushMatrix();

		copy_v3_v3(center, t->center);

		if ((t->spacetype == SPACE_VIEW3D) && t->obedit) {
			mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */
		}
		else if (t->spacetype == SPACE_IMAGE) {
			float aspx, aspy;

			if (t->options & CTX_MASK) {
				/* untested - mask aspect is TODO */
				ED_space_image_get_aspect(t->sa->spacedata.first, &aspx, &aspy);
			}
			else {
				ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
			}
			glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
		}

		depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
		if (depth_test_enabled)
			glDisable(GL_DEPTH_TEST);

		set_inverted_drawing(1);
		drawcircball(GL_LINE_LOOP, center, t->prop_size, imat);
		set_inverted_drawing(0);

		if (depth_test_enabled)
			glEnable(GL_DEPTH_TEST);

		glPopMatrix();
	}
}
Esempio n. 14
0
/* Sets the current drawing color based on the format character specified */
static void format_draw_color(char formatchar)
{
	switch (formatchar) {
		case '_': /* Whitespace */
			break;
		case '!': /* Symbols */
			UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f);
			break;
		case '#': /* Comments */
			UI_ThemeColor(TH_SYNTAX_C);
			break;
		case 'n': /* Numerals */
			UI_ThemeColor(TH_SYNTAX_N);
			break;
		case 'l': /* Strings */
			UI_ThemeColor(TH_SYNTAX_L);
			break;
		case 'v': /* Specials: class, def */
			UI_ThemeColor(TH_SYNTAX_V);
			break;
		case 'b': /* Keywords: for, print, etc. */
			UI_ThemeColor(TH_SYNTAX_B);
			break;
		case 'q': /* Other text (identifiers) */
		default:
			UI_ThemeColor(TH_TEXT);
			break;
	}
}
Esempio n. 15
0
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
	if (t->flag & T_PROP_EDIT) {
		RegionView3D *rv3d = CTX_wm_region_view3d(C);
		float tmat[4][4], imat[4][4];
		int depth_test_enabled;

		UI_ThemeColor(TH_GRID);

		if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
			copy_m4_m4(tmat, rv3d->viewmat);
			invert_m4_m4(imat, tmat);
		}
		else {
			unit_m4(tmat);
			unit_m4(imat);
		}

		glPushMatrix();

		if (t->spacetype == SPACE_VIEW3D) {
			/* pass */
		}
		else if (t->spacetype == SPACE_IMAGE) {
			glScalef(1.0f / t->aspect[0], 1.0f / t->aspect[1], 1.0f);
		}
		else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) {
			/* only scale y */
			rcti *mask = &t->ar->v2d.mask;
			rctf *datamask = &t->ar->v2d.cur;
			float xsize = BLI_rctf_size_x(datamask);
			float ysize = BLI_rctf_size_y(datamask);
			float xmask = BLI_rcti_size_x(mask);
			float ymask = BLI_rcti_size_y(mask);
			glScalef(1.0f, (ysize / xsize) * (xmask / ymask), 1.0f);
		}

		depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
		if (depth_test_enabled)
			glDisable(GL_DEPTH_TEST);

		set_inverted_drawing(1);
		drawcircball(GL_LINE_LOOP, t->center_global, t->prop_size, imat);
		set_inverted_drawing(0);

		if (depth_test_enabled)
			glEnable(GL_DEPTH_TEST);

		glPopMatrix();
	}
}
Esempio n. 16
0
/* General call for drawing current frame indicator in animation editor */
void ANIM_draw_cfra (const bContext *C, View2D *v2d, short flag)
{
	Scene *scene= CTX_data_scene(C);
	float vec[2];
	
	/* Draw a light green line to indicate current frame */
	vec[0]= (float)(scene->r.cfra * scene->r.framelen);
	
	UI_ThemeColor(TH_CFRAME);
	glLineWidth(2.0);
	
	glBegin(GL_LINE_STRIP);
		vec[1]= v2d->cur.ymin-500.0f;	/* XXX arbitrary... want it go to bottom */
		glVertex2fv(vec);
		
		vec[1]= v2d->cur.ymax;
		glVertex2fv(vec);
	glEnd();
	
	/* Draw dark green line if slow-parenting/time-offset is enabled */
	if (flag & DRAWCFRA_SHOW_TIMEOFS) {
		Object *ob= OBACT;
		if(ob) {
			float timeoffset= give_timeoffset(ob);
			// XXX ob->ipoflag is depreceated!
			if ((ob->ipoflag & OB_OFFS_OB) && (timeoffset != 0.0f)) {
				vec[0]-= timeoffset; /* could avoid calling twice */
			
				UI_ThemeColorShade(TH_CFRAME, -30);
			
				glBegin(GL_LINE_STRIP);
					/*vec[1]= v2d->cur.ymax;*/ // this is set already. this line is only included
					glVertex2fv(vec);
				
					vec[1]= v2d->cur.ymin;
					glVertex2fv(vec);
				glEnd();
			}
		}
	}
	
	glLineWidth(1.0);
	
	/* Draw current frame number in a little box */
	if (flag & DRAWCFRA_SHOW_NUMBOX) {
		UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
		draw_cfra_number(scene, v2d, vec[0], (flag & DRAWCFRA_UNIT_SECONDS));
	}
}
Esempio n. 17
0
/**
 * Callback that draws a line between the mouse and a position given as the initial argument.
 */
void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info)
{
	wmWindow *win = CTX_wm_window(C);
	const float *mval_src = (float *)arg_info;
	const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
	                         win->eventstate->y - ar->winrct.ymin};

	UI_ThemeColor(TH_VIEW_OVERLAY);
	setlinestyle(3);
	glBegin(GL_LINE_STRIP);
	glVertex2iv(mval_dst);
	glVertex2fv(mval_src);
	glEnd();
	setlinestyle(0);
}
Esempio n. 18
0
void draw_image_cache(const bContext *C, ARegion *ar)
{
	SpaceImage *sima = CTX_wm_space_image(C);
	Scene *scene = CTX_data_scene(C);
	Image *image = ED_space_image(sima);
	float x, cfra = CFRA, sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1);
	Mask *mask = NULL;

	if (!ED_space_image_show_cache(sima)) {
		return;
	}

	if (sima->mode == SI_MODE_MASK) {
		mask = ED_space_image_get_mask(sima);
	}

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	/* Draw cache background. */
	ED_region_cache_draw_background(ar);

	/* Draw cached segments. */
	if (image != NULL && image->cache != NULL && ELEM(image->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
		int num_segments = 0;
		int *points = NULL;

		IMB_moviecache_get_cache_segments(image->cache, IMB_PROXY_NONE, 0, &num_segments, &points);
		ED_region_cache_draw_cached_segments(ar, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset);
	}

	glDisable(GL_BLEND);

	/* Draw current frame. */
	x = (cfra - sfra) / (efra - sfra + 1) * ar->winx;

	UI_ThemeColor(TH_CFRAME);
	glRecti(x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC);
	ED_region_cache_draw_curfra_label(cfra, x, 8.0f * UI_DPI_FAC);

	if (mask != NULL) {
		ED_mask_draw_frames(mask, ar, cfra, sfra, efra);
	}
}
Esempio n. 19
0
/* draw a short status message in the top-right corner */
static void gp_draw_status_text(bGPdata *gpd, ARegion *ar)
{
	rcti rect;
	
	/* Cannot draw any status text when drawing OpenGL Renders */
	if (G.f & G_RENDER_OGL)
		return;
	
	/* Get bounds of region - Necessary to avoid problems with region overlap */
	ED_region_visible_rect(ar, &rect);
	
	/* for now, this should only be used to indicate when we are in stroke editmode */
	if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
		const char *printable = IFACE_("GPencil Stroke Editing");
		float       printable_size[2];
		int xco, yco;
		
		BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
		
		xco = (rect.xmax - U.widget_unit) - (int)printable_size[0];
		yco = (rect.ymax - U.widget_unit);
		
		/* text label */
		UI_ThemeColor(TH_TEXT_HI);
#ifdef WITH_INTERNATIONAL
		BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#else
		BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
#endif
		
		/* grease pencil icon... */
		// XXX: is this too intrusive?
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
		
		xco -= U.widget_unit;
		yco -= (int)printable_size[1] / 2;

		UI_icon_draw(xco, yco, ICON_GREASEPENCIL);
		
		glDisable(GL_BLEND);
	}
}
Esempio n. 20
0
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
	if (t->flag & T_PROP_EDIT) {
		RegionView3D *rv3d = CTX_wm_region_view3d(C);
		float tmat[4][4], imat[4][4];
		float center[3];

		UI_ThemeColor(TH_GRID);

		if(t->spacetype == SPACE_VIEW3D && rv3d != NULL)
		{
			copy_m4_m4(tmat, rv3d->viewmat);
			invert_m4_m4(imat, tmat);
		}
		else
		{
			unit_m4(tmat);
			unit_m4(imat);
		}

		glPushMatrix();

		VECCOPY(center, t->center);

		if((t->spacetype == SPACE_VIEW3D) && t->obedit)
		{
			mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */
		}
		else if(t->spacetype == SPACE_IMAGE)
		{
			float aspx, aspy;

			ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
			glScalef(1.0f/aspx, 1.0f/aspy, 1.0);
		}

		set_inverted_drawing(1);
		drawcircball(GL_LINE_LOOP, center, t->prop_size, imat);
		set_inverted_drawing(0);

		glPopMatrix();
	}
}
Esempio n. 21
0
void clip_draw_curfra_label(SpaceClip *sc, float x, float y)
{
	uiStyle *style = UI_GetStyle();
	int fontid = style->widget.uifont_id;
	char numstr[32];
	float font_dims[2] = {0.0f, 0.0f};

	/* frame number */
	BLF_size(fontid, 11.0f, U.dpi);
	BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr);

	BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]);

	glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);

	UI_ThemeColor(TH_TEXT);
	BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f);
	BLF_draw(fontid, numstr, sizeof(numstr));
}
Esempio n. 22
0
static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
{
	bTheme *btheme = UI_GetTheme();
	uiWidgetColors wcol = btheme->tui.wcol_scroll;
	unsigned char col[4];
	float rad;
	
	UI_ThemeColor(TH_BACK);
	glRecti(back->xmin, back->ymin, back->xmax, back->ymax);

	uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);

	uiSetRoundBox(UI_CNR_ALL);
	rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll));
	UI_GetThemeColor3ubv(TH_HILITE, col);
	col[3] = 48;
	glColor4ubv(col);
	glEnable(GL_BLEND);
	uiRoundBox(st->txtscroll.xmin + 1, st->txtscroll.ymin, st->txtscroll.xmax - 1, st->txtscroll.ymax, rad);
	glDisable(GL_BLEND);
}
Esempio n. 23
0
/* Draw current frame number in a little green box beside the current frame indicator */
static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const bool time)
{
	const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
	float xscale, yscale, x, y;
	char numstr[32] = "    t";  /* t is the character to start replacing from */
	int slen;
	
	/* because the frame number text is subject to the same scaling as the contents of the view */
	UI_view2d_scale_get(v2d, &xscale, &yscale);
	glScalef(1.0f / xscale, 1.0f, 1.0f);
	
	/* get timecode string 
	 *	- padding on str-buf passed so that it doesn't sit on the frame indicator
	 *	- power = 0, gives 'standard' behavior for time
	 *	  but power = 1 is required for frames (to get integer frames)
	 */
	if (time) {
		BLI_timecode_string_from_time(&numstr[4], sizeof(numstr) - 4, 0, FRA2TIME(cfra), FPS, U.timecode_style);
	}
	else {
		BLI_timecode_string_from_time_seconds(&numstr[4], sizeof(numstr) - 4, 1, cfra);
	}

	slen = UI_fontstyle_string_width(fstyle, numstr) - 1;
	
	/* get starting coordinates for drawing */
	x = cfra * xscale;
	y = 0.9f * U.widget_unit;
	
	/* draw green box around/behind text */
	UI_ThemeColorShade(TH_CFRAME, 0);
	glRectf(x, y,  x + slen,  y + 0.75f * U.widget_unit);
	
	/* draw current frame number - black text */
	UI_ThemeColor(TH_TEXT);
	UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr);
	
	/* restore view transform */
	glScalef(xscale, 1.0, 1.0);
}
Esempio n. 24
0
/* draw backdrop of the sequencer strips view */
static void draw_seq_backdrop(View2D *v2d)
{
	int i;
	
	/* darker gray overlay over the view backdrop */
	UI_ThemeColorShade(TH_BACK, -20);
	glRectf(v2d->cur.xmin,  -1.0,  v2d->cur.xmax,  1.0);

	/* Alternating horizontal stripes */
	i = max_ii(1, ((int)v2d->cur.ymin) - 1);

	glBegin(GL_QUADS);
	while (i < v2d->cur.ymax) {
		if (((int)i) & 1)
			UI_ThemeColorShade(TH_BACK, -15);
		else
			UI_ThemeColorShade(TH_BACK, -25);
			
		glVertex2f(v2d->cur.xmax, i);
		glVertex2f(v2d->cur.xmin, i);
		glVertex2f(v2d->cur.xmin, i + 1);
		glVertex2f(v2d->cur.xmax, i + 1);

		i += 1.0;
	}
	glEnd();
	
	/* Darker lines separating the horizontal bands */
	i = max_ii(1, ((int)v2d->cur.ymin) - 1);
	UI_ThemeColor(TH_GRID);
	
	glBegin(GL_LINES);
	while (i < v2d->cur.ymax) {
		glVertex2f(v2d->cur.xmax, i);
		glVertex2f(v2d->cur.xmin, i);
			
		i += 1.0;
	}
	glEnd();
}
Esempio n. 25
0
void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm)
{
	drawMeshFaceSelect_userData data;

	data.me = me;
	data.edge_flags = get_tface_mesh_marked_edge_info(me);

	glEnable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	ED_view3d_polygon_offset(rv3d, 1.0);

	/* Draw (Hidden) Edges */
	setlinestyle(1);
	UI_ThemeColor(TH_EDGE_FACESEL);
	dm->drawMappedEdges(dm, draw_mesh_face_select__setHiddenOpts, &data);
	setlinestyle(0);

	/* Draw Selected Faces */
	if (me->drawflag & ME_DRAWFACES) {
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		/* dull unselected faces so as not to get in the way of seeing color */
		glColor4ub(96, 96, 96, 64);
		dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, (void *)me, 0);
		glDisable(GL_BLEND);
	}
	
	ED_view3d_polygon_offset(rv3d, 1.0);

	/* Draw Stippled Outline for selected faces */
	glColor3ub(255, 255, 255);
	setlinestyle(1);
	dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data);
	setlinestyle(0);

	ED_view3d_polygon_offset(rv3d, 0.0);  /* resets correctly now, even after calling accumulated offsets */

	MEM_freeN(data.edge_flags);
}
Esempio n. 26
0
static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg)
{
	/* draws an aim/cross in the center */
	WalkInfo *walk = arg;

	const int outter_length = 24;
	const int inner_length = 14;
	int xoff, yoff;
	rctf viewborder;

	if (walk->scene->camera) {
		ED_view3d_calc_camera_border(walk->scene, ar, walk->v3d, walk->rv3d, &viewborder, false);
		xoff = viewborder.xmin + BLI_rctf_size_x(&viewborder) * 0.5f;
		yoff = viewborder.ymin + BLI_rctf_size_y(&viewborder) * 0.5f;
	}
	else {
		xoff = walk->ar->winx / 2;
		yoff = walk->ar->winy / 2;
	}

	UI_ThemeColor(TH_VIEW_OVERLAY);
	glBegin(GL_LINES);
	/* North */
	glVertex2i(xoff, yoff + inner_length);
	glVertex2i(xoff, yoff + outter_length);

	/* East */
	glVertex2i(xoff + inner_length, yoff);
	glVertex2i(xoff + outter_length, yoff);

	/* South */
	glVertex2i(xoff, yoff - inner_length);
	glVertex2i(xoff, yoff - outter_length);

	/* West */
	glVertex2i(xoff - inner_length, yoff);
	glVertex2i(xoff - outter_length, yoff);
	glEnd();
}
Esempio n. 27
0
/* General call for drawing current frame indicator in animation editor */
void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
{
	Scene *scene = CTX_data_scene(C);

	/* Draw a light green line to indicate current frame */
	UI_ThemeColor(TH_CFRAME);

	const float time = scene->r.cfra + scene->r.subframe;
	const float x = (float)(time * scene->r.framelen);

	glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);

	glBegin(GL_LINES);
	glVertex2f(x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
	glVertex2f(x, v2d->cur.ymax);
	glEnd();

	/* Draw current frame number in a little box */
	if (flag & DRAWCFRA_SHOW_NUMBOX) {
		UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
		draw_cfra_number(scene, v2d, x, (flag & DRAWCFRA_UNIT_SECONDS) != 0);
	}
}
Esempio n. 28
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 numstr[32] = "    t";  /* t is the character to start replacing from */
	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);
	
	/* get timecode string 
	 *	- padding on str-buf passed so that it doesn't sit on the frame indicator
	 *	- power = 0, gives 'standard' behavior for time
	 *	  but power = 1 is required for frames (to get integer frames)
	 */
	if (time)
		ANIM_timecode_string_from_frame(&numstr[4], scene, 0, time, FRA2TIME(cfra));
	else
		ANIM_timecode_string_from_frame(&numstr[4], scene, 1, time, cfra);
	slen = (short)UI_GetStringWidth(numstr) - 1;
	
	/* get starting coordinates for drawing */
	x = cfra * xscale;
	y = 0.9f * U.widget_unit;
	
	/* draw green box around/behind text */
	UI_ThemeColorShade(TH_CFRAME, 0);
	glRectf(x, y,  x + slen,  y + 0.75f * U.widget_unit);
	
	/* draw current frame number - black text */
	UI_ThemeColor(TH_TEXT);
	UI_DrawString(x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr);
	
	/* restore view transform */
	glScalef(xscale, 1.0, 1.0);
}
Esempio n. 29
0
/* function to draw markers */
static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
{
	float xpos, ypixels, xscale, yscale;
	int icon_id = 0;
	
	xpos = marker->frame;
	
	/* no time correction for framelen! space is drawn with old values */
	ypixels = BLI_rcti_size_y(&v2d->mask);
	UI_view2d_getscale(v2d, &xscale, &yscale);
	
	glScalef(1.0f / xscale, 1.0f, 1.0f);
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	/* vertical line - dotted */
#ifdef DURIAN_CAMERA_SWITCH
	if ((marker->camera) || (flag & DRAW_MARKERS_LINES))
#else
	if (flag & DRAW_MARKERS_LINES)
#endif
	{
		setlinestyle(3);
		
		if (marker->flag & SELECT)
			glColor4ub(255, 255, 255, 96);
		else
			glColor4ub(0, 0, 0, 96);
		
		glBegin(GL_LINES);
		glVertex2f((xpos * xscale) + 0.5f, 12.0f);
		glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
		glEnd();
		
		setlinestyle(0);
	}
	
	/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
	if (flag & DRAW_MARKERS_LOCAL) {
		icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
		          (marker->flag & SELECT) ? ICON_PMARKER_SEL :
		          ICON_PMARKER;
	}
	else {
		icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT :
		          ICON_MARKER;
	}
	
	UI_icon_draw(xpos * xscale - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id);
	
	glDisable(GL_BLEND);
	
	/* and the marker name too, shifted slightly to the top-right */
	if (marker->name && marker->name[0]) {
		float x, y;

		/* minimal y coordinate which wouldn't be occluded by scroll */
		int min_y = 17.0f * UI_DPI_FAC;
		
		if (marker->flag & SELECT) {
			UI_ThemeColor(TH_TEXT_HI);
			x = xpos * xscale + 4.0f * UI_DPI_FAC;
			y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
			y = max_ii(y, min_y);
		}
		else {
			UI_ThemeColor(TH_TEXT);
			if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) {
				x = xpos * xscale + 8.0f * UI_DPI_FAC;
				y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC;
				y = max_ii(y, min_y);
			}
			else {
				x = xpos * xscale + 8.0f * UI_DPI_FAC;
				y = 17.0f * UI_DPI_FAC;
			}
		}

#ifdef DURIAN_CAMERA_SWITCH
		if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) {
			float col[4];
			glGetFloatv(GL_CURRENT_COLOR, col);
			col[3] = 0.4;
			glColor4fv(col);
		}
#endif

		UI_DrawString(x, y, marker->name);
	}
	
	glScalef(xscale, 1.0f, 1.0f);
}
Esempio n. 30
0
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */
static void mat_livedb_draw_tree_element(bContext *C, uiBlock *block, ARegion *ar, SpaceLDB *slivedb, LiveDbTreeElement *te, int startx, int *starty, int *row_num)
{
    LiveDbTreeElement   *ten;
    float               ufac = UI_UNIT_X / 20.0f;
    int                 offsx = 0, active = 0;
    int                 CUR_UNIT_Y;

    if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
        CUR_UNIT_Y = UI_UNIT_Y;
    else
        CUR_UNIT_Y = MAT_LIVEDB_UI_UNIT_Y;

    *starty -= CUR_UNIT_Y;
    ++ *row_num;

    if (*starty + 2 * CUR_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) {
        int xmax = ar->v2d.cur.xmax;
        unsigned char alpha = 128;

        /* icons can be ui buts, we don't want it to overlap with material previews */
        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_MATERIAL)
            xmax -= MAT_LIVEDB_UI_UNIT_Y;

        glEnable(GL_BLEND);

        if(*row_num % 2) {
            UI_ThemeColorShade(TH_BACK, 6);
            glRecti(0, *starty + 1, ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);
        }

        if (*te->flag & TE_SELECTED) {
            float           col[4];
            unsigned char   col_circle[4];

            UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col);
            glColor3fv(col);
            glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);

            /* active circle */
            UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col_circle);
            col_circle[3] = alpha;
            glColor4ubv((GLubyte *)col_circle);

            UI_draw_roundbox_corner_set(UI_CNR_ALL);
            UI_draw_roundbox((float)startx + UI_UNIT_X - ufac,
                       (float)*starty + (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY ? 1.0f : UI_UNIT_Y * 3),
                       (float)startx + 2.0f * UI_UNIT_X - 2.0f * ufac,
                       (float)*starty + CUR_UNIT_Y - 1.0f * ufac,
                       UI_UNIT_Y / 2.0f - 1.0f * ufac);
            glEnable(GL_BLEND); /* roundbox disables it */
        }

        /* start by highlighting search matches */
        if (SEARCHING_MAT_LIVEDB(slivedb) && (*te->flag & TE_SEARCHMATCH))
        {
            char col[4];
            UI_GetThemeColorType4ubv(TH_MATCH, SPACE_MAT_LIVEDB, col);
            col[3] = alpha;
            glColor4ubv((GLubyte *)col);
            glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);
        }

        /* open/close icon, only when sublevels */
        if (te->subtree.first || (*te->flag & TE_LAZY_CLOSED)) {
            int icon_x;
            if (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
                icon_x = startx;
            else
                icon_x = startx + 5 * ufac;

            if (MAT_LIVEDB_ELEM_OPEN(te, slivedb))
                UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_DOWN);
            else
                UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_RIGHT);
        }
        offsx += UI_UNIT_X;

        /* Element type icon */
        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
            mat_livedb_elem_draw_icon((float)startx + offsx, (float)*starty, te);
        else
            mat_livedb_elem_draw_icon((float)startx + offsx, (float)*starty + UI_UNIT_X * 3, te);

        offsx += UI_UNIT_X;

        glDisable(GL_BLEND);

        /* name */
        if (active == 1) UI_ThemeColor(TH_TEXT_HI);
        else UI_ThemeColor(TH_TEXT);

        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + 5 * ufac, te->name);
        else {
            uiBut *bt;

            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X * 3 + 5 * ufac, te->name);
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X * 2 + 5 * ufac, te->nick_name);
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X + 5 * ufac, te->copyright);

            bt = uiDefIconBut(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_WORLD,
                                xmax - UI_UNIT_X - 3, *starty + 1 * ufac, UI_UNIT_X, UI_UNIT_Y,
                                NULL, 0.0, 0.0, 1.0, 0.5f, "Get item");
            UI_but_func_set(bt, get_material_cb, (void*)slivedb->server_address, (void*)te->item->mat_item.id);
            UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
        }

        offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(UI_FSTYLE_WIDGET, te->name));

        /* Closed item, we draw the category-info icons */
        if (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY && !MAT_LIVEDB_ELEM_OPEN(te, slivedb)) {
            if (te->subtree.first) {
                int tempx = startx + offsx;

                /* divider */
                UI_ThemeColorShade(TH_BACK, -40);
                glRecti(tempx   - 10.0f * ufac,
                        *starty +  4.0f * ufac,
                        tempx   -  8.0f * ufac,
                        *starty + CUR_UNIT_Y - 4.0f * ufac);

                glEnable(GL_BLEND);
                glPixelTransferf(GL_ALPHA_SCALE, 0.5);

                mat_livedb_draw_content_count_icons(&te->subtree, xmax, &tempx, *starty);

                glPixelTransferf(GL_ALPHA_SCALE, 1.0);
                glDisable(GL_BLEND);
            }
        }
    }
    /* store coord and continue, we need coordinates for elements outside view too */
    te->xs   = (float)startx;
    te->ys   = (float)*starty;
    te->xend = startx + offsx;

    if (MAT_LIVEDB_ELEM_OPEN(te, slivedb)) {
        for (ten = te->subtree.first; ten; ten = ten->next)
            mat_livedb_draw_tree_element(C, block, ar, slivedb, ten, startx + UI_UNIT_X, starty, row_num);
    }
    else {
        for (ten = te->subtree.first; ten; ten = ten->next)
            mat_livedb_set_coord_tree_element(slivedb, te, startx, starty);
    }
} /* mat_livedb_draw_tree_element() */