Max 5 API Reference
00001 /** 00002 @page chapter_appendix_b Appendix: Providing Icons for UI Objects 00003 00004 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. 00005 00006 00007 @section appendix_b_svg Object SVG Icon 00008 00009 To see the icons provided by Cycling '74 for objects included in Max, look in the <b>Cycling '74/object-palettes</b> 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 <code>main()</code> function) with which they are associated. You will need to place your svg in this folder for it to be found by Max. 00010 00011 <em> 00012 SVG files can be edited in a variety of software applications such as InkScape or Adobe Illustrator. 00013 You can also export SVG files from OmniGraffle on the Mac, which is how the Max's object icons were created. 00014 </em> 00015 00016 00017 @section appendix_b_icon Object Palette Definition 00018 00019 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 <b>Cycling '74/object-palettes</b> 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. 00020 00021 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: 00022 <pre> 00023 { 00024 "patcher" : { 00025 "rect" : [ 0.000000, 0.000000, 1000.000000, 1000.000000 ], 00026 "bgcolor" : [ 1.000000, 1.000000, 1.000000, 1.000000 ], 00027 "bglocked" : 0, 00028 "defrect" : [ 10.000000, 59.000000, 1176.000000, 668.000000 ], 00029 "boxes" : [ { 00030 "box" : { 00031 "maxclass" : "fpic", 00032 "boxalpha" : 1.000000, 00033 "presentation" : 0, 00034 "destrect" : [ 0.000000, 0.000000, 0.000000, 0.000000 ], 00035 "patching_rect" : [ 241.000000, 244.000000, 100.000000, 50.000000 ], 00036 "autofit" : 0, 00037 "id" : "obj-1", 00038 "ignoreclick" : 0, 00039 "hidden" : 0, 00040 "fontname" : "Courier", 00041 "pic" : "littleuifoo.svg", 00042 "xoffset" : 0.000000, 00043 "yoffset" : 0.000000, 00044 "background" : 0, 00045 "presentation_rect" : [ 0.000000, 0.000000, 0.000000, 0.000000 ], 00046 "fontsize" : 12.000000, 00047 "instance_attributes" : { 00048 "palette_category" : [ "Images", "Interface" ], 00049 "palette_action" : "littleuifoo" 00050 } 00051 00052 } 00053 00054 } 00055 ], 00056 "lines" : [ ] 00057 } 00058 } 00059 </pre> 00060 00061 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 <b>fpic</b> object. We care about three lines in this dictionary: 00062 <ol> 00063 <li>The 'pic' attribute of the fpic object determines what image will be displayed in the new-object palette.</li> 00064 <li>The 'palette_category' instance attribute will determine what categories/tabs your icon will appear under in the new-object palette.</li> 00065 <li>The 'palette_action' instance attribute will determine what object class is instantiated by when user chooses your icon.</li> 00066 </ol> 00067 00068 00069 */
Copyright © 2008, Cycling '74