Search code examples
macoscocoaprintingcore-graphicsquartz-2d

Best Practice for laying out images for printing in a WYSIWYG Mac app?


I'm in the concept phase of a Mac application that should let the user easily select and layout images for printing. It's a document-based app and a document can have multiple pages with lots of pictures in different sizes and rotations on it. The UI would kind of be like the UI of Pages.app.

Those pictures can possibly be large hi-res images. The user should also be able to print them in the best quality that the images offer.

I have re-watched some WWDC sessions about Quartz, 2D drawing optimization and NSView.

I know that there are a few different ways of accomplishing what I want to do, namely:

  1. Use a custom view for a "page" and draw the images in drawRect: with Core Graphics/Quartz. Use CG transforms to rotate and scale images.

  2. Also use a custom view for a "page", but use NSImageView-subviews to display the images. Use Core Animation and layer transforms to scale/rotate images.

What is the best practice for this? Drawing with Core Graphics or using NSViews? Why?

Thank you so much!

  • Johannes

Solution

  • Depends on how interactive these pages should be. If there is a lot of mouse interaction, e.g. dragging, selecting etc. I'd go with views. If you want fluid animations I'd even use plain CALayers with their content set to one image. This would also let you zPosition the images in case they overlap. A view based solution makes z-ordering hard. The drawRect method should be fastest but you have hard times integrating user interaction and you must z-order manually.