Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 11, 2010, 05:27 PM   #1
chumchum
macrumors newbie
 
Join Date: Nov 2010
Scrollbars and big picture

Hi everyone,

I am writing an application that displays a large graph. When I use an NSScrollView the application slows down as the graph is quite big and therefore slow to draw on a subclass of NSView. Instead I would like to draw only the part of the graph that is visible (the size of the window) but I would still need scrollbars to choose what part of the graph is supposed to be drawn. Does any body as any suggestions about how to implement this as I am new to cocoa. Should I subclass an NSScrollView, or use NSSlider (although they are not very nice)?

Thanks
M
chumchum is offline   0 Reply With Quote
Old Nov 11, 2010, 05:28 PM   #2
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Use an NSScrollView and only draw the correct portion of the content view as it's requested.
robbieduncan is offline   0 Reply With Quote
Old Nov 11, 2010, 10:52 PM   #3
chumchum
Thread Starter
macrumors newbie
 
Join Date: Nov 2010
Hi

Thanks for the reply but do you have any suggestions on how to extend NSScrollView?

Cheers,
M
chumchum is offline   0 Reply With Quote
Old Nov 12, 2010, 12:47 AM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
There is no reason to subclass NSScrollView. Doing so won't solve anything.

If the problem is your BigGraphView, then nothing done by NSScrollView can make BigGraphView draw less. The problem lies in BigGraphView. You wrote:
Quote:
Instead I would like to draw only the part of the graph that is visible ...
Well why are you drawing parts that aren't visible? And why would you think that NSScrollView could make your class draw less?

If you're drawing parts that lie outside the visible part of your view, then stop drawing those parts. You should only draw the parts that lie inside the bounds rect of your document view, which will be set by the content view of the NSScrollView.

If your view is drawing invisible parts, then nothing NSScrollView can do will cause your view to draw less. You have to change how your view draws. When you do that, then NSScrollView will be faster.

If that doesn't make sense, then you don't understand how NSScrollView works. Review the reference doc:
http://developer.apple.com/library/m...TP40003461-SW1

From that reference doc:
The content view is responsible for managing the position of the document view, clipping the document view to the content view's frame, and handling the details of scrolling in an efficient manner. The content view scrolls the document view by altering its bounds rectangle, which determines where the document view’s frame lies.
chown33 is offline   0 Reply With Quote
Old Nov 12, 2010, 03:26 PM   #5
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by chown33 View Post
There is no reason to subclass NSScrollView. Doing so won't solve anything.

If the problem is your BigGraphView, then nothing done by NSScrollView can make BigGraphView draw less. The problem lies in BigGraphView. You wrote:

Well why are you drawing parts that aren't visible? And why would you think that NSScrollView could make your class draw less?

If you're drawing parts that lie outside the visible part of your view, then stop drawing those parts. You should only draw the parts that lie inside the bounds rect of your document view, which will be set by the content view of the NSScrollView.

If your view is drawing invisible parts, then nothing NSScrollView can do will cause your view to draw less. You have to change how your view draws. When you do that, then NSScrollView will be faster.

If that doesn't make sense, then you don't understand how NSScrollView works. Review the reference doc:
http://developer.apple.com/library/m...TP40003461-SW1

From that reference doc:
The content view is responsible for managing the position of the document view, clipping the document view to the content view's frame, and handling the details of scrolling in an efficient manner. The content view scrolls the document view by altering its bounds rectangle, which determines where the document view’s frame lies.
You'd hope that drawRect: had some parameter telling the view which bits need to be redrawn. Wait a second...
gnasher729 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Preview - Scrollbars even in fullscreen mode Agreugreu OS X Mavericks (10.9) 4 Jan 6, 2014 05:17 PM
OS-neutral: The Big Picture msavwah Mac and PC Games 3 Oct 15, 2013 09:11 AM
OS X: Steam Big Picture not working with Mac Book Pro TeamRocket Mac and PC Games 1 May 9, 2013 04:33 PM
Big Picture mazz0 Mac and PC Games 5 Dec 7, 2012 04:29 AM
Scrollbars SDAVE OS X 10.8 Mountain Lion 2 Jul 30, 2012 11:05 PM

Forum Jump

All times are GMT -5. The time now is 11:58 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC