示例#1
0
static void draw_background(t_tab *x, t_object *view, t_rect *rect)
{
    int i;
    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_border);
        egraphics_set_line_width(g, 2);
        if(x->f_orientation)
        {
            const float ratio = rect->height / (float)x->f_nitems;
            for(i = 1; i < x->f_nitems; i++)
            {
                egraphics_line_fast(g, 0, ratio * i, rect->width, ratio * i);
            }
        }
        else
        {
            const float ratio = rect->width / (float)x->f_nitems;
            for(i = 1; i < x->f_nitems; i++)
            {
                egraphics_line_fast(g, ratio * i, 0, ratio * i, rect->height);
            }
        }
        ebox_end_layer((t_ebox*)x, cream_sym_background_layer);
    }
    ebox_paint_layer((t_ebox *)x, cream_sym_background_layer,  0., 0.);
}
示例#2
0
void draw_knob(t_gain *x, t_object *view, t_rect *rect)
{
    float ratio;
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("knob_layer"), rect->width, rect->height);
    
	if (g)
	{
        float value = (x->f_value + 90.) / 108.;
        egraphics_set_color_rgba(g, &x->f_color_knob);
        if(x->f_direction)
        {
            ratio = pd_clip_minmax(rect->width * 0.05, 4., 12.);
            egraphics_set_line_width(g, ratio);
            egraphics_line_fast(g, value * rect->width, -2, value * rect->width, rect->height+4);
        }
        else
        {
            ratio = pd_clip_minmax(rect->height * 0.05, 4., 12.);
            egraphics_set_line_width(g, ratio);
            egraphics_line_fast(g, -2, (1. - value) * rect->height, rect->width+4, (1. - value) * rect->height);
        }
        ebox_end_layer((t_ebox*)x, gensym("knob_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("knob_layer"), 0., 0.);
}
示例#3
0
void draw_background(t_toggle *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)
	{
        if(x->f_active)
        {
            egraphics_set_color_rgba(g, &x->f_color_cross);
            egraphics_set_line_width(g, 2);
            egraphics_line_fast(g, 0, 0, rect->width, rect->height);
            egraphics_line_fast(g, 0, rect->height, rect->width, 0);
        }
        ebox_end_layer((t_ebox*)x, gensym("background_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.);
}
示例#4
0
static void draw_background(t_scope *x,  t_object *view, t_rect *rect)
{
    int i;
    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_border);
        for(i = 1; i < 4; i++)
        {
            egraphics_line_fast(g, -2, rect->height * 0.25 * (float)i, rect->width + 4, rect->height * 0.25 * (float)i);
        }
        for(i = 1; i < 6; i++)
        {
            egraphics_line_fast(g, rect->width * (1. / 6.) * (float)i, -2, rect->width * (1. / 6.) * (float)i, rect->height + 4);
        }
        ebox_end_layer((t_ebox*)x, cream_sym_background_layer);
    }
    ebox_paint_layer((t_ebox *)x, cream_sym_background_layer, 0.f, 0.f);
}
示例#5
0
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.);
}
示例#6
0
void draw_needle(t_knob *x, t_object *view, t_rect *rect)
{
    float size, abs, ord, pimul, pimin;
    t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("needle_layer"), rect->width, rect->height);
    
    if (g)
	{
        size = rect->width * 0.5;
        if(x->f_endless)
        {
            pimul = EPD_2PI;
            pimin = EPD_PI2;
        }
        else
        {
            pimul = 1.5 * EPD_PI;
            if (x->f_min < x->f_max)
                pimin = 1.5 * EPD_PI2;
            else
                pimin = 0.5 * EPD_PI2;
        }
        if(x->f_min < x->f_max)
        {
            abs =  pd_abscissa(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin);
            ord =  pd_ordinate(size * 0.9 - 1, (x->f_value - x->f_min) / (x->f_max - x->f_min) * pimul + pimin);
        }
        else
        {
            abs =  pd_abscissa(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin);
            ord =  pd_ordinate(size * 0.9 - 1, -(x->f_value - x->f_max) / (x->f_min - x->f_max) * pimul + pimin);
            
        }
        egraphics_set_line_width(g, 2);
        egraphics_set_color_rgba(g, &x->f_color_needle);
        egraphics_line_fast(g, rect->width * 0.5, rect->height * 0.5, abs + rect->width * 0.5, ord + rect->height * 0.5);
        ebox_end_layer((t_ebox*)x, gensym("needle_layer"));
    }
   
    ebox_paint_layer((t_ebox *)x, gensym("needle_layer"), 0., 0.);

}
示例#7
0
void draw_background(t_gain *x, t_object *view, t_rect *rect)
{
    float ratio;
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("background_layer"), rect->width, rect->height);
    
	if (g)
	{
        if(x->f_direction)
        {
            ratio = 90. / 108.;
            egraphics_set_line_width(g, pd_clip_minmax(rect->height * 0.1, 2., 4.));
            
            egraphics_set_color_rgba(g, &x->f_color_border);
            egraphics_line_fast(g, rect->width * ratio, 0, rect->width * ratio, rect->height);
            
            egraphics_set_color_rgba(g, &x->f_color_background);
            egraphics_line_fast(g, rect->width * ratio, pd_clip_min(rect->height * 0.1, 2), rect->width * ratio, rect->height - pd_clip_min(rect->height * 0.1, 2));
            
            egraphics_set_color_rgba(g, &x->f_color_border);
            egraphics_line_fast(g, pd_clip_min(rect->height * 0.1, 2), rect->height * 0.5, rect->width-pd_clip_min(rect->height * 0.1, 2), rect->height * 0.5);
        }
        else
        {
            ratio = 1. - 90. / 108.;
            egraphics_set_line_width(g, pd_clip_minmax(rect->width * 0.1, 2., 4.));
            
            egraphics_set_color_rgba(g, &x->f_color_border);
            egraphics_line_fast(g, 0, rect->height * ratio, rect->width, rect->height * ratio);
            
            egraphics_set_color_rgba(g, &x->f_color_background);
            egraphics_line_fast(g, pd_clip_min(rect->width * 0.1, 2), rect->height * ratio, rect->width - pd_clip_min(rect->width * 0.1, 2), rect->height * ratio);
            
            egraphics_set_color_rgba(g, &x->f_color_border);
            egraphics_line_fast(g, rect->width * 0.5, pd_clip_min(rect->width * 0.1, 2), rect->width * 0.5, rect->height -pd_clip_min(rect->width * 0.1, 2));
            
        }
        ebox_end_layer((t_ebox*)x, gensym("background_layer"));
	}
	ebox_paint_layer((t_ebox *)x, gensym("background_layer"), 0., 0.);
}
示例#8
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.);
}
示例#9
0
void draw_points(t_breakpoints *x, t_object *view, t_rect *rect)
{
    int i;
    float abs, ord;
    float max, inc;
    float abs2;
    float ratiox, ratioy;
    float height = sys_fontheight(ebox_getfontsize((t_ebox *)x)) + 2;
	t_elayer *g = ebox_start_layer((t_ebox *)x, gensym("points_layer"), rect->width, rect->height);
    
	if (g && x->f_number_of_points)
	{
        ratiox = (rect->width - 4.) / (x->f_range_abscissa[1] - x->f_range_abscissa[0]);
        ratioy = (rect->height - height - 4.) / (x->f_range_ordinate[1] - x->f_range_ordinate[0]);

        egraphics_set_line_width(g, 2);
        egraphics_set_color_rgba(g, &x->f_color_line);
        
        if(x->f_outline_mode == 0)
        {
            abs = (x->f_point_abscissa[0] - x->f_range_abscissa[0]) * ratiox + 2.;
            ord = rect->height - (x->f_point_ordinate[0] - x->f_range_ordinate[0]) * ratioy - 2.;
            egraphics_move_to(g, abs, ord);
            for(i = 0; i < x->f_number_of_points; i++)
            {
                abs = (x->f_point_abscissa[i] - x->f_range_abscissa[0]) * ratiox + 2.;
                ord = rect->height - (x->f_point_ordinate[i] - x->f_range_ordinate[0]) * ratioy - 2.;
                egraphics_line_to(g, abs, ord);
            }
            egraphics_stroke(g);
        }
        else if (x->f_outline_mode == 1 || x->f_outline_mode == 2)
        {
            abs = (x->f_point_abscissa[0] - x->f_range_abscissa[0]) * ratiox + 2.;
            ord = rect->height - (x->f_point_ordinate[0] - x->f_range_ordinate[0]) * ratioy - 2.;
            egraphics_move_to(g, abs, ord);
            
            max = (x->f_point_abscissa[x->f_number_of_points-1] - x->f_range_ordinate[0]) * ratiox + 2.;
            inc = (x->f_point_abscissa[x->f_number_of_points-1] - x->f_point_abscissa[0]) / (float)(max - abs);
            abs2 = x->f_point_abscissa[0]+inc;
            if(x->f_point_abscissa[x->f_number_of_points-1] == x->f_point_abscissa[x->f_number_of_points-2])
            {
                for(i = abs; i <= max && abs2 <= x->f_point_abscissa[x->f_number_of_points-1]+inc; i++, abs2 += inc)
                {
                    ord = rect->height - (breakpoints_interpolation(x, abs2) - x->f_range_ordinate[0]) * ratioy - 2.;
                    egraphics_line_to(g, i, ord);
                }
            }
            else
            {
                for(i = abs; i <= max && abs2 <= x->f_point_abscissa[x->f_number_of_points-1]; i++, abs2 += inc)
                {
                    ord = rect->height - (breakpoints_interpolation(x, abs2) - x->f_range_ordinate[0]) * ratioy - 2.;
                    egraphics_line_to(g, i, ord);
                }
            }
            
            egraphics_stroke(g);
        }

        egraphics_set_color_rgba(g, &x->f_color_point);
        for(i = 0; i < x->f_number_of_points; i++)
        {
            abs = (x->f_point_abscissa[i] - x->f_range_abscissa[0]) * ratiox + 2;
            ord = rect->height - (x->f_point_ordinate[i] - x->f_range_ordinate[0]) * ratioy - 2;
            if(i == x->f_point_hover || i == x->f_point_selected)
            {
                egraphics_circle(g, abs, ord, 4.);
            }
            else
                egraphics_circle(g, abs, ord, 3.);
            egraphics_fill(g);
        }
	}
    if(g)
    {
        egraphics_set_color_rgba(g, &x->f_color_border);
        egraphics_set_line_width(g, 2.);
        egraphics_line_fast(g, -2, height - 1, rect->width+4, height - 1);
        ebox_end_layer((t_ebox*)x, gensym("points_layer"));
    }
	ebox_paint_layer((t_ebox *)x, gensym("points_layer"), 0., 0.);
}