Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 684) +++ trunk/src/gui_act.c (revision 685) @@ -64,10 +64,10 @@ return rnd_actionv_bin(RND_ACT_DESIGN, "rnd_zoom", res, argc, argv); } -#define get_layer(ly, idx) \ +#define get_layer(ly, idx, actname) \ if ((argv[1].type & FGW_STR) == FGW_STR) { \ const char *targets = NULL; \ - RND_ACT_MAY_CONVARG(1, FGW_STR, RotateLayer, targets = argv[1].val.str); \ + RND_ACT_MAY_CONVARG(1, FGW_STR, actname, targets = argv[1].val.str); \ if ((targets[0] == '@') && (targets[1] == '\0')) { \ idx = camv->lysel; \ if ((idx < 0) || (idx >= camv->layers.used)) { \ @@ -77,10 +77,10 @@ } \ } \ else \ - RND_ACT_MAY_CONVARG(1, FGW_INT, RotateLayer, idx = argv[1].val.nat_int); \ + RND_ACT_MAY_CONVARG(1, FGW_INT, actname, idx = argv[1].val.nat_int); \ } \ else \ - RND_ACT_MAY_CONVARG(1, FGW_INT, RotateLayer, idx = argv[1].val.nat_int); \ + RND_ACT_MAY_CONVARG(1, FGW_INT, actname, idx = argv[1].val.nat_int); \ \ if ((idx < 0) || (idx >= camv->layers.used)) { \ rnd_message(RND_MSG_ERROR, "No such layer\n"); \ @@ -92,7 +92,7 @@ static const char camv_acts_RotateLayer[] = "RotateLayer(@|idx, deg)"; -static const char camv_acth_RotateLayer[] = "Rotates the layer addressed (@ for current) by deg degrees CCW"; +static const char camv_acth_RotateLayer[] = "Rotates the layer addressed (@ for current) by deg degrees CCW. (The transformation is added to the current transformation matrix of the layer.)"; static fgw_error_t camv_act_RotateLayer(fgw_arg_t *res, int argc, fgw_arg_t *argv) { rnd_design_t *hl = RND_ACT_DESIGN; @@ -101,7 +101,7 @@ camv_layer_t *ly; int idx; - get_layer(ly, idx); + get_layer(ly, idx, RotateLayer); RND_ACT_MAY_CONVARG(2, FGW_DOUBLE, RotateLayer, deg = argv[2].val.nat_double); @@ -112,10 +112,33 @@ return FGW_SUCCESS; } +static const char camv_acts_TranslateLayer[] = "TranslateLayer(@|idx, dx, dy)"; +static const char camv_acth_TranslateLayer[] = "Translates (moves) the layer addressed (@ for current) by dx and dy. (The transformation is added to the current transformation matrix of the layer.)"; +static fgw_error_t camv_act_TranslateLayer(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + rnd_design_t *hl = RND_ACT_DESIGN; + camv_design_t *camv = (camv_design_t *)hl; + rnd_coord_t dx, dy; + camv_layer_t *ly; + int idx; + + get_layer(ly, idx, TranslateLayer); + + RND_ACT_MAY_CONVARG(2, FGW_COORD_, TranslateLayer, dx = fgw_coord(&argv[2])); + RND_ACT_MAY_CONVARG(3, FGW_COORD_, TranslateLayer, dy = fgw_coord(&argv[3])); + + rnd_xform_mx_translate(ly->mx, dx, dy); + ly->enable_mx = 1; + + RND_ACT_IRES(0); + return FGW_SUCCESS; +} + static rnd_action_t gui_action_list[] = { {"Quit", camv_act_Quit, camv_acth_Quit, camv_acts_Quit}, {"Zoom", camv_act_Zoom, camv_acth_Zoom, camv_acts_Zoom}, - {"RotateLayer", camv_act_RotateLayer, camv_acth_RotateLayer, camv_acts_RotateLayer} + {"RotateLayer", camv_act_RotateLayer, camv_acth_RotateLayer, camv_acts_RotateLayer}, + {"TranslateLayer", camv_act_TranslateLayer, camv_acth_TranslateLayer, camv_acts_TranslateLayer} }; void gui_act_init(void)