Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toolkit-agnostic Core->GUI Communication - WIP #1763

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
54e63f0
NIT: tcl/tk, pd_readsocket: refactoring command execution to ::pd_con…
giuliomoro Sep 12, 2022
6bce2aa
NIT: glist_drawiofor: refactored coord calculation to avoid duplications
giuliomoro Sep 12, 2022
e8f8d02
NIT: glist_eraseiofor: refactored to avoid duplication
giuliomoro Sep 14, 2022
82ead4f
NIT: refactored coords in gatom_displace
giuliomoro Sep 15, 2022
58a151d
NIT: refactoring of col for bng_draw_update
giuliomoro Sep 17, 2022
afca458
NIT: refactored coordinates in iemgui_label_pos
giuliomoro Sep 19, 2022
d8655b2
Added glist_deletefromtag() and canvas_deletefromtag() and use them t…
giuliomoro Sep 14, 2022
f227d05
tcl: evaluate one command at a time. This is mainly for testing purpo…
giuliomoro Sep 13, 2022
a2f07d9
tcl: print docmds as they get executed. This is for testing purposes …
giuliomoro Sep 13, 2022
585ad0e
pdtk_canvas::creates can handle some messages directly and pass them …
giuliomoro Sep 12, 2022
81371be
pdtk_canvas: handle inlet and outlet
giuliomoro Sep 12, 2022
d7b3b5d
pdtk_canvas::create handles atom. pdtk_canvas::select handles obj and…
giuliomoro Sep 14, 2022
28896fc
pdtk_canvas handles bang's create and select
giuliomoro Sep 14, 2022
bf4e798
using ::pdtk_canvas::delete to delete gui objects
giuliomoro Sep 15, 2022
9a781b3
tcl: added get_{rect,atom}_coords and refactored around that
giuliomoro Sep 15, 2022
a6b74d1
tcl: added check_argc_{exact,least} and parse_cnv_coords and refactor…
giuliomoro Sep 15, 2022
d76cc2f
tcl: added parse_obj_atom_args and get_poly_coords and refactored acc…
giuliomoro Sep 16, 2022
924a5c3
pdtk_canvas::move: handles both literal "move" tk commands and some o…
giuliomoro Sep 16, 2022
69b206f
pdtk_canvas::select use 'tag' instead of 'obj' for generic
giuliomoro Sep 16, 2022
0e61c88
pdtk_canvas::create: work around simplification of calling bang creat…
giuliomoro Sep 16, 2022
e17f130
pdtk_canvas::update: this is meant to handle iemgui's xxx_draw_update…
giuliomoro Sep 17, 2022
ee3b97e
refactoring: renamed macro via sed -i "" "s/USE_PDTK_CANVAS_CREATE/US…
giuliomoro Sep 17, 2022
b0c6271
refactoring: actually using the first argument of pdgui_vmess instead…
giuliomoro Sep 17, 2022
ca40faa
tcl: split new and config for bang
giuliomoro Sep 17, 2022
e548c45
tcl: introduced bang_get_tags and refactored accordingly
giuliomoro Sep 17, 2022
996c4d8
tcl: added array_to_vars and refactored accordingly
giuliomoro Sep 17, 2022
47167fe
tcl: passing a list of tags to pdtk_canvas::create
giuliomoro Sep 17, 2022
09050b5
tcl: pdtk_canvas::create now handles iemgui_draw_iolets calls as well
giuliomoro Sep 17, 2022
98fcff3
tcl: added handlers for iemgui_label_font and iemgui_label_pos
giuliomoro Sep 19, 2022
b649cde
tcl: simplified pdtk_canvas::delete with fixed number of args
giuliomoro Sep 19, 2022
fae84e8
tcl: handling listbox as well as the existing floatatom and symbolato…
giuliomoro Sep 20, 2022
46b6493
tcl: now handling commentbar
giuliomoro Sep 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 42 additions & 5 deletions src/g_all_guis.c
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#endif

#define USE_PDTK_CANVAS_PROC

