Index: trunk/src/stub_draw.c =================================================================== --- trunk/src/stub_draw.c (revision 34346) +++ trunk/src/stub_draw.c (revision 34347) @@ -85,7 +85,7 @@ /****** font selector GUI ******/ -static void dummy_draw_fontsel(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt) +static void dummy_draw_fontsel(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt, pcb_font_id_t *dst_fid) { static rnd_xform_t xform = {0}; static pcb_draw_info_t info = {0}; @@ -95,11 +95,11 @@ dummy_draw_text(&info, gc, "Can't render the font selector: the draw_fontsel plugin is not compiled and/or not loaded"); } -static rnd_bool dummy_mouse_fontsel(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt) +static rnd_bool dummy_mouse_fontsel(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt, pcb_font_id_t *dst_fid) { return 0; } -void (*pcb_stub_draw_fontsel)(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt) = dummy_draw_fontsel; -rnd_bool (*pcb_stub_draw_fontsel_mouse_ev)(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt) = dummy_mouse_fontsel; +void (*pcb_stub_draw_fontsel)(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt, pcb_font_id_t *dst_fid) = dummy_draw_fontsel; +rnd_bool (*pcb_stub_draw_fontsel_mouse_ev)(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt, pcb_font_id_t *dst_fid) = dummy_mouse_fontsel; Index: trunk/src/stub_draw.h =================================================================== --- trunk/src/stub_draw.h (revision 34346) +++ trunk/src/stub_draw.h (revision 34347) @@ -45,7 +45,7 @@ extern rnd_bool (*pcb_stub_draw_csect_mouse_ev)(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y); /* fontsel */ -extern void (*pcb_stub_draw_fontsel)(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt); -extern rnd_bool (*pcb_stub_draw_fontsel_mouse_ev)(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt); +extern void (*pcb_stub_draw_fontsel)(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt, pcb_font_id_t *dst_fid); +extern rnd_bool (*pcb_stub_draw_fontsel_mouse_ev)(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt, pcb_font_id_t *dst_fid); #endif Index: trunk/src_plugins/dialogs/dlg_fontsel.c =================================================================== --- trunk/src_plugins/dialogs/dlg_fontsel.c (revision 34346) +++ trunk/src_plugins/dialogs/dlg_fontsel.c (revision 34347) @@ -45,6 +45,7 @@ unsigned alloced:1; pcb_idpath_t *txt_id; + pcb_font_id_t *dst_fid; void *last_fobj; pcb_font_id_t last_fid; gdl_elem_t link; @@ -78,12 +79,17 @@ if (ctx->txt_id != NULL) { pcb_text_t *txt = (pcb_text_t *)pcb_idpath2obj_in(ctx->pcb->Data, ctx->txt_id); if (txt != NULL) - pcb_stub_draw_fontsel(gc, e, txt); + pcb_stub_draw_fontsel(gc, e, txt, NULL); ctx->last_fobj = txt; ctx->last_fid = txt->fid; } + else if (ctx->dst_fid != NULL) { + pcb_stub_draw_fontsel(gc, e, NULL, ctx->dst_fid); + ctx->last_fobj = NULL; + ctx->last_fid = *ctx->dst_fid; + } else { - pcb_stub_draw_fontsel(gc, e, NULL); + pcb_stub_draw_fontsel(gc, e, NULL, NULL); ctx->last_fobj = NULL; } } @@ -96,9 +102,13 @@ pcb_text_t *txt = (pcb_text_t *)pcb_idpath2obj_in(ctx->pcb->Data, ctx->txt_id); if (txt == NULL) return 0; - return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, txt); + return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, txt, NULL); } - return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, NULL); + + if (ctx->dst_fid != NULL) + return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, NULL, ctx->dst_fid); + + return pcb_stub_draw_fontsel_mouse_ev(kind, x, y, NULL, NULL); } void fontsel_free_cb(rnd_hid_attribute_t *attrib, void *user_ctx, void *hid_ctx) @@ -143,10 +153,11 @@ } -static void pcb_dlg_fontsel(pcb_board_t *pcb, int modal, int global, pcb_text_t *txt_obj) +static void pcb_dlg_fontsel(pcb_board_t *pcb, int modal, int global, pcb_text_t *txt_obj, pcb_font_id_t *dst_fid) { rnd_box_t vbox = {0, 0, RND_MM_TO_COORD(55), RND_MM_TO_COORD(55)}; rnd_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; + rnd_hid_dad_buttons_t clbtn_select[] = {{"Use selected", 1}, {"Cancel", 0}, {NULL, 0}}; fontsel_ctx_t *c, *ctx = NULL; if (global) { @@ -169,6 +180,7 @@ } ctx->pcb = pcb; + ctx->dst_fid = dst_fid; if (txt_obj != NULL) ctx->txt_id = pcb_obj2idpath((pcb_any_obj_t *)txt_obj); else @@ -189,12 +201,22 @@ RND_DAD_CHANGE_CB(ctx->dlg, btn_remove_cb); RND_DAD_HELP(ctx->dlg, "Remove currently selected font"); RND_DAD_END(ctx->dlg); - RND_DAD_BUTTON_CLOSES(ctx->dlg, clbtn); + if (modal && (dst_fid != NULL)) + RND_DAD_BUTTON_CLOSES(ctx->dlg, clbtn_select); + else + RND_DAD_BUTTON_CLOSES(ctx->dlg, clbtn); RND_DAD_END(ctx->dlg); ctx->active = 1; RND_DAD_DEFSIZE(ctx->dlg, 250, 200); RND_DAD_NEW("fontsel", ctx->dlg, "Font selection", ctx, modal, fontsel_close_cb); + + if (modal && (dst_fid != NULL)) { + if (RND_DAD_RUN(ctx->dlg) == 1) + printf("SAVE fid: %ld\n", *dst_fid); + else + *dst_fid = -1; + } } const char pcb_acts_Fontsel[] = "Fontsel()\n"; @@ -204,6 +226,7 @@ const char *op = NULL; int modal = 0, global = 1; pcb_text_t *txt_obj = NULL; + pcb_font_id_t fid, *dst_fid = NULL; if (argc > 2) RND_ACT_FAIL(Fontsel); @@ -222,10 +245,19 @@ global = 0; } } + if (rnd_strcasecmp(op, "fontid") == 0) { + modal = 1; + global = 0; + fid = -1; + dst_fid = &fid; + } else RND_ACT_FAIL(Fontsel); } - pcb_dlg_fontsel(PCB, modal, global, txt_obj); + pcb_dlg_fontsel(PCB, modal, global, txt_obj, dst_fid); + if (modal && (dst_fid != NULL)) { + printf("fid: %ld\n", *dst_fid); + } return 0; } Index: trunk/src_plugins/draw_fontsel/draw_fontsel.c =================================================================== --- trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 34346) +++ trunk/src_plugins/draw_fontsel/draw_fontsel.c (revision 34347) @@ -110,14 +110,21 @@ font_coord_t font_coord[MAX_FONT]; int font_coords; -static void pcb_draw_font(rnd_hid_gc_t gc, pcb_font_t *f, int x, int *y, pcb_text_t *txt) +static void pcb_draw_font(rnd_hid_gc_t gc, pcb_font_t *f, int x, int *y, pcb_text_t *txt, pcb_font_id_t *dst_fid) { char buf[256]; pcb_text_t *t; const char *nm; int y_old = *y; - pcb_font_id_t target_fid = (txt == NULL) ? conf_core.design.text_font_id : txt->fid; + pcb_font_id_t target_fid; + if (dst_fid != NULL) + target_fid = *dst_fid; + else if (txt != NULL) + target_fid = txt->fid; + else + target_fid = conf_core.design.text_font_id; + nm = (f->name == NULL) ? "" : f->name; rnd_snprintf(buf, sizeof(buf), "#%d [abc ABC 123] %s", f->id, nm); @@ -138,17 +145,17 @@ } -static void pcb_draw_fontsel(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt) +static void pcb_draw_fontsel(rnd_hid_gc_t gc, const rnd_hid_expose_ctx_t *e, pcb_text_t *txt, pcb_font_id_t *dst_fid) { int y = 0; font_coords = 0; - pcb_draw_font(gc, &PCB->fontkit.dflt, 0, &y, txt); + pcb_draw_font(gc, &PCB->fontkit.dflt, 0, &y, txt, dst_fid); if (PCB->fontkit.hash_inited) { htip_entry_t *e; for (e = htip_first(&PCB->fontkit.fonts); e; e = htip_next(&PCB->fontkit.fonts, e)) - pcb_draw_font(gc, e->value, 0, &y, txt); + pcb_draw_font(gc, e->value, 0, &y, txt, dst_fid); } } @@ -162,7 +169,7 @@ return -1; } -static rnd_bool pcb_mouse_fontsel(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt) +static rnd_bool pcb_mouse_fontsel(rnd_hid_mouse_ev_t kind, rnd_coord_t x, rnd_coord_t y, pcb_text_t *txt, pcb_font_id_t *dst_fid) { pcb_font_id_t fid; int ymm; @@ -173,9 +180,13 @@ fid = lookup_fid_for_coord(ymm); if (fid >= 0) { if (txt == NULL) { - char sval[128]; - sprintf(sval, "%ld", fid); - rnd_conf_set(RND_CFR_DESIGN, "design/text_font_id", 0, sval, RND_POL_OVERWRITE); + if (dst_fid == NULL) { + char sval[128]; + sprintf(sval, "%ld", fid); + rnd_conf_set(RND_CFR_DESIGN, "design/text_font_id", 0, sval, RND_POL_OVERWRITE); + } + else + *dst_fid = fid; } else { switch(txt->type) { Index: trunk/src_plugins/lib_hid_pcbui/routest_dlg.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/routest_dlg.c (revision 34346) +++ trunk/src_plugins/lib_hid_pcbui/routest_dlg.c (revision 34347) @@ -174,13 +174,14 @@ pcb_route_style_change(PCB, rstdlg_ctx.curr, &attr->val.crd, NULL, NULL, NULL, NULL, NULL, 1); else if (idx == rstdlg_ctx.wtxtth) pcb_route_style_change(PCB, rstdlg_ctx.curr, NULL, &attr->val.crd, NULL, NULL, NULL, NULL, 1); - else if (idx == rstdlg_ctx.wfont) { - printf("TODO: font change!\n"); - } else if (idx == rstdlg_ctx.wtxtscale) { int tmp = attr->val.lng; pcb_route_style_change(PCB, rstdlg_ctx.curr, NULL, NULL, &tmp, NULL, NULL, NULL, 1); } + else if (idx == rstdlg_ctx.wfont) { + pcb_font_id_t tmp = attr->val.lng; + pcb_route_style_change(PCB, rstdlg_ctx.curr, NULL, NULL, NULL, &tmp, NULL, NULL, 1); + } else if (idx == rstdlg_ctx.wclr) pcb_route_style_change(PCB, rstdlg_ctx.curr, NULL, NULL, NULL, NULL, &attr->val.crd, NULL, 1); else if (idx == rstdlg_ctx.wviahole) {