Skip to content

Commit 882f452

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

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
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

+5-3
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+
auto 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)

0 commit comments

Comments
 (0)