typedef struct _iemgui_private {
int p_prevX, p_prevY;
Expand Down Expand Up @@ -484,10 +485,17 @@ void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av
{
char tag[128];
sprintf(tag, "%lxLABEL", x);
int x0 = text_xpix((t_object *)x, iemgui->x_glist) + iemgui->x_ldx*zoom;
int y0 = text_ypix((t_object *)x, iemgui->x_glist) + iemgui->x_ldy*zoom;
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::iemgui_label_pos", "rcr ii",
"tag", glist_getcanvas(iemgui->x_glist), tag,
x0, y0);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crs ii",
glist_getcanvas(iemgui->x_glist), "coords", tag,
text_xpix((t_object *)x, iemgui->x_glist) + iemgui->x_ldx*zoom,
text_ypix((t_object *)x, iemgui->x_glist) + iemgui->x_ldy*zoom);
x0, y0);
#endif // USE_PDTK_CANVAS_PROC
}
}

Expand Down Expand Up @@ -516,9 +524,15 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a
SETSYMBOL(fontatoms+0, gensym(iemgui->x_font));
SETFLOAT (fontatoms+1, -iemgui->x_fontsize*zoom);
SETSYMBOL(fontatoms+2, gensym(sys_fontweight));
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::iemgui_label_font", "rcs A",
"tag", glist_getcanvas(iemgui->x_glist), tag,
3, fontatoms);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crs rA",
glist_getcanvas(iemgui->x_glist), "itemconfigure", tag,
"-font", 3, fontatoms);
#endif // USE_PDTK_CANVAS_PROC
}
}

Expand Down Expand Up @@ -887,28 +901,44 @@ static void iemgui_draw_iolets(t_iemgui*x, t_glist*glist, int old_snd_rcv_flags)

/* re-create outlet */
sprintf(tag, "%lxOUT%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
canvas_deletefromtag(canvas, tag);
if(!x->x_fsf.x_snd_able) {
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::create", "r c iiii Ss",
"iemgui_outlet",
canvas,
xpos, ypos + x->x_h + zoom - ioh, xpos + iow, ypos + x->x_h,
2, tags, tag_label);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crr iiii rs rS",
canvas, "create", "rectangle",
xpos, ypos + x->x_h + zoom - ioh, xpos + iow, ypos + x->x_h,
"-fill", "black",
"-tags", 2, tags);
/* keep label above outlet */
pdgui_vmess(0, "crss", canvas, "lower", tag, tag_label);
#endif // USE_PDTK_CANVAS_PROC
}

/* re-create inlet */
sprintf(tag, "%lxIN%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
canvas_deletefromtag(canvas, tag);
if(!x->x_fsf.x_rcv_able) {
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::create", "r c iiii Ss",
"iemgui_inlet",
canvas,
xpos, ypos, xpos + iow, ypos - zoom + ioh,
2, tags, tag_label);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crr iiii rs rS",
canvas, "create", "rectangle",
xpos, ypos, xpos + iow, ypos - zoom + ioh,
"-fill", "black",
"-tags", 2, tags);
/* keep label above inlet */
pdgui_vmess(0, "crss", canvas, "lower", tag, tag_label);
#endif // USE_PDTK_CANVAS_PROC
}
}

Expand All @@ -918,7 +948,7 @@ static void iemgui_draw_erase(t_iemgui* x, t_glist* glist)
char tag_object[128];
sprintf(tag_object, "%lxOBJ", x);

pdgui_vmess(0, "crs", canvas, "delete", tag_object);
canvas_deletefromtag(canvas, tag_object);
}

static void iemgui_draw_move(t_iemgui *x, t_glist *glist)
Expand All @@ -930,7 +960,14 @@ static void iemgui_draw_move(t_iemgui *x, t_glist *glist)
char tag_object[128];
sprintf(tag_object, "%lxOBJ", x);

#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::move", "r c rii",
"tag",
canvas,
tag_object, dx, dy);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crs ii", canvas, "move", tag_object, dx, dy);
#endif // USE_PDTK_CANVAS_PROC
}

