Index: trunk/src_plugins/lib_hid_common/zoompan.h =================================================================== --- trunk/src_plugins/lib_hid_common/zoompan.h (nonexistent) +++ trunk/src_plugins/lib_hid_common/zoompan.h (revision 29928) @@ -0,0 +1,51 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 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") + */ + +/* Return error from an action if there's no GUI, or set result to 0 + if there's GUI */ +#define PCB_GUI_NOGUI() \ +do { \ + if ((pcb_gui == NULL) || (!pcb_gui->gui)) { \ + PCB_ACT_IRES(1); \ + return 0; \ + } \ + PCB_ACT_IRES(0); \ +} while(0) + + +/* Core of the generic Zoom() action; the actual action needs to be + implemented by the application so it can extend it with things like + Zoom(Selected). */ + +#define pcb_gui_acts_zoom \ + "Zoom()\n" \ + "Zoom([+|-|=]factor)\n" \ + "Zoom(x1, y1, x2, y2)\n" \ + "Zoom(?)\n" \ + "Zoom(get)\n" \ + +fgw_error_t pcb_gui_act_zoom(fgw_arg_t *res, int argc, fgw_arg_t *argv); + Index: trunk/src_plugins/lib_hid_pcbui/act.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/act.c (revision 29927) +++ trunk/src_plugins/lib_hid_pcbui/act.c (revision 29928) @@ -44,15 +44,6 @@ #include "util.h" #include "act.h" -#define NOGUI() \ -do { \ - if ((pcb_gui == NULL) || (!pcb_gui->gui)) { \ - PCB_ACT_IRES(1); \ - return 0; \ - } \ - PCB_ACT_IRES(0); \ -} while(0) - const char pcb_acts_Zoom[] = pcb_gui_acts_zoom "Zoom(found|selected)\n"; @@ -60,7 +51,7 @@ /* DOC: zoom.html */ fgw_error_t pcb_act_Zoom(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - NOGUI(); + PCB_GUI_NOGUI(); if (argc == 2) { const char *vp; @@ -97,7 +88,7 @@ int mode; pcb_coord_t x, y; - NOGUI(); + PCB_GUI_NOGUI(); pcb_hid_get_coords("Click on a place to pan", &x, &y, 0); @@ -114,7 +105,7 @@ fgw_error_t pcb_act_Center(fgw_arg_t *res, int argc, fgw_arg_t *argv) { pcb_coord_t x, y; - NOGUI(); + PCB_GUI_NOGUI(); pcb_hid_get_coords("Click to center", &x, &y, 0); @@ -168,7 +159,7 @@ pcb_coord_t x, y; double xcent, ycent, xoffs, yoffs; - NOGUI(); + PCB_GUI_NOGUI(); pcb_hid_get_coords("Click to center of flip", &x, &y, 0); @@ -264,7 +255,7 @@ /* DOC: command */ fgw_error_t pcb_act_Command(fgw_arg_t *res, int argc, fgw_arg_t *argv) { - NOGUI(); + PCB_GUI_NOGUI(); pcb_gui->open_command(pcb_gui); PCB_ACT_IRES(0); return 0; @@ -283,7 +274,7 @@ CTX_OBJ_TYPE } ctx_sens = CTX_NONE; - NOGUI(); + PCB_GUI_NOGUI(); if (argc != 2 && argc != 3) PCB_ACT_FAIL(Popup);