How to make inspector panels for custom Quartz Composer patches How to make inspector panels for custom Quartz Composer patches

Posted by smokris on 2007.05.13 @ 10:52

Filed under:

…in thirteen easy steps or your money back.

This release is only compatible with Tiger (10.4).
Please see kineme.net for Leopard-specific informations.

 

 

 

  1. Start up Interface Builder:
  2. Make a new NIB, with a “Cocoa / Empty” starting point:
  3. Make a subclass of NSObject called QCInspector. Then make a subclass of QCInspector with the class name of your patch, followed by “UI”. P5GloveUI in this case:
  4. Drag a “CustomView” into the project:
  5. Select “File’s Owner” and set its “Custom Class” to the UI subclass you created above (P5GloveUI in this case):
  6. Control-drag from “File’s Owner” to “View”, then “Connect” the view to the UI subclass’s “view” outlet:
  7. Throw a few controls onto the View if you’d like:
  8. Save the NIB in your patch’s English.lproj folder, and add it to the project:
  9. Add the QCInspector interface to your patch’s qcplugin.h:
    @interface QCInspector : NSObject
    {
        NSView *view;
        QCPatch *_patch;
        void *_unused2[4];
    }
    + (id)viewNibName;
    + (id)viewTitle;
    - (id)init;
    - (void)didLoadNib;
    - (id)patch;
    - (void)setupViewForPatch:(id)fp8;
    - (void)resetView;
    - (id)view;
    @end
    
  10. Add inspectorClassWithIdentifier to your patch’s interface: P5Glove.h:
    @interface P5Glove : QCPatch
    
    ...
    
    + (Class)inspectorClassWithIdentifier:(id)fp8;
    @end
    
  11. Implement inspectorClassWithIdentifier: P5Glove.m:
    @implementation P5Glove : QCPatch
    
    ...
    
    + (Class)inspectorClassWithIdentifier:(id)fp8
    {
        return [P5GloveUI class];
    }
    @end
    
  12. Add the P5GloveUI class interface and implementation to your patch’s project: P5GloveUI.h:
    @interface P5GloveUI : QCInspector
    + (id)viewNibName;  // IMP=0x97b89415
    @end
    
    P5GloveUI.m:
    @implementation P5GloveUI : QCInspector
    + (id)viewNibName
    {
        return @"P5GloveUI";
    }
    
  13. Build and launch Quartz Composer. You’ve got an inspector:
  14.  Enjoy.

This was a great tutorial… a couple of small details that probably wouldn’t take anybody to long to figure out but are worth mentioning (unless I’m wrong about them).

  1. I believe you need to link to the UI header file from within your patches .h file, since the inspectorClassWithIdentifier method returns the UI class.

  2. You need to link to the qcplugin.h file inside your UI Header file, so that the UI class knows what a QCInspector is.

Thanks again for this tutorial, and for your excellent template.