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); } }
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_background(t_space *x, t_object *view, t_rect *rect) { int i; double y1, y2, rotateAngle; t_jmatrix transform; t_jgraphics *g = jbox_start_layer((t_object *)x, view, gensym("background_layer"), rect->width, rect->height); if (g) { /* Background ************************************/ jgraphics_rectangle_rounded(g, 0.5, 0.5, rect->width-1., rect->height-1., 12, 12); jgraphics_set_source_jrgba(g, &x->f_color_background); jgraphics_fill_preserve(g); jgraphics_set_source_jrgba(g, &x->f_color_border_box); jgraphics_stroke(g); /* Rotation slider *******************************/ if (x->f_shadow) { /* Inner shadow */ jgraphics_set_line_width(g, 4); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)5.5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 4); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)5.8 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Circle color */ jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)5.5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); jgraphics_set_line_width(g, 3); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)5.8 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); /* Gros cercle */ jgraphics_arc(g, x->f_center.x, x->f_center.y, 5 * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_set_source_jrgba(g, &x->f_color_circleInner); jgraphics_fill(g); /* Circles ***************************************/ for(i = 5; i > 0; i--) { if (x->f_shadow) { /* Inner shadow */ jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_arc(g, x->f_center.x+0.5, x->f_center.y+0.5, (double)i * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Circle color */ jgraphics_set_line_width(g, 1); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_arc(g, x->f_center.x, x->f_center.y, (double)i * x->f_rayonCircle, 0., JGRAPHICS_2PI); jgraphics_stroke(g); } /* Axes *******************************************/ jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_matrix_init(&transform, 1, 0, 0, -1, x->f_center.x, x->f_center.y); jgraphics_set_matrix(g, &transform); for(i = 0; i < x->f_number_of_microphones; i++) { rotateAngle = (double)i/ (double)x->f_number_of_microphones * JGRAPHICS_2PI - JGRAPHICS_2PI / ((double)x->f_number_of_microphones * 2.); jgraphics_rotate(g, rotateAngle); y1 = 1. / 6. * x->f_rayonGlobal; y2 = 5. / 6. * x->f_rayonGlobal; if (x->f_shadow) { if ( (rotateAngle <= JGRAPHICS_PI && rotateAngle > 0.) ) { jgraphics_move_to(g, -0.5, y1-0.5); jgraphics_line_to(g, -0.5, y2-0.5); } else { jgraphics_move_to(g, 0.5, y1+0.5); jgraphics_line_to(g, 0.5, y2+0.5); } jgraphics_set_line_width(g, 2); jgraphics_set_source_jrgba(g, &x->f_color_circleShadow); jgraphics_stroke(g); } jgraphics_move_to(g, 0, y1); jgraphics_line_to(g, 0, y2); jgraphics_set_source_jrgba(g, &x->f_color_circle); jgraphics_set_line_width(g, 1); jgraphics_stroke(g); jgraphics_rotate(g, -rotateAngle); } jbox_end_layer((t_object*)x, view, gensym("background_layer")); } jbox_paint_layer((t_object *)x, view, gensym("background_layer"), 0., 0.); }