Index: trunk/src_plugins/gui/camv_gui.c =================================================================== --- trunk/src_plugins/gui/camv_gui.c (revision 763) +++ trunk/src_plugins/gui/camv_gui.c (revision 764) @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -49,6 +50,7 @@ #include "layersel.h" #include "status.h" +#include "draw.h" static const char *layersel_cookie = "camv_gui/layersel"; static const char *status_cookie = "camv_gui/status"; @@ -245,7 +247,81 @@ return 0; } +const char camv_acts_SwapSides[] = "SwapSides(|v|h|r, [S])"; +const char camv_acth_SwapSides[] = "Swaps the side of the board you're looking at."; +fgw_error_t camv_act_SwapSides(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + rnd_box_t vb; + rnd_coord_t x, y; + double xcent, ycent, xoffs, yoffs; + RND_GUI_NOGUI(); + + rnd_hid_get_coords("Click to center of flip", &x, &y, 0); + + x = camv.crosshair_x; + y = camv.crosshair_y; + + rnd_gui->view_get(rnd_gui, &vb); + xcent = (double)(vb.X1 + vb.X2)/2.0; + ycent = (double)(vb.Y1 + vb.Y2)/2.0; + xoffs = xcent - x; + yoffs = ycent - y; + + camv_draw_inhibit_inc(); + if (argc > 1) { + const char *a, *b = ""; + + RND_ACT_CONVARG(1, FGW_STR, SwapSides, a = argv[1].val.str); + RND_ACT_MAY_CONVARG(2, FGW_STR, SwapSides, b = argv[2].val.str); + switch (a[0]) { + case 'h': case 'H': + rnd_conf_toggle_heditor_("view/flip_x", view.flip_x); + xoffs = 0; + break; + case 'v': case 'V': + if (!rnd_conf.editor.view.flip_y) + yoffs = -yoffs; + else + yoffs = 0; + rnd_conf_toggle_heditor_("view/flip_y", view.flip_y); + break; + case 'r': case 'R': + xoffs = 0; + if (!rnd_conf.editor.view.flip_y) + yoffs = -yoffs; + else + yoffs = 0; + + rnd_conf_toggle_heditor_("view/flip_x", view.flip_x); + rnd_conf_toggle_heditor_("view/flip_y", view.flip_y); + break; + + default: + camv_draw_inhibit_dec(); + RND_ACT_IRES(1); + return 0; + } + + switch (b[0]) { + case 'S': + case 's': + break; + } + } + + camv_draw_inhibit_dec(); + + rnd_gui->pan(rnd_gui, rnd_round(x + xoffs), rnd_round(y + yoffs), 0); + rnd_gui->set_crosshair(rnd_gui, x, y, RND_SC_PAN_VIEWPORT); + + rnd_gui->invalidate_all(rnd_gui); + + RND_ACT_IRES(0); + return 0; +} + + static rnd_action_t camv_gui_action_list[] = { {"PrintGUI", rnd_act_PrintDialog, rnd_acth_PrintDialog, rnd_acts_PrintDialog}, {"Popup", camv_act_Popup, camv_acth_Popup, camv_acts_Popup}, @@ -253,7 +329,8 @@ {"Layer", camv_act_Layer, camv_acth_Layer, camv_acts_Layer}, {"StatusSetText", camv_act_StatusSetText, camv_acth_StatusSetText, camv_acts_StatusSetText}, {"Save", camv_act_Save, camv_acth_Save, camv_acts_Save}, - {"SaveAs", camv_act_Save, camv_acth_SaveAs, camv_acts_SaveAs} + {"SaveAs", camv_act_Save, camv_acth_SaveAs, camv_acts_SaveAs}, + {"SwapSides", camv_act_SwapSides, camv_acth_SwapSides, camv_acts_SwapSides} }; int pplg_check_ver_gui(int ver_needed) { return 0; }