Skip to content

Commit 5c65e09

Browse files
committed
Simplifications for plugdata drawing mechanism, fixed iolet position offset when zoomed in pd-vanilla
1 parent f1dcfde commit 5c65e09

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pdlua.c

-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,6 @@ static int pdlua_object_new(lua_State *L)
11111111
#else
11121112
// NULL until plugdata overrides them with something useful
11131113
o->gfx.plugdata_draw_callback = NULL;
1114-
o->gfx.plugdata_callback_target = NULL;
11151114
#endif
11161115

11171116
lua_pushlightuserdata(L, o);

pdlua.h

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ typedef struct _pdlua_gfx
4545
char current_color[8]; // Keep track of current color
4646
#else
4747
void(*plugdata_draw_callback)(void*, t_symbol*, int, t_atom*); // Callback to perform drawing in plugdata
48-
void* plugdata_callback_target; // Pointer to plugdata object, the target for our draw callback
4948
#endif
5049

5150
// Size variables

pdlua_gfx.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ static int get_size(lua_State* L)
244244
// Wrapper around draw callback to plugdata
245245
static inline void plugdata_draw(t_pdlua* obj, t_symbol* sym, int argc, t_atom* argv)
246246
{
247-
if(obj->gfx.plugdata_callback_target) {
248-
obj->gfx.plugdata_draw_callback(obj->gfx.plugdata_callback_target, sym, argc, argv);
247+
if(obj->gfx.plugdata_draw_callback) {
248+
obj->gfx.plugdata_draw_callback(obj, sym, argc, argv);
249249
}
250250
}
251251

@@ -637,9 +637,11 @@ static void gfx_displace(t_pdlua *x, t_glist *glist, int dx, int dy)
637637
sys_vgui(".x%lx.c move .x%lx %d %d\n", glist_getcanvas(x->canvas), (long)x, dx, dy);
638638
canvas_fixlinesfor(glist, (t_text*)x);
639639

640+
int scale = glist_getzoom(glist_getcanvas(x->canvas));
641+
640642
int xpos = text_xpix((t_object*)x, x->canvas);
641643
int ypos = text_ypix((t_object*)x, x->canvas);
642-
glist_drawiofor(glist_getcanvas(x->canvas), (t_object*)x, 0, x->gfx.object_tag, xpos, ypos, xpos + x->gfx.width, ypos + x->gfx.height);
644+
glist_drawiofor(x->canvas, (t_object*)x, 0, x->gfx.object_tag, xpos, ypos, xpos + (x->gfx.width * scale), ypos + (x->gfx.height * scale));
643645
}
644646

645647
static const char* register_drawing(t_pdlua *object)
@@ -710,10 +712,12 @@ static int end_paint(lua_State* L) {
710712
t_canvas *cnv = glist_getcanvas(obj->canvas);
711713
t_pdlua_gfx *gfx = &obj->gfx;
712714

715+
int scale = glist_getzoom(glist_getcanvas(obj->canvas));
716+
713717
// Draw iolets on top
714718
int xpos = text_xpix((t_object*)obj, obj->canvas);
715719
int ypos = text_ypix((t_object*)obj, obj->canvas);
716-
glist_drawiofor(glist_getcanvas(obj->canvas), (t_object*)obj, 1, gfx->object_tag, xpos, ypos, xpos + gfx->width, ypos + gfx->height);
720+
glist_drawiofor(glist_getcanvas(obj->canvas), (t_object*)obj, 1, gfx->object_tag, xpos, ypos, xpos + (x->gfx.width * scale), ypos + (x->gfx.height * scale));
717721

718722
if(!gfx->first_draw && gfx->order_tag[0] != '\0') {
719723
// Move everything to below the order marker, to make sure redrawn stuff isn't always on top

0 commit comments

Comments
 (0)