Max 5 API Reference

Appendix: Providing Icons for UI Objects

If you are writing user interface objects for Max, it is recommended that you provide an icon for your object.

Providing an icon will allow users to create an instance of your class from the object palette, and improve the user's experience in other interactions with Max including the Object Defaults inspector.

Object SVG Icon

To see the icons provided by Cycling '74 for objects included in Max, look in the Cycling '74/object-palettes folder installed by Max. You fill find a variety of SVG (scalable vector graphics) files for the objects. The files are named with the same name of the class (as it is defined in your main() function) with which they are associated. You will need to place your svg in this folder for it to be found by Max.

SVG files can be edited in a variety of software applications such as InkScape or Adobe Illustrator. You can also export SVG files from OmniGraffle on the Mac, which is how the Max's object icons were created.

Object Palette Definition

Adding the svg file will make the icon available to Max for use in some ways. To make your icon appear in the new object palette, however, you must create a palette containing your SVG file. If you look in the Cycling '74/object-palettes folder (where you placed your SVG file), you should notice some files with names like "palette1.json", "palette2.json", and "palette3.json". For your object, you should create a new palette file.

For the following example we will assume you have created an object called 'littleuifoo'. For this object we will create a palette called 'littleuifoo-palette.json'. The contents of this file will look like this:

{
	"patcher" : 	{
		"rect" : [ 0.000000, 0.000000, 1000.000000, 1000.000000 ],
		"bgcolor" : [ 1.000000, 1.000000, 1.000000, 1.000000 ],
		"bglocked" : 0,
		"defrect" : [ 10.000000, 59.000000, 1176.000000, 668.000000 ],
		"boxes" : [ 			{
				"box" : 				{
					"maxclass" : "fpic",
					"boxalpha" : 1.000000,
					"presentation" : 0,
					"destrect" : [ 0.000000, 0.000000, 0.000000, 0.000000 ],
					"patching_rect" : [ 241.000000, 244.000000, 100.000000, 50.000000 ],
					"autofit" : 0,
					"id" : "obj-1",
					"ignoreclick" : 0,
					"hidden" : 0,
					"fontname" : "Courier",
					"pic" : "littleuifoo.svg",
					"xoffset" : 0.000000,
					"yoffset" : 0.000000,
					"background" : 0,
					"presentation_rect" : [ 0.000000, 0.000000, 0.000000, 0.000000 ],
					"fontsize" : 12.000000,
					"instance_attributes" : 					{
						"palette_category" : [ "Images", "Interface" ],
						"palette_action" : "littleuifoo"
					}
				}
			}
 		],
		"lines" : [  ]
	}
}	

Most of this palette file will be the same for any given object. The astute reader might notice that this is a JSON representation of a t_dictionary representing a patcher that includes an fpic object. We care about three lines in this dictionary:

  1. The 'pic' attribute of the fpic object determines what image will be displayed in the new-object palette.
  2. The 'palette_category' instance attribute will determine what categories/tabs your icon will appear under in the new-object palette.
  3. The 'palette_action' instance attribute will determine what object class is instantiated by when user chooses your icon.

Copyright © 2008, Cycling '74