Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

fix build with Pd API changes #16

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8df5b73
Merge branch 'master' of github.com:avilleret/CicmWrapper
avilleret Mar 16, 2015
a9b827d
Merge branch 'master' of https://github.com/CICM/CicmWrapper
avilleret Mar 18, 2015
15d467a
add CMakeLists.txt to build easily with Jamoma
avilleret Mar 26, 2015
ecad4f4
Merge branch 'master' into feature/CMakeLists.txt
avilleret May 14, 2015
b3d2968
Merge branch 'master' of https://github.com/CICM/CicmWrapper into fea…
avilleret May 29, 2015
8ed284f
Merge branch 'master' of https://github.com/CICM/CicmWrapper
avilleret Jun 26, 2015
10fca93
Merge branch 'master' into feature/CMakeLists.txt
avilleret Jun 26, 2015
6cc3fd8
update CMakeLists to reflect repo reorganisation
avilleret Jun 26, 2015
6c3b549
Merge pull request #1 from avilleret/feature/CMakeLists.txt
avilleret Oct 29, 2015
0b42c35
Should fix build on windows
jcelerier Dec 5, 2016
6343214
Merge pull request #2 from jcelerier/patch-1
avilleret Dec 5, 2016
d941dab
reflect recent change in Pd API
avilleret May 14, 2017
dc0abfa
avoid crash when getter is called from patcher
avilleret Sep 19, 2017
b9321e9
add default label
avilleret Sep 19, 2017
7d9f5eb
fix Visual Studio build
avilleret Apr 24, 2019
96a473a
remove legacy sys_gui call when building against PurrData
avilleret Apr 30, 2019
80ef113
Fix some issues in CicmWrapper
jcelerier Jun 24, 2020
dc96eb9
Merge pull request #3 from jcelerier/master
avilleret Jun 24, 2020
79394e2
Fix incompatibilities with purr-data
jcelerier Aug 1, 2020
d44f1fa
Merge pull request #4 from jcelerier/master
avilleret Aug 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.0)
project(CicmWrapper C)

message("Configuring CicmWrapper")


file(GLOB_RECURSE PROJECT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.c)

file(GLOB_RECURSE PROJECT_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)

add_library(${PROJECT_NAME} ${PROJECT_SRCS})

set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
7 changes: 5 additions & 2 deletions Sources/ebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,11 @@ t_pd_err ebox_set_font(t_ebox *x, t_object *attr, int argc, t_atom *argv)
else
x->b_font.c_family = gensym("Helvetica");

x->b_font.c_family = gensym(strtok(x->b_font.c_family->s_name," ',.-"));
x->b_font.c_family->s_name[0] = (char)toupper(x->b_font.c_family->s_name[0]);
const char* token = strtok(x->b_font.c_family->s_name," ',.-");
char* buffer = strdup(token);
buffer[0] = toupper(buffer[0]);
x->b_font.c_family = gensym(buffer);
free(buffer);
return 0;
}

