From 9ade045527abde8a74fa2b4b8286e2e4b3de9fbf Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Wed, 20 Dec 2023 19:29:22 +0100 Subject: [PATCH] Fixed text drawing for non-gui objects --- pdlua.c | 27 +++++++++++++++++++++++++++ pdlua_gfx.h | 3 --- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pdlua.c b/pdlua.c index e65b624..16620a2 100644 --- a/pdlua.c +++ b/pdlua.c @@ -50,6 +50,7 @@ #include "m_pd.h" #include "s_stuff.h" // for sys_register_loader() #include "m_imp.h" // for struct _class +#include "g_canvas.h" /* BAD: support for Pd < 0.41 */ #include "pdlua_gfx.h" @@ -663,6 +664,30 @@ static void pdlua_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp } void pdlua_vis(t_gobj *z, t_glist *glist, int vis){ + if(!((t_pdlua *)z)->has_gui) + { + t_text *x = (t_text *)z; + if (vis) + { + if (gobj_shouldvis(&x->te_g, glist)) + { + t_rtext *y = glist_findrtext(glist, x); + text_drawborder(x, glist, rtext_gettag(y), + rtext_width(y), rtext_height(y), 1); + rtext_draw(y); + } + } + else + { + t_rtext *y = glist_findrtext(glist, x); + if (gobj_shouldvis(&x->te_g, glist)) + { + text_eraseborder(x, glist, rtext_gettag(y)); + rtext_erase(y); + } + } + return; + } if(vis) { pdlua_gfx_repaint((t_object*)z); @@ -876,6 +901,8 @@ static int pdlua_object_creategui(lua_State *L) { gfx_initialize(o); } + + return 0; } /** Lua object inlet creation. */ diff --git a/pdlua_gfx.h b/pdlua_gfx.h index 13f4707..2c7c909 100644 --- a/pdlua_gfx.h +++ b/pdlua_gfx.h @@ -1,5 +1,3 @@ -#include - typedef struct _pdlua_gfx { #if !PLUGDATA @@ -647,7 +645,6 @@ static int line_to(lua_State* L) { int x = luaL_checknumber(L, 1); int y = luaL_checknumber(L, 2); - gfx->path_segments[gfx->num_path_segments][0] = x; gfx->path_segments[gfx->num_path_segments][1] = y; gfx->num_path_segments++;