Apple Shake 4 User Manual

Page 927

Advertising
background image

Chapter 30

Installing and Creating Macros

927

To attach a pop-up menu:

1

Add the following code to the ui file to create a pop-up menu:

nuiPushMenu(“Tools”);

nuiPushToolBox(“Transform”);

nuiToolBoxItem(“@VidResize”,VidResize());

nuiPopToolBox();

nuiPopMenu();

nuxDefExprToggle(“VidResize.keepAspect”);

nuiPushControlGroup(“VidResize.Background Color”);

nuiGroupControl(“VidResize.bgRed”);
nuiGroupControl(“VidResize.bgGreen”);
nuiGroupControl(“VidResize.bgBlue”);

nuiPopControlGroup();
nuiPushControlWidget(“VidResize.Background Color”,
nuiConnectColorPControl(kRGBToggle,kCurrentColor,1)
);
nuxDefMultiChoice(“VidResize.vidFormat”, “NTSC|PAL”);

You can add as many entries as you want, and each entry is separated by the “|”
symbol. There is a problem with pop-up menus, however. As mentioned above, pop-up
menus only return the word you entered. Therefore, you must change the startup
macro file. In VidResize.h in the startup directory, change vidFormat to be a string
instead of an integer, placing its default parameter as either NTSC or PAL, both in
quotes. You also use an if/else statement below it to evaluate vidFormat and assign the
proper yRes value based on the vidFormat value.

2

Edit the VidResize.h file in startup to change the vidFormat logic to deal with strings
instead of integers:

image VidResize(
image In=0,
int keepAspect=1, //keeps aspect ratio or not
string vidFormat=“NTSC”, //This select NTSC or PAL res
float bgRed=0, //if keeping aspect ratio, determines
float bgGreen=0, //the bg color
float bgBlue=0
)
{
if (vidFormat==“NTSC”){

yRes=486;
} else {
yRes=576;
}

// curve int yRes = vidFormat==0?486:576;

Fit1 = Fit(In, 720, yRes, “default”, xFilter, 1);
Resize1 = Resize(In, 720, yRes, “default”, 0);
SetBGColor1 = SetBGColor(Fit1, “rgbaz”,
bgRed, bgGreen, bgBlue, 0,0

Advertising