Expand Down
91 changes: 49 additions & 42 deletions Sources/eclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void eclass_guiinit(t_eclass* c, long flags)
{
ewidget_init(c);
c->c_box = 1;

// DEFAULT ATTRIBUTES //
CLASS_ATTR_FLOAT_ARRAY (c, "size", 0, t_ebox, b_rect.width, 2);
CLASS_ATTR_SYMBOL (c, "fontname", 0, t_ebox, b_font.c_family);
Expand All @@ -58,15 +58,15 @@ void eclass_guiinit(t_eclass* c, long flags)
CLASS_ATTR_LONG (c, "fontsize", 0, t_ebox, b_font.c_sizereal);
CLASS_ATTR_SYMBOL (c, "receive", 0, t_ebox, b_receive_id);
CLASS_ATTR_SYMBOL (c, "send", 0, t_ebox, b_send_id);

CLASS_ATTR_DEFAULT (c, "size", 0, "100. 100.");
CLASS_ATTR_FILTER_MIN (c, "size", 4);
CLASS_ATTR_SAVE (c, "size", 0);
CLASS_ATTR_PAINT (c, "size", 0);
CLASS_ATTR_CATEGORY (c, "size", 0, "Basic");
CLASS_ATTR_LABEL (c, "size", 0, "Patching Size");
CLASS_ATTR_ACCESSORS (c, "size", NULL, (t_err_method)ebox_size_set);

CLASS_ATTR_DEFAULT (c, "fontname", 0, "Helvetica");
CLASS_ATTR_SAVE (c, "fontname", 0);
CLASS_ATTR_PAINT (c, "fontname", 0);
Expand All @@ -75,7 +75,7 @@ void eclass_guiinit(t_eclass* c, long flags)
CLASS_ATTR_ACCESSORS (c, "fontname", NULL, (t_err_method)ebox_set_font);
CLASS_ATTR_STYLE (c, "fontname", 0, "menu");
CLASS_ATTR_ITEMS (c, "fontname", 0, "Helvetica Monaco Courier Times DejaVu");

CLASS_ATTR_DEFAULT (c, "fontweight", 0, "normal");
CLASS_ATTR_SAVE (c, "fontweight", 0);
CLASS_ATTR_PAINT (c, "fontweight", 0);
Expand All @@ -84,7 +84,7 @@ void eclass_guiinit(t_eclass* c, long flags)
CLASS_ATTR_ACCESSORS (c, "fontweight", NULL, (t_err_method)ebox_set_fontweight);
CLASS_ATTR_STYLE (c, "fontweight", 0, "menu");
CLASS_ATTR_ITEMS (c, "fontweight", 0, "normal bold");

CLASS_ATTR_DEFAULT (c, "fontslant", 0, "roman");
CLASS_ATTR_SAVE (c, "fontslant", 0);
CLASS_ATTR_PAINT (c, "fontslant", 0);
Expand All @@ -93,7 +93,7 @@ void eclass_guiinit(t_eclass* c, long flags)
CLASS_ATTR_ACCESSORS (c, "fontslant", NULL, (t_err_method)ebox_set_fontslant);
CLASS_ATTR_STYLE (c, "fontslant", 0, "menu");
CLASS_ATTR_ITEMS (c, "fontslant", 0, "roman italic");

CLASS_ATTR_DEFAULT (c, "fontsize", 0, "11");
CLASS_ATTR_FILTER_MIN (c, "fontsize", 4);
CLASS_ATTR_SAVE (c, "fontsize", 0);
Expand All @@ -102,32 +102,32 @@ void eclass_guiinit(t_eclass* c, long flags)
CLASS_ATTR_LABEL (c, "fontsize", 0, "Font Size");
CLASS_ATTR_ACCESSORS (c, "fontsize", NULL, ebox_set_fontsize);
CLASS_ATTR_STYLE (c, "fontsize", 0, "number");

CLASS_ATTR_DEFAULT (c, "receive", 0, "(null)");
CLASS_ATTR_ACCESSORS (c, "receive", NULL, ebox_set_receiveid);
CLASS_ATTR_SAVE (c, "receive", 0);
CLASS_ATTR_CATEGORY (c, "receive", 0, "Basic");
CLASS_ATTR_LABEL (c, "receive", 0, "Receive Symbol");

CLASS_ATTR_DEFAULT (c, "send", 0, "(null)");
CLASS_ATTR_ACCESSORS (c, "send", NULL, ebox_set_sendid);
CLASS_ATTR_SAVE (c, "send", 0);
CLASS_ATTR_CATEGORY (c, "send", 0, "Basic");
CLASS_ATTR_LABEL (c, "send", 0, "Send Symbol");

// GUI always need this methods //
class_addmethod((t_class *)c, (t_method)ebox_attrprint, gensym("attrprint"), A_NULL, 0);
class_addmethod((t_class *)c, (t_method)ebox_dialog, gensym("dialog"), A_GIMME, 0);

class_addmethod((t_class *)c, (t_method)ebox_mouse_enter, gensym("mouseenter"), A_NULL, 0);
class_addmethod((t_class *)c, (t_method)ebox_mouse_leave, gensym("mouseleave"), A_NULL, 0);
class_addmethod((t_class *)c, (t_method)ebox_mouse_move, gensym("mousemove"), A_GIMME, 0);
class_addmethod((t_class *)c, (t_method)ebox_mouse_down, gensym("mousedown"), A_GIMME, 0);
class_addmethod((t_class *)c, (t_method)ebox_mouse_up, gensym("mouseup"), A_GIMME, 0);

class_addmethod((t_class *)c, (t_method)ebox_pos, gensym("pos"), A_DEFFLOAT,A_DEFFLOAT,0);
class_addmethod((t_class *)c, (t_method)ebox_vis, gensym("vis"), A_DEFFLOAT,0);

class_setwidget((t_class *)&c->c_class, (t_widgetbehavior *)&c->c_widget);
class_setsavefn((t_class *)&c->c_class, (t_savefn)eobj_save);
}
Expand All @@ -150,7 +150,7 @@ t_pd_err eclass_register(t_symbol *name, t_eclass *c)
{
c->c_class.c_floatsignalin = calcoffset(t_edspobj, d_dsp.d_float);
}

