aboutsummaryrefslogtreecommitdiff
path: root/gui/slider.c
blob: 22b3c69d4bca93f4c97107b1d159024ed8f25ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* (C) Guenter Geiger <geiger@epy.co.at> */


/* ------------------------ slider ----------------------------- */

#include "slider.h"

static t_class *slider_class;


static void *slider_new(t_floatarg h,t_floatarg o,t_floatarg w,t_floatarg n,t_floatarg horiz)
{
    t_slider *x = (t_slider *)pd_new(slider_class);
    x->x_glist = (t_glist*) canvas_getcurrent();
    
    if (w) x->x_width = w;
    else x->x_width = 15;
    if (h) x->x_height = h - o;
    else
	 x->x_height = 127;
    x->x_offset = o;
    x->x_pos = o;
    x->x_pos2 = o;
    x->a_pos.a_type = A_FLOAT;
    if (n) x->x_num = n;
    else x->x_num = 1;
    outlet_new(&x->x_obj, &s_float);

/* make us think we're an atom .. we are one ... this doesn work, 
 because  the object resets it .. so we will have to create our own menu entry later */
/*    x->x_obj.te_type = T_ATOM; */
    x->x_horizontal = horiz;

    return (x);
}



void slider_setup(void)
{
    slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0,
				sizeof(t_slider), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
    class_addbang(slider_class,slider_bang);
    class_addfloat(slider_class,slider_float);

    class_addmethod(slider_class, (t_method)slider_mark, gensym("mark"),
    	A_FLOAT, 0);


    class_addmethod(slider_class, (t_method)slider_click, gensym("click"),
    	A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
    class_addmethod(slider_class, (t_method)slider_motion, gensym("motion"),
    	A_FLOAT, A_FLOAT, 0);
    class_addmethod(slider_class, (t_method)slider_set, gensym("set"),
A_FLOAT, 0);
    class_addmethod(slider_class, (t_method)slider_type, gensym("type"),A_FLOAT,0);

    
    slider_setwidget();
    class_setwidget(slider_class,&slider_widgetbehavior);
}