Index: trunk/src/plugins/sch_dialogs/dlg_library.c =================================================================== --- trunk/src/plugins/sch_dialogs/dlg_library.c (revision 3312) +++ trunk/src/plugins/sch_dialogs/dlg_library.c (revision 3313) @@ -56,6 +56,13 @@ #include "adialogs_conf.h" +#define MAX_PARAMS 128 + +typedef struct library_dlg_ctx_s library_ctx_t; +typedef csch_lib_t library_ent_t; + +#include "../../../src_3rd/rnd_inclib/dialogs/dlg_library_param.h" + typedef struct library_dlg_ctx_s { RND_DAD_DECL_NOINIT(dlg) csch_sheet_t *sheet; @@ -65,9 +72,10 @@ rnd_hidval_t timer; unsigned timer_active:1; unsigned active:1; - unsigned pactive:1; /* parametric dialog active */ unsigned last_clicked:1; + library_param_ctx_t param; /* for the parametric */ + int modal; char *last_path; csch_sheet_t prsh; /* temp sheet for preview */ @@ -153,16 +161,7 @@ htip_pop(&sheetlib2dlg, sheetlib_id(sheet, master)); } -static void library_dlg_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) -{ - library_dlg_ctx_t *ctx = caller_data; - csch_sheet_uninit(&ctx->prsh); - sheetlib_del(ctx->sheet, ctx->master); - if (!ctx->modal) - free(ctx); -} - static csch_cgrp_t *first_grp(const csch_cgrp_t *src) { htip_entry_t *e; @@ -411,11 +410,36 @@ param_selected = (l != NULL) && (l->type == CSCH_SLIB_PARAMETRIC); } - param_entered = !ctx->pactive && (otext != NULL) && (strchr(otext, '(') != NULL); + param_entered = !ctx->param.pactive && (otext != NULL) && (strchr(otext, '(') != NULL); rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, ctx->wedit, param_selected || param_entered); } +static void library_set_filter(library_ctx_t *ctx, const char *text) +{ + rnd_hid_attr_val_t hv; + + hv.str = text; + rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wfilt, &hv); +} + +static const char *library_get_ent_name(library_ent_t *e) { return e->name; } +static const char *library_ent_path(library_ent_t *e) { return e->realpath; } + +#include "../../../src_3rd/rnd_inclib/dialogs/dlg_library_param.c" + +static void library_dlg_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) +{ + library_dlg_ctx_t *ctx = caller_data; + + library_param_dialog_close(&ctx->param); + + csch_sheet_uninit(&ctx->prsh); + sheetlib_del(ctx->sheet, ctx->master); + if (!ctx->modal) + free(ctx); +} + static void library_select(rnd_hid_attribute_t *attrib, void *hid_ctx, rnd_hid_row_t *row) { rnd_hid_attr_val_t hv; @@ -436,12 +460,12 @@ if ((l->type == CSCH_SLIB_PARAMETRIC)) { if (last != l) { /* first click */ TODO("param"); -/* library_select_show_param_example(ctx, l);*/ + library_select_show_param_example(ctx, l); update_edit_button(ctx); } else { /* second click */ - TODO("param"); -/* library_param_dialog(ctx, l);*/ + ctx->param.lib_ctx = ctx; + library_param_dialog(&ctx->param, l, ctx->dlg[ctx->wfilt].val.str); close_param = 0; } } @@ -456,7 +480,8 @@ if (close_param) { TODO("param"); -/* library_param_dialog(ctx, NULL);*/ + ctx->param.lib_ctx = ctx; + library_param_dialog(&ctx->param, NULL, NULL); } hv.str = NULL; @@ -490,9 +515,86 @@ rnd_message(RND_MSG_ERROR, "Failed to refresh %s\n", path); } +static rnd_hid_row_t *find_sym_prefix_(rnd_hid_tree_t *tree, gdl_list_t *rowlist, const char *name, int namelen) +{ + rnd_hid_row_t *r, *pr; + + for(r = gdl_first(rowlist); r != NULL; r = gdl_next(rowlist, r)) { + csch_lib_t *l = r->user_data; + if ((rnd_strncasecmp(r->cell[0], name, namelen) == 0) && (l->type == CSCH_SLIB_PARAMETRIC)) + return r; + pr = find_sym_prefix_(tree, &r->children, name, namelen); + if (pr != NULL) + return pr; + } + return NULL; +} + +static rnd_hid_row_t *find_sym_prefix(library_ctx_t *ctx, const char *name, int namelen) +{ + rnd_hid_attribute_t *attr; + rnd_hid_tree_t *tree; + + attr = &ctx->dlg[ctx->wtree]; + tree = attr->wdata; + + return find_sym_prefix_(tree, &tree->rows, name, namelen); +} + static void library_edit_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr_inp) { - rnd_message(RND_MSG_ERROR, "Sorry, not yet implemented.\n"); + library_ctx_t *ctx = caller_data; + rnd_hid_attribute_t *attr; + rnd_hid_row_t *r, *rnew; + const char *otext = ctx->dlg[ctx->wfilt].val.str; + char *name = NULL, *sep; + int namelen; + + attr = &ctx->dlg[ctx->wtree]; + r = rnd_dad_tree_get_selected(attr); + + if (!ctx->last_clicked && (otext != NULL)) { + get_from_filt:; + name = rnd_strdup(otext); + sep = strchr(name, '('); + if (sep != NULL) + *sep = '\0'; + } + else if (r != NULL) { + csch_lib_t *l = r->user_data; + name = rnd_strdup(l->name); + if (name != NULL) { + rnd_hid_attr_val_t hv; + hv.str = name; + rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, ctx->wfilt, &hv); + } + } + else if (otext != NULL) + goto get_from_filt; + + if ((name == NULL) || (*name == '\0')) { + rnd_message(RND_MSG_ERROR, "Failed to figure the name of the parametric symbol\n"); + return; + } + namelen = strlen(name); + + if ((r == NULL) || (rnd_strncasecmp(name, r->cell[0], namelen) != 0)) { + /* no selection or wrong selection: go find the right one */ + rnew = find_sym_prefix(ctx, name, namelen); + } + else + rnew = r; + + if (rnew != NULL) { + if (r != rnew) + rnd_dad_tree_jumpto(attr, rnew); + ctx->param.lib_ctx = ctx; + library_param_dialog(&ctx->param, rnew->user_data, ctx->dlg[ctx->wfilt].val.str); + } + else + rnd_message(RND_MSG_ERROR, "No such parametric symbol: '%s'\n", name); + + free(name); } @@ -585,7 +687,7 @@ skip_filter:; - /* parametric footprints need to be refreshed on edit */ + /* parametric symbols need to be refreshed on edit */ if (is_para_closed) timed_update_preview(ctx, 1); @@ -630,11 +732,11 @@ RND_DAD_BEGIN_HBOX(ctx->dlg); RND_DAD_STRING(ctx->dlg); RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_INIT_FOCUS); - RND_DAD_HELP(ctx->dlg, "filter: display only footprints matching this text\n(if empty: display all)"); + RND_DAD_HELP(ctx->dlg, "filter: display only symbols matching this text\n(if empty: display all)"); RND_DAD_CHANGE_CB(ctx->dlg, library_filter_cb); ctx->wfilt = RND_DAD_CURRENT(ctx->dlg); RND_DAD_PICBUTTON(ctx->dlg, xpm_edit_param); - RND_DAD_HELP(ctx->dlg, "open GUI to edit the parameters\nof a parametric footprint"); + RND_DAD_HELP(ctx->dlg, "open GUI to edit the parameters\nof a parametric symbol"); RND_DAD_CHANGE_CB(ctx->dlg, library_edit_cb); ctx->wedit = RND_DAD_CURRENT(ctx->dlg); RND_DAD_PICBUTTON(ctx->dlg, xpm_refresh); Index: trunk/src/sch-rnd/Makefile.dep =================================================================== --- trunk/src/sch-rnd/Makefile.dep (revision 3312) +++ trunk/src/sch-rnd/Makefile.dep (revision 3313) @@ -149,14 +149,15 @@ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ ../libcschem/TODO.h ../libcschem/abstract.h ../plugins/io_tinycad/read.h ../plugins/io_tinycad/read.o: ../plugins/io_tinycad/read.c \ - ../plugins/io_tinycad/read.h ../libcschem/plug_io.h \ - ../libcschem/concrete.h ../libcschem/common_types.h \ - ../libcschem/config.h ../libcschem/rtree.h ../libcschem/attrib.h \ + ../libcschem/config.h ../libcschem/message.h \ + ../plugins/lib_alien/read_helper.h ../libcschem/concrete.h \ + ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \ ../libcschem/oidpath.h ../libcschem/vtoid.h \ ../../src_3rd/libuundo/uundo.h \ ../../src_3rd/gengeo2d/typecfg_long_double.h ../../src_3rd/opc89.h \ ../../src_3rd/gengeo2d/common.h ../../src_3rd/gengeo2d/prim.h \ - ../libcschem/TODO.h ../libcschem/abstract.h + ../libcschem/TODO.h ../plugins/io_tinycad/read.h ../libcschem/plug_io.h \ + ../libcschem/abstract.h ../plugins/lib_alien/lib_alien.o: ../plugins/lib_alien/lib_alien.c \ ../libcschem/config.h ../plugins/lib_alien/read_helper.o: ../plugins/lib_alien/read_helper.c \ @@ -340,7 +341,9 @@ ../libcschem/util_wirenet.h ../libcschem/cnc_line.h \ ../sch-rnd/conf_core.h ../sch-rnd/draw.h ../sch-rnd/search.h \ ../sch-rnd/buffer.h ../sch-rnd/funchash_core.h \ - ../sch-rnd/funchash_core_list.h ../plugins/sch_dialogs/adialogs_conf.h + ../sch-rnd/funchash_core_list.h ../plugins/sch_dialogs/adialogs_conf.h \ + ../plugins/sch_dialogs/../../../src_3rd/rnd_inclib/dialogs/dlg_library_param.h \ + ../plugins/sch_dialogs/../../../src_3rd/rnd_inclib/dialogs/dlg_library_param.c ../plugins/sch_dialogs/dlg_pen.o: ../plugins/sch_dialogs/dlg_pen.c \ ../libcschem/config.h ../libcschem/search.h ../libcschem/concrete.h \ ../libcschem/common_types.h ../libcschem/rtree.h ../libcschem/attrib.h \ Index: trunk/src_3rd =================================================================== --- trunk/src_3rd (revision 3312) +++ trunk/src_3rd (revision 3313) Property changes on: trunk/src_3rd ___________________________________________________________________ Modified: svn:externals ## -1,4 +1,6 ## libminuid svn://svn.repo.hu/libminuid/trunk/libminuid -gengeo2d svn://repo.hu/gengeo2d/trunk/gengeo2d -libuundo svn://repo.hu/libuundo/trunk/libuundo -ttf2bbox svn://repo.hu/ttf2bbox/trunk/src +gengeo2d svn://svn.repo.hu/gengeo2d/trunk/gengeo2d +libuundo svn://svn.repo.hu/libuundo/trunk/libuundo +ttf2bbox svn://svn.repo.hu/ttf2bbox/trunk/src +rnd_inclib svn://svn.repo.hu/pcb-rnd/trunk/src_3rd/rnd_inclib +