static void iemgui_draw(t_iemgui *x, t_glist *glist, int mode)
Expand Down
36 changes: 35 additions & 1 deletion src/g_bang.c
Expand Up @@ -11,6 +11,7 @@

#include "g_all_guis.h"

#define USE_PDTK_CANVAS_PROC
/* --------------- bng gui-bang ------------------------- */

t_widgetbehavior bng_widgetbehavior;
Expand All @@ -33,6 +34,18 @@ static void bng_draw_config(t_bng* x, t_glist* glist)
SETFLOAT (fontatoms+1, -iemgui->x_fontsize*zoom);
SETSYMBOL(fontatoms+2, gensym(sys_fontweight));

#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::config", "r c iiii o ikk ii A k",
"bang",
canvas,
xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
x, // used to generate various tags
zoom, x->x_gui.x_bcol, x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol,
xpos + x->x_gui.x_ldx * zoom, ypos + x->x_gui.x_ldy * zoom, // label coord
3, fontatoms,
x->x_gui.x_fsf.x_selected ? IEM_GUI_COLOR_SELECTED : x->x_gui.x_lcol);

#else // USE_PDTK_CANVAS_PROC
sprintf(tag, "%lxBASE", x);
pdgui_vmess(0, "crs iiii", canvas, "coords", tag,
xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
Expand All @@ -52,12 +65,17 @@ static void bng_draw_config(t_bng* x, t_glist* glist)
pdgui_vmess(0, "crs rA rk", canvas, "itemconfigure", tag,
"-font", 3, fontatoms,
"-fill", (x->x_gui.x_fsf.x_selected ? IEM_GUI_COLOR_SELECTED : x->x_gui.x_lcol));
#endif // USE_PDTK_CANVAS_PROC
iemgui_dolabel(x, &x->x_gui, x->x_gui.x_lab, 1);
}

static void bng_draw_new(t_bng *x, t_glist *glist)
{
t_canvas *canvas = glist_getcanvas(glist);
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::create", "rco",
"bang", canvas, x);
#else // USE_PDTK_CANVAS_PROC
char tag[128], tag_object[128];
char*tags[] = {tag_object, tag, "label", "text"};
sprintf(tag_object, "%lxOBJ", x);
Expand All @@ -73,6 +91,7 @@ static void bng_draw_new(t_bng *x, t_glist *glist)
sprintf(tag, "%lxLABEL", x);
pdgui_vmess(0, "crr ii rs rS", canvas, "create", "text",
0, 0, "-anchor", "w", "-tags", 4, tags);
#endif // USE_PDTK_CANVAS_PROC

bng_draw_config(x, glist);
(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO);
Expand All @@ -87,22 +106,37 @@ static void bng_draw_select(t_bng* x, t_glist* glist)
if(x->x_gui.x_fsf.x_selected)
col = lcol = IEM_GUI_COLOR_SELECTED;

#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::select", "r co kk",
"bang",
canvas, x,
col, lcol);
#else // USE_PDTK_CANVAS_PROC
sprintf(tag, "%lxBASE", x);
pdgui_vmess(0, "crs rk", canvas, "itemconfigure", tag, "-outline", col);
sprintf(tag, "%lxBUT", x);
pdgui_vmess(0, "crs rk", canvas, "itemconfigure", tag, "-outline", col);
sprintf(tag, "%lxLABEL", x);
pdgui_vmess(0, "crs rk", canvas, "itemconfigure", tag, "-fill", lcol);
#endif // USE_PDTK_CANVAS_PROC
}

static void bng_draw_update(t_bng *x, t_glist *glist)
{
if(glist_isvisible(glist))
{
int col = (x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol);
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::update", "r co k",
"bang",
glist_getcanvas(glist), x,
col);
#else // USE_PDTK_CANVAS_PROC
char tag[128];
sprintf(tag, "%lxBUT", x);
pdgui_vmess(0, "crs rk", glist_getcanvas(glist), "itemconfigure", tag,
"-fill", (x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol));
"-fill", col);
#endif // USE_PDTK_CANVAS_PROC
}
}

