Update the scroller in a NSScrollView from its documentView ?
Update the scroller in a NSScrollView from its documentView ?
- Subject: Update the scroller in a NSScrollView from its documentView ?
- From: Oliver Quas <email@hidden>
- Date: Thu, 9 Feb 2006 12:41:50 +0100
Hi all,
i got a problem with a document-based Cocoa-application i am
currently working on.
I made a subclass of NSView to display waveform data, that is
collected from a QTMovie. In Interface Builder, i setup a custom view
and set its class to the WaveformView class. Additionally, i made it
a subview of Scroll View so if the waveform exceeds the current
window width, you should be able to scroll the view.
The application also contains a NSSlider, that changes the zoom of
the WaveformView (it invokes an IBAction in the MyDocument class,
which triggers WaveformView to update using the new zoom value).
Everything works just fine, but when i drag the slider at a high
speed, the WaveformView just disappears. It turned out, that the
WaveformView's frame width resizes to 0.0. Once it gets this small,
the slider can still be dragged, but the WaveformView remains empty.
Here's what i do in the WaveformView's drawRect-method:
- (void) drawRect:(NSRect)rect
{
[self lockFocus];
....
[self setFrameSize:NSMakeSize([scrollView contentSize].width,
[self frame].size.height)]; // (1)
[[self superview] setFrameSize:NSMakeSize([scrollView
contentSize].width, [[self superview] frame].size.height)]; // (2)
....
// some bezier drawing here
....
[self unlockFocus];
}
By commenting out (2), the bug disappears, but the horizontal
scroller doesn't show up any more, when the drawn waveform exceeds
the width of the visible space, because the NSScrollView's NSClipView
doesn't update it's width any more.
So i wonder, how can i implement it correctly? How do you implement
things like this? Where and how should i implement the NSScrollView's
updating?
Also i would like to add another view to the NSScrollView. It should
provide some basic timeline-editing known from applications like
Final Cut Pro or iMovie. How do i have to add it to the NSScrollView?
And if i use the NSSlider, how do i update the width of both
(TimelineView and WaveformView) dynamically?
Any help would be greatly appreciated.
Thanks in advance.
Best regards,
Oliver
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden