From f12b0d7aa5d1f996b25ede45a2938dc1a1529e53 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 13 Dec 2010 00:55:15 +0000 Subject: updated Makefile to 1.0.6 and added aliases for GUI objects svn path=/trunk/; revision=14597 --- externals/vanilla/Makefile | 186 +++++++----- externals/vanilla/hsl.c | 656 ++++++++++++++++++++++++++++++++++++++++ externals/vanilla/hslider.c | 5 + externals/vanilla/my_canvas.c | 6 + externals/vanilla/my_numbox.c | 6 + externals/vanilla/radiobut.c | 6 + externals/vanilla/radiobutton.c | 6 + externals/vanilla/rdb.c | 6 + externals/vanilla/toggle.c | 6 + externals/vanilla/vsl.c | 629 ++++++++++++++++++++++++++++++++++++++ externals/vanilla/vslider.c | 5 + 11 files changed, 1448 insertions(+), 69 deletions(-) create mode 100644 externals/vanilla/hsl.c create mode 100644 externals/vanilla/hslider.c create mode 100644 externals/vanilla/my_canvas.c create mode 100644 externals/vanilla/my_numbox.c create mode 100644 externals/vanilla/radiobut.c create mode 100644 externals/vanilla/radiobutton.c create mode 100644 externals/vanilla/rdb.c create mode 100644 externals/vanilla/toggle.c create mode 100644 externals/vanilla/vsl.c create mode 100644 externals/vanilla/vslider.c diff --git a/externals/vanilla/Makefile b/externals/vanilla/Makefile index 9d9ddf7e..5b74ca77 100644 --- a/externals/vanilla/Makefile +++ b/externals/vanilla/Makefile @@ -1,20 +1,11 @@ -## Pd library template version 1.0 +## Pd library template version 1.0.6 # For instructions on how to use this template, see: # http://puredata.info/docs/developer/MakefileTemplate LIBRARY_NAME = vanilla -# add your .c source files to the SOURCES variable, help files will be -# included automatically -SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c exp~.c ftom~.c hradio.c hsl.c key.c keyname.c keyup.c list.c log~.c mtof~.c nbx.c openpanel.c powtodb~.c pow~.c print.c qlist.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c vradio.c vslider.c vu.c wrap~.c - -# For objects that only build on certain platforms, add those to the SOURCES -# line for the right platforms. -SOURCES_android = -SOURCES_cygwin = -SOURCES_macosx = -SOURCES_iphoneos = -SOURCES_linux = -SOURCES_windows = +# add your .c source files, one object per file, to the SOURCES +# variable, help files will be included automatically +SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c exp~.c ftom~.c hradio.c hsl.c hslider.c key.c keyname.c keyup.c list.c log~.c mtof~.c my_canvas.c my_numbox.c nbx.c openpanel.c powtodb~.c pow~.c print.c qlist.c radiobut.c radiobutton.c rdb.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c toggle.c vradio.c vsl.c vslider.c vu.c wrap~.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically @@ -27,13 +18,24 @@ EXAMPLES = MANUAL = # if you want to include any other files in the source and binary tarballs, -# list them here. This can be anything from header files, example patches, +# list them here. This can be anything from header files, test patches, # documentation, etc. README.txt and LICENSE.txt are required and therefore # automatically included EXTRA_DIST = +#------------------------------------------------------------------------------# +# +# things you might need to edit if you are using other C libraries +# +#------------------------------------------------------------------------------# + +# -I"$(PD_INCLUDE)/pd" supports the header location for 0.43 +CFLAGS = -I"$(PD_INCLUDE)/pd" -Wall -W -g +LDFLAGS = +LIBS = + #------------------------------------------------------------------------------# # # you shouldn't need to edit anything below here, if we did it right :) @@ -43,25 +45,26 @@ EXTRA_DIST = # get library version from meta file LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) -# where Pd lives -PD_PATH = ../../pd -# where to install the library +CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"' + +PD_INCLUDE = $(PD_PATH)/include +# where to install the library, overridden below depending on platform prefix = /usr/local libdir = $(prefix)/lib pkglibdir = $(libdir)/pd-externals objectsdir = $(pkglibdir) - INSTALL = install -INSTALL_FILE = $(INSTALL) -p -m 644 +INSTALL_PROGRAM = $(INSTALL) -p -m 644 +INSTALL_DATA = $(INSTALL) -p -m 644 INSTALL_DIR = $(INSTALL) -p -m 755 -d -CFLAGS = -DPD -I$(PD_PATH)/src -Wall -W -g -LDFLAGS = -LIBS = ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) +DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) +ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION) + UNAME := $(shell uname -s) ifeq ($(UNAME),Darwin) CPU := $(shell uname -p) @@ -69,6 +72,7 @@ ifeq ($(UNAME),Darwin) SOURCES += $(SOURCES_iphoneos) EXTENSION = pd_darwin OS = iphoneos + PD_PATH = /Applications/Pd-extended.app/Contents/Resources IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin CC=$(IPHONE_BASE)/gcc CPP=$(IPHONE_BASE)/cpp @@ -76,17 +80,16 @@ ifeq ($(UNAME),Darwin) ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer - CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) \ - -I/Applications/Pd-extended.app/Contents/Resources/include + CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) LIBS += -lc STRIP = strip -x - DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) DISTBINDIR=$(DISTDIR)-$(OS) else # Mac OS X SOURCES += $(SOURCES_macosx) EXTENSION = pd_darwin OS = macosx + PD_PATH = /Applications/Pd-extended.app/Contents/Resources OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast # build universal 32-bit on 10.4 and 32/64 on newer ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) @@ -95,61 +98,92 @@ ifeq ($(UNAME),Darwin) FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 SOURCES += $(SOURCES_iphoneos) endif - CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \ - -I/Applications/Pd-extended.app/Contents/Resources/include + CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib # if the 'pd' binary exists, check the linking against it to aid with stripping LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) LIBS += -lc STRIP = strip -x - DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) DISTBINDIR=$(DISTDIR)-$(OS) # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much pkglibdir=$(HOME)/Library/Pd endif endif ifeq ($(UNAME),Linux) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += -fPIC + LDFLAGS += -Wl,--export-dynamic -shared -fPIC + LIBS += -lc + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq ($(UNAME),GNU) + # GNU/Hurd, should work like GNU/Linux for basically all externals + CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += -fPIC + LDFLAGS += -Wl,--export-dynamic -shared -fPIC + LIBS += -lc + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq ($(UNAME),GNU/kFreeBSD) + # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + OS = linux + PD_PATH = /usr OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += -fPIC LDFLAGS += -Wl,--export-dynamic -shared -fPIC LIBS += -lc STRIP = strip --strip-unneeded -R .note -R .comment - DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) + CPU := $(shell uname -m) SOURCES += $(SOURCES_cygwin) EXTENSION = dll OS = cygwin + PD_PATH = $(cygpath $(PROGRAMFILES))/pd OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += - LDFLAGS += -Wl,--export-dynamic -shared -L$(PD_PATH)/src + LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" LIBS += -lc -lpd STRIP = strip --strip-unneeded -R .note -R .comment - DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) DISTBINDIR=$(DISTDIR)-$(OS) endif ifeq (MINGW,$(findstring MINGW,$(UNAME))) + CPU := $(shell uname -m) SOURCES += $(SOURCES_windows) EXTENSION = dll OS = windows + PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd) OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer - WINDOWS_HACKS = -D'O_NONBLOCK=1' - CFLAGS += -mms-bitfields $(WINDOWS_HACKS) + CFLAGS += -mms-bitfields LDFLAGS += -s -shared -Wl,--enable-auto-import - LIBS += -L$(PD_PATH)/src -L$(PD_PATH)/bin -L$(PD_PATH)/obj -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 + LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 STRIP = strip --strip-unneeded -R .note -R .comment - DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) DISTBINDIR=$(DISTDIR)-$(OS) endif +# in case somebody manually set the HELPPATCHES above +HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd) + CFLAGS += $(OPT_CFLAGS) -.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags +.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME) all: $(SOURCES:.c=.$(EXTENSION)) @@ -165,56 +199,52 @@ $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS) chmod a-x $(LIBRARY_NAME).$(EXTENSION) - install: libdir_install # The meta and help files are explicitly installed to make sure they are # actually there. Those files are not optional, then need to be there. libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) - $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd \ + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES))" || (\ - $(INSTALL_FILE) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ + $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) test -z "$(strip $(PDOBJECTS))" || \ - $(INSTALL_FILE) $(PDOBJECTS) \ + $(INSTALL_DATA) $(PDOBJECTS) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) # install library linked as single binary single_install: $(LIBRARY_NAME) install-doc install-exec $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) - $(INSTALL_FILE) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) install-doc: $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) -# test -z "$(strip $(SOURCES))" || \ -# $(INSTALL_FILE) $(SOURCES:.c=-help.pd) \ -# $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) -# test -z "$(strip $(PDOBJECTS))" || \ -# $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) \ -# $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) - $(INSTALL_FILE) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt - $(INSTALL_FILE) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt + test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(HELPPATCHES) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt + $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt install-examples: test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ for file in $(EXAMPLES); do \ - $(INSTALL_FILE) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ + $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ done install-manual: test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ for file in $(MANUAL); do \ - $(INSTALL_FILE) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ + $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ done clean: - -rm -f -- $(SOURCES:.c=.o) + -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) -rm -f -- $(SOURCES:.c=.$(EXTENSION)) -rm -f -- $(LIBRARY_NAME).o -rm -f -- $(LIBRARY_NAME).$(EXTENSION) @@ -224,54 +254,70 @@ distclean: clean -rm -rf -- $(DISTBINDIR) -rm -f -- $(DISTDIR).tar.gz -rm -rf -- $(DISTDIR) + -rm -f -- $(ORIGDIR).tar.gz + -rm -rf -- $(ORIGDIR) $(DISTBINDIR): $(INSTALL_DIR) $(DISTBINDIR) libdir: all $(DISTBINDIR) - $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) - $(INSTALL_FILE) $(SOURCES) $(DISTBINDIR) - $(INSTALL_FILE) $(SOURCES:.c=-help.pd) $(DISTBINDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) + $(INSTALL_DATA) $(SOURCES) $(DISTBINDIR) + $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR) test -z "$(strip $(EXTRA_DIST))" || \ - $(INSTALL_FILE) $(EXTRA_DIST) $(DISTBINDIR) + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) $(DISTDIR): $(INSTALL_DIR) $(DISTDIR) +$(ORIGDIR): + $(INSTALL_DIR) $(ORIGDIR) + dist: $(DISTDIR) - $(INSTALL_FILE) Makefile $(DISTDIR) - $(INSTALL_FILE) README.txt $(DISTDIR) - $(INSTALL_FILE) LICENSE.txt $(DISTDIR) - $(INSTALL_FILE) $(LIBRARY_NAME)-meta.pd $(DISTDIR) + $(INSTALL_DATA) Makefile $(DISTDIR) + $(INSTALL_DATA) README.txt $(DISTDIR) + $(INSTALL_DATA) LICENSE.txt $(DISTDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) test -z "$(strip $(ALLSOURCES))" || \ - $(INSTALL_FILE) $(ALLSOURCES) $(DISTDIR) -# test -z "$(strip $(ALLSOURCES))" || \ -# $(INSTALL_FILE) $(ALLSOURCES:.c=-help.pd) $(DISTDIR) + $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) test -z "$(strip $(PDOBJECTS))" || \ - $(INSTALL_FILE) $(PDOBJECTS) $(DISTDIR) -# test -z "$(strip $(PDOBJECTS))" || \ -# $(INSTALL_FILE) $(PDOBJECTS:.pd=-help.pd) $(DISTDIR) + $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) + test -z "$(strip $(HELPPATCHES))" || \ + $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR) test -z "$(strip $(EXTRA_DIST))" || \ - $(INSTALL_FILE) $(EXTRA_DIST) $(DISTDIR) + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DISTDIR)/examples && \ for file in $(EXAMPLES); do \ - $(INSTALL_FILE) examples/$$file $(DISTDIR)/examples; \ + $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ done test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DISTDIR)/manual && \ for file in $(MANUAL); do \ - $(INSTALL_FILE) manual/$$file $(DISTDIR)/manual; \ + $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ done tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) +# make a Debian source package +dpkg-source: + debclean + make distclean dist + mv $(DISTDIR) $(ORIGDIR) + tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) + rm -f -- $(DISTDIR).tar.gz + rm -rf -- $(DISTDIR) $(ORIGDIR) + cd .. && dpkg-source -b $(LIBRARY_NAME) etags: etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h showsetup: + @echo "CFLAGS: $(CFLAGS)" + @echo "LDFLAGS: $(LDFLAGS)" + @echo "LIBS: $(LIBS)" + @echo "PD_INCLUDE: $(PD_INCLUDE)" @echo "PD_PATH: $(PD_PATH)" @echo "objectsdir: $(objectsdir)" @echo "LIBRARY_NAME: $(LIBRARY_NAME)" @@ -282,3 +328,5 @@ showsetup: @echo "UNAME: $(UNAME)" @echo "CPU: $(CPU)" @echo "pkglibdir: $(pkglibdir)" + @echo "DISTDIR: $(DISTDIR)" + @echo "ORIGDIR: $(ORIGDIR)" diff --git a/externals/vanilla/hsl.c b/externals/vanilla/hsl.c new file mode 100644 index 00000000..05474a23 --- /dev/null +++ b/externals/vanilla/hsl.c @@ -0,0 +1,656 @@ +/* Copyright (c) 1997-1999 Miller Puckette. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ +/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ + + +#include +#include +#include +#include +#include "m_pd.h" +#include "g_canvas.h" + +#include "g_all_guis.h" +#include + +#ifdef MSW +#include +#else +#include +#endif + + +/* ------------ hsl gui-horicontal slider ----------------------- */ + +t_widgetbehavior hslider_widgetbehavior; +static t_class *hslider_class; + +/* widget helper functions */ + +static void hslider_draw_update(t_gobj *client, t_glist *glist) +{ + t_hslider *x = (t_hslider *)client; + t_canvas *canvas=glist_getcanvas(glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + + if (glist_isvisible(glist)) + { + int r = text_xpix(&x->x_gui.x_obj, glist) + (x->x_val + 50)/100; + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, r, ypos+1, + r, ypos + x->x_gui.x_h); + if(x->x_val == x->x_center) + { + if(!x->x_thick) + { + sys_vgui(".x%lx.c itemconfigure %lxKNOB -width 7\n", canvas, x); + x->x_thick = 1; + } + } + else + { + if(x->x_thick) + { + sys_vgui(".x%lx.c itemconfigure %lxKNOB -width 3\n", canvas, x); + x->x_thick = 0; + } + } + } +} + +static void hslider_draw_new(t_hslider *x, t_glist *glist) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + int r = xpos + (x->x_val + 50)/100; + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n", + canvas, xpos-3, ypos, + xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h, + x->x_gui.x_bcol, x); + sys_vgui(".x%lx.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %lxKNOB\n", + canvas, r, ypos+1, r, + ypos + x->x_gui.x_h, x->x_gui.x_fcol, x); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ + -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n", + canvas, xpos+x->x_gui.x_ldx, + ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", + canvas, xpos-3, ypos + x->x_gui.x_h-1, + xpos+4, ypos + x->x_gui.x_h, x, 0); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n", + canvas, xpos-3, ypos, + xpos+4, ypos+1, x, 0); +} + +static void hslider_draw_move(t_hslider *x, t_glist *glist) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + int r = xpos + (x->x_val + 50)/100; + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", + canvas, x, + xpos-3, ypos, + xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h); + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, r, ypos+1, + r, ypos + x->x_gui.x_h); + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n", + canvas, x, 0, + xpos-3, ypos + x->x_gui.x_h-1, + xpos+4, ypos + x->x_gui.x_h); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n", + canvas, x, 0, + xpos-3, ypos, + xpos+4, ypos+1); +} + +static void hslider_draw_erase(t_hslider* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); + sys_vgui(".x%lx.c delete %lxKNOB\n", canvas, x); + sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0); +} + +static void hslider_draw_config(t_hslider* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n", + canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); + sys_vgui(".x%lx.c itemconfigure %lxKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); +} + +static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + t_canvas *canvas=glist_getcanvas(glist); + + if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", + canvas, xpos-3, ypos + x->x_gui.x_h-1, + xpos+4, ypos + x->x_gui.x_h, x, 0); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0); + if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n", + canvas, xpos-3, ypos, + xpos+4, ypos+1, x, 0); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0); +} + +static void hslider_draw_select(t_hslider* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if(x->x_gui.x_fsf.x_selected) + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); + } + else + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); + } +} + +void hslider_draw(t_hslider *x, t_glist *glist, int mode) +{ + if(mode == IEM_GUI_DRAW_MODE_UPDATE) + sys_queuegui(x, glist, hslider_draw_update); + else if(mode == IEM_GUI_DRAW_MODE_MOVE) + hslider_draw_move(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_NEW) + hslider_draw_new(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_SELECT) + hslider_draw_select(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_ERASE) + hslider_draw_erase(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_CONFIG) + hslider_draw_config(x, glist); + else if(mode >= IEM_GUI_DRAW_MODE_IO) + hslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); +} + +/* ------------------------ hsl widgetbehaviour----------------------------- */ + + +static void hslider_getrect(t_gobj *z, t_glist *glist, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_hslider* x = (t_hslider*)z; + + *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 3; + *yp1 = text_ypix(&x->x_gui.x_obj, glist); + *xp2 = *xp1 + x->x_gui.x_w + 5; + *yp2 = *yp1 + x->x_gui.x_h; +} + +static void hslider_save(t_gobj *z, t_binbuf *b) +{ + t_hslider *x = (t_hslider *)z; + int bflcol[3]; + t_symbol *srl[3]; + + iemgui_save(&x->x_gui, srl, bflcol); + binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"), + (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, + gensym("hsl"), x->x_gui.x_w, x->x_gui.x_h, + (t_float)x->x_min, (t_float)x->x_max, + x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa), + srl[0], srl[1], srl[2], + x->x_gui.x_ldx, x->x_gui.x_ldy, + iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + bflcol[0], bflcol[1], bflcol[2], + x->x_val, x->x_steady); + binbuf_addv(b, ";"); +} + +void hslider_check_width(t_hslider *x, int w) +{ + if(w < IEM_SL_MINSIZE) + w = IEM_SL_MINSIZE; + x->x_gui.x_w = w; + x->x_center = (x->x_gui.x_w-1)*50; + if(x->x_val > (x->x_gui.x_w*100 - 100)) + { + x->x_pos = x->x_gui.x_w*100 - 100; + x->x_val = x->x_pos; + } + if(x->x_lin0_log1) + x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1); + else + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1); +} + +void hslider_check_minmax(t_hslider *x, double min, double max) +{ + if(x->x_lin0_log1) + { + if((min == 0.0)&&(max == 0.0)) + max = 1.0; + if(max > 0.0) + { + if(min <= 0.0) + min = 0.01*max; + } + else + { + if(min > 0.0) + max = 0.01*min; + } + } + x->x_min = min; + x->x_max = max; + if(x->x_min > x->x_max) /* bugfix */ + x->x_gui.x_isa.x_reverse = 1; + else + x->x_gui.x_isa.x_reverse = 0; + if(x->x_lin0_log1) + x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1); + else + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1); +} + +static void hslider_properties(t_gobj *z, t_glist *owner) +{ + t_hslider *x = (t_hslider *)z; + char buf[800]; + t_symbol *srl[3]; + + iemgui_properties(&x->x_gui, srl); + sprintf(buf, "pdtk_iemgui_dialog %%s |hsl| \ + --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \ + -----------output-range:----------- %g left: %g right: %g \ + %d lin log %d %d empty %d \ + %s %s \ + %s %d %d \ + %d %d \ + %d %d %d\n", + x->x_gui.x_w, IEM_SL_MINSIZE, x->x_gui.x_h, IEM_GUI_MINSIZE, + x->x_min, x->x_max, 0.0,/*no_schedule*/ + x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ + srl[0]->s_name, srl[1]->s_name, + srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, + x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); + gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); +} + +static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */ +{ + double g; + + if(x->x_gui.x_isa.x_reverse) /* bugfix */ + { + if(f > x->x_min) + f = x->x_min; + if(f < x->x_max) + f = x->x_max; + } + else + { + if(f > x->x_max) + f = x->x_max; + if(f < x->x_min) + f = x->x_min; + } + if(x->x_lin0_log1) + g = log(f/x->x_min)/x->x_k; + else + g = (f - x->x_min) / x->x_k; + x->x_val = (int)(100.0*g + 0.49999); + x->x_pos = x->x_val; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); +} + +static void hslider_bang(t_hslider *x) +{ + double out; + + if(x->x_lin0_log1) + out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); + else + out = (double)(x->x_val)*0.01*x->x_k + x->x_min; + if((out < 1.0e-10)&&(out > -1.0e-10)) + out = 0.0; + outlet_float(x->x_gui.x_obj.ob_outlet, out); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_float(x->x_gui.x_snd->s_thing, out); +} + +static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv) +{ + t_symbol *srl[3]; + int w = (int)atom_getintarg(0, argc, argv); + int h = (int)atom_getintarg(1, argc, argv); + double min = (double)atom_getfloatarg(2, argc, argv); + double max = (double)atom_getfloatarg(3, argc, argv); + int lilo = (int)atom_getintarg(4, argc, argv); + int steady = (int)atom_getintarg(17, argc, argv); + int sr_flags; + + if(lilo != 0) lilo = 1; + x->x_lin0_log1 = lilo; + if(steady) + x->x_steady = 1; + else + x->x_steady = 0; + sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); + x->x_gui.x_h = iemgui_clip_size(h); + hslider_check_width(x, w); + hslider_check_minmax(x, min, max); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); +} + +static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy) +{ + int old = x->x_val; + + if(x->x_gui.x_fsf.x_finemoved) + x->x_pos += (int)dx; + else + x->x_pos += 100*(int)dx; + x->x_val = x->x_pos; + if(x->x_val > (100*x->x_gui.x_w - 100)) + { + x->x_val = 100*x->x_gui.x_w - 100; + x->x_pos += 50; + x->x_pos -= x->x_pos%100; + } + if(x->x_val < 0) + { + x->x_val = 0; + x->x_pos -= 50; + x->x_pos -= x->x_pos%100; + } + if(old != x->x_val) + { + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + hslider_bang(x); + } +} + +static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + if(!x->x_steady) + x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist))); + if(x->x_val > (100*x->x_gui.x_w - 100)) + x->x_val = 100*x->x_gui.x_w - 100; + if(x->x_val < 0) + x->x_val = 0; + x->x_pos = x->x_val; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + hslider_bang(x); + glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)hslider_motion, + 0, xpos, ypos); +} + +static int hslider_newclick(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_hslider* x = (t_hslider *)z; + + if(doit) + { + hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, + 0, (t_floatarg)alt); + if(shift) + x->x_gui.x_fsf.x_finemoved = 1; + else + x->x_gui.x_fsf.x_finemoved = 0; + } + return (1); +} + +static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{ + hslider_check_width(x, (int)atom_getintarg(0, ac, av)); + if(ac > 1) + x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av)); + iemgui_size((void *)x, &x->x_gui); +} + +static void hslider_delta(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} + +static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} + +static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{ + hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), + (double)atom_getfloatarg(1, ac, av)); +} + +static void hslider_color(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_color((void *)x, &x->x_gui, s, ac, av);} + +static void hslider_send(t_hslider *x, t_symbol *s) +{iemgui_send(x, &x->x_gui, s);} + +static void hslider_receive(t_hslider *x, t_symbol *s) +{iemgui_receive(x, &x->x_gui, s);} + +static void hslider_label(t_hslider *x, t_symbol *s) +{iemgui_label((void *)x, &x->x_gui, s);} + +static void hslider_label_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} + +static void hslider_label_font(t_hslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} + +static void hslider_log(t_hslider *x) +{ + x->x_lin0_log1 = 1; + hslider_check_minmax(x, x->x_min, x->x_max); +} + +static void hslider_lin(t_hslider *x) +{ + x->x_lin0_log1 = 0; + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1); +} + +static void hslider_init(t_hslider *x, t_floatarg f) +{ + x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; +} + +static void hslider_steady(t_hslider *x, t_floatarg f) +{ + x->x_steady = (f==0.0)?0:1; +} + +static void hslider_float(t_hslider *x, t_floatarg f) +{ + double out; + + hslider_set(x, f); + if(x->x_lin0_log1) + out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); + else + out = (double)(x->x_val)*0.01*x->x_k + x->x_min; + if((out < 1.0e-10)&&(out > -1.0e-10)) + out = 0.0; + if(x->x_gui.x_fsf.x_put_in2out) + { + outlet_float(x->x_gui.x_obj.ob_outlet, out); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_float(x->x_gui.x_snd->s_thing, out); + } +} + +static void hslider_loadbang(t_hslider *x) +{ + if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + { + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + hslider_bang(x); + } +} + +static void *hslider_new(t_symbol *s, int argc, t_atom *argv) +{ + t_hslider *x = (t_hslider *)pd_new(hslider_class); + int bflcol[]={-262144, -1, -1}; + int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE; + int lilo=0, ldx=-2, ldy=-8, f=0, v=0, steady=1; + int fs=10; + double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); + char str[144]; + + iem_inttosymargs(&x->x_gui.x_isa, 0); + iem_inttofstyle(&x->x_gui.x_fsf, 0); + + if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) + &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) + &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5) + &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6)) + &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7)) + &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8)) + &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10) + &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13) + &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16)) + { + w = (int)atom_getintarg(0, argc, argv); + h = (int)atom_getintarg(1, argc, argv); + min = (double)atom_getfloatarg(2, argc, argv); + max = (double)atom_getfloatarg(3, argc, argv); + lilo = (int)atom_getintarg(4, argc, argv); + iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv)); + iemgui_new_getnames(&x->x_gui, 6, argv); + ldx = (int)atom_getintarg(9, argc, argv); + ldy = (int)atom_getintarg(10, argc, argv); + iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv)); + fs = (int)atom_getintarg(12, argc, argv); + bflcol[0] = (int)atom_getintarg(13, argc, argv); + bflcol[1] = (int)atom_getintarg(14, argc, argv); + bflcol[2] = (int)atom_getintarg(15, argc, argv); + v = (int)atom_getintarg(16, argc, argv); + } + else iemgui_new_getnames(&x->x_gui, 6, 0); + if((argc == 18)&&IS_A_FLOAT(argv,17)) + steady = (int)atom_getintarg(17, argc, argv); + + x->x_gui.x_draw = (t_iemfunptr)hslider_draw; + + x->x_gui.x_fsf.x_snd_able = 1; + x->x_gui.x_fsf.x_rcv_able = 1; + + x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); + if(x->x_gui.x_isa.x_loadinit) + x->x_val = v; + else + x->x_val = 0; + x->x_pos = x->x_val; + if(lilo != 0) lilo = 1; + x->x_lin0_log1 = lilo; + if(steady != 0) steady = 1; + x->x_steady = steady; + if (!strcmp(x->x_gui.x_snd->s_name, "empty")) + x->x_gui.x_fsf.x_snd_able = 0; + if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) + x->x_gui.x_fsf.x_rcv_able = 0; + if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); + else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); + else { x->x_gui.x_fsf.x_font_style = 0; + strcpy(x->x_gui.x_font, sys_font); } + if(x->x_gui.x_fsf.x_rcv_able) + pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); + x->x_gui.x_ldx = ldx; + x->x_gui.x_ldy = ldy; + if(fs < 4) + fs = 4; + x->x_gui.x_fontsize = fs; + x->x_gui.x_h = iemgui_clip_size(h); + hslider_check_width(x, w); + hslider_check_minmax(x, min, max); + iemgui_all_colfromload(&x->x_gui, bflcol); + x->x_thick = 0; + iemgui_verify_snd_ne_rcv(&x->x_gui); + outlet_new(&x->x_gui.x_obj, &s_float); + return (x); +} + +static void hslider_free(t_hslider *x) +{ + if(x->x_gui.x_fsf.x_rcv_able) + pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); + gfxstub_deleteforkey(x); +} + +void hsl_setup(void) +{ + hslider_class = class_new(gensym("hsl"), (t_newmethod)hslider_new, + (t_method)hslider_free, sizeof(t_hslider), 0, A_GIMME, 0); +#ifndef GGEE_HSLIDER_COMPATIBLE + class_addcreator((t_newmethod)hslider_new, gensym("hslider"), A_GIMME, 0); +#endif + class_addbang(hslider_class,hslider_bang); + class_addfloat(hslider_class,hslider_float); + class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(hslider_class, (t_method)hslider_motion, gensym("motion"), + A_FLOAT, A_FLOAT, 0); + class_addmethod(hslider_class, (t_method)hslider_dialog, gensym("dialog"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_loadbang, gensym("loadbang"), 0); + class_addmethod(hslider_class, (t_method)hslider_set, gensym("set"), A_FLOAT, 0); + class_addmethod(hslider_class, (t_method)hslider_size, gensym("size"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_delta, gensym("delta"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_pos, gensym("pos"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_range, gensym("range"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_color, gensym("color"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_send, gensym("send"), A_DEFSYM, 0); + class_addmethod(hslider_class, (t_method)hslider_receive, gensym("receive"), A_DEFSYM, 0); + class_addmethod(hslider_class, (t_method)hslider_label, gensym("label"), A_DEFSYM, 0); + class_addmethod(hslider_class, (t_method)hslider_label_pos, gensym("label_pos"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(hslider_class, (t_method)hslider_log, gensym("log"), 0); + class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0); + class_addmethod(hslider_class, (t_method)hslider_init, gensym("init"), A_FLOAT, 0); + class_addmethod(hslider_class, (t_method)hslider_steady, gensym("steady"), A_FLOAT, 0); + hslider_widgetbehavior.w_getrectfn = hslider_getrect; + hslider_widgetbehavior.w_displacefn = iemgui_displace; + hslider_widgetbehavior.w_selectfn = iemgui_select; + hslider_widgetbehavior.w_activatefn = NULL; + hslider_widgetbehavior.w_deletefn = iemgui_delete; + hslider_widgetbehavior.w_visfn = iemgui_vis; + hslider_widgetbehavior.w_clickfn = hslider_newclick; + class_setwidget(hslider_class, &hslider_widgetbehavior); + class_sethelpsymbol(hslider_class, gensym("hslider")); + class_setsavefn(hslider_class, hslider_save); + class_setpropertiesfn(hslider_class, hslider_properties); +} diff --git a/externals/vanilla/hslider.c b/externals/vanilla/hslider.c new file mode 100644 index 00000000..30a33d1f --- /dev/null +++ b/externals/vanilla/hslider.c @@ -0,0 +1,5 @@ +#include "hsl.c" +void hslider_setup(void) +{ + hsl_setup(); +} diff --git a/externals/vanilla/my_canvas.c b/externals/vanilla/my_canvas.c new file mode 100644 index 00000000..af787836 --- /dev/null +++ b/externals/vanilla/my_canvas.c @@ -0,0 +1,6 @@ +#include "cnv.c" +void my_canvas_setup(void) +{ + cnv_setup(); +} + diff --git a/externals/vanilla/my_numbox.c b/externals/vanilla/my_numbox.c new file mode 100644 index 00000000..12f34773 --- /dev/null +++ b/externals/vanilla/my_numbox.c @@ -0,0 +1,6 @@ +#include "nbx.c" +void my_numbox_setup(void) +{ + nbx_setup(); +} + diff --git a/externals/vanilla/radiobut.c b/externals/vanilla/radiobut.c new file mode 100644 index 00000000..e62a6c98 --- /dev/null +++ b/externals/vanilla/radiobut.c @@ -0,0 +1,6 @@ +#include "hradio.c" +void radiobut_setup(void) +{ + hradio_setup(); +} + diff --git a/externals/vanilla/radiobutton.c b/externals/vanilla/radiobutton.c new file mode 100644 index 00000000..dff90251 --- /dev/null +++ b/externals/vanilla/radiobutton.c @@ -0,0 +1,6 @@ +#include "hradio.c" +void radiobutton_setup(void) +{ + hradio_setup(); +} + diff --git a/externals/vanilla/rdb.c b/externals/vanilla/rdb.c new file mode 100644 index 00000000..62ce4549 --- /dev/null +++ b/externals/vanilla/rdb.c @@ -0,0 +1,6 @@ +#include "hradio.c" +void rdb_setup(void) +{ + hradio_setup(); +} + diff --git a/externals/vanilla/toggle.c b/externals/vanilla/toggle.c new file mode 100644 index 00000000..2b39a515 --- /dev/null +++ b/externals/vanilla/toggle.c @@ -0,0 +1,6 @@ +#include "tgl.c" +void toggle_setup(void) +{ + tgl_setup(); +} + diff --git a/externals/vanilla/vsl.c b/externals/vanilla/vsl.c new file mode 100644 index 00000000..fac5d2e8 --- /dev/null +++ b/externals/vanilla/vsl.c @@ -0,0 +1,629 @@ +/* Copyright (c) 1997-1999 Miller Puckette. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ +/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ + + +#include +#include +#include +#include +#include "m_pd.h" +#include "g_canvas.h" + +#include "g_all_guis.h" +#include + +#ifdef MSW +#include +#else +#include +#endif + + +/* ------------ vsl gui-vertical slider ----------------------- */ + +t_widgetbehavior vslider_widgetbehavior; +static t_class *vslider_class; + +/* widget helper functions */ + +static void vslider_draw_update(t_gobj *client, t_glist *glist) +{ + t_vslider *x = (t_vslider *)client; + if (glist_isvisible(glist)) + { + int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100; + int xpos=text_xpix(&x->x_gui.x_obj, glist); + + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + glist_getcanvas(glist), x, xpos+1, r, + xpos + x->x_gui.x_w, r); + } +} + +static void vslider_draw_new(t_vslider *x, t_glist *glist) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100; + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n", + canvas, xpos, ypos-2, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3, + x->x_gui.x_bcol, x); + sys_vgui(".x%lx.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %lxKNOB\n", + canvas, xpos+1, r, + xpos + x->x_gui.x_w, r, x->x_gui.x_fcol, x); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ + -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n", + canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", + canvas, + xpos, ypos + x->x_gui.x_h+2, + xpos+7, ypos + x->x_gui.x_h+3, + x, 0); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n", + canvas, + xpos, ypos-2, + xpos+7, ypos-1, + x, 0); +} + +static void vslider_draw_move(t_vslider *x, t_glist *glist) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100; + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", + canvas, x, + xpos, ypos-2, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3); + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, xpos+1, r, + xpos + x->x_gui.x_w, r); + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n", + canvas, x, 0, + xpos, ypos + x->x_gui.x_h+2, + xpos+7, ypos + x->x_gui.x_h+3); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n", + canvas, x, 0, + xpos, ypos-2, + xpos+7, ypos-1); +} + +static void vslider_draw_erase(t_vslider* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); + sys_vgui(".x%lx.c delete %lxKNOB\n", canvas, x); + sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); + if(!x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0); + if(!x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0); +} + +static void vslider_draw_config(t_vslider* x,t_glist* glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n", + canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); + sys_vgui(".x%lx.c itemconfigure %lxKNOB -fill #%6.6x\n", canvas, + x, x->x_gui.x_fcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, + x, x->x_gui.x_bcol); +} + +static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags) +{ + int xpos=text_xpix(&x->x_gui.x_obj, glist); + int ypos=text_ypix(&x->x_gui.x_obj, glist); + t_canvas *canvas=glist_getcanvas(glist); + + if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n", + canvas, + xpos, ypos + x->x_gui.x_h+2, + xpos+7, ypos + x->x_gui.x_h+3, + x, 0); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) + sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0); + if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n", + canvas, + xpos, ypos-2, + xpos+7, ypos-1, + x, 0); + if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0); +} + +static void vslider_draw_select(t_vslider *x, t_glist *glist) +{ + t_canvas *canvas=glist_getcanvas(glist); + + if(x->x_gui.x_fsf.x_selected) + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); + } + else + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); + } +} + +void vslider_draw(t_vslider *x, t_glist *glist, int mode) +{ + if(mode == IEM_GUI_DRAW_MODE_UPDATE) + sys_queuegui(x, glist, vslider_draw_update); + else if(mode == IEM_GUI_DRAW_MODE_MOVE) + vslider_draw_move(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_NEW) + vslider_draw_new(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_SELECT) + vslider_draw_select(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_ERASE) + vslider_draw_erase(x, glist); + else if(mode == IEM_GUI_DRAW_MODE_CONFIG) + vslider_draw_config(x, glist); + else if(mode >= IEM_GUI_DRAW_MODE_IO) + vslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); +} + +/* ------------------------ vsl widgetbehaviour----------------------------- */ + + +static void vslider_getrect(t_gobj *z, t_glist *glist, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_vslider* x = (t_vslider*)z; + + *xp1 = text_xpix(&x->x_gui.x_obj, glist); + *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2; + *xp2 = *xp1 + x->x_gui.x_w; + *yp2 = *yp1 + x->x_gui.x_h + 5; +} + +static void vslider_save(t_gobj *z, t_binbuf *b) +{ + t_vslider *x = (t_vslider *)z; + int bflcol[3]; + t_symbol *srl[3]; + + iemgui_save(&x->x_gui, srl, bflcol); + binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"), + (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix, + gensym("vsl"), x->x_gui.x_w, x->x_gui.x_h, + (t_float)x->x_min, (t_float)x->x_max, + x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa), + srl[0], srl[1], srl[2], + x->x_gui.x_ldx, x->x_gui.x_ldy, + iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, + bflcol[0], bflcol[1], bflcol[2], + x->x_val, x->x_steady); + binbuf_addv(b, ";"); +} + +void vslider_check_height(t_vslider *x, int h) +{ + if(h < IEM_SL_MINSIZE) + h = IEM_SL_MINSIZE; + x->x_gui.x_h = h; + if(x->x_val > (x->x_gui.x_h*100 - 100)) + { + x->x_pos = x->x_gui.x_h*100 - 100; + x->x_val = x->x_pos; + } + if(x->x_lin0_log1) + x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1); + else + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1); +} + +void vslider_check_minmax(t_vslider *x, double min, double max) +{ + if(x->x_lin0_log1) + { + if((min == 0.0)&&(max == 0.0)) + max = 1.0; + if(max > 0.0) + { + if(min <= 0.0) + min = 0.01*max; + } + else + { + if(min > 0.0) + max = 0.01*min; + } + } + x->x_min = min; + x->x_max = max; + if(x->x_min > x->x_max) /* bugfix */ + x->x_gui.x_isa.x_reverse = 1; + else + x->x_gui.x_isa.x_reverse = 0; + if(x->x_lin0_log1) + x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1); + else + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1); +} + +static void vslider_properties(t_gobj *z, t_glist *owner) +{ + t_vslider *x = (t_vslider *)z; + char buf[800]; + t_symbol *srl[3]; + + iemgui_properties(&x->x_gui, srl); + + sprintf(buf, "pdtk_iemgui_dialog %%s |vsl| \ + --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \ + -----------output-range:----------- %g bottom: %g top: %d \ + %d lin log %d %d empty %d \ + %s %s \ + %s %d %d \ + %d %d \ + %d %d %d\n", + x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_SL_MINSIZE, + x->x_min, x->x_max, 0,/*no_schedule*/ + x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/ + srl[0]->s_name, srl[1]->s_name, + srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, + x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, + 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); + gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); +} + +static void vslider_bang(t_vslider *x) +{ + double out; + + if(x->x_lin0_log1) + out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); + else + out = (double)(x->x_val)*0.01*x->x_k + x->x_min; + if((out < 1.0e-10)&&(out > -1.0e-10)) + out = 0.0; + + outlet_float(x->x_gui.x_obj.ob_outlet, out); + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) + pd_float(x->x_gui.x_snd->s_thing, out); +} + +static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv) +{ + t_symbol *srl[3]; + int w = (int)atom_getintarg(0, argc, argv); + int h = (int)atom_getintarg(1, argc, argv); + double min = (double)atom_getfloatarg(2, argc, argv); + double max = (double)atom_getfloatarg(3, argc, argv); + int lilo = (int)atom_getintarg(4, argc, argv); + int steady = (int)atom_getintarg(17, argc, argv); + int sr_flags; + + if(lilo != 0) lilo = 1; + x->x_lin0_log1 = lilo; + if(steady) + x->x_steady = 1; + else + x->x_steady = 0; + sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); + x->x_gui.x_w = iemgui_clip_size(w); + vslider_check_height(x, h); + vslider_check_minmax(x, min, max); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); +} + +static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy) +{ + int old = x->x_val; + + if(x->x_gui.x_fsf.x_finemoved) + x->x_pos -= (int)dy; + else + x->x_pos -= 100*(int)dy; + x->x_val = x->x_pos; + if(x->x_val > (100*x->x_gui.x_h - 100)) + { + x->x_val = 100*x->x_gui.x_h - 100; + x->x_pos += 50; + x->x_pos -= x->x_pos%100; + } + if(x->x_val < 0) + { + x->x_val = 0; + x->x_pos -= 50; + x->x_pos -= x->x_pos%100; + } + if(old != x->x_val) + { + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + vslider_bang(x); + } +} + +static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +{ + if(!x->x_steady) + x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos)); + if(x->x_val > (100*x->x_gui.x_h - 100)) + x->x_val = 100*x->x_gui.x_h - 100; + if(x->x_val < 0) + x->x_val = 0; + x->x_pos = x->x_val; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + vslider_bang(x); + glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, + (t_glistmotionfn)vslider_motion, 0, xpos, ypos); +} + +static int vslider_newclick(t_gobj *z, struct _glist *glist, + int xpix, int ypix, int shift, int alt, int dbl, int doit) +{ + t_vslider* x = (t_vslider *)z; + + if(doit) + { + vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, + 0, (t_floatarg)alt); + if(shift) + x->x_gui.x_fsf.x_finemoved = 1; + else + x->x_gui.x_fsf.x_finemoved = 0; + } + return (1); +} + +static void vslider_set(t_vslider *x, t_floatarg f) +{ + double g; + + if(x->x_gui.x_isa.x_reverse) /* bugfix */ + { + if(f > x->x_min) + f = x->x_min; + if(f < x->x_max) + f = x->x_max; + } + else + { + if(f > x->x_max) + f = x->x_max; + if(f < x->x_min) + f = x->x_min; + } + if(x->x_lin0_log1) + g = log(f/x->x_min)/x->x_k; + else + g = (f - x->x_min) / x->x_k; + x->x_val = (int)(100.0*g + 0.49999); + x->x_pos = x->x_val; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); +} + +static void vslider_float(t_vslider *x, t_floatarg f) +{ + vslider_set(x, f); + if(x->x_gui.x_fsf.x_put_in2out) + vslider_bang(x); +} + +static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{ + x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); + if(ac > 1) + vslider_check_height(x, (int)atom_getintarg(1, ac, av)); + iemgui_size((void *)x, &x->x_gui); +} + +static void vslider_delta(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_delta((void *)x, &x->x_gui, s, ac, av);} + +static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_pos((void *)x, &x->x_gui, s, ac, av);} + +static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{ + vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av), + (double)atom_getfloatarg(1, ac, av)); +} + +static void vslider_color(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_color((void *)x, &x->x_gui, s, ac, av);} + +static void vslider_send(t_vslider *x, t_symbol *s) +{iemgui_send(x, &x->x_gui, s);} + +static void vslider_receive(t_vslider *x, t_symbol *s) +{iemgui_receive(x, &x->x_gui, s);} + +static void vslider_label(t_vslider *x, t_symbol *s) +{iemgui_label((void *)x, &x->x_gui, s);} + +static void vslider_label_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} + +static void vslider_label_font(t_vslider *x, t_symbol *s, int ac, t_atom *av) +{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} + +static void vslider_log(t_vslider *x) +{ + x->x_lin0_log1 = 1; + vslider_check_minmax(x, x->x_min, x->x_max); +} + +static void vslider_lin(t_vslider *x) +{ + x->x_lin0_log1 = 0; + x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1); +} + +static void vslider_init(t_vslider *x, t_floatarg f) +{ + x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; +} + +static void vslider_steady(t_vslider *x, t_floatarg f) +{ + x->x_steady = (f==0.0)?0:1; +} + +static void vslider_loadbang(t_vslider *x) +{ + if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) + { + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + vslider_bang(x); + } +} + +static void *vslider_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vslider *x = (t_vslider *)pd_new(vslider_class); + int bflcol[]={-262144, -1, -1}; + int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE; + int lilo=0, f=0, ldx=0, ldy=-9; + int fs=10, v=0, steady=1; + double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1); + char str[144]; + + iem_inttosymargs(&x->x_gui.x_isa, 0); + iem_inttofstyle(&x->x_gui.x_fsf, 0); + + if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1) + &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3) + &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5) + &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6)) + &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7)) + &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8)) + &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10) + &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13) + &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16)) + { + w = (int)atom_getintarg(0, argc, argv); + h = (int)atom_getintarg(1, argc, argv); + min = (double)atom_getfloatarg(2, argc, argv); + max = (double)atom_getfloatarg(3, argc, argv); + lilo = (int)atom_getintarg(4, argc, argv); + iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv)); + iemgui_new_getnames(&x->x_gui, 6, argv); + ldx = (int)atom_getintarg(9, argc, argv); + ldy = (int)atom_getintarg(10, argc, argv); + iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv)); + fs = (int)atom_getintarg(12, argc, argv); + bflcol[0] = (int)atom_getintarg(13, argc, argv); + bflcol[1] = (int)atom_getintarg(14, argc, argv); + bflcol[2] = (int)atom_getintarg(15, argc, argv); + v = (int)atom_getintarg(16, argc, argv); + } + else iemgui_new_getnames(&x->x_gui, 6, 0); + if((argc == 18)&&IS_A_FLOAT(argv,17)) + steady = (int)atom_getintarg(17, argc, argv); + x->x_gui.x_draw = (t_iemfunptr)vslider_draw; + x->x_gui.x_fsf.x_snd_able = 1; + x->x_gui.x_fsf.x_rcv_able = 1; + x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); + if(x->x_gui.x_isa.x_loadinit) + x->x_val = v; + else + x->x_val = 0; + x->x_pos = x->x_val; + if(lilo != 0) lilo = 1; + x->x_lin0_log1 = lilo; + if(steady != 0) steady = 1; + x->x_steady = steady; + if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0; + if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0; + if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); + else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); + else { x->x_gui.x_fsf.x_font_style = 0; + strcpy(x->x_gui.x_font, sys_font); } + if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); + x->x_gui.x_ldx = ldx; + x->x_gui.x_ldy = ldy; + if(fs < 4) + fs = 4; + x->x_gui.x_fontsize = fs; + x->x_gui.x_w = iemgui_clip_size(w); + vslider_check_height(x, h); + vslider_check_minmax(x, min, max); + iemgui_all_colfromload(&x->x_gui, bflcol); + iemgui_verify_snd_ne_rcv(&x->x_gui); + outlet_new(&x->x_gui.x_obj, &s_float); + return (x); +} + +static void vslider_free(t_vslider *x) +{ + if(x->x_gui.x_fsf.x_rcv_able) + pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); + gfxstub_deleteforkey(x); +} + +void vsl_setup(void) +{ + vslider_class = class_new(gensym("vsl"), (t_newmethod)vslider_new, + (t_method)vslider_free, sizeof(t_vslider), 0, A_GIMME, 0); + class_addcreator((t_newmethod)vslider_new, gensym("vslider"), A_GIMME, 0); + class_addbang(vslider_class,vslider_bang); + class_addfloat(vslider_class,vslider_float); + class_addmethod(vslider_class, (t_method)vslider_click, gensym("click"), + A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_motion, gensym("motion"), + A_FLOAT, A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_dialog, gensym("dialog"), + A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_loadbang, gensym("loadbang"), 0); + class_addmethod(vslider_class, (t_method)vslider_set, gensym("set"), A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_delta, gensym("delta"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_pos, gensym("pos"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_color, gensym("color"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_send, gensym("send"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_receive, gensym("receive"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_label, gensym("label"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_label_pos, gensym("label_pos"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0); + class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0); + class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0); + vslider_widgetbehavior.w_getrectfn = vslider_getrect; + vslider_widgetbehavior.w_displacefn = iemgui_displace; + vslider_widgetbehavior.w_selectfn = iemgui_select; + vslider_widgetbehavior.w_activatefn = NULL; + vslider_widgetbehavior.w_deletefn = iemgui_delete; + vslider_widgetbehavior.w_visfn = iemgui_vis; + vslider_widgetbehavior.w_clickfn = vslider_newclick; + class_setwidget(vslider_class, &vslider_widgetbehavior); + class_sethelpsymbol(vslider_class, gensym("vslider")); + class_setsavefn(vslider_class, vslider_save); + class_setpropertiesfn(vslider_class, vslider_properties); +} diff --git a/externals/vanilla/vslider.c b/externals/vanilla/vslider.c new file mode 100644 index 00000000..8c5ce228 --- /dev/null +++ b/externals/vanilla/vslider.c @@ -0,0 +1,5 @@ +#include "vsl.c" +void vslider_setup(void) +{ + vsl_setup(); +} -- cgit v1.2.1