if(c->c_nattr)
{
eclass_properties_dialog(c);
Expand Down Expand Up @@ -264,7 +264,7 @@ void eclass_addmethod(t_eclass* c, t_typ_method m, const char* name, t_atomtype
class_addmethod((t_class *)c, (t_method)m, gensym(name), type, 0);
}
else if(gensym(name) == gensym("write"))
{
{
class_addmethod((t_class *)c, (t_method)eobj_write, gensym(name), type, 0);
class_addmethod((t_class *)c, (t_method)eobj_write, gensym("eobjwriteto"), type, 0);
c->c_widget.w_write = m;
Expand Down Expand Up @@ -322,7 +322,7 @@ void eclass_new_attr_typed(t_eclass* c, const char* attrname, const char* type,
attr->defvals = NULL;
attr->itemslist = NULL;
attr->itemssize = 0;

attrs = (t_eattr **)realloc(c->c_attr, (size_t)(c->c_nattr + 1) * sizeof(t_eattr *));
if(attrs)
{
Expand All @@ -332,12 +332,13 @@ void eclass_new_attr_typed(t_eclass* c, const char* attrname, const char* type,
sprintf(getattr, "get%s", attrname);
class_addmethod((t_class *)c, (t_method)eclass_attr_getter, gensym(getattr), A_GIMME, 0);
c->c_nattr++;
eclass_attr_label(c, attrname, 0, attrname);
}
else
{
error("%s can't increase memory for %s attribute.", c->c_class.c_name->s_name, attrname);
}

}
else
{
Expand Down Expand Up @@ -445,7 +446,7 @@ void eclass_attr_itemlist(t_eclass* c, const char* attrname, long flags, const c
if(c->c_attr[i]->name == gensym(attrname))
{
pch = strtok(gensym(list)->s_name," ,");

while(pch != NULL)
{
pch = strtok(NULL, " ,");
Expand Down Expand Up @@ -475,7 +476,7 @@ void eclass_attr_itemlist(t_eclass* c, const char* attrname, long flags, const c
j++;
}
}

}
else
{
Expand All @@ -499,7 +500,7 @@ void eclass_attr_filter_min(t_eclass* c, const char* attrname, float value)
c->c_attr[i]->clipped = 1;
else if(c->c_attr[i]->clipped == 2)
c->c_attr[i]->clipped = 3;

c->c_attr[i]->minimum = value;
return ;
}
Expand All @@ -517,7 +518,7 @@ void eclass_attr_filter_max(t_eclass* c, const char* attrname, float value)
c->c_attr[i]->clipped = 2;
else if(c->c_attr[i]->clipped == 1)
c->c_attr[i]->clipped = 3;

c->c_attr[i]->maximum = value;
return ;
}
Expand Down Expand Up @@ -596,10 +597,15 @@ void eclass_attr_getter(t_object* x, t_symbol *s, int* argc, t_atom** argv)
char *point;
t_ebox* z = (t_ebox *)x;
t_eclass* c = (t_eclass *)z->b_obj.o_obj.te_g.g_pd;

// if argc is null, this might have been wrongly called from patcher
if(!argc)
return;

if(argv[0] && argc[0])
free(argv);
argc[0] = 0;

for(i = 0; i < c->c_nattr; i++)
{
if(c->c_attr[i]->name == s)
Expand All @@ -614,9 +620,9 @@ void eclass_attr_getter(t_object* x, t_symbol *s, int* argc, t_atom** argv)
if(argc[0] > c->c_attr[i]->sizemax)
argc[0] = (int)c->c_attr[i]->sizemax;
}

point = (char *)x + c->c_attr[i]->offset;

argv[0] = (t_atom *)calloc((size_t)argc[0], sizeof(t_atom));
if(c->c_attr[i]->getter)
{
Expand Down Expand Up @@ -679,7 +685,7 @@ void eclass_attr_setter(t_object* x, t_symbol *s, int argc, t_atom *argv)
long *point_size;
t_ebox* z = (t_ebox *)x;
t_eclass* c = (t_eclass *)z->b_obj.o_obj.te_g.g_pd;

for(i = 0; i < c->c_nattr; i++)
{
if(c->c_attr[i]->name == s)
Expand All @@ -700,9 +706,9 @@ void eclass_attr_setter(t_object* x, t_symbol *s, int argc, t_atom *argv)
point_size = (long *)point;
point_size[0] = (long)size;
}

point = (char *)(x) + c->c_attr[i]->offset;

if(c->c_attr[i]->clipped == 1 || c->c_attr[i]->clipped == 3)
{
for(j = 0; j < argc; j++)
Expand All @@ -723,7 +729,7 @@ void eclass_attr_setter(t_object* x, t_symbol *s, int argc, t_atom *argv)
}
}
}

if(c->c_attr[i]->setter)
{
c->c_attr[i]->setter(x, c->c_attr[i], argc, argv);
Expand Down Expand Up @@ -791,13 +797,13 @@ void eclass_attr_setter(t_object* x, t_symbol *s, int argc, t_atom *argv)
pointor[j] = argv[j];
}
}

ebox_notify(z, s, s_attr_modified, NULL, NULL);
if(c->c_widget.w_notify != NULL)
{
c->c_widget.w_notify(x, s, s_attr_modified, NULL, NULL);
}

if(c->c_attr[i]->paint)
{
if(c->c_widget.w_oksize != NULL)
Expand All @@ -808,7 +814,7 @@ void eclass_attr_setter(t_object* x, t_symbol *s, int argc, t_atom *argv)
{
c->c_widget.w_getdrawparameters(x, NULL, &z->b_boxparameters);
}

ebox_redraw(z);
}
if(c->c_attr[i]->save && eobj_isbox(x) && ebox_isdrawable((t_ebox*) x))
Expand All @@ -828,7 +834,7 @@ static void ewidget_init(t_eclass* c)
c->c_widget.w_activatefn = NULL;
c->c_widget.w_deletefn = ebox_wdelete;
c->c_widget.w_clickfn = NULL;

c->c_widget.w_paint = NULL;
c->c_widget.w_mouseenter = NULL;
c->c_widget.w_mouseleave = NULL;
Expand Down Expand Up @@ -859,10 +865,11 @@ static void ewidget_init(t_eclass* c)
*/
static void eclass_properties_dialog(t_eclass* c)
{
#ifndef PURR_DATA
int i, j, lenght;
char buffer[1000];
char temp[1000];

// DIALOG WINDOW APPLY //
for(i = 0; i < c->c_nattr; i++)
{
Expand Down Expand Up @@ -915,7 +922,7 @@ static void eclass_properties_dialog(t_eclass* c)
sys_gui("}\n");
}
}

// DIALOG WINDOW CREATION //
sys_vgui("proc pdtk_%s_dialog {id \n", c->c_class.c_name->s_name);
for(i = 0; i < c->c_nattr; i++)
Expand All @@ -927,7 +934,7 @@ static void eclass_properties_dialog(t_eclass* c)
}
sys_gui("} {\n");
sys_gui("set vid [string trimleft $id .]\n");

for(i = 0; i < c->c_nattr; i++)
{
if(!c->c_attr[i]->invisible)
Expand All @@ -940,19 +947,19 @@ static void eclass_properties_dialog(t_eclass* c)
sys_vgui("toplevel $id\n");
sys_vgui("wm title $id {%s properties}\n", c->c_class.c_name->s_name);
sys_vgui("wm resizable $id 0 0\n", c->c_class.c_name->s_name);

for(i = 0; i < c->c_nattr; i++)
{
if(!c->c_attr[i]->invisible)
{
sys_vgui("frame $id.name%i \n", i+1);
sys_vgui("frame $id.sele%i \n", i+1);

// ATTRIBUTES NAMES //
sys_vgui("label $id.name%i.name -justify left -font {Helvetica 12} -text \"%s :\"\n", i+1, c->c_attr[i]->label->s_name);
sys_vgui("pack $id.name%i.name -side left\n", i+1);
// SELECTOR //

if(c->c_attr[i]->style == gensym("checkbutton"))
{
sys_vgui("checkbutton $id.sele%i.selec -variable $var_%s -command [concat pdtk_%s_dialog_apply_%s $id]\n", i+1, c->c_attr[i]->name->s_name, c->c_class.c_name->s_name, c->c_attr[i]->name->s_name);
Expand All @@ -972,7 +979,7 @@ static void eclass_properties_dialog(t_eclass* c)
sys_vgui("$id.sele%i.selec configure -from -9999999999999 -to 9999999999999\n", i+1, (float)c->c_attr[i]->maximum); // Should be enough
sys_vgui("$id.sele%i.selec delete 0 end \n", i+1);
sys_vgui("$id.sele%i.selec insert 0 $%s \n", i+1, c->c_attr[i]->name->s_name);

sys_vgui("bind $id.sele%i.selec <KeyPress-Return> [concat pdtk_%s_dialog_apply_%s $id]\n", i+1, c->c_class.c_name->s_name, c->c_attr[i]->name->s_name);
sys_vgui("pack $id.sele%i.selec -side left\n", i+1);
}
Expand All @@ -986,7 +993,7 @@ static void eclass_properties_dialog(t_eclass* c)
sys_vgui("%s ", c->c_attr[i]->itemslist[c->c_attr[i]->itemssize - 1 - j]->s_name);
}
sys_vgui("}\n");

sys_vgui("bind $id.sele%i.selec <KeyPress-Return> [concat pdtk_%s_dialog_apply_%s $id]\n", i+1, c->c_class.c_name->s_name, c->c_attr[i]->name->s_name);
sys_vgui("pack $id.sele%i.selec -side left\n", i+1);
sys_vgui("$id.sele%i.selec set $%s \n", i+1, c->c_attr[i]->name->s_name);
Expand All @@ -996,15 +1003,15 @@ static void eclass_properties_dialog(t_eclass* c)
sys_vgui("entry $id.sele%i.selec -font {Helvetica 12} -width 20 -textvariable [string trim $var_%s]\n", i+1, c->c_attr[i]->name->s_name);
sys_vgui("bind $id.sele%i.selec <KeyPress-Return> [concat pdtk_%s_dialog_apply_%s $id]\n", i+1, c->c_class.c_name->s_name, c->c_attr[i]->name->s_name);
sys_vgui("pack $id.sele%i.selec -side left\n", i+1);

}

sys_vgui("grid config $id.name%i -column 0 -row %i -sticky w\n", i+1, i+1);
sys_vgui("grid config $id.sele%i -column 1 -row %i -sticky w\n", i+1, i+1);
}
}
sys_gui("}\n");
#endif
}


Expand Down
Loading