Beispiel #1
0
void uisimp_paint(t_uisimp *x, t_object *view)
{
	t_jgraphics *g;
	t_rect rect;
	t_jrgba rgba, textcolor;
	t_jfont *jf;
	t_jtextlayout *jtl;
	char text[16];
	
	g = (t_jgraphics*) patcherview_get_jgraphics(view); 
	jbox_get_rect_for_view(&x->j_box.b_ob, view, &rect);
			
	if (x->j_mouse_is_down) {
		jbox_get_color((t_object *)x, &rgba);
		jgraphics_set_source_jrgba(g, &rgba);
	} else
		jgraphics_set_source_rgba(g, 0, 0, 0, 1.0);
	//jgraphics_fill(g);
	// draw counter
	jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, jbox_get_font_slant((t_object *)x), jbox_get_font_weight((t_object *)x), jbox_get_fontsize((t_object *)x));
	jtl = jtextlayout_create();
	sprintf(text,"%d",x->j_mouse_counter);
	
	jtextlayout_set(jtl, text, jf, 5, 5, rect.width - 10, rect.height- 10, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP);
	textcolor.red = textcolor.green = textcolor.blue = 1;
	textcolor.alpha = 1;
	jtextlayout_settextcolor(jtl, &textcolor); 
	jtextlayout_draw(jtl, g);
	jtextlayout_destroy(jtl);
	jfont_destroy(jf);
}
Beispiel #2
0
void uisimp_paint(t_uisimp *x, t_object *view)
{
	t_jgraphics *g;
	t_rect rect;
	t_jrgba rgba, textcolor;
	t_jfont *jf;
	t_jtextlayout *jtl;
	char text[16];
	long inset = x->j_inset;
	
	g = (t_jgraphics*) patcherview_get_jgraphics(view); 
	jbox_get_rect_for_view(&x->j_box.b_ob, view, &rect);
	
	if (x->j_shape == EXAMP_SQUARE)
		jgraphics_rectangle(g, inset, inset, rect.width - (inset * 2), rect.height - (inset * 2));
	else if (x->j_shape == EXAMP_CIRCLE) {
		jgraphics_arc(g, rect.width * .5, rect.height * .5, (rect.width * .5) - (inset * 2), 0, JGRAPHICS_2PI);
		jgraphics_close_path(g);
	} else if (x->j_shape == EXAMP_ANGLE) {
		jgraphics_move_to(g, inset * 2, inset);
		jgraphics_line_to(g, rect.width - (inset * 2), inset);
		jgraphics_line_to(g, rect.width - (inset * 2), inset * 2);
		jgraphics_line_to(g, rect.width - (inset * 2), rect.height - (inset * 2));
		jgraphics_line_to(g, rect.width - (inset * 2), rect.height - inset);
		jgraphics_line_to(g, inset * 2, rect.height - (inset * 2));
		jgraphics_line_to(g, inset, rect.height - (inset * 3));
		jgraphics_line_to(g, inset, inset * 2);
		jgraphics_line_to(g, inset * 2, inset);
		jgraphics_close_path(g);
	}
		
	if (x->j_mouse_is_down) {
		jbox_get_color((t_object *)x, &rgba);
		jgraphics_set_source_jrgba(g, &rgba);
	} else
		jgraphics_set_source_rgba(g, 0, 0, 0, 1.0);
	jgraphics_fill(g);
	// draw counter
	jf = jfont_create(jbox_get_fontname((t_object *)x)->s_name, jbox_get_font_slant((t_object *)x), jbox_get_font_weight((t_object *)x), jbox_get_fontsize((t_object *)x));
	jtl = jtextlayout_create();
	sprintf(text,"%d",x->j_mouse_counter);
	
	jtextlayout_set(jtl, text, jf, 5, 5, rect.width - 10, rect.height- 10, JGRAPHICS_TEXT_JUSTIFICATION_CENTERED, JGRAPHICS_TEXTLAYOUT_NOWRAP);
	textcolor.red = textcolor.green = textcolor.blue = 1;
	textcolor.alpha = 1;
	jtextlayout_settextcolor(jtl, &textcolor); 
	jtextlayout_draw(jtl, g);
	jtextlayout_destroy(jtl);
	jfont_destroy(jf);
}
void paramui_paint(t_paramui *x, t_object *view)
{
	t_rect 		rect;
	t_jgraphics *g;
	double		middle;
	double 		border_thickness = 1.5;
	double 		cornersize = 13.0;

	g = (t_jgraphics*) patcherview_get_jgraphics(view);
	jbox_get_rect_for_view((t_object*) &x->box, view, &rect);

	// clear the background
	jgraphics_rectangle_rounded(g,  border_thickness, 
									border_thickness, 
									rect.width - (border_thickness * 2.0), 
									rect.height - (border_thickness * 2.0), 
									cornersize, cornersize); 
	jgraphics_set_source_rgba(g, 0.1, 0.1, 0.1, 1.0);
	jgraphics_fill(g);
		
	// draw the inspector icon

	jgraphics_set_source_rgb(g, 0.2, 0.2, 0.2);
	jgraphics_set_line_width(g, 1.5);
	jgraphics_oval(g,	border_thickness,
						border_thickness, 
						rect.height - (border_thickness * 2.0),
						rect.height - (border_thickness * 2.0));
	jgraphics_fill(g);
	
	jgraphics_rectangle_fill_fast(g,	border_thickness + rect.height / 2 - (border_thickness), 
										border_thickness,
										border_thickness + rect.height / 2, 
										rect.height - (border_thickness * 2.0));

	jgraphics_set_source_rgb(g, 0.4, 0.4, 0.4);
	middle = 6.0;
	jgraphics_move_to(g, 9.5, middle + 4.0);
	jgraphics_line_to(g, 13.0, middle);
	jgraphics_line_to(g, 6.0, middle);
	jgraphics_close_path(g);
	jgraphics_fill(g);


	if(x->attr_dataspace != jps_none) {
		char data[64];	
	
		strncpy(data, x->attr_unitActive->s_name, 64);

		// draw the unit display
		jgraphics_set_source_rgb(g, 0.2, 0.2, 0.2);
		jgraphics_set_line_width(g, 1.5);
		jgraphics_oval(g,	rect.width - (rect.height - (border_thickness * 2.0)) - 2.0, 
							border_thickness, 
							rect.height - (border_thickness * 2.0), 
							rect.height - (border_thickness * 2.0));
		jgraphics_fill(g);
		
		jgraphics_rectangle_fill_fast(g,	rect.width - ((border_thickness + rect.height / 2 - (border_thickness)) * 3.0) - 2.0, 
											border_thickness, 
											border_thickness + rect.height / 1, 
											rect.height - (border_thickness * 2.0));


		jtextlayout_settextcolor(x->layout_unit, &s_light_gray);
		jtextlayout_set(x->layout_unit,
						data,
						jfont_create(JAMOMA_DEFAULT_FONT, JGRAPHICS_FONT_SLANT_NORMAL, JGRAPHICS_FONT_WEIGHT_NORMAL, JAMOMA_DEFAULT_FONTSIZE),
						rect.width - 28.0, 0.0, 28.0, rect.height - 1.0,
						JGRAPHICS_TEXT_JUSTIFICATION_CENTERED,
						JGRAPHICS_TEXTLAYOUT_USEELLIPSIS);
		jtextlayout_draw(x->layout_unit, g);
	}
	
	{
		char	data[256];
		t_atom	*av = NULL;
		long	ac = 0;

		if(x->obj_parameter){
			object_attr_getvalueof(x->obj_parameter, gensym("value"), &ac, &av);
			if(ac){
				if(x->attr_type == jps_decimal)
					snprintf(data, 256, "%.4f", atom_getfloat(av));
				else if(x->attr_type == jps_integer || x->attr_type == jps_boolean)
					snprintf(data, 256, "%ld", atom_getlong(av));
				else if(x->attr_type == jps_string)
					strcpy(data, atom_getsym(av)->s_name);
				
				jtextlayout_settextcolor(x->layout_value, &s_light_gray);
				jtextlayout_set(x->layout_value,
								data,
								jfont_create(JAMOMA_DEFAULT_FONT, JGRAPHICS_FONT_SLANT_NORMAL, JGRAPHICS_FONT_WEIGHT_NORMAL, JAMOMA_DEFAULT_FONTSIZE),
								84.0, 2.0, rect.width - 84.0 - 20.0, rect.height - 1.0,
								JGRAPHICS_TEXT_JUSTIFICATION_LEFT,
								JGRAPHICS_TEXTLAYOUT_USEELLIPSIS);
				jtextlayout_draw(x->layout_value, g);
				sysmem_freeptr(av);
			}
		}
	}

	// draw borders
	jgraphics_rectangle_rounded(g,  border_thickness, 
									border_thickness, 
									rect.width - (border_thickness * 2.0), 
									rect.height - (border_thickness * 2.0), 
									cornersize, cornersize); 
	jgraphics_set_source_rgb(g, 0.3, 0.3, 0.3);
	jgraphics_set_line_width(g, 1.5);
	jgraphics_stroke(g);

	jgraphics_set_line_width(g, 1.0);
	jgraphics_move_to(g, border_thickness, 19.5);
	jgraphics_line_to(g, rect.width - (border_thickness * 1.0), 19.5);
	jgraphics_stroke(g);
}
void draw_vectors(t_meter *x, t_object *view, t_rect *rect)
{
	double pointSize = rect->width*0.02;
	double maxRadius = (x->f_rayonInt-pointSize-1);
	if (pointSize > maxRadius)
		return;
	
	double vecX, vecY;
	t_jmatrix transform;
	t_jgraphics *g = jbox_start_layer((t_object *)x, view, hoa_sym_vectors_layer, rect->width, rect->height);
	
	if (g)
	{
		jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center, x->f_center);
		jgraphics_set_matrix(g, &transform);
        
        
		if (x->f_rotation)
			jgraphics_rotate(g, x->f_meter->getPlanewavesRotationX());
		else
			jgraphics_rotate(g, -x->f_meter->getPlanewavesRotationX());
        
		if (x->f_drawvector == VECTOR_BOTH || x->f_drawvector == VECTOR_ENERGY)
		{
			if (x->f_rotation)
			{
				vecX = x->f_vector_coords[2] * maxRadius;
				vecY = x->f_vector_coords[3] * maxRadius;
			}
			else
			{
                double rad = Math<double>::radius(x->f_vector_coords[2], x->f_vector_coords[3]) * maxRadius;
                double ang = -Math<double>::azimuth(x->f_vector_coords[2], x->f_vector_coords[3]);
                vecX = Math<double>::abscissa(rad, ang);
                vecY = Math<double>::ordinate(rad, ang);
			}
			
			jgraphics_set_source_jrgba(g, &x->f_color_energy);
			jgraphics_arc(g, vecX, vecY, pointSize, 0., HOA_2PI);
			jgraphics_fill_preserve(g);
			jgraphics_set_source_rgba(g, 0.2, 0.2, 0.2, 1.);
			jgraphics_stroke(g);
		}
		
		if (x->f_drawvector == VECTOR_BOTH || x->f_drawvector == VECTOR_VELOCITY)
		{
			if (x->f_rotation)
			{
				double rad = min(Math<double>::radius(x->f_vector_coords[0], x->f_vector_coords[1]), 1.) * maxRadius;
                double ang = Math<double>::azimuth(x->f_vector_coords[0], x->f_vector_coords[1]);
                vecX = Math<double>::abscissa(rad, ang);
                vecY = Math<double>::ordinate(rad, ang);
			}
			else
			{
				double rad = min(Math<double>::radius(x->f_vector_coords[0], x->f_vector_coords[1]), 1.) * maxRadius;
                double ang = -Math<double>::azimuth(x->f_vector_coords[0], x->f_vector_coords[1]);
                vecX = Math<double>::abscissa(rad, ang);
                vecY = Math<double>::ordinate(rad, ang);
			}
						
			jgraphics_set_source_jrgba(g, &x->f_color_velocity);
			jgraphics_arc(g, vecX, vecY, pointSize, 0., HOA_2PI);
			jgraphics_fill_preserve(g);
			jgraphics_set_source_rgba(g, 0.2, 0.2, 0.2, 1.);
			jgraphics_stroke(g);
		}
		jbox_end_layer((t_object*)x, view, hoa_sym_vectors_layer);
	}
	
	jbox_paint_layer((t_object *)x, view, hoa_sym_vectors_layer, 0., 0.);
}