Index: 06_features/scripting/examples/zillion/zillion.fawk =================================================================== --- 06_features/scripting/examples/zillion/zillion.fawk (revision 5729) +++ 06_features/scripting/examples/zillion/zillion.fawk (revision 5730) @@ -1,5 +1,8 @@ +# GUI callback when nx or ny value is changed; "which" is x or y to indicate +# which value is being changed, "other" is the opposite index function zillion_gui_chg(which, other) { + # remember the new value GUI[which] = dad("zdlg", "get", W[which]); # make sure we are not going to do an 1x1 copy @@ -7,6 +10,9 @@ dad("zdlg", "set", W[other], 2); } +# dialog box for setting nx and ny when they are not given in arguments +# save widget IDs in script-global W["x"] and W["y"], save results in +# script-global GUI["x"] and GUI["y"] function zillion_gui() { dad("zdlg", "new"); @@ -29,8 +35,11 @@ return dad("zdlg", "run_modal", "Zillion copies", ""); } +# User callable action function zillion(nx, ny, x,y,dx,dy,list,oidp,addr,x1,y1,x2,y2,bbx1,bby1,bbx2,bby2,ox,oy) { + + # if number of copies is not specified, present a dialog for setting them if (nx == "") { GUI["x"] = GUI["y"] = 3; if (zillion_gui() != 0) @@ -94,13 +103,14 @@ # undone atomically: do not increase undo serial while doing rotations undo("FreezeSerial"); + # make a copy of the selection, grab at ox;oy buffercopy(ox, oy); - # create an array of copies + # create an array of copies, grown to right and up; skip the copy at + # 0;0 so that we do not paste over the original input for(y = 0; y < ny; y++) { for(x = 0; x < nx; x++) { if (x+y > 0) { - fawk_print("paste:", ox + dx*x, oy + dy*y); bufferpaste(ox + dx*x, oy + dy*y); } } @@ -123,7 +133,7 @@ # register action called back yb gui widgets fgw_func_reg(zillion_gui_chg); - # create a menu with the hotkey {a t} + # create a menu with the hotkey {p s z} cookie = scriptcookie(); createmenu("/main_menu/Plugins/script/make a lot of copies", "zillion([x, y])", "Make a lot of copies of selected objects", cookie, "p;s;z"); }