summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_hslider.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_hslider.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_hslider.c653
1 files changed, 0 insertions, 653 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_hslider.c b/apps/plugins/pdbox/PDa/src/g_hslider.c
index 77cd05c127..c5d660c5d7 100644
--- a/apps/plugins/pdbox/PDa/src/g_hslider.c
+++ b/apps/plugins/pdbox/PDa/src/g_hslider.c
@@ -652,657 +652,4 @@ void g_hslider_setup(void)
652 class_setsavefn(hslider_class, hslider_save); 652 class_setsavefn(hslider_class, hslider_save);
653 class_setpropertiesfn(hslider_class, hslider_properties); 653 class_setpropertiesfn(hslider_class, hslider_properties);
654} 654}
655/* Copyright (c) 1997-1999 Miller Puckette.
656 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
657 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
658
659/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
660/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
661
662
663#include <stdlib.h>
664#include <string.h>
665#include <stdio.h>
666#include <ctype.h>
667#include "m_pd.h"
668#include "g_canvas.h"
669#include "t_tk.h"
670#include "g_all_guis.h"
671#include <math.h>
672
673#ifdef MSW
674#include <io.h>
675#else
676#include <unistd.h>
677#endif
678
679
680/* ------------ hsl gui-horicontal slider ----------------------- */
681
682t_widgetbehavior hslider_widgetbehavior;
683static t_class *hslider_class;
684
685/* widget helper functions */
686
687static void hslider_draw_update(t_hslider *x, t_glist *glist)
688{
689 t_canvas *canvas=glist_getcanvas(glist);
690 int ypos=text_ypix(&x->x_gui.x_obj, glist);
691
692 if (glist_isvisible(glist))
693 {
694 int r = text_xpix(&x->x_gui.x_obj, glist) + (x->x_val + 50)/100;
695 sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
696 canvas, x, r, ypos+1,
697 r, ypos + x->x_gui.x_h);
698 if(x->x_val == x->x_center)
699 {
700 if(!x->x_thick)
701 {
702 sys_vgui(".x%x.c itemconfigure %xKNOB -width 7\n", canvas, x);
703 x->x_thick = 1;
704 }
705 }
706 else
707 {
708 if(x->x_thick)
709 {
710 sys_vgui(".x%x.c itemconfigure %xKNOB -width 3\n", canvas, x);
711 x->x_thick = 0;
712 }
713 }
714 }
715}
716
717static void hslider_draw_new(t_hslider *x, t_glist *glist)
718{
719 int xpos=text_xpix(&x->x_gui.x_obj, glist);
720 int ypos=text_ypix(&x->x_gui.x_obj, glist);
721 int r = xpos + (x->x_val + 50)/100;
722 t_canvas *canvas=glist_getcanvas(glist);
723
724 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
725 canvas, xpos-3, ypos,
726 xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h,
727 x->x_gui.x_bcol, x);
728 sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xKNOB\n",
729 canvas, r, ypos+1, r,
730 ypos + x->x_gui.x_h, x->x_gui.x_fcol, x);
731 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
732 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
733 canvas, xpos+x->x_gui.x_ldx,
734 ypos+x->x_gui.x_ldy,
735 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
736 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
737 if(!x->x_gui.x_fsf.x_snd_able)
738 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
739 canvas, xpos-3, ypos + x->x_gui.x_h-1,
740 xpos+4, ypos + x->x_gui.x_h, x, 0);
741 if(!x->x_gui.x_fsf.x_rcv_able)
742 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
743 canvas, xpos-3, ypos,
744 xpos+4, ypos+1, x, 0);
745}
746
747static void hslider_draw_move(t_hslider *x, t_glist *glist)
748{
749 int xpos=text_xpix(&x->x_gui.x_obj, glist);
750 int ypos=text_ypix(&x->x_gui.x_obj, glist);
751 int r = xpos + (x->x_val + 50)/100;
752 t_canvas *canvas=glist_getcanvas(glist);
753
754 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
755 canvas, x,
756 xpos-3, ypos,
757 xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h);
758 sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
759 canvas, x, r, ypos+1,
760 r, ypos + x->x_gui.x_h);
761 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
762 canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
763 if(!x->x_gui.x_fsf.x_snd_able)
764 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
765 canvas, x, 0,
766 xpos-3, ypos + x->x_gui.x_h-1,
767 xpos+4, ypos + x->x_gui.x_h);
768 if(!x->x_gui.x_fsf.x_rcv_able)
769 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
770 canvas, x, 0,
771 xpos-3, ypos,
772 xpos+4, ypos+1);
773}
774
775static void hslider_draw_erase(t_hslider* x,t_glist* glist)
776{
777 t_canvas *canvas=glist_getcanvas(glist);
778
779 sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
780 sys_vgui(".x%x.c delete %xKNOB\n", canvas, x);
781 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
782 if(!x->x_gui.x_fsf.x_snd_able)
783 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
784 if(!x->x_gui.x_fsf.x_rcv_able)
785 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
786}
787
788static void hslider_draw_config(t_hslider* x,t_glist* glist)
789{
790 t_canvas *canvas=glist_getcanvas(glist);
791
792 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
793 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
794 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
795 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
796 sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
797 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
798}
799
800static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags)
801{
802 int xpos=text_xpix(&x->x_gui.x_obj, glist);
803 int ypos=text_ypix(&x->x_gui.x_obj, glist);
804 t_canvas *canvas=glist_getcanvas(glist);
805
806 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
807 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
808 canvas, xpos-3, ypos + x->x_gui.x_h-1,
809 xpos+4, ypos + x->x_gui.x_h, x, 0);
810 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
811 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
812 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
813 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
814 canvas, xpos-3, ypos,
815 xpos+4, ypos+1, x, 0);
816 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
817 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
818}
819 655
820static void hslider_draw_select(t_hslider* x,t_glist* glist)
821{
822 t_canvas *canvas=glist_getcanvas(glist);
823
824 if(x->x_gui.x_fsf.x_selected)
825 {
826 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
827 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
828 }
829 else
830 {
831 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
832 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
833 }
834}
835
836void hslider_draw(t_hslider *x, t_glist *glist, int mode)
837{
838 if(mode == IEM_GUI_DRAW_MODE_UPDATE)
839 hslider_draw_update(x, glist);
840 else if(mode == IEM_GUI_DRAW_MODE_MOVE)
841 hslider_draw_move(x, glist);
842 else if(mode == IEM_GUI_DRAW_MODE_NEW)
843 hslider_draw_new(x, glist);
844 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
845 hslider_draw_select(x, glist);
846 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
847 hslider_draw_erase(x, glist);
848 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
849 hslider_draw_config(x, glist);
850 else if(mode >= IEM_GUI_DRAW_MODE_IO)
851 hslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
852}
853
854/* ------------------------ hsl widgetbehaviour----------------------------- */
855
856
857static void hslider_getrect(t_gobj *z, t_glist *glist,
858 int *xp1, int *yp1, int *xp2, int *yp2)
859{
860 t_hslider* x = (t_hslider*)z;
861
862 *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 3;
863 *yp1 = text_ypix(&x->x_gui.x_obj, glist);
864 *xp2 = *xp1 + x->x_gui.x_w + 5;
865 *yp2 = *yp1 + x->x_gui.x_h;
866}
867
868static void hslider_save(t_gobj *z, t_binbuf *b)
869{
870 t_hslider *x = (t_hslider *)z;
871 int bflcol[3];
872 t_symbol *srl[3];
873
874 iemgui_save(&x->x_gui, srl, bflcol);
875 binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
876 (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
877 gensym("hsl"), x->x_gui.x_w, x->x_gui.x_h,
878 (float)x->x_min, (float)x->x_max,
879 x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
880 srl[0], srl[1], srl[2],
881 x->x_gui.x_ldx, x->x_gui.x_ldy,
882 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
883 bflcol[0], bflcol[1], bflcol[2],
884 x->x_val, x->x_steady);
885 binbuf_addv(b, ";");
886}
887
888void hslider_check_width(t_hslider *x, int w)
889{
890 if(w < IEM_SL_MINSIZE)
891 w = IEM_SL_MINSIZE;
892 x->x_gui.x_w = w;
893 x->x_center = (x->x_gui.x_w-1)*50;
894 if(x->x_val > (x->x_gui.x_w*100 - 100))
895 {
896 x->x_pos = x->x_gui.x_w*100 - 100;
897 x->x_val = x->x_pos;
898 }
899 if(x->x_lin0_log1)
900 x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
901 else
902 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
903}
904
905void hslider_check_minmax(t_hslider *x, double min, double max)
906{
907 if(x->x_lin0_log1)
908 {
909 if((min == 0.0)&&(max == 0.0))
910 max = 1.0;
911 if(max > 0.0)
912 {
913 if(min <= 0.0)
914 min = 0.01*max;
915 }
916 else
917 {
918 if(min > 0.0)
919 max = 0.01*min;
920 }
921 }
922 x->x_min = min;
923 x->x_max = max;
924 if(x->x_min > x->x_max) /* bugfix */
925 x->x_gui.x_isa.x_reverse = 1;
926 else
927 x->x_gui.x_isa.x_reverse = 0;
928 if(x->x_lin0_log1)
929 x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
930 else
931 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
932}
933
934static void hslider_properties(t_gobj *z, t_glist *owner)
935{
936 t_hslider *x = (t_hslider *)z;
937 char buf[800];
938 t_symbol *srl[3];
939
940 iemgui_properties(&x->x_gui, srl);
941 sprintf(buf, "pdtk_iemgui_dialog %%s HSLIDER \
942 --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
943 -----------output-range:----------- %g left: %g right: %g \
944 %d lin log %d %d empty %d \
945 %s %s \
946 %s %d %d \
947 %d %d \
948 %d %d %d\n",
949 x->x_gui.x_w, IEM_SL_MINSIZE, x->x_gui.x_h, IEM_GUI_MINSIZE,
950 x->x_min, x->x_max, 0.0,/*no_schedule*/
951 x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
952 srl[0]->s_name, srl[1]->s_name,
953 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
954 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
955 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
956 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
957}
958
959static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */
960{
961 double g;
962
963 if(x->x_gui.x_isa.x_reverse) /* bugfix */
964 {
965 if(f > x->x_min)
966 f = x->x_min;
967 if(f < x->x_max)
968 f = x->x_max;
969 }
970 else
971 {
972 if(f > x->x_max)
973 f = x->x_max;
974 if(f < x->x_min)
975 f = x->x_min;
976 }
977 if(x->x_lin0_log1)
978 g = log(f/x->x_min)/x->x_k;
979 else
980 g = (f - x->x_min) / x->x_k;
981 x->x_val = (int)(100.0*g + 0.49999);
982 x->x_pos = x->x_val;
983 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
984}
985
986static void hslider_bang(t_hslider *x)
987{
988 double out;
989
990 if(x->x_lin0_log1)
991 out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
992 else
993 out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
994 if((out < 1.0e-10)&&(out > -1.0e-10))
995 out = 0.0;
996 outlet_float(x->x_gui.x_obj.ob_outlet, out);
997 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
998 pd_float(x->x_gui.x_snd->s_thing, out);
999}
1000
1001static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv)
1002{
1003 t_symbol *srl[3];
1004 int w = (int)atom_getintarg(0, argc, argv);
1005 int h = (int)atom_getintarg(1, argc, argv);
1006 double min = (double)atom_getfloatarg(2, argc, argv);
1007 double max = (double)atom_getfloatarg(3, argc, argv);
1008 int lilo = (int)atom_getintarg(4, argc, argv);
1009 int steady = (int)atom_getintarg(17, argc, argv);
1010 int sr_flags;
1011
1012 if(lilo != 0) lilo = 1;
1013 x->x_lin0_log1 = lilo;
1014 if(steady)
1015 x->x_steady = 1;
1016 else
1017 x->x_steady = 0;
1018 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
1019 x->x_gui.x_h = iemgui_clip_size(h);
1020 hslider_check_width(x, w);
1021 hslider_check_minmax(x, min, max);
1022 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
1023 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
1024 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
1025 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
1026}
1027
1028static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
1029{
1030 int old = x->x_val;
1031
1032 if(x->x_gui.x_fsf.x_finemoved)
1033 x->x_pos += (int)dx;
1034 else
1035 x->x_pos += 100*(int)dx;
1036 x->x_val = x->x_pos;
1037 if(x->x_val > (100*x->x_gui.x_w - 100))
1038 {
1039 x->x_val = 100*x->x_gui.x_w - 100;
1040 x->x_pos += 50;
1041 x->x_pos -= x->x_pos%100;
1042 }
1043 if(x->x_val < 0)
1044 {
1045 x->x_val = 0;
1046 x->x_pos -= 50;
1047 x->x_pos -= x->x_pos%100;
1048 }
1049 if(old != x->x_val)
1050 {
1051 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1052 hslider_bang(x);
1053 }
1054}
1055
1056static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos,
1057 t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
1058{
1059 if(!x->x_steady)
1060 x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)));
1061 if(x->x_val > (100*x->x_gui.x_w - 100))
1062 x->x_val = 100*x->x_gui.x_w - 100;
1063 if(x->x_val < 0)
1064 x->x_val = 0;
1065 x->x_pos = x->x_val;
1066 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1067 hslider_bang(x);
1068 glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)hslider_motion,
1069 0, xpos, ypos);
1070}
1071
1072static int hslider_newclick(t_gobj *z, struct _glist *glist,
1073 int xpix, int ypix, int shift, int alt, int dbl, int doit)
1074{
1075 t_hslider* x = (t_hslider *)z;
1076
1077 if(doit)
1078 {
1079 hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
1080 0, (t_floatarg)alt);
1081 if(shift)
1082 x->x_gui.x_fsf.x_finemoved = 1;
1083 else
1084 x->x_gui.x_fsf.x_finemoved = 0;
1085 }
1086 return (1);
1087}
1088
1089static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1090{
1091 hslider_check_width(x, (int)atom_getintarg(0, ac, av));
1092 if(ac > 1)
1093 x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av));
1094 iemgui_size((void *)x, &x->x_gui);
1095}
1096
1097static void hslider_delta(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1098{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
1099
1100static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1101{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
1102
1103static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1104{
1105 hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
1106 (double)atom_getfloatarg(1, ac, av));
1107}
1108
1109static void hslider_color(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1110{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
1111
1112static void hslider_send(t_hslider *x, t_symbol *s)
1113{iemgui_send(x, &x->x_gui, s);}
1114
1115static void hslider_receive(t_hslider *x, t_symbol *s)
1116{iemgui_receive(x, &x->x_gui, s);}
1117
1118static void hslider_label(t_hslider *x, t_symbol *s)
1119{iemgui_label((void *)x, &x->x_gui, s);}
1120
1121static void hslider_label_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1122{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
1123
1124static void hslider_label_font(t_hslider *x, t_symbol *s, int ac, t_atom *av)
1125{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
1126
1127static void hslider_log(t_hslider *x)
1128{
1129 x->x_lin0_log1 = 1;
1130 hslider_check_minmax(x, x->x_min, x->x_max);
1131}
1132
1133static void hslider_lin(t_hslider *x)
1134{
1135 x->x_lin0_log1 = 0;
1136 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
1137}
1138
1139static void hslider_init(t_hslider *x, t_floatarg f)
1140{
1141 x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
1142}
1143
1144static void hslider_steady(t_hslider *x, t_floatarg f)
1145{
1146 x->x_steady = (f==0.0)?0:1;
1147}
1148
1149static void hslider_float(t_hslider *x, t_floatarg f)
1150{
1151 double out;
1152
1153 hslider_set(x, f);
1154 if(x->x_lin0_log1)
1155 out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
1156 else
1157 out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
1158 if((out < 1.0e-10)&&(out > -1.0e-10))
1159 out = 0.0;
1160 if(x->x_gui.x_fsf.x_put_in2out)
1161 {
1162 outlet_float(x->x_gui.x_obj.ob_outlet, out);
1163 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1164 pd_float(x->x_gui.x_snd->s_thing, out);
1165 }
1166}
1167
1168static void hslider_loadbang(t_hslider *x)
1169{
1170 if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
1171 {
1172 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1173 hslider_bang(x);
1174 }
1175}
1176
1177static void *hslider_new(t_symbol *s, int argc, t_atom *argv)
1178{
1179 t_hslider *x = (t_hslider *)pd_new(hslider_class);
1180 int bflcol[]={-262144, -1, -1};
1181 int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE;
1182 int lilo=0, ldx=-2, ldy=-6, f=0, v=0, steady=1;
1183 int fs=8;
1184 double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
1185 char str[144];
1186
1187 iem_inttosymargs(&x->x_gui.x_isa, 0);
1188 iem_inttofstyle(&x->x_gui.x_fsf, 0);
1189
1190 if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
1191 &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
1192 &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
1193 &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
1194 &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
1195 &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
1196 &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
1197 &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
1198 &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
1199 {
1200 w = (int)atom_getintarg(0, argc, argv);
1201 h = (int)atom_getintarg(1, argc, argv);
1202 min = (double)atom_getfloatarg(2, argc, argv);
1203 max = (double)atom_getfloatarg(3, argc, argv);
1204 lilo = (int)atom_getintarg(4, argc, argv);
1205 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
1206 iemgui_new_getnames(&x->x_gui, 6, argv);
1207 ldx = (int)atom_getintarg(9, argc, argv);
1208 ldy = (int)atom_getintarg(10, argc, argv);
1209 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
1210 fs = (int)atom_getintarg(12, argc, argv);
1211 bflcol[0] = (int)atom_getintarg(13, argc, argv);
1212 bflcol[1] = (int)atom_getintarg(14, argc, argv);
1213 bflcol[2] = (int)atom_getintarg(15, argc, argv);
1214 v = (int)atom_getintarg(16, argc, argv);
1215 }
1216 else iemgui_new_getnames(&x->x_gui, 6, 0);
1217 if((argc == 18)&&IS_A_FLOAT(argv,17))
1218 steady = (int)atom_getintarg(17, argc, argv);
1219
1220 x->x_gui.x_draw = (t_iemfunptr)hslider_draw;
1221
1222 x->x_gui.x_fsf.x_snd_able = 1;
1223 x->x_gui.x_fsf.x_rcv_able = 1;
1224
1225 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
1226 if(x->x_gui.x_isa.x_loadinit)
1227 x->x_val = v;
1228 else
1229 x->x_val = 0;
1230 x->x_pos = x->x_val;
1231 if(lilo != 0) lilo = 1;
1232 x->x_lin0_log1 = lilo;
1233 if(steady != 0) steady = 1;
1234 x->x_steady = steady;
1235 if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
1236 x->x_gui.x_fsf.x_snd_able = 0;
1237 if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
1238 x->x_gui.x_fsf.x_rcv_able = 0;
1239 if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
1240 else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
1241 else { x->x_gui.x_fsf.x_font_style = 0;
1242 strcpy(x->x_gui.x_font, "courier"); }
1243 if(x->x_gui.x_fsf.x_rcv_able)
1244 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1245 x->x_gui.x_ldx = ldx;
1246 x->x_gui.x_ldy = ldy;
1247 if(fs < 4)
1248 fs = 4;
1249 x->x_gui.x_fontsize = fs;
1250 x->x_gui.x_h = iemgui_clip_size(h);
1251 hslider_check_width(x, w);
1252 hslider_check_minmax(x, min, max);
1253 iemgui_all_colfromload(&x->x_gui, bflcol);
1254 x->x_thick = 0;
1255 iemgui_verify_snd_ne_rcv(&x->x_gui);
1256 outlet_new(&x->x_gui.x_obj, &s_float);
1257 return (x);
1258}
1259
1260static void hslider_free(t_hslider *x)
1261{
1262 if(x->x_gui.x_fsf.x_rcv_able)
1263 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1264 gfxstub_deleteforkey(x);
1265}
1266
1267void g_hslider_setup(void)
1268{
1269 hslider_class = class_new(gensym("hsl"), (t_newmethod)hslider_new,
1270 (t_method)hslider_free, sizeof(t_hslider), 0, A_GIMME, 0);
1271#ifndef GGEE_HSLIDER_COMPATIBLE
1272 class_addcreator((t_newmethod)hslider_new, gensym("hslider"), A_GIMME, 0);
1273#endif
1274 class_addbang(hslider_class,hslider_bang);
1275 class_addfloat(hslider_class,hslider_float);
1276 class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"),
1277 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
1278 class_addmethod(hslider_class, (t_method)hslider_motion, gensym("motion"),
1279 A_FLOAT, A_FLOAT, 0);
1280 class_addmethod(hslider_class, (t_method)hslider_dialog, gensym("dialog"), A_GIMME, 0);
1281 class_addmethod(hslider_class, (t_method)hslider_loadbang, gensym("loadbang"), 0);
1282 class_addmethod(hslider_class, (t_method)hslider_set, gensym("set"), A_FLOAT, 0);
1283 class_addmethod(hslider_class, (t_method)hslider_size, gensym("size"), A_GIMME, 0);
1284 class_addmethod(hslider_class, (t_method)hslider_delta, gensym("delta"), A_GIMME, 0);
1285 class_addmethod(hslider_class, (t_method)hslider_pos, gensym("pos"), A_GIMME, 0);
1286 class_addmethod(hslider_class, (t_method)hslider_range, gensym("range"), A_GIMME, 0);
1287 class_addmethod(hslider_class, (t_method)hslider_color, gensym("color"), A_GIMME, 0);
1288 class_addmethod(hslider_class, (t_method)hslider_send, gensym("send"), A_DEFSYM, 0);
1289 class_addmethod(hslider_class, (t_method)hslider_receive, gensym("receive"), A_DEFSYM, 0);
1290 class_addmethod(hslider_class, (t_method)hslider_label, gensym("label"), A_DEFSYM, 0);
1291 class_addmethod(hslider_class, (t_method)hslider_label_pos, gensym("label_pos"), A_GIMME, 0);
1292 class_addmethod(hslider_class, (t_method)hslider_label_font, gensym("label_font"), A_GIMME, 0);
1293 class_addmethod(hslider_class, (t_method)hslider_log, gensym("log"), 0);
1294 class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0);
1295 class_addmethod(hslider_class, (t_method)hslider_init, gensym("init"), A_FLOAT, 0);
1296 class_addmethod(hslider_class, (t_method)hslider_steady, gensym("steady"), A_FLOAT, 0);
1297 hslider_widgetbehavior.w_getrectfn = hslider_getrect;
1298 hslider_widgetbehavior.w_displacefn = iemgui_displace;
1299 hslider_widgetbehavior.w_selectfn = iemgui_select;
1300 hslider_widgetbehavior.w_activatefn = NULL;
1301 hslider_widgetbehavior.w_deletefn = iemgui_delete;
1302 hslider_widgetbehavior.w_visfn = iemgui_vis;
1303 hslider_widgetbehavior.w_clickfn = hslider_newclick;
1304 class_setwidget(hslider_class, &hslider_widgetbehavior);
1305 class_sethelpsymbol(hslider_class, gensym("hslider"));
1306 class_setsavefn(hslider_class, hslider_save);
1307 class_setpropertiesfn(hslider_class, hslider_properties);
1308}