Expand Down
23 changes: 20 additions & 3 deletions src/g_canvas.c
Expand Up @@ -15,6 +15,8 @@ to be different but are now unified except for some fossilized names.) */
#include <string.h>
#include "g_undo.h"

#define USE_PDTK_CANVAS_PROC

#ifdef _WIN32
#include <io.h>
#endif
Expand Down Expand Up @@ -779,7 +781,7 @@ void canvas_drawredrect(t_canvas *x, int doit)
"-tags", "GOP"); /* better: "-tags", 1, &"GOP" */
}
else
pdgui_vmess(0, "crs", glist_getcanvas(x), "delete", "GOP");
glist_deletefromtag(x, "GOP");
}

/* the window becomes "mapped" (visible and not miniaturized) or
Expand Down Expand Up @@ -820,7 +822,7 @@ void canvas_map(t_canvas *x, t_floatarg f)
return;
}
/* just clear out the whole canvas */
pdgui_vmess(0, "crs", x, "delete", "all");
canvas_deletefromtag(x, "all");
x->gl_mapped = 0;
}
}
Expand Down Expand Up @@ -978,7 +980,22 @@ static void _canvas_delete_line(t_canvas*x, t_outconnect *oc)
if (!glist_isvisible(x))
return;
sprintf(tag, "l%lx", oc);
pdgui_vmess(0, "crs", glist_getcanvas(x), "delete", tag);
glist_deletefromtag(x, tag);
}

void canvas_deletefromtag(t_canvas* x, const char* tag)
{
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::delete", "cs",
x, tag);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crs", x, "delete", tag);
#endif // USE_PDTK_CANVAS_PROC
}

void glist_deletefromtag(t_canvas* x, const char* tag)
{
canvas_deletefromtag(glist_getcanvas(x), tag);
}

