Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 24905) +++ trunk/scconfig/Rev.h (revision 24906) @@ -1 +1 @@ -static const int myrev = 24872; +static const int myrev = 24906; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 24905) +++ trunk/scconfig/Rev.tab (revision 24906) @@ -1,3 +1,4 @@ +24906 configure hidlib: split lib_hid_common into a PCB-related and a PCB-unrelated plugin 24872 configure split excellon exporter from gerber to a separate plugin 24862 configure code simplification: merge hid_flags.[ch] into lib_hid_common 24824 configure move window placement from dialogs to lib_hid_commonfor hidlib cleanup Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 24905) +++ trunk/scconfig/plugins.h (revision 24906) @@ -11,6 +11,7 @@ plugin_def("lib_gtk_hid", "hid_gtk generic part", sdisable, 0) plugin_def("lib_hid_common", "all-gui-hid common code", sdisable, 0) plugin_def("lib_hid_gl", "openGL rendering", sdisable, 0) +plugin_def("lib_hid_pcbui", "all-gui-hid common PCB GUI elements",sdisable, 0) plugin_def("lib_legacy_func", "legacy functions", sbuildin, 1) plugin_def("lib_netmap", "map nets and objects", sdisable, 0) plugin_def("lib_polyhelp", "polygon helpers", sbuildin, 1) @@ -132,6 +133,7 @@ plugin_dep("dialogs", "draw_csect", 0) plugin_dep("dialogs", "draw_fontsel", 0) plugin_dep("dialogs", "lib_hid_common", 0) +plugin_dep("dialogs", "lib_hid_pcbui", 0) plugin_dep("draw_fab", "report", 0) plugin_dep("export_fidocadj", "lib_compat_help", 0) plugin_dep("export_gerber", "export_excellon", 0) @@ -153,6 +155,7 @@ plugin_dep("hid_gtk3_cairo", "lib_gtk_common", 0) plugin_dep("hid_gtk3_cairo", "lib_gtk_hid", 0) plugin_dep("hid_lesstif", "lib_hid_common", 0) +plugin_dep("hid_lesstif", "lib_hid_pcbui", 0) plugin_dep("import_dsn", "lib_compat_help", 0) plugin_dep("import_ipcd356", "lib_compat_help", 0) plugin_dep("import_mentor_sch", "lib_gensexpr", 0) @@ -169,6 +172,8 @@ plugin_dep("io_tedax", "lib_compat_help", 0) plugin_dep("io_tedax", "lib_netmap", 0) plugin_dep("lib_gtk_common", "lib_hid_common", 0) +plugin_dep("lib_gtk_common", "lib_hid_pcbui", 0) plugin_dep("lib_gtk_hid", "lib_hid_common", 0) +plugin_dep("lib_gtk_hid", "lib_hid_pcbui", 0) plugin_dep("lib_vfs", "propedit", 0) plugin_dep("millpath", "lib_polyhelp", 0) Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 24905) +++ trunk/src/Makefile.dep (revision 24906) @@ -2272,7 +2272,7 @@ compat_misc.h layer_vis.h tool.h \ ../src_plugins/hid_lesstif/dlg_fileselect.h global_typedefs.h \ ../src_plugins/lib_hid_common/clip.h \ - ../src_plugins/lib_hid_common/util.h \ + ../src_plugins/lib_hid_pcbui/util.h \ ../src_plugins/lib_hid_common/cli_history.h \ ../src_plugins/hid_lesstif/wt_preview.c \ ../src_plugins/hid_lesstif/wt_preview.h dolists.h @@ -4338,7 +4338,7 @@ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h layer_vis.h \ ../src_plugins/lib_gtk_common/bu_status_line.h \ - ../src_plugins/lib_hid_common/util.h + ../src_plugins/lib_hid_pcbui/util.h ../src_plugins/lib_gtk_common/util_ext_chg.o: \ ../src_plugins/lib_gtk_common/util_ext_chg.c ../config.h \ ../src_plugins/lib_gtk_common/util_ext_chg.h pcb_bool.h board.h \ @@ -4806,7 +4806,7 @@ math_helper.h misc_util.h layer_grp.h rats_patch.h hidlib.h event.h \ hid_cfg.h hid.h error.h hid.h ../src_plugins/lib_hid_common/grid_menu.h ../src_plugins/lib_hid_common/layer_menu.o: \ - ../src_plugins/lib_hid_common/layer_menu.c ../config.h board.h \ + ../src_plugins/lib_hid_pcbui/layer_menu.c ../config.h board.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h global_typedefs.h \ pcb_bool.h unit.h vtroutestyle.h attrib.h \ ../src_3rd/genvector/genvector_impl.h \ @@ -4829,7 +4829,7 @@ vtpadstack_t.h conf_core.h conf.h pcb-printf.h \ ../src_3rd/liblihata/lihata.h list_conf.h event.h layer.h layer_ui.h \ layer_grp.h pcb-printf.h hid_cfg.h hid.h \ - ../src_plugins/lib_hid_common/layer_menu.h + ../src_plugins/lib_hid_pcbui/layer_menu.h ../src_plugins/lib_hid_common/lead_user.o: \ ../src_plugins/lib_hid_common/lead_user.c ../config.h draw.h hid.h \ ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ @@ -4858,11 +4858,11 @@ ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ ../src_3rd/genlist/gendlist.h error.h event.h \ ../src_plugins/lib_hid_common/grid_menu.h conf.h \ - ../src_plugins/lib_hid_common/layer_menu.h \ - ../src_plugins/lib_hid_common/routest_menu.h \ + ../src_plugins/lib_hid_pcbui/layer_menu.h \ + ../src_plugins/lib_hid_pcbui/routest_menu.h \ ../src_plugins/lib_hid_common/cli_history.h \ - ../src_plugins/lib_hid_common/util.c \ - ../src_plugins/lib_hid_common/util.h data.h globalconst.h layer.h \ + ../src_plugins/lib_hid_pcbui/util.c \ + ../src_plugins/lib_hid_pcbui/util.h data.h globalconst.h layer.h \ attrib.h color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h \ obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h obj_text.h font.h \ @@ -4937,7 +4937,7 @@ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ ../src_3rd/genvector/vtp0.h list_conf.h conf.h conf_core.h route_style.h \ event.h hid_cfg.h hid.h error.h hid.h \ - ../src_plugins/lib_hid_common/routest_menu.h + ../src_plugins/lib_hid_pcbui/routest_menu.h ../src_plugins/lib_hid_gl/hidgl.o: ../src_plugins/lib_hid_gl/hidgl.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ pcb-printf.h ../src_3rd/genvector/gds_char.h \ Index: trunk/src_plugins/dialogs/dialogs.pup =================================================================== --- trunk/src_plugins/dialogs/dialogs.pup (revision 24905) +++ trunk/src_plugins/dialogs/dialogs.pup (revision 24906) @@ -6,5 +6,6 @@ dep draw_fontsel dep draw_csect dep lib_hid_common +dep lib_hid_pcbui default disable autoload 1 Index: trunk/src_plugins/hid_lesstif/hid_lesstif.pup =================================================================== --- trunk/src_plugins/hid_lesstif/hid_lesstif.pup (revision 24905) +++ trunk/src_plugins/hid_lesstif/hid_lesstif.pup (revision 24906) @@ -5,4 +5,5 @@ $package hid-lesstif default buildin dep lib_hid_common +dep lib_hid_pcbui autoload 1 Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 24905) +++ trunk/src_plugins/hid_lesstif/main.c (revision 24906) @@ -47,7 +47,7 @@ #include "dlg_fileselect.h" #include "../src_plugins/lib_hid_common/clip.h" -#include "../src_plugins/lib_hid_common/util.h" +#include "../src_plugins/lib_hid_pcbui/util.h" #include "../src_plugins/lib_hid_common/cli_history.h" #include Index: trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup =================================================================== --- trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup (revision 24905) +++ trunk/src_plugins/lib_gtk_common/lib_gtk_common.pup (revision 24906) @@ -4,5 +4,6 @@ $state works $package lib-gtk dep lib_hid_common +dep lib_hid_pcbui default disable-all Index: trunk/src_plugins/lib_gtk_common/ui_zoompan.c =================================================================== --- trunk/src_plugins/lib_gtk_common/ui_zoompan.c (revision 24905) +++ trunk/src_plugins/lib_gtk_common/ui_zoompan.c (revision 24906) @@ -40,7 +40,7 @@ #include "layer_vis.h" #include "bu_status_line.h" -#include "../src_plugins/lib_hid_common/util.h" +#include "../src_plugins/lib_hid_pcbui/util.h" double pcb_gtk_clamp_zoom(const pcb_gtk_view_t *vw, double coord_per_px) { Index: trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup =================================================================== --- trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup (revision 24905) +++ trunk/src_plugins/lib_gtk_hid/lib_gtk_hid.pup (revision 24906) @@ -5,3 +5,4 @@ $package lib-gtk default disable-all dep lib_hid_common +dep lib_hid_pcbui Index: trunk/src_plugins/lib_hid_common/routest_menu.c =================================================================== --- trunk/src_plugins/lib_hid_common/routest_menu.c (revision 24905) +++ trunk/src_plugins/lib_hid_common/routest_menu.c (nonexistent) @@ -1,87 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018 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 "config.h" - -#include "board.h" -#include "conf.h" -#include "conf_core.h" -#include "route_style.h" -#include "event.h" -#include "hid_cfg.h" -#include "hid.h" - -#include "routest_menu.h" - -#define ANCH "@routestyles" - -static void rst_install_menu(void *ctx, pcb_hid_cfg_t *cfg, lht_node_t *node, char *path) -{ - pcb_menu_prop_t props; - char *end = path + strlen(path); - char act[256], chk[256]; - int idx; - - memset(&props, 0,sizeof(props)); - props.action = act; - props.checked = chk; - props.update_on = ""; - props.cookie = ANCH; - - pcb_hid_cfg_del_anchor_menus(node, ANCH); - - /* prepare for appending the strings at the end of the path, "under" the anchor */ - *end = '/'; - end++; - - /* have to go reverse to keep order because this will insert items */ - for(idx = vtroutestyle_len(&PCB->RouteStyle)-1; idx >= 0; idx--) { - sprintf(act, "RouteStyle(%d)", idx+1); /* for historical reasons this action counts from 1 */ - sprintf(chk, "ChkRst(%d)", idx); - strcpy(end, PCB->RouteStyle.array[idx].name); - pcb_gui->create_menu(path, &props); - } -} - -static int rst_lock = 0; -static void rst_update(void) -{ - if (rst_lock) return; - rst_lock++; - pcb_hid_cfg_map_anchor_menus(ANCH, rst_install_menu, NULL); - rst_lock--; -} - -void pcb_rst_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) -{ - rst_update(); -} - -void pcb_rst_update_conf(conf_native_t *cfg, int arr_idx) -{ - if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) - pcb_gui->update_menu_checkbox(NULL); -} Index: trunk/src_plugins/lib_hid_common/routest_menu.h =================================================================== --- trunk/src_plugins/lib_hid_common/routest_menu.h (revision 24905) +++ trunk/src_plugins/lib_hid_common/routest_menu.h (nonexistent) @@ -1,6 +0,0 @@ -#include "conf.h" -#include "event.h" - -void pcb_rst_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); -void pcb_rst_update_conf(conf_native_t *cfg, int arr_idx); - Index: trunk/src_plugins/lib_hid_common/layer_menu.h =================================================================== --- trunk/src_plugins/lib_hid_common/layer_menu.h (revision 24905) +++ trunk/src_plugins/lib_hid_common/layer_menu.h (nonexistent) @@ -1,5 +0,0 @@ -#include "event.h" - -void pcb_layer_menu_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); -void pcb_layer_menu_vis_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); - Index: trunk/src_plugins/lib_hid_common/layer_menu.c =================================================================== --- trunk/src_plugins/lib_hid_common/layer_menu.c (revision 24905) +++ trunk/src_plugins/lib_hid_common/layer_menu.c (nonexistent) @@ -1,194 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2017, 2018 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 "config.h" - -#include "board.h" -#include "data.h" -#include "conf_core.h" -#include "event.h" -#include "layer.h" -#include "layer_ui.h" -#include "layer_grp.h" -#include "pcb-printf.h" -#include "hid_cfg.h" -#include "hid.h" - -#include "layer_menu.h" - -typedef struct { - const char *anch; - int view; -} ly_ctx_t; - -static void layer_install_menu1(void *ctx_, pcb_hid_cfg_t *cfg, lht_node_t *node, char *path) -{ - ly_ctx_t *ctx = ctx_; - int plen = strlen(path); - int len_avail = 125; - char *end = path + plen; - pcb_menu_prop_t props; - char act[256], chk[256]; - int idx, max_ml, sect; - pcb_layergrp_id_t gid; - const pcb_menu_layers_t *ml; - - memset(&props, 0, sizeof(props)); - props.action = act; - props.update_on = ""; - props.cookie = ctx->anch; - - pcb_hid_cfg_del_anchor_menus(node, ctx->anch); - - /* prepare for appending the strings at the end of the path, "under" the anchor */ - *end = '/'; - end++; - - /* ui layers; have to go reverse to keep order because this will insert items */ - if ((ctx->view) && (vtp0_len(&pcb_uilayers) > 0)) { - for(idx = vtp0_len(&pcb_uilayers)-1; idx >= 0; idx--) { - pcb_layer_t *ly = pcb_uilayers.array[idx]; - if ((ly == NULL) || (ly->name == NULL)) - continue; - - props.checked = chk; - sprintf(act, "ToggleView(ui:%d)", idx); - sprintf(chk, "ChkView(ui:%d)", idx); - - pcb_snprintf(end, len_avail, " %s", ly->name); - pcb_gui->create_menu(path, &props); - } - - props.checked = NULL; - pcb_snprintf(end, len_avail, "[UI]"); - pcb_gui->create_menu(path, &props); - } - - /* menu-only virtual layers; have to go reverse to keep order because this will insert items */ - for(ml = pcb_menu_layers, max_ml = 0; ml->name != NULL; ml++) max_ml++; - for(idx = max_ml-1; idx >= 0; idx--) { - ml = &pcb_menu_layers[idx]; - props.checked = chk; - if (ctx->view) { - sprintf(act, "ToggleView(%s)", ml->abbrev); - sprintf(chk, "ChkView(%s)", ml->abbrev); - } - else { - if (ml->sel_offs == 0) /* do not list layers that can not be selected */ - continue; - sprintf(act, "SelectLayer(%s)", ml->abbrev); - sprintf(chk, "ChkLayer(%s)", ml->abbrev); - } - pcb_snprintf(end, len_avail, " %s", ml->name); - pcb_gui->create_menu(path, &props); - } - - props.checked = NULL; - pcb_snprintf(end, len_avail, "[virtual]"); - pcb_gui->create_menu(path, &props); - - - /* have to go reverse to keep order because this will insert items */ - for(sect = 0; sect < 2; sect++) { - - pcb_snprintf(end, len_avail, "-"); - props.foreground = NULL; - props.background = NULL; - props.checked = NULL; - *act = '\0'; - *chk = '\0'; - pcb_gui->create_menu(path, &props); - - for(gid = pcb_max_group(PCB)-1; gid >= 0; gid--) { - pcb_layergrp_t *g = &PCB->LayerGroups.grp[gid]; - int n; - - if (g->ltype & PCB_LYT_SUBSTRATE) - continue; - - if (!!sect != !!(PCB_LAYER_IN_STACK(g->ltype))) - continue; - - for(n = g->len-1; n >= 0; n--) { - pcb_layer_id_t lid = g->lid[n]; - pcb_layer_t *l = pcb_get_layer(PCB->Data, lid); - pcb_layer_type_t lyt = pcb_layer_flags_(l); - - props.background = &l->meta.real.color; - props.foreground = &conf_core.appearance.color.background; - props.checked = chk; - if (ctx->view) { - sprintf(act, "ToggleView(%ld)", lid+1); - sprintf(chk, "ChkView(%ld)", lid+1); - } - else { - sprintf(act, "SelectLayer(%ld)", lid+1); - sprintf(chk, "ChkLayer(%ld)", lid+1); - } - pcb_snprintf(end, len_avail, " %s", l->name); - pcb_gui->create_menu(path, &props); - } - - props.foreground = NULL; - props.background = NULL; - props.checked = NULL; - pcb_snprintf(end, len_avail, "[%s]", g->name); - pcb_gui->create_menu(path, &props); - } - } - - /* restore the path */ - end--; - *end = '\0'; -} - - -static void layer_install_menu(void) -{ - ly_ctx_t ctx; - - ctx.view = 1; - ctx.anch = "@layerview"; - pcb_hid_cfg_map_anchor_menus(ctx.anch, layer_install_menu1, &ctx); - - ctx.view = 0; - ctx.anch = "@layerpick"; - pcb_hid_cfg_map_anchor_menus(ctx.anch, layer_install_menu1, &ctx); -} - -void pcb_layer_menu_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) -{ - layer_install_menu(); - if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) - pcb_gui->update_menu_checkbox(NULL); -} - -void pcb_layer_menu_vis_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) -{ - if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) - pcb_gui->update_menu_checkbox(NULL); -} - Index: trunk/src_plugins/lib_hid_common/util.c =================================================================== --- trunk/src_plugins/lib_hid_common/util.c (revision 24905) +++ trunk/src_plugins/lib_hid_common/util.c (nonexistent) @@ -1,59 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018 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 "config.h" - -#include "util.h" -#include "data_it.h" -#include "flag.h" - -static pcb_cardinal_t pcb_get_bbox_by_flag(pcb_box_t *dst, const pcb_data_t *data, pcb_flag_values_t flg) -{ - pcb_any_obj_t *o; - pcb_data_it_t it; - pcb_cardinal_t cnt = 0; - - dst->X1 = dst->Y1 = PCB_MAX_COORD; - dst->X2 = dst->Y2 = -PCB_MAX_COORD; - - for(o = pcb_data_first(&it, (pcb_data_t *)data, PCB_OBJ_CLASS_REAL); o != NULL; o = pcb_data_next(&it)) { - if (!PCB_FLAG_TEST(flg, o)) - continue; - cnt++; - pcb_box_bump_box(dst, &o->BoundingBox); - } - return cnt; -} - -pcb_cardinal_t pcb_get_selection_bbox(pcb_box_t *dst, const pcb_data_t *data) -{ - return pcb_get_bbox_by_flag(dst, data, PCB_FLAG_SELECTED); -} - -pcb_cardinal_t pcb_get_found_bbox(pcb_box_t *dst, const pcb_data_t *data) -{ - return pcb_get_bbox_by_flag(dst, data, PCB_FLAG_FOUND); -} Index: trunk/src_plugins/lib_hid_common/util.h =================================================================== --- trunk/src_plugins/lib_hid_common/util.h (revision 24905) +++ trunk/src_plugins/lib_hid_common/util.h (nonexistent) @@ -1,7 +0,0 @@ -#include "data.h" - -/* calculate the bounding box of all selections/founds in data, return the number - of selected objects. When returns 0, the dst box is infinitely large. */ -pcb_cardinal_t pcb_get_selection_bbox(pcb_box_t *dst, const pcb_data_t *data); -pcb_cardinal_t pcb_get_found_bbox(pcb_box_t *dst, const pcb_data_t *data); - Index: trunk/src_plugins/lib_hid_common/Plug.tmpasm =================================================================== --- trunk/src_plugins/lib_hid_common/Plug.tmpasm (revision 24905) +++ trunk/src_plugins/lib_hid_common/Plug.tmpasm (revision 24906) @@ -1,10 +1,8 @@ put /local/pcb/mod {lib_hid_common} put /local/pcb/mod/OBJS [@ $(PLUGDIR)/lib_hid_common/lib_hid_common.o - $(PLUGDIR)/lib_hid_common/layer_menu.o $(PLUGDIR)/lib_hid_common/lead_user.o $(PLUGDIR)/lib_hid_common/grid_menu.o - $(PLUGDIR)/lib_hid_common/routest_menu.o $(PLUGDIR)/lib_hid_common/cli_history.o $(PLUGDIR)/lib_hid_common/place.o $(PLUGDIR)/lib_hid_common/menu_helper.o Index: trunk/src_plugins/lib_hid_common/lib_hid_common.c =================================================================== --- trunk/src_plugins/lib_hid_common/lib_hid_common.c (revision 24905) +++ trunk/src_plugins/lib_hid_common/lib_hid_common.c (revision 24906) @@ -32,10 +32,7 @@ #include "event.h" #include "grid_menu.h" -#include "layer_menu.h" -#include "routest_menu.h" #include "cli_history.h" -#include "util.c" #include "lead_user.h" #include "place.h" @@ -45,8 +42,6 @@ const conf_dialogs_t dialogs_conf; static const char *grid_cookie = "lib_hid_common/grid"; -static const char *layer_cookie = "lib_hid_common/layer"; -static const char *rst_cookie = "lib_hid_common/route_style"; static const char *lead_cookie = "lib_hid_common/user_lead"; static const char *wplc_cookie = "lib_hid_common/window_placement"; @@ -59,12 +54,9 @@ pcb_clihist_save(); pcb_clihist_uninit(); pcb_event_unbind_allcookie(grid_cookie); - pcb_event_unbind_allcookie(layer_cookie); - pcb_event_unbind_allcookie(rst_cookie); pcb_event_unbind_allcookie(lead_cookie); pcb_event_unbind_allcookie(wplc_cookie); conf_hid_unreg(grid_cookie); - conf_hid_unreg(rst_cookie); pcb_dialog_place_uninit(); conf_unreg_fields("plugins/lib_hid_common/"); } @@ -71,11 +63,8 @@ int pplg_init_lib_hid_common(void) { -TODO("padstack: remove some paths when route style has proto") - const char **rp, *rpaths[] = {"design/line_thickness", "design/via_thickness", "design/via_drilling_hole", "design/clearance", NULL}; - static conf_hid_callbacks_t ccb, rcb[sizeof(rpaths)/sizeof(rpaths[0])]; + static conf_hid_callbacks_t ccb; conf_native_t *nat; - int n; PCB_API_CHK_VER; #define conf_reg(field,isarray,type_name,cpath,cname,desc,flags) \ @@ -86,12 +75,6 @@ pcb_dialog_place_init(); pcb_event_bind(PCB_EVENT_GUI_INIT, pcb_grid_update_ev, NULL, grid_cookie); - pcb_event_bind(PCB_EVENT_BOARD_CHANGED, pcb_layer_menu_update_ev, NULL, layer_cookie); - pcb_event_bind(PCB_EVENT_LAYERS_CHANGED, pcb_layer_menu_update_ev, NULL, layer_cookie); - pcb_event_bind(PCB_EVENT_LAYERVIS_CHANGED, pcb_layer_menu_vis_update_ev, NULL, layer_cookie); - pcb_event_bind(PCB_EVENT_ROUTE_STYLES_CHANGED, pcb_rst_update_ev, NULL, rst_cookie); - pcb_event_bind(PCB_EVENT_BOARD_CHANGED, pcb_rst_update_ev, NULL, rst_cookie); - pcb_event_bind(PCB_EVENT_GUI_INIT, pcb_rst_update_ev, NULL, rst_cookie); pcb_event_bind(PCB_EVENT_GUI_LEAD_USER, pcb_lead_user_ev, NULL, lead_cookie); pcb_event_bind(PCB_EVENT_GUI_DRAW_OVERLAY_XOR, pcb_lead_user_draw_ev, NULL, lead_cookie); pcb_event_bind(PCB_EVENT_DAD_NEW_DIALOG, pcb_dialog_place, NULL, wplc_cookie); @@ -105,14 +88,5 @@ if (nat != NULL) conf_hid_set_cb(nat, conf_id, &ccb); - conf_id = conf_hid_reg(rst_cookie, NULL); - for(rp = rpaths, n = 0; *rp != NULL; rp++, n++) { - memset(&rcb[n], 0, sizeof(rcb[0])); - rcb[n].val_change_post = pcb_rst_update_conf; - nat = conf_get_field(*rp); - if (nat != NULL) - conf_hid_set_cb(nat, conf_id, &rcb[n]); - } - return 0; } Index: trunk/src_plugins/lib_hid_common/lib_hid_common.pup =================================================================== --- trunk/src_plugins/lib_hid_common/lib_hid_common.pup (revision 24905) +++ trunk/src_plugins/lib_hid_common/lib_hid_common.pup (revision 24906) @@ -1,6 +1,6 @@ $class lib $short all-gui-hid common code -$long hid_* common helper functions for GUI HIDs +$long hidlib common helper functions for non-PCB GUI $state works $package lib-gui default disable-all Index: trunk/src_plugins/lib_hid_pcbui/Makefile =================================================================== --- trunk/src_plugins/lib_hid_pcbui/Makefile (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/Makefile (revision 24906) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_lib_hid_common + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/lib_hid_pcbui/Plug.tmpasm =================================================================== --- trunk/src_plugins/lib_hid_pcbui/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/Plug.tmpasm (revision 24906) @@ -0,0 +1,18 @@ +put /local/pcb/mod {lib_hid_pcbui} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/lib_hid_pcbui/lib_hid_pcbui.o + $(PLUGDIR)/lib_hid_pcbui/layer_menu.o + $(PLUGDIR)/lib_hid_pcbui/routest_menu.o +@] + +# dialog config is here because of hidlib: each hidlib user shall have its +# own dialogs plugin +put /local/pcb/mod/CONFFILE {dialogs.conf} +put /local/pcb/mod/CONF {$(PLUGDIR)/lib_hid_pcbui/dialogs_conf.h} + + +switch /local/pcb/lib_hid_pcbui/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/lib_hid_pcbui/layer_menu.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/layer_menu.c (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/layer_menu.c (revision 24906) @@ -0,0 +1,194 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017, 2018 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 "config.h" + +#include "board.h" +#include "data.h" +#include "conf_core.h" +#include "event.h" +#include "layer.h" +#include "layer_ui.h" +#include "layer_grp.h" +#include "pcb-printf.h" +#include "hid_cfg.h" +#include "hid.h" + +#include "layer_menu.h" + +typedef struct { + const char *anch; + int view; +} ly_ctx_t; + +static void layer_install_menu1(void *ctx_, pcb_hid_cfg_t *cfg, lht_node_t *node, char *path) +{ + ly_ctx_t *ctx = ctx_; + int plen = strlen(path); + int len_avail = 125; + char *end = path + plen; + pcb_menu_prop_t props; + char act[256], chk[256]; + int idx, max_ml, sect; + pcb_layergrp_id_t gid; + const pcb_menu_layers_t *ml; + + memset(&props, 0, sizeof(props)); + props.action = act; + props.update_on = ""; + props.cookie = ctx->anch; + + pcb_hid_cfg_del_anchor_menus(node, ctx->anch); + + /* prepare for appending the strings at the end of the path, "under" the anchor */ + *end = '/'; + end++; + + /* ui layers; have to go reverse to keep order because this will insert items */ + if ((ctx->view) && (vtp0_len(&pcb_uilayers) > 0)) { + for(idx = vtp0_len(&pcb_uilayers)-1; idx >= 0; idx--) { + pcb_layer_t *ly = pcb_uilayers.array[idx]; + if ((ly == NULL) || (ly->name == NULL)) + continue; + + props.checked = chk; + sprintf(act, "ToggleView(ui:%d)", idx); + sprintf(chk, "ChkView(ui:%d)", idx); + + pcb_snprintf(end, len_avail, " %s", ly->name); + pcb_gui->create_menu(path, &props); + } + + props.checked = NULL; + pcb_snprintf(end, len_avail, "[UI]"); + pcb_gui->create_menu(path, &props); + } + + /* menu-only virtual layers; have to go reverse to keep order because this will insert items */ + for(ml = pcb_menu_layers, max_ml = 0; ml->name != NULL; ml++) max_ml++; + for(idx = max_ml-1; idx >= 0; idx--) { + ml = &pcb_menu_layers[idx]; + props.checked = chk; + if (ctx->view) { + sprintf(act, "ToggleView(%s)", ml->abbrev); + sprintf(chk, "ChkView(%s)", ml->abbrev); + } + else { + if (ml->sel_offs == 0) /* do not list layers that can not be selected */ + continue; + sprintf(act, "SelectLayer(%s)", ml->abbrev); + sprintf(chk, "ChkLayer(%s)", ml->abbrev); + } + pcb_snprintf(end, len_avail, " %s", ml->name); + pcb_gui->create_menu(path, &props); + } + + props.checked = NULL; + pcb_snprintf(end, len_avail, "[virtual]"); + pcb_gui->create_menu(path, &props); + + + /* have to go reverse to keep order because this will insert items */ + for(sect = 0; sect < 2; sect++) { + + pcb_snprintf(end, len_avail, "-"); + props.foreground = NULL; + props.background = NULL; + props.checked = NULL; + *act = '\0'; + *chk = '\0'; + pcb_gui->create_menu(path, &props); + + for(gid = pcb_max_group(PCB)-1; gid >= 0; gid--) { + pcb_layergrp_t *g = &PCB->LayerGroups.grp[gid]; + int n; + + if (g->ltype & PCB_LYT_SUBSTRATE) + continue; + + if (!!sect != !!(PCB_LAYER_IN_STACK(g->ltype))) + continue; + + for(n = g->len-1; n >= 0; n--) { + pcb_layer_id_t lid = g->lid[n]; + pcb_layer_t *l = pcb_get_layer(PCB->Data, lid); + pcb_layer_type_t lyt = pcb_layer_flags_(l); + + props.background = &l->meta.real.color; + props.foreground = &conf_core.appearance.color.background; + props.checked = chk; + if (ctx->view) { + sprintf(act, "ToggleView(%ld)", lid+1); + sprintf(chk, "ChkView(%ld)", lid+1); + } + else { + sprintf(act, "SelectLayer(%ld)", lid+1); + sprintf(chk, "ChkLayer(%ld)", lid+1); + } + pcb_snprintf(end, len_avail, " %s", l->name); + pcb_gui->create_menu(path, &props); + } + + props.foreground = NULL; + props.background = NULL; + props.checked = NULL; + pcb_snprintf(end, len_avail, "[%s]", g->name); + pcb_gui->create_menu(path, &props); + } + } + + /* restore the path */ + end--; + *end = '\0'; +} + + +static void layer_install_menu(void) +{ + ly_ctx_t ctx; + + ctx.view = 1; + ctx.anch = "@layerview"; + pcb_hid_cfg_map_anchor_menus(ctx.anch, layer_install_menu1, &ctx); + + ctx.view = 0; + ctx.anch = "@layerpick"; + pcb_hid_cfg_map_anchor_menus(ctx.anch, layer_install_menu1, &ctx); +} + +void pcb_layer_menu_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + layer_install_menu(); + if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) + pcb_gui->update_menu_checkbox(NULL); +} + +void pcb_layer_menu_vis_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) + pcb_gui->update_menu_checkbox(NULL); +} + Index: trunk/src_plugins/lib_hid_pcbui/layer_menu.h =================================================================== --- trunk/src_plugins/lib_hid_pcbui/layer_menu.h (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/layer_menu.h (revision 24906) @@ -0,0 +1,5 @@ +#include "event.h" + +void pcb_layer_menu_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); +void pcb_layer_menu_vis_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); + Index: trunk/src_plugins/lib_hid_pcbui/lib_hid_pcbui.pup =================================================================== --- trunk/src_plugins/lib_hid_pcbui/lib_hid_pcbui.pup (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/lib_hid_pcbui.pup (revision 24906) @@ -0,0 +1,6 @@ +$class lib +$short all-gui-hid common PCB GUI elements +$long PCB related helper functions for GUI HIDs +$state works +$package lib-gui +default disable-all Index: trunk/src_plugins/lib_hid_pcbui/routest_menu.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/routest_menu.c (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/routest_menu.c (revision 24906) @@ -0,0 +1,87 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2018 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 "config.h" + +#include "board.h" +#include "conf.h" +#include "conf_core.h" +#include "route_style.h" +#include "event.h" +#include "hid_cfg.h" +#include "hid.h" + +#include "routest_menu.h" + +#define ANCH "@routestyles" + +static void rst_install_menu(void *ctx, pcb_hid_cfg_t *cfg, lht_node_t *node, char *path) +{ + pcb_menu_prop_t props; + char *end = path + strlen(path); + char act[256], chk[256]; + int idx; + + memset(&props, 0,sizeof(props)); + props.action = act; + props.checked = chk; + props.update_on = ""; + props.cookie = ANCH; + + pcb_hid_cfg_del_anchor_menus(node, ANCH); + + /* prepare for appending the strings at the end of the path, "under" the anchor */ + *end = '/'; + end++; + + /* have to go reverse to keep order because this will insert items */ + for(idx = vtroutestyle_len(&PCB->RouteStyle)-1; idx >= 0; idx--) { + sprintf(act, "RouteStyle(%d)", idx+1); /* for historical reasons this action counts from 1 */ + sprintf(chk, "ChkRst(%d)", idx); + strcpy(end, PCB->RouteStyle.array[idx].name); + pcb_gui->create_menu(path, &props); + } +} + +static int rst_lock = 0; +static void rst_update(void) +{ + if (rst_lock) return; + rst_lock++; + pcb_hid_cfg_map_anchor_menus(ANCH, rst_install_menu, NULL); + rst_lock--; +} + +void pcb_rst_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + rst_update(); +} + +void pcb_rst_update_conf(conf_native_t *cfg, int arr_idx) +{ + if ((pcb_gui != NULL) && (pcb_gui->update_menu_checkbox != NULL)) + pcb_gui->update_menu_checkbox(NULL); +} Index: trunk/src_plugins/lib_hid_pcbui/routest_menu.h =================================================================== --- trunk/src_plugins/lib_hid_pcbui/routest_menu.h (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/routest_menu.h (revision 24906) @@ -0,0 +1,6 @@ +#include "conf.h" +#include "event.h" + +void pcb_rst_update_ev(void *user_data, int argc, pcb_event_arg_t argv[]); +void pcb_rst_update_conf(conf_native_t *cfg, int arr_idx); + Index: trunk/src_plugins/lib_hid_pcbui/util.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/util.c (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/util.c (revision 24906) @@ -0,0 +1,59 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2018 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 "config.h" + +#include "util.h" +#include "data_it.h" +#include "flag.h" + +static pcb_cardinal_t pcb_get_bbox_by_flag(pcb_box_t *dst, const pcb_data_t *data, pcb_flag_values_t flg) +{ + pcb_any_obj_t *o; + pcb_data_it_t it; + pcb_cardinal_t cnt = 0; + + dst->X1 = dst->Y1 = PCB_MAX_COORD; + dst->X2 = dst->Y2 = -PCB_MAX_COORD; + + for(o = pcb_data_first(&it, (pcb_data_t *)data, PCB_OBJ_CLASS_REAL); o != NULL; o = pcb_data_next(&it)) { + if (!PCB_FLAG_TEST(flg, o)) + continue; + cnt++; + pcb_box_bump_box(dst, &o->BoundingBox); + } + return cnt; +} + +pcb_cardinal_t pcb_get_selection_bbox(pcb_box_t *dst, const pcb_data_t *data) +{ + return pcb_get_bbox_by_flag(dst, data, PCB_FLAG_SELECTED); +} + +pcb_cardinal_t pcb_get_found_bbox(pcb_box_t *dst, const pcb_data_t *data) +{ + return pcb_get_bbox_by_flag(dst, data, PCB_FLAG_FOUND); +} Index: trunk/src_plugins/lib_hid_pcbui/util.h =================================================================== --- trunk/src_plugins/lib_hid_pcbui/util.h (nonexistent) +++ trunk/src_plugins/lib_hid_pcbui/util.h (revision 24906) @@ -0,0 +1,7 @@ +#include "data.h" + +/* calculate the bounding box of all selections/founds in data, return the number + of selected objects. When returns 0, the dst box is infinitely large. */ +pcb_cardinal_t pcb_get_selection_bbox(pcb_box_t *dst, const pcb_data_t *data); +pcb_cardinal_t pcb_get_found_bbox(pcb_box_t *dst, const pcb_data_t *data); + Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 24905) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 24906) @@ -80,6 +80,7 @@ include {../src_plugins/lib_gtk_hid/Plug.tmpasm} include {../src_plugins/lib_hid_common/Plug.tmpasm} include {../src_plugins/lib_hid_gl/Plug.tmpasm} +include {../src_plugins/lib_hid_pcbui/Plug.tmpasm} include {../src_plugins/lib_legacy_func/Plug.tmpasm} include {../src_plugins/lib_netmap/Plug.tmpasm} include {../src_plugins/lib_polyhelp/Plug.tmpasm}