示例#1
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);
	}
}
示例#2
0
void tralala_paintRun(t_tll *x, t_object *pv)
{
    double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP);
    double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE);
    t_jgraphics *g = NULL;
    
    PIZEvent *event = NULL;
    PIZEvent *nextEvent = NULL;
    
    pizArrayClear(x->temp[0]);
    
    TLL_DAEMON_LOCK
    
    pizLinklistPtrAtIndex(x->daemon, 0, (void **)&event);
    
    while (event) {
    //
    long argc;
    long *argv = NULL;

    pizLinklistNextWithPtr(x->daemon, (void *)event, (void **)&nextEvent);
    
    pizEventData(event, &argc, &argv);
    
    pizArrayAppend(x->temp[0], argv[0]);
    pizArrayAppend(x->temp[0], argv[1]);
    pizArrayAppend(x->temp[0], argv[2]);
    pizArrayAppend(x->temp[0], argv[3]);
        
    event = nextEvent;
    //
    }
    
    TLL_DAEMON_UNLOCK
    
    if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_RUN, w, h)) {
    //
    long j;
    long *note = pizArrayPtr(x->temp[0]);
    
    for (j = 0; j < pizArrayCount(x->temp[0]); j += 4) {
        t_rect r;
        r.x = TLL_POSITION_TO_X(note[j]);
        r.y = TLL_PITCH_TO_Y_UP(note[j + 1]); 
        r.width  = TLL_POSITION_TO_X(note[j] + note[j + 3]) - r.x; 
        r.height = TLL_PITCH_TO_Y_DOWN(note[j + 1]) - r.y;
    
        jgraphics_set_source_jrgba(g, &x->hColor3);
        jgraphics_rectangle_fill_fast(g, r.x, r.y, r.width, r.height);
    }
    
    jbox_end_layer((t_object*)x, pv, TLL_SYM_RUN);
    //
    }
        
    jbox_paint_layer((t_object *)x, pv, TLL_SYM_RUN, -x->offsetX, -x->offsetY);
}
示例#3
0
void scripto_ui_paint(t_scripto_ui *x, t_object *patcherview)
{
	t_jgraphics *g;
	t_rect r;
	long i, j;

	g = (t_jgraphics *) patcherview_get_jgraphics(patcherview);
	for (i = 0; i < SCRIPTO_UI_ROWS; i++) {
		for (j = 0; j < SCRIPTO_UI_COLS; j++) {
			scripto_ui_makerect(x, i, j, &r);
			jgraphics_set_source_jrgba(g, x->u_state[(i * SCRIPTO_UI_COLS) + j]? &x->u_oncolor : &x->u_offcolor);
			jgraphics_rectangle_fill_fast(g, r.x, r.y, r.width, r.height);
		}
	}
}
示例#4
0
void tralala_paintCurrentNote(t_tll *x, t_object *pv)
{  
    double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP);
    double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE);
    t_jgraphics *g = NULL;
    
    if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_NOTE, w, h)) {
    //
    long i;
    for (i = 0; i < 3; i++) {
    //
    long j;
    long *note = pizArrayPtr(x->temp[i]);
    
    for (j = 0; j < pizArrayCount(x->temp[i]); j += 4) {
        t_rect r;
        r.x = TLL_POSITION_TO_X(note[j + 0]);
        r.y = TLL_PITCH_TO_Y_UP(note[j + 1]); 
        r.width  = TLL_POSITION_TO_X(note[j + 0] + note[j + 3]) - r.x; 
        r.height = TLL_PITCH_TO_Y_DOWN(note[j + 1]) - r.y;
    
        if (i == 0 ) {
            jgraphics_set_source_jrgba(g, &x->color);
        } else if (i == 1) {
            jgraphics_set_source_jrgba(g, &x->hColor1);
        } else {
            jgraphics_set_source_jrgba(g, &x->hColor2);
        }

        
        jgraphics_rectangle_fill_fast(g, r.x, r.y, r.width, r.height);
    }
    //
    }
    
    jbox_end_layer((t_object*)x, pv, TLL_SYM_NOTE);
    //
    }
        
    jbox_paint_layer((t_object *)x, pv, TLL_SYM_NOTE, -x->offsetX, -x->offsetY);
}
示例#5
0
void tralala_paintLasso(t_tll *x, t_object *pv)
{
    double w = (PIZ_SEQUENCE_SIZE_TIMELINE * TLL_PIXELS_PER_STEP);
    double h = ((PIZ_MAGIC_PITCH + 1) * TLL_PIXELS_PER_SEMITONE);
    t_jgraphics *g = NULL;

    if (g = jbox_start_layer((t_object *)x, pv, TLL_SYM_LASSO, w, h)) {
        t_rect r;
        
        r.x = MIN(x->origin.x, x->cursor.x);
        r.y = MIN(x->origin.y, x->cursor.y);
        r.width = MAX(x->origin.x, x->cursor.x) - r.x;
        r.height = MAX(x->origin.y, x->cursor.y) - r.y;
        
        if (TLL_FLAG_TRUE(TLL_FLAG_LASSO)) {
            jgraphics_set_source_jrgba(g, &x->lasso);
            jgraphics_rectangle_fill_fast(g, TLL_X_OFFSET(r.x), TLL_Y_OFFSET(r.y), r.width, r.height);
        }
        
        jbox_end_layer((t_object*)x, pv, TLL_SYM_LASSO);
    }
        
    jbox_paint_layer((t_object *)x, pv, TLL_SYM_LASSO, -x->offsetX, -x->offsetY);
}
示例#6
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);
}