/* kill all lines for the object */
Expand Down
2 changes: 2 additions & 0 deletions src/g_canvas.h
Expand Up @@ -410,6 +410,7 @@ EXTERN void glist_deselect(t_glist *x, t_gobj *y);
EXTERN void glist_noselect(t_glist *x);
EXTERN void glist_selectall(t_glist *x);
EXTERN void glist_delete(t_glist *x, t_gobj *y);
EXTERN void glist_deletefromtag(t_glist *x, const char* tag);
EXTERN void glist_retext(t_glist *x, t_text *y);
EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
t_glistkeyfn keyfn, int xpos, int ypos);
Expand Down Expand Up @@ -489,6 +490,7 @@ EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
EXTERN void canvas_deletefromtag(t_canvas *x, const char *tag);
EXTERN void canvas_stowconnections(t_canvas *x);
EXTERN void canvas_restoreconnections(t_canvas *x);
EXTERN void canvas_redraw(t_canvas *x);
Expand Down
9 changes: 4 additions & 5 deletions src/g_editor.c
Expand Up @@ -466,7 +466,7 @@ void canvas_disconnect(t_canvas *x,
{
char tag[128];
sprintf(tag, "l%lx", oc);
pdgui_vmess(0, "crs", x, "delete", tag);
canvas_deletefromtag(x, tag);
obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
break;
}
Expand Down Expand Up @@ -2631,7 +2631,7 @@ static void canvas_doconnect(t_canvas *x, int xpos, int ypos, int mod, int doit)
#endif
if (doit) {
pdgui_vmess("::pdtk_canvas::cords_to_foreground", "ci", x, 1);
pdgui_vmess(0, "crs", x, "delete", "x");
canvas_deletefromtag(x, "x");
}
else
pdgui_vmess(0, "crs iiii",
Expand Down Expand Up @@ -2854,7 +2854,7 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
loy = x->gl_editor->e_ywas, hiy = ypos;
else hiy = x->gl_editor->e_ywas, loy = ypos;
canvas_selectinrect(x, lox, loy, hix, hiy);
pdgui_vmess(0, "crs", x, "delete", "x");
canvas_deletefromtag(x, "x");
x->gl_editor->e_onmotion = MA_NONE;
}
else
Expand Down Expand Up @@ -4800,8 +4800,7 @@ void canvas_editmode(t_canvas *x, t_floatarg state)
if (glist_isvisible(x) && glist_istoplevel(x))
{
canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
pdgui_vmess(0, "crs",
glist_getcanvas(x), "delete", "commentbar");
glist_deletefromtag(x, "commentbar");
}
}
if (glist_isvisible(x) && x->gl_havewindow)
Expand Down
5 changes: 2 additions & 3 deletions src/g_graph.c
Expand Up @@ -757,8 +757,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
"-joinstyle", "miter",
"-tags", 2, tags2);
else
pdgui_vmess(0, "crs",
glist_getcanvas(x->gl_owner), "delete", tag);
glist_deletefromtag(x->gl_owner, tag);
return;
}
/* otherwise draw (or erase) us as a graph inside another glist. */
Expand Down Expand Up @@ -894,7 +893,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis)
}
else
{
pdgui_vmess(0, "crs", glist_getcanvas(x->gl_owner), "delete", tag);
glist_deletefromtag(x->gl_owner, tag);
for (g = x->gl_list; g; g = g->g_next)
gobj_vis(g, x, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/g_radio.c
Expand Up @@ -40,7 +40,7 @@ static void radio_draw_io(t_radio* x, t_glist* glist, int old_snd_rcv_flags)
sprintf(tag_but, "%lxBUT", x);

sprintf(tag, "%lxOUT%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
canvas_deletefromtag(canvas, tag);
if(!x->x_gui.x_fsf.x_snd_able)
{
int height = x->x_gui.x_h * ((x->x_orientation == horizontal)? 1: x->x_number);
Expand All @@ -55,7 +55,7 @@ static void radio_draw_io(t_radio* x, t_glist* glist, int old_snd_rcv_flags)
}

sprintf(tag, "%lxIN%d", x, 0);
pdgui_vmess(0, "crs", canvas, "delete", tag);
canvas_deletefromtag(canvas, tag);
if(!x->x_gui.x_fsf.x_rcv_able)
{
pdgui_vmess(0, "crr iiii rs rS", canvas, "create", "rectangle",
Expand Down
11 changes: 10 additions & 1 deletion src/g_rtext.c
Expand Up @@ -9,6 +9,8 @@
#include "g_canvas.h"
#include "s_utf8.h"

#define USE_PDTK_CANVAS_PROC

#define LMARGIN 2
#define RMARGIN 2
#define TMARGIN 3
Expand Down Expand Up @@ -518,13 +520,20 @@ void rtext_draw(t_rtext *x)

void rtext_erase(t_rtext *x)
{
pdgui_vmess(0, "crs", glist_getcanvas(x->x_glist), "delete", x->x_tag);
glist_deletefromtag(x->x_glist, x->x_tag);
}

void rtext_displace(t_rtext *x, int dx, int dy)
{
#ifdef USE_PDTK_CANVAS_PROC
pdgui_vmess("::pdtk_canvas::move", "r c rii",
"tag",
glist_getcanvas(x->x_glist),
x->x_tag, dx, dy);
#else // USE_PDTK_CANVAS_PROC
pdgui_vmess(0, "crs ii", glist_getcanvas(x->x_glist), "move", x->x_tag,
dx, dy);
#endif // USE_PDTK_CANVAS_PROC
}

void rtext_select(t_rtext *x, int state)
Expand Down
4 changes: 2 additions & 2 deletions src/g_scalar.c
Expand Up @@ -397,7 +397,7 @@ static void scalar_drawselectrect(t_scalar *x, t_glist *glist, int state)
"-fill", "blue",
"-tags", tag);
} else {
pdgui_vmess(0, "crs", glist_getcanvas(glist), "delete", tag);
glist_deletefromtag(glist, tag);
}
}

Expand Down Expand Up @@ -489,7 +489,7 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
"-tags", tag);
}
else
pdgui_vmess(0, "crs", glist_getcanvas(owner), "delete", tag);
glist_deletefromtag(owner, tag);
return;
}

Expand Down