0
votes

I have built a custom view component that displays a timeline of events. The component is built from several custom subclasses of NSView, each implementing specific visual aspects of the events in the timeline. Most classes display themselves by a combination of existing Cocoa components (added via the initWithFrame method) and some custom drawing (via the drawRect method).

The timeline is - due to its size - wrapped in an NSScrollView that allows the user to horizontally scroll through the timeline. The timeline maps the coordinate system of its frame to the events that are displayed, so events that run for a long time take up more pixel real estate.

This all works nice. However, I would now like to add a feature that displays a view which is scaled down version of the real timeline - comparable to the effect of scaling down an image where you lose detail when scaling down.

Is it somehow possible to "echo" the drawing done in one view to another view, which is a scaled down version /copy of the original view?

1

1 Answers

2
votes

If you want to echo the larger timeline and simply resize it down ...

NSView has:

- (NSData *)dataWithPDFInsideRect:(NSRect)aRect

Pass the NSRect of the larger view to snapshot.

Then, create an NSImage with:

- (id)initWithData:(NSData *)data

Then call setSize and place it in the NSImageView.