void hoa_gain_mouseup(t_hoa_gain *x, t_object *patcherview, t_pt pt, long modifiers)
{
    double pos, vp;
    t_rect rect;
    double mx, my;
    char ishoriz;
    
    jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
    ishoriz = hoa_gain_ishorizontal(x, &rect);
    pos = hoa_gain_valtopos(x, x->j_val, &rect, ishoriz);
    vp = pos + 0.5;
    if (ishoriz)
    {
        mx = vp;
        my = pt.y;	// have y position be same as where mouse down clicked
    }
    else
    {
        mx = pt.x;	// have x position be same as where mouse down clicked
        my = vp;
    }
    
    if (fabs(pt.x-mx) > 1. || fabs(pt.y-my) > 1.) // this make sure that if you click at the "same" location we don't move the mouse.
        jmouse_setposition_box(patcherview, (t_object*) x, mx, my);
}
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];
	
	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 #3
0
void meter_paint(t_meter *x, t_object *view)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, view, &rect);
    x->f_rect = rect;
	
	x->f_center = rect.width * .5;
	x->f_center = rect.height * .5;
	
	x->f_rayonMax = rect.width * .5;
	if(rect.width > rect.height)
		x->f_rayonMax = rect.height * .5;
	
	x->f_fontsize = (x->f_rayonMax / 14.) - 1.;
	x->f_rayonCircle = x->f_rayonMax / 32;
	
	x->f_rayonExt = x->f_rayonMax - (1*0.5) - 2;
	x->f_rayonInt = x->f_rayonExt*(1 - x->f_metersize);
	
	draw_skeleton(x, view, &rect);
    draw_leds(x, view, &rect);
    if (x->f_drawmborder == 2 || x->f_drawmborder == 3)
        draw_separator(x, view, &rect);
    if (x->f_drawvector == 2 || x->f_drawvector == 3)
		draw_vector_velocity(x, view, &rect);
	if (x->f_drawvector == 1 || x->f_drawvector == 3)
		draw_vector_energy(x, view, &rect);
}
Beispiel #4
0
void rd_mousedrag(t_rd *x, t_object *patcherview, t_pt pt, long modifiers){
	t_rect rect;
    	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	double f;
	if(x->mode){
		f = rd_scale(pt.y, rect.height, 0, x->freqmin, x->freqmax);
	}else{
		f = rd_scale(pt.x, 0, rect.width, x->freqmin, x->freqmax);
	}
	if((f > x->selection.min)&&(f >= x->selection.max)){
		x->selection.max = f;
	}else if ((f <= x->selection.min)&&(f < x->selection.max)){
		x->selection.min = f;
				
	}else{
		//if its in between both, move the closest one. 
		if (abs(f - x->selection.min) < abs(f - x->selection.max)){
			x->selection.min = f;
		} else {
			x->selection.max = f;
		}
	}
	rd_output_sel(x);
	jbox_redraw(&(x->ob));
}
Beispiel #5
0
void pictmeter_paint(t_pictmeter *x, t_object *patcherview)
{
	t_rect src, dst, rect;
	t_jgraphics *g = (t_jgraphics *) patcherview_get_jgraphics(patcherview);		// obtain graphics context
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	if (!x->p_surface)
		return;

	// draw if the value is non zero
	if (x->p_value) {
		src.width = jgraphics_image_surface_get_width(x->p_surface);
		src.height = jgraphics_image_surface_get_height(x->p_surface);
		src.x = 0;
		src.y = 0;
		dst.width = rect.width * x->p_value;
		dst.height = rect.height * x->p_value;
		if (dst.width < 1 || dst.height < 1)
			return;
		dst.x = 0 + ((rect.width * 0.5) - (dst.width * 0.5));
		dst.y = 0 + ((rect.height * 0.5) - (dst.height * 0.5));

		jgraphics_image_surface_draw(g, x->p_surface, src, dst);
	}
}
Beispiel #6
0
void tralala_paintCurrentText(t_tll *x, t_object *pv, char *string)
{
    t_rect r;
    t_jgraphics *g = NULL; 
    t_jfont *font = NULL;
    t_jgraphics_textlayout_flags flags = (t_jgraphics_textlayout_flags) (0);
    t_jgraphics_text_justification justification = JGRAPHICS_TEXT_JUSTIFICATION_RIGHT;
    
    jbox_get_rect_for_view((t_object *)x, pv, &r);
    
    g = (t_jgraphics *)patcherview_get_jgraphics(pv);
    font = jfont_create((jbox_get_fontname(((t_object *)x)))->s_name, 
                (t_jgraphics_font_slant)(jbox_get_font_slant((t_object *)x)), 
                (t_jgraphics_font_weight)(jbox_get_font_weight((t_object *)x)), 
                (jbox_get_fontsize((t_object *)x))); 
    
    jtextlayout_set(x->layer, string, font, 5., 5., r.width - 10., r.height - 5., justification, flags);

    if (TLL_FLAG_TRUE(TLL_FLAG_FOCUS)) {
        jtextlayout_settextcolor(x->layer, &x->text);
    } else {
        jtextlayout_settextcolor(x->layer, &x->uText);
    }
    
    jtextlayout_draw(x->layer, g);
    
    jfont_destroy(font);
}
Beispiel #7
0
void hoa_meter_mousedown(t_hoa_meter *x, t_object *patcherview, t_pt pt, long modifiers)
{
    t_rect rect;
    jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
    x->f_mouse = pt;
    x->f_camera_ref[0] = x->f_camera[0];
    x->f_camera_ref[1] = x->f_camera[1];
}
Beispiel #8
0
void uisimp_mouseup(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
	jmouse_setposition_view(patcherview, rect.x + x->j_absolute_position.x, rect.y + x->j_absolute_position.y);
	x->j_mouse_is_down = false;
	jbox_redraw((t_jbox *)x);
}
Beispiel #9
0
void uisimp_mousedragdelta(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
	rect.x += pt.x;
	rect.y += pt.y;
	jbox_set_rect_for_view((t_object *)x, patcherview, &rect);
}
Beispiel #10
0
void paramui_mousedown(t_paramui *x, t_object *patcherview, t_pt px, long modifiers)
{
	t_rect rect;
	
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect); 
	if(px.x < 14)
		paramui_menu_do(x, patcherview, px, modifiers);
}
Beispiel #11
0
void hoa_meter_mousedrag(t_hoa_meter *x, t_object *patcherview, t_pt pt, long modifiers)
{
    t_atom av[2];
    t_rect rect;
    jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
    atom_setfloat(av, x->f_camera_ref[0] + (pt.x - x->f_mouse.x) / (rect.width * 0.5) * CICM_PI2);
    atom_setfloat(av+1, x->f_camera_ref[1] + (pt.y - x->f_mouse.y) / (-rect.height * 0.5) * CICM_PI2);
    object_method(x, gensym("camera"), 2, av);
}
void hoa_gain_paint(t_hoa_gain *x, t_object *view)
{
    t_rect rect;
    char isHoriz;
    jbox_get_rect_for_view((t_object *)x, view, &rect);
    isHoriz = hoa_gain_ishorizontal(x, &rect);
    draw_background(x, view, &rect, isHoriz);
    draw_cursor(x, view, &rect, isHoriz);
    draw_valuerect(x, view, &rect, isHoriz);
}
Beispiel #13
0
void hoa_scope_paint(t_hoa_scope *x, t_object *view)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, view, &rect);
	
	x->f_center = rect.width * .5;
	x->f_radius = x->f_center * 0.95;
	
    draw_background(x, view, &rect);
    draw_harmonics(x, view, &rect);
}
void hoa_gain_mousedown(t_hoa_gain *x, t_object *patcherview, t_pt pt, long modifiers)
{
    t_rect rect;
    jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
    s_hoa_gain_cum.x = s_hoa_gain_cum.y = 0;
    bool ishoriz = hoa_gain_ishorizontal(x, &rect);
    double val = hoa_gain_postoval(x, pt, &rect, ishoriz);
    
    if (!x->j_relative)
    {
        hoa_gain_float_dB(x, val + x->j_min);	// set value immediately
    }
    s_hoa_gain_startval = x->j_val;
}
Beispiel #15
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);
}
Beispiel #16
0
void meter_dopaint_vertical(t_meter *x, t_object *view) {

	t_rect			rect;
	t_jgraphics*	g;
	double			level = TTClip(x->envelope, 0.0f, 1.0f);
	double			position;
	double			peakPosition;
	t_jrgba			c;
	
	if (level > 0.0)
		level = pow(level, kTTGainMidiPowerInv);	// this is taken from the midi conversion in the Gain Dataspace
	
	g = (t_jgraphics*) patcherview_get_jgraphics(view);		// obtain graphics context
	jbox_get_rect_for_view((t_object *)x, view, &rect);		// this is the box rectangle -- but we draw relative to 0 0, and thus only care about width & height
	rect.x = 0;
	rect.y = 0;
	position = rect.height * level * 0.96;
	peakPosition = rect.height * x->peak * 0.96;

	if (level > x->peak)
		x->peak = level;
						
	// TODO: Can we export this from the kernel???	
	//	jgraphics_image_surface_draw_fast(g, x->gradientSurface);
	jgraphics_image_surface_draw(g, x->gradientSurface, x->gradientRect, rect);
	
	jgraphics_set_source_jrgba(g, &x->attrBgColor);
	jgraphics_rectangle_fill_fast(g, 0, 0, rect.width, rect.height-position);

	if (x->envelope > 1.0 || x->peak > 1.0) {
		c.red = 1.0;
		c.green = c.blue = 0.0;
		c.alpha = 1.0;
		jgraphics_set_source_jrgba(g, &c);
		jgraphics_rectangle_fill_fast(g, 0, 0, rect.width, rect.height * .04);
	}
	else {
		c.red = peakPosition / x->gradientRect.height;
		c.green = 1.0;
		c.blue = 0.0;
		c.alpha = 1.0;
		jgraphics_set_source_jrgba(g, &c);
		// TODO: Can we export this from the kernel???	
		// jgraphics_line_draw_fast(g, rect.width * level * 0.96, 0, rect.width * level * 0.96, rect.height, 1.0);
		jgraphics_move_to(g, 0.0, rect.height - peakPosition);
		jgraphics_line_to(g, rect.width, rect.height - peakPosition);
		jgraphics_set_line_width(g, 1.0);
		jgraphics_stroke(g);
	}
}
Beispiel #17
0
void rd_mousedown(t_rd *x, t_object *patcherview, t_pt pt, long modifiers){
	t_rect rect;
    	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	double f;
	if(x->mode){
		f = rd_scale(pt.y, rect.height, 0, x->freqmin, x->freqmax);
	}else{
		f = rd_scale(pt.x, 0, rect.width, x->freqmin, x->freqmax);
	}
	x->selection.min = x->selection.max = f;

	jbox_redraw(&(x->ob));
}
void hoa_gain_mousedragdelta(t_hoa_gain *x, t_object *patcherview, t_pt pt, long modifiers)
{
    t_rect rect;
    double inc;
    double val, cval;
    double factor;
    
    jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
    
    if (modifiers & eShiftKey)
    {
        pt.y *= 0.2;
        pt.x *= 0.2;
    }
    
    // need to cancel cum change if it is beyond zero or the max value
    s_hoa_gain_cum.x += pt.x;
    s_hoa_gain_cum.y -= pt.y;
    if (hoa_gain_ishorizontal(x, &rect))
    {
        factor = x->j_size / (rect.width - (hoa_gain_DISPLAYINSET*2));
        inc = s_hoa_gain_cum.x * factor;
        val = s_hoa_gain_startval + inc;
        cval = hoa_gain_constrain(x,val);
        hoa_gain_float_dB(x,cval + x->j_min);
        // in case we were constrained, adjust the cum
        if (cval != val)
            s_hoa_gain_cum.x = (cval-s_hoa_gain_startval) / factor;
    }
    else
    {
        factor = x->j_size / (rect.height - (hoa_gain_DISPLAYINSET*2));
        inc = s_hoa_gain_cum.y * factor;
        val = s_hoa_gain_startval + inc;
        cval = hoa_gain_constrain(x,val);
        hoa_gain_float_dB(x, cval + x->j_min);
        if (cval != val)
            s_hoa_gain_cum.y = (cval - s_hoa_gain_startval) / factor;
    }
    
    // force to 0dB :
    if (isInside(x->j_valdB, -0.05, 0.05) )
        hoa_gain_float_dB(x, 0);
}
void meter_paint(t_meter *x, t_object *view)
{
    t_rect rect;
    jbox_get_rect_for_view((t_object *)x, view, &rect);
    
    x->f_center = rect.width * 0.5;
    x->f_rayonMax = x->f_center;
    x->f_fontsize = (x->f_rayonMax / 14.) - 1.;
    x->f_rayonCircle = x->f_rayonMax / 32;
    x->f_rayonExt = x->f_rayonMax - 2.5;
    x->f_rayonInt = x->f_rayonExt * (1 - x->f_metersize);
    
    draw_skeleton(x, view, &rect);
    draw_leds(x, view, &rect);
    if (x->f_drawmborder == 2 || x->f_drawmborder == 3)
        draw_separator(x, view, &rect);
    if (x->f_drawvector != VECTOR_NONE)
        draw_vectors(x, view, &rect);
}
Beispiel #20
0
void odisplay_paint(t_odisplay *x, t_object *patcherview)
{
	int have_new_data = 0;
	int draw_new_data_indicator = 0;
	critical_enter(x->lock);
	have_new_data = x->have_new_data;
	draw_new_data_indicator = x->draw_new_data_indicator;
	critical_exit(x->lock);
	if(have_new_data){	
        odisplay_bundle2text(x);
	}
    
	t_rect rect;
	t_jgraphics *g = (t_jgraphics *)patcherview_get_jgraphics(patcherview);
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	jgraphics_set_source_jrgba(g, &(x->background_color));
    jgraphics_rectangle_rounded(g, 0, 0, rect.width, rect.height - 10, 8, 8);
    jgraphics_rectangle(g, 0, rect.height - 14, 4, 4);
    jgraphics_rectangle(g, rect.width - 4, rect.height - 14, 4, 4);
    jgraphics_fill(g);

    jgraphics_set_source_jrgba(g, &(x->frame_color));
    jgraphics_rectangle_rounded(g, 0, rect.height - 10, rect.width, 10, 8, 8);
    jgraphics_rectangle(g, 0, rect.height - 10, 4, 4);
    jgraphics_rectangle(g, rect.width - 4, rect.height - 10, 4, 4);
    jgraphics_fill(g);
    
    jgraphics_set_source_jrgba(g, &(x->frame_color));
    jgraphics_rectangle_rounded(g, 1, 1, rect.width - 2, rect.height - 2, 8, 8);
    jgraphics_set_line_width(g, 2.);
    jgraphics_stroke(g);
    
    if (draw_new_data_indicator) {
        jgraphics_set_source_jrgba(g, &(x->flash_color));
		jgraphics_ellipse(g, rect.width - 12, 6, 6, 6);
		jgraphics_fill(g);
		critical_enter(x->lock);
		x->draw_new_data_indicator = 0;
		critical_exit(x->lock);
		clock_delay(x->new_data_indicator_clock, 100);
    }
}
Beispiel #21
0
void space_paint(t_space *x, t_object *view)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, view, &rect);
	
	x->f_center.x = rect.width * .5;
	x->f_center.y = rect.height * .5;
	
	x->f_rayonGlobal = rect.width * .5;
	if(rect.width > rect.height)
		x->f_rayonGlobal = rect.height * .5;
	
	x->f_rayonCircle = x->f_rayonGlobal / 6;
	
	draw_background(x, view, &rect);
    draw_rotation(x, view, &rect);
	draw_harmonics(x, view, &rect);
	draw_microphones_points(x, view, &rect);
}
Beispiel #22
0
void hoa_space_paint(t_hoa_space *x, t_object *view)
{
    t_rect rect;
	jbox_get_rect_for_view((t_object *)x, view, &rect);
    
    x->f_center.x = rect.width  * .5;
	x->f_center.y = rect.height * .5;
	
	x->f_radius_global = rect.width * .5;
	if(rect.width > rect.height)
		x->f_radius_global = rect.height * .5;
	

    x->f_radius_ext_circle = x->f_radius_global - 5;
    x->f_radius_circle = x->f_radius_ext_circle / NUMBER_OF_CIRCLES;
    
    hoa_space_draw_background(x, view, &rect);
    hoa_space_draw_harmonics(x, view, &rect);
    hoa_space_draw_microphones(x, view, &rect);
}
Beispiel #23
0
void uisimp_mousedrag(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers)
{
	t_rect rect;

	// test to see if mouse is still inside the object
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	// redraw if changed
	if (pt.x >= 0 && pt.x <= rect.width && pt.y >= 0 && pt.y <= rect.height) {
		if (!x->u_mousedowninside) {
			x->u_mousedowninside = true;
			jbox_redraw((t_jbox *)x);
		}
	} else {
		if (x->u_mousedowninside) {
			x->u_mousedowninside = false;
			jbox_redraw((t_jbox *)x);
		}
	}
}
Beispiel #24
0
void scope_paint(t_scope *x, t_object *view)
{
	t_rect rect;
	jbox_get_rect_for_view((t_object *)x, view, &rect);
	
	x->f_center.x = rect.width * .5;
	x->f_center.y = rect.height * .5;
	
	x->f_rayonGlobal = rect.width * .5;
	if(rect.width > rect.height)
		x->f_rayonGlobal = rect.height * .5;
	
	x->f_fontsize = (x->f_rayonGlobal / 14.) - 1.;
	x->f_rayonAngle = 5. / 6. * x->f_rayonGlobal + x->f_fontsize * 1.5;
	x->f_rayonCircle = x->f_rayonGlobal / 6;
	
	if (x->f_drawCircle) draw_background(x, view, &rect);
    if (x->f_drawAngles) draw_angles(x, view, &rect);
    if (x->f_drawContributions) draw_contribution(x, view, &rect);
    draw_harmonics(x, view, &rect);
}
void jucebox_paint(t_jucebox* x, t_object *patcherview)
{
    t_rect rect, srcRect, destRect;
    int width, height, imgStride;
    unsigned char* data;
    
    if(x->j_component->isOnDesktop())
    {
        x->j_component->setActive();
        if(x->j_component->isContextOk())
        {
            jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
            t_jgraphics *g = (t_jgraphics *)patcherview_get_jgraphics(patcherview);
            if(g)
            {
                juce::Image openGLSnap = x->j_component->makeScreenshot((t_object *)x, rect.width, rect.height);
               
                juce::Image::BitmapData* snapBitmap = new juce::Image::BitmapData(openGLSnap, juce::Image::BitmapData::readOnly);
                data = snapBitmap->data;
                width = openGLSnap.getWidth();
                height = openGLSnap.getHeight();
                imgStride = snapBitmap->lineStride;
                
                srcRect.x = 0;
                destRect.x = 0;
                srcRect.y = 0;
                destRect.y = 0;
                srcRect.width = openGLSnap.getWidth();
                srcRect.height = openGLSnap.getHeight();
                destRect.width = rect.width;
                destRect.height = rect.height;
                
                t_jsurface* surface = jgraphics_image_surface_create_for_data(data, JGRAPHICS_FORMAT_ARGB32, width, height, imgStride, NULL, NULL);
                jgraphics_image_surface_draw(g, surface, srcRect, destRect);
                jgraphics_surface_destroy(surface);
            }
        }
        
    }
}
Beispiel #26
0
void uisimp_paint(t_uisimp *x, t_object *patcherview)
{
	t_rect rect;
	t_jgraphics *g = (t_jgraphics *) patcherview_get_jgraphics(patcherview);		// obtain graphics context
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);

	// paint outline
	jgraphics_set_source_jrgba(g, &x->u_outline);
	jgraphics_set_line_width(g, 1.);
	jgraphics_rectangle(g, 0., 0., rect.width, rect.height);
	jgraphics_stroke(g);

	// paint "inner highlight" to indicate mouseover
	if (x->u_mouseover && !x->u_mousedowninside) {
		jgraphics_set_source_jrgba(g, &x->u_hilite);
		jgraphics_set_line_width(g, 1.);
		jgraphics_rectangle(g, 1., 1., rect.width - 2, rect.height - 2);
		jgraphics_stroke(g);
	}
	if (x->u_mousedowninside && !x->u_state) {		// paint hilite color
		jgraphics_set_source_jrgba(g, &x->u_hilite);
		jgraphics_rectangle(g, 1., 1., rect.width - 2, rect.height - 2);
		jgraphics_fill(g);
	}

	// paint "check" (actually a filled rectangle) if state is on
	if (x->u_state) {
		t_jrgba col;

		jbox_get_color((t_object *)x, &col);
		jgraphics_set_source_jrgba(g, &col);
		if (x->u_mousedowninside)		// make rect bigger if mouse is down and we are unchecking
			jgraphics_rectangle(g, 3., 3., rect.width - 6, rect.height - 6);
		else
			jgraphics_rectangle(g, 4., 4., rect.width - 8, rect.height - 8);
		jgraphics_fill(g);
	}
}
Beispiel #27
0
void rd_paint(t_rd *x, t_object *patcherview){
	t_rect rect;
    
	t_jgraphics *g = (t_jgraphics *)patcherview_get_jgraphics(patcherview);
	jbox_get_rect_for_view((t_object *)x, patcherview, &rect);
        
	jgraphics_set_source_jrgba(g, &(x->bordercolor));
	jgraphics_set_line_width(g, 1);
	jgraphics_rectangle(g, 0., 0., rect.width, rect.height);
	jgraphics_stroke(g);
    
	jgraphics_set_source_jrgba(g, &(x->bgcolor));
	jgraphics_rectangle(g, 0., 0., rect.width, rect.height);
	jgraphics_fill(g);

	// data
	{
		jgraphics_set_source_jrgba(g, &(x->datacolor));
		int i;
		if(x->sinusoids){
			t_sin *s = (t_sin *)(x->buffer);
			for(i = 0; i < x->n; i++){
				double xx, yy;
				xx = rd_scale(s[i].f, x->freqmin, x->freqmax, 0, rect.width);
				if(x->log){
					yy = rd_scale((20. * log(s[i].a)) / log(10), x->ampmin_log, x->ampmax_log, rect.height, 0.);
				}else{
					yy = rd_scale(s[i].a, x->ampmin, x->ampmax, rect.height, 0);
				}

				jgraphics_move_to(g, xx, yy);
				jgraphics_line_to(g, xx, rect.height);
				jgraphics_stroke(g);
			}

		}else if(x->mode){
			t_jsurface *s = jgraphics_image_surface_create(JGRAPHICS_FORMAT_ARGB32, rect.width, rect.height);
			//t_jgraphics *gg = jgraphics_create(s);
			t_res *r = (t_res *)(x->buffer);
			int j;
			t_jrgba c;
			for(j = 0; j < rect.width; j++){
				for(i = 0; i < x->n; i++){
					double amp = exp((-j / (rect.width * .1)) * r[i].d);
					c = (t_jrgba){x->datacolor.red * amp, x->datacolor.green * amp, x->datacolor.blue * amp, 1.};
					jgraphics_image_surface_set_pixel(s, j, rd_scale(r[i].f, x->freqmin, x->freqmax, rect.height, 0), c);

					//jgraphics_set_source_jrgba(g, &c);
					//jgraphics_ellipse(g, j, rd_scale(r[i].f, 0., 22050., rect.height, 0), 1, 1);
					//jgraphics_fill(g);
					//jgraphics_move_to(g, 0, yy1);
					//jgraphics_line_to(g, xx, yy2);
				}
			}
			jgraphics_image_surface_draw(g, s, (t_rect){0., 0., rect.width, rect.height}, (t_rect){0., 0., rect.width, rect.height});
		}else{
			t_res *r = (t_res *)(x->buffer);
			for(i = 0; i < x->n; i++){
				double xx, yy1, yy2;
				xx = rd_scale(r[i].f, x->freqmin, x->freqmax, 0, rect.width);
				if(x->log){
					//yy1 = rd_scale((100+20.0*log(r[i].a))/100./log(10), -1., 1., rect.height, 0.);
					yy1 = rd_scale((20.0*log(r[i].a))/log(10), x->ampmin_log, x->ampmax_log, rect.height, 0.);
				}else{
					yy1 = rd_scale(r[i].a, x->ampmin, x->ampmax, rect.height, 0);
				}
				yy2 = fabs((rect.height - yy1) * (.4 / sqrt(r[i].d))) + yy1;

				jgraphics_move_to(g, xx, yy1);
				jgraphics_line_to(g, xx, yy2);
				jgraphics_stroke(g);
			}
		}
	}

	// selection lines
	{
		jgraphics_set_source_jrgba(g, &(x->selectioncolor));
		if(x->mode){
			jgraphics_move_to(g, 0, rd_scale(x->selection.min, x->freqmin, x->freqmax, rect.height, 0));
			jgraphics_line_to(g, rect.width, rd_scale(x->selection.min, x->freqmin, x->freqmax, rect.height, 0));
			jgraphics_move_to(g, 0, rd_scale(x->selection.max, x->freqmin, x->freqmax, rect.height, 0));
			jgraphics_line_to(g, rect.width, rd_scale(x->selection.max, x->freqmin, x->freqmax, rect.height, 0));
		}else{
			jgraphics_move_to(g, rd_scale(x->selection.min, x->freqmin, x->freqmax, 0, rect.width), 0);
			jgraphics_line_to(g, rd_scale(x->selection.min, x->freqmin, x->freqmax, 0, rect.width), rect.height);
			jgraphics_move_to(g, rd_scale(x->selection.max, x->freqmin, x->freqmax, 0, rect.width), 0);
			jgraphics_line_to(g, rd_scale(x->selection.max, x->freqmin, x->freqmax, 0, rect.width), rect.height);
		}
		jgraphics_stroke(g);
	}

	// info
	{
		char buf[128];
		double w, h;
		jgraphics_set_source_jrgba(g, &x->datacolor);
		sprintf(buf, "%0.2f", x->selection.min);
		jgraphics_text_measure(g, buf, &w, &h);
		jgraphics_move_to(g, 0, h);
		jgraphics_show_text(g, buf);

		sprintf(buf, "%0.2f", x->selection.max);
		jgraphics_text_measure(g, buf, &w, &h);
		jgraphics_move_to(g, rect.width - w, h);
		jgraphics_show_text(g, buf);

		sprintf(buf, "%0.2fHz (%0.2fMc) %d/%ld", x->selection.max - x->selection.min, rd_ftom(x->selection.max) - rd_ftom(x->selection.min), x->num_partials_selected, x->n);
		jgraphics_text_measure(g, buf, &w, &h);
		jgraphics_move_to(g, (rect.width / 2) - (w / 2), h);
		jgraphics_show_text(g, buf);
	}
}
Beispiel #28
0
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);
}