Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 683) +++ trunk/src/gui_act.c (revision 684) @@ -64,9 +64,58 @@ return rnd_actionv_bin(RND_ACT_DESIGN, "rnd_zoom", res, argc, argv); } +#define get_layer(ly, idx) \ + 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); \ + if ((targets[0] == '@') && (targets[1] == '\0')) { \ + idx = camv->lysel; \ + if ((idx < 0) || (idx >= camv->layers.used)) { \ + rnd_message(RND_MSG_ERROR, "No layer selected\n"); \ + RND_ACT_IRES(-1); \ + return FGW_SUCCESS; \ + } \ + } \ + else \ + RND_ACT_MAY_CONVARG(1, FGW_INT, RotateLayer, idx = argv[1].val.nat_int); \ + } \ + else \ + RND_ACT_MAY_CONVARG(1, FGW_INT, RotateLayer, idx = argv[1].val.nat_int); \ + \ + if ((idx < 0) || (idx >= camv->layers.used)) { \ + rnd_message(RND_MSG_ERROR, "No such layer\n"); \ + RND_ACT_IRES(-1); \ + return FGW_SUCCESS; \ + } \ + ly = camv->layers.array[idx]; + + + +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 fgw_error_t camv_act_RotateLayer(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; + double deg; + camv_layer_t *ly; + int idx; + + get_layer(ly, idx); + + RND_ACT_MAY_CONVARG(2, FGW_DOUBLE, RotateLayer, deg = argv[2].val.nat_double); + + rnd_xform_mx_rotate(ly->mx, -deg); + 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} }; void gui_act_init(void)