Index: Plug.tmpasm =================================================================== --- Plug.tmpasm (revision 38350) +++ Plug.tmpasm (revision 38351) @@ -1,5 +1,8 @@ put /local/rnd/mod {fontmode} -put /local/rnd/mod/OBJS [@ $(PLUGDIR)/fontmode/fontmode.o @] +put /local/rnd/mod/OBJS [@ + $(PLUGDIR)/fontmode/fontmode.o + $(PLUGDIR)/fontmode/preview.o +@] switch /local/module/fontmode/controls case {buildin} include /local/pcb/tmpasm/buildin; end; Index: fontmode.c =================================================================== --- fontmode.c (revision 38350) +++ fontmode.c (revision 38351) @@ -58,6 +58,7 @@ #include "event.h" #include "polygon.h" #include "obj_poly_draw.h" +#include "preview.h" /* FIXME - we currently hardcode the grid and PCB size. What we should do in the future is scan the font for its extents, and size @@ -715,7 +716,8 @@ {"FontXform", pcb_act_FontXform, pcb_acth_FontXform, pcb_acts_FontXform}, {"FontSetXdelta", pcb_act_FontSetXdelta, pcb_acth_FontSetXdelta, pcb_acts_FontSetXdelta}, {"FontNormalize", pcb_act_FontNormalize, pcb_acth_FontNormalize, pcb_acts_FontNormalize}, - {"FontBaseline", pcb_act_FontBaseline, pcb_acth_FontBaseline, pcb_acts_FontBaseline} + {"FontBaseline", pcb_act_FontBaseline, pcb_acth_FontBaseline, pcb_acts_FontBaseline}, + {"FontModePreview", pcb_act_FontModePreview, pcb_acth_FontModePreview, pcb_acts_FontModePreview} }; static const char *fontmode_cookie = "fontmode plugin"; Index: preview.c =================================================================== --- preview.c (nonexistent) +++ preview.c (revision 38351) @@ -0,0 +1,69 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design - font editor preview dlg + * Copyright (C) 2023 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include +#include + +typedef struct{ + RND_DAD_DECL_NOINIT(dlg) + int active; /* already open - allow only one instance */ +} fmprv_ctx_t; + +fmprv_ctx_t fmprv_ctx; + +static void fmprv_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) +{ + fmprv_ctx_t *ctx = caller_data; + RND_DAD_FREE(ctx->dlg); + memset(ctx, 0, sizeof(fmprv_ctx_t)); /* reset all states to the initial - includes ctx->active = 0; */ +} + +static void pcb_dlg_fontmode_preview(void) +{ + rnd_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; + + if (fmprv_ctx.active) + return; /* do not open another */ + + RND_DAD_BEGIN_VBOX(fmprv_ctx.dlg); + RND_DAD_COMPFLAG(fmprv_ctx.dlg, RND_HATF_EXPFILL); + RND_DAD_LABEL(fmprv_ctx.dlg, "fmprv"); + RND_DAD_BUTTON_CLOSES(fmprv_ctx.dlg, clbtn); + RND_DAD_END(fmprv_ctx.dlg); + + /* set up the context */ + fmprv_ctx.active = 1; + + RND_DAD_NEW("font_mode_preview", fmprv_ctx.dlg, "Font editor: preview", &fmprv_ctx, rnd_false, fmprv_close_cb); +} + +const char pcb_acts_FontModePreview[] = "FontModePreview()\n"; +const char pcb_acth_FontModePreview[] = "Open the font mode preview dialog that also helps editing font tables"; +fgw_error_t pcb_act_FontModePreview(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + pcb_dlg_fontmode_preview(); + return 0; +} Index: preview.h =================================================================== --- preview.h (nonexistent) +++ preview.h (revision 38351) @@ -0,0 +1,3 @@ +extern const char pcb_acts_FontModePreview[]; +extern const char pcb_acth_FontModePreview[]; +fgw_error_t pcb_act_FontModePreview(fgw_arg_t *res, int argc, fgw_arg_t *argv);