static void incdec_paint(t_incdec *x, t_object *view) { t_rect rect; ebox_get_rect_for_view((t_ebox *)x, &rect); t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_background_layer, rect.width, rect.height); if (g) { egraphics_set_color_rgba(g, &x->f_color_arrow); if(x->f_mouse_down) { if(x->f_mouse_down == 1) { egraphics_rectangle(g, 0.f, 0.f, rect.width, rect.height * 0.5f); } else { egraphics_rectangle(g, 0.f, rect.height * 0.5f, rect.width, rect.height); } egraphics_fill(g); } if(x->f_mouse_down == 1) { egraphics_set_color_rgba(g, &x->f_color_background); } egraphics_move_to(g, 2.f, rect.height * 0.5f - 3.f); egraphics_line_to(g, rect.width - 2.f, rect.height * 0.5f - 3.f); egraphics_line_to(g, rect.width * 0.5f, 2.f); egraphics_fill(g); if(x->f_mouse_down == -1) { egraphics_set_color_rgba(g, &x->f_color_background); } else { egraphics_set_color_rgba(g, &x->f_color_arrow); } egraphics_move_to(g, 2.f, rect.height * 0.5f + 3.f); egraphics_line_to(g, rect.width - 2.f, rect.height * 0.5f + 3.f); egraphics_line_to(g, rect.width * 0.5f, rect.height - 2.f); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2.f); egraphics_line_fast(g, 0., rect.height * 0.5f, rect.width, rect.height * 0.5f); ebox_end_layer((t_ebox*)x, cream_sym_background_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0., 0.); }
void draw_background(t_knob *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { float size = rect->width * 0.5; egraphics_set_color_rgba(g, &x->f_color_border); egraphics_rectangle(g, -1, -1, rect->width+1, rect->height+1); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, size * 0.9); egraphics_fill(g); if(!x->f_endless) { float hsize = pd_clip_min(size * 0.15, 2); float alpha = rect->height - hsize; egraphics_set_color_rgba(g, &x->f_color_border); egraphics_move_to(g, rect->width * 0.5, rect->height * 0.5 + hsize); egraphics_line_to(g, rect->height * 0.5 - alpha * 0.5, rect->height); egraphics_line_to(g, rect->height * 0.5 + alpha * 0.5, rect->height); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_background); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, pd_clip_min(size * 0.3, 3)); egraphics_fill(g); } egraphics_set_color_rgba(g, &x->f_color_needle); egraphics_circle(g, rect->width * 0.5, rect->height * 0.5, pd_clip_min(size * 0.2, 2)); egraphics_fill(g); ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
static void draw_selection(t_tab *x, t_object *view, t_rect *rect) { t_elayer *g = ebox_start_layer((t_ebox *)x, cream_sym_selection_layer, rect->width, rect->height); if(g) { const int selec = (int)ebox_parameter_getvalue((t_ebox *)x, 1); egraphics_set_line_width(g, 2); if(x->f_orientation) { const float ratio = rect->height / (float)x->f_nitems; if(x->f_item_hover != -1) { egraphics_set_color_rgba(g, &x->f_color_hover); egraphics_rectangle(g, 0, ratio * x->f_item_hover, rect->width, ratio); egraphics_fill(g); } if(x->f_toggle || !x->f_off) { egraphics_set_color_rgba(g, &x->f_color_select); egraphics_rectangle(g, 0, ratio * selec, rect->width, ratio); egraphics_fill(g); } } else { const float ratio = rect->width / (float)x->f_nitems; if(x->f_item_hover != -1) { egraphics_set_color_rgba(g, &x->f_color_hover); egraphics_rectangle(g, ratio * x->f_item_hover, 0, ratio, rect->height); egraphics_fill(g); } if(x->f_toggle || !x->f_off) { egraphics_set_color_rgba(g, &x->f_color_select); egraphics_rectangle(g, ratio * selec, 0, ratio, rect->height); egraphics_fill(g); } } ebox_end_layer((t_ebox*)x, cream_sym_selection_layer); } ebox_paint_layer((t_ebox *)x, cream_sym_selection_layer, 0., 0.); }
void draw_background(t_incdec *x, t_object *view, t_rect *rect) { float height; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height); if (g) { // Background // egraphics_set_color_rgba(g, &x->f_color_arrow); if(x->f_mouse_down == 1) egraphics_rectangle(g, 0, 0, rect->width, rect->height / 2.); else if(x->f_mouse_down == -1) egraphics_rectangle(g, 0, rect->height / 2., rect->width, rect->height); egraphics_fill(g); egraphics_set_color_rgba(g, &x->f_color_arrow); // Arrow Up // if(x->f_mouse_down == 1) egraphics_set_color_rgba(g, &x->f_color_background); else egraphics_set_color_rgba(g, &x->f_color_arrow); #ifdef __APPLE__ height = rect->height / 2. - 2; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #elif _WINDOWS height = rect->height / 2. - 2; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 1)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #else height = rect->height / 2.; egraphics_move_to(g, rect->width * 0.1, pd_clip_max(height * 0.9, height - 2)); egraphics_line_to(g, rect->width * 0.9, pd_clip_max(height * 0.9, height - 2)); egraphics_line_to(g, rect->width * 0.5, pd_clip_min(height* 0.1, 1)); egraphics_fill(g); #endif // Arrow Down // if(x->f_mouse_down == -1) egraphics_set_color_rgba(g, &x->f_color_background); else egraphics_set_color_rgba(g, &x->f_color_arrow); #ifdef __APPLE__ egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 2.5, rect->height - 1)); egraphics_fill(g); #elif _WINDOWS egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 2.5, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 2.5, rect->height - 1)); egraphics_fill(g); #else egraphics_move_to(g, rect->width * 0.1, pd_clip_min(height * 0.1 + rect->height / 2. + 1, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.9, pd_clip_min(height * 0.1 + rect->height / 2. + 1, rect->height / 2. + 2.5)); egraphics_line_to(g, rect->width * 0.5, pd_clip_max(height * 0.9 + rect->height / 2. + 1, rect->height - 1)); egraphics_fill(g); #endif // Middle Line // egraphics_set_color_rgba(g, &x->f_color_border); egraphics_set_line_width(g, 2); egraphics_line_fast(g, 0., rect->height / 2. + 0.5, rect->width, rect->height / 2. + 0.5); ebox_end_layer((t_ebox*)x, gensym("background_layer")); } ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.); }
void draw_items(t_radio *x, t_object *view, t_rect *rect) { int i; t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("items_layer"), rect->width, rect->height); if (g) { egraphics_set_color_rgba(g, &x->f_color_item); egraphics_set_line_width(g, 2); if(x->f_mode) { if(x->f_direction) { float ratio = rect->width / x->f_nitems; float offset = rect->height * 0.35; for(i = 0; i < x->f_nitems; i++) { if(x->f_items[i]) { egraphics_rectangle(g, (i + 0.5) * ratio - offset, rect->height *0.15, offset * 2., offset * 2.); egraphics_fill(g); } } } else { float ratio = rect->height / x->f_nitems; float offset = rect->width * 0.35; for(i = 0; i < x->f_nitems; i++) { if(x->f_items[i]) { egraphics_rectangle(g, rect->width * 0.15, (i + 0.5) * ratio - offset, offset * 2., offset * 2.); egraphics_fill(g); } } } } else { if(x->f_direction) { float ratio = rect->width / x->f_nitems; for(i = 0; i < x->f_nitems; i++) { if(x->f_items[i]) { egraphics_circle(g, (i + 0.5) * ratio, rect->height * 0.5, rect->height * 0.35); egraphics_fill(g); } } } else { float ratio = rect->height / x->f_nitems; for(i = 0; i < x->f_nitems; i++) { if(x->f_items[i]) { egraphics_circle(g, rect->width * 0.5, (i + 0.5) * ratio, rect->width * 0.35); egraphics_fill(g); } } } } ebox_end_layer((t_ebox*)x, gensym("items_layer")); } ebox_paint_layer((t_ebox *)x, gensym("items_layer"), 0., 0.); }