Re: Mystery Threads
> On 29 Sep 2016, at 10:05, Gerriet M. Denkmannwrote: > > >> On 29 Sep 2016, at 14:38, Quincey Morris >> wrote: >> >> On Sep 29, 2016, at 00:15 , Gerriet M. Denkmann wrote: >>> >>> dispatch_apply( nbrOfThreads, queue, ^void(size_t idx) >>> >>> As my computer has just 8 CPUs, I thought that using nbrOfThreads > 8 would >>> be silly: adding overhead without gaining anything. >>> >>> Turns out this is quite wrong. One function (called threadHappyFunction) >>> works more than 10 times faster using nbrOfThreads = a few ten-thousand (as >>> compared to nbrOfThreads = 8). >>> >>> This is nice, but I would like to know why can this happen. >> >> What makes you think “nbrOfThreads” represents a number of threads? > > Well, nothing. Just let’s call it nbrOfBlocksToBeUsedByDispatchApply, or > whatever. But ultimately any of these things has to run on a CPU, of which > there are no more than 8. There are mored shared resources than just execution units in your system (e.g. memory bandwidth, or for non-linear accesses latency). Maybe one of your blocks is bandwidth bound, while the other is compute bound? Your second function might be memory bound (with lots of read-modify-write traffic). There are many other factors (and the dispatch_apply man-page tells you that number of invocations is very dependant on your block), such as caches or hyper-threading. The performance counters in Instruments may be able to guide you. Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSOperation Dispatch Thread Soft Limit
Hi, On 3 Mar 2014, at 09:43, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: I have a MyOperation, subclass of NSOperation. MyOperation does: create an NSOperationQueue add a few MyOperations to this queue waitUntilAllOperationsAreFinished (obviously this recursion stops at some point - I do not create an infinite number of operations). The good thing: this is very energy saving: cpu utilisation = 0% The bad thing: nothing gets done. Using Activity Monitor to sample my app I see: “Dispatch Thread Soft Limit: 64 reached in 2152 of 2152 samples -- too many dispatch threads blocked in synchronous operations IMO the problem is not really the limit itself, but the second part of the message: That your operations themselves are blocking. If you haven’t, take a look at https://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practicum.html He has reasonably expensive blocks, so he aims to have 2x cpuCores operations in flight (and does IO scheduling). But: Is there some way to find out programmatically at which point my app should stop adding operations? That depends largely on what your operations do (e.g. whether I/O is involved, duration, dependencies, …). Somehow (constant) scaling with the number of cores available in the machine seems like a good start, as you cannot ever execute more things in parallel. Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Scene Kit
Hi, On 21 Oct 2012, at 00:44, Thomas Cunningham maui...@maui.net wrote: How (as in by which amounts) are you modifying the properties to arrive at those mixed results? Why are they not what you want? What do you actually want? I want to know what properties I should be adjusting to simulate a zoom in and a zoom out. No, you already *know* what you should adjust to zoom in and out, because as you say below, it works the first time. Using the Scene Kit Fun project, I place this code in the mousedown event, distance is an ivar that is set to 45. self-distance = self-distance - 5.0; camera.xFov = distance; // degrees camera.yFov = distance; [self setNeedsDisplay:YES]; // just in case it needs refreshing On the first click it zooms in fine, subsequent clicks are ignored, no zoom in, values are correctly reflected in the log. The basic principle works absolutely fine here (although I had to hunt down to the non-Apple example code you were referring to). I think your problem lies elsewhere, probably not setting the properties on the right object. What is camera in your snippet above? In the example I had, it was only a local variable declared in awakeFromNib:. Here are my changes from SceneKitFun - HitTest: --- /Users/maven/Downloads/SceneKitFun-1/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.h 2012-08-17 19:32:50.0 +0200 +++ /Users/maven/Downloads/SceneKitFun/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.h 2012-10-21 11:25:00.0 +0200 @@ -9,4 +9,6 @@ #import Cocoa/Cocoa.h #import SceneKit/SceneKit.h @interface MCPSceneView : SCNView +@property double distance; +@property SCNCamera *camera; @end --- /Users/maven/Downloads/SceneKitFun-1/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.m 2012-08-18 16:40:52.0 +0200 +++ /Users/maven/Downloads/SceneKitFun/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.m 2012-10-21 11:34:44.0 +0200 @@ -13,6 +13,7 @@ @implementation MCPSceneView -(void)awakeFromNib { +self.distance = 45.0; self.backgroundColor = [NSColor grayColor]; // Create an empty scene @@ -20,11 +21,11 @@ self.scene = scene; // Create a camera -SCNCamera *camera = [SCNCamera camera]; -camera.xFov = 45; // Degrees, not radians -camera.yFov = 45; +self.camera = [SCNCamera camera]; +self.camera.xFov = 45; // Degrees, not radians +self.camera.yFov = 45; SCNNode *cameraNode = [SCNNode node]; - cameraNode.camera = camera; + cameraNode.camera = self.camera; cameraNode.position = SCNVector3Make(0, 0, 30); [scene.rootNode addChildNode:cameraNode]; @@ -107,6 +108,10 @@ highlightAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [material.emission addAnimation:highlightAnimation forKey:@highlight]; + +self.distance = self.distance - 5.0; +self.camera.xFov = self.distance; // degrees +self.camera.yFov = self.distance; } [super mouseDown:event]; Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Scene Kit
Hi, Disclaimer: I've not worked with SceneKit yet. On 19 Oct 2012, at 22:13, Thomas Cunningham maui...@maui.net wrote: On desktop, what mechanisms should I be using to implement a simple zoom in and out of the 3d scene? I am using a camera node and have tried using xFov, yFov and position properties with mixed results. How (as in by which amounts) are you modifying the properties to arrive at those mixed results? Why are they not what you want? What do you actually want? As far as I can see from the documentation, you've at least twiddling the right knobs (unless you're using an Orthographic Projection). Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Finding object array index when iterating through array
On 7 Mar 2012, at 12:09, John Maisey wrote: Hi, If the items are unique, how about: [array indexOfObject:object]; Congratulations, you have just (depending on NSArray-implementation details) improved your loop from from O(N) to O(N^2). Don't do this. Using a counter is likely be faster though. Correct. Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSScrollView animation (animate scroll point)
'lo, On 2 Sep 2011, at 06:54, Indragie Karunaratne wrote: This has been asked a few times before, but not after Lion was released so I figured I'd ask again. Is there any way to animate the scroll point of an NSScrollView? I figure that animation must be possible somehow, considering that inertial scrolling is basically animating the scroll point. I expected to see new API's in Lion for this, but there seems to be nothing that was added to NSScrollView that would enable me to easily do this. The only way that comes to mind is to use an NSTimer to create an animation of sorts, but I imagine that this wouldn't perform too well and that it wouldn't look very smooth either. You can simply animate the bounds-rectangle of the scrollview's clipview, e.g. [NSAnimationContext beginGrouping]; NSClipView* clipView = [[_myView enclosingScrollView] contentView]; NSPoint newOrigin = [clipView bounds].origin; newOrigin.x = MY_NEW_POSITION; [[clipView animator] setBoundsOrigin:newOrigin]; [NSAnimationContext endGrouping]; Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView with autoResizing Column: How to trigger auto-resizing after setFrame:?
On 4 Aug 2011, at 20:25, Quincey Morris wrote: On Aug 4, 2011, at 03:12, Daniel Vollmer wrote: On 3 Aug 2011, at 19:20, Quincey Morris wrote: By modifying the frame of what? You should be changing the scroll view frame, but you make it sound like you're changing the table view frame. The frame of the tableview. I want the scrollview to stay the same size, only to display half of twice as much content (i.e. display the left half of the original content in twice as much detail, with the ability to scroll over to the 2nd half). If you want to have other content that scrolls along with the table view inside the scroll view (which I *think* is what you're trying to do), then the correct way to do it is to enclose the table view (along with its own scroll view) and the associated content in a containing scroll view (which means the table view's scroll view and the other content will be enclosed in a custom view that's the outer scroll view's document view). The inner scroll view would be set to autoresize, so it basically has no effect, all the resizing being driven by the outer scroll view. I finally managed what I set out to do: http://www.maven.de/code/cocoa/scrollview_wowplot.mov (example movie). I subclassed NSTableView so that the size of the column is also resized on setFrame: messages. This then allowed me to use animation proxies for the zooming (achieved by animating the tableView's frame.size (inside the scrollView) as well as the clipView's bounds.origin). Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView with autoResizing Column: How to trigger auto-resizing after setFrame:?
On 3 Aug 2011, at 19:20, Quincey Morris wrote: On Aug 3, 2011, at 05:41, Daniel Vollmer wrote: Now, what I'm trying to do is resize the tableview horizontally inside the scrollview *without* changing the size of the window itself[1]. I can do that easily enough by modifying its frame, but this seems to ignore the column auto-resizing and leaves the column at the original width. Of course, I could just set the new column width explicitly, but I'm trying use the autoresizing so that I can use NSViewAnimation to animate this transition. Any ideas on why the column autosizing doesn't work when setting the frame directly? I tried calling various NSView and NSControl methods to force a relayout after changing the size, but had no success. By modifying the frame of what? You should be changing the scroll view frame, but you make it sound like you're changing the table view frame. The frame of the tableview. I want the scrollview to stay the same size, only to display half of twice as much content (i.e. display the left half of the original content in twice as much detail, with the ability to scroll over to the 2nd half). Also, check that you've enabled column resizing correctly in *both* places -- the column resizing behavior of the table view itself (it's a popup -- resize first column/resize last column/etc) AND the resizing behavior of the column (it's a checkbox prior to Xcode 4 IIRC, and a popup in Xcode 4). They are both enabled, and as mentioned before, the column resizing works fine when resizing the window itself (which in turn changes the size of the scrollView). Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTableView with autoResizing Column: How to trigger auto-resizing after setFrame:?
Hello all, I have a window covered with an NSTableView inside an NSScrollView. The tableview has a single column which is set to autoresize with the tableview. This works as expected when I resize the window, the column extends correctly to fill the newly available space. Now, what I'm trying to do is resize the tableview horizontally inside the scrollview *without* changing the size of the window itself[1]. I can do that easily enough by modifying its frame, but this seems to ignore the column auto-resizing and leaves the column at the original width. Of course, I could just set the new column width explicitly, but I'm trying use the autoresizing so that I can use NSViewAnimation to animate this transition. Any ideas on why the column autosizing doesn't work when setting the frame directly? I tried calling various NSView and NSControl methods to force a relayout after changing the size, but had no success. Thanks, Daniel. [1] Why? My column content stretches out to fill all available space and display a higher resolution representation, and I want to have a zoom operation that shows content in more detail (albeit only in 1 dimension) without changing the current window dimensions.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSView-based NSTableView: How to animate when using bindings?
Helloes, I'm experimenting with migrating from my formerly NSCollectionView-based drawing to using an NSView-based table-view (as the tableView is conceptually closer to what I'm displaying (http://www.maven.de/code/wowplot/example_chains.png). The NSCollectionView had really nice animation behaviour for inserting and removing items and well as changing the minimum item size (which I used to force the collectionView to expand into its scrollView and thus zoom into my content). I'm not sure how to replicated these animations in an NSTableView when populating it with bindings, as I cannot call both [arrayController insertObject:] as well as [tableView insertRowsAtIndexes:withAnimation:]. Is combining the animation properties of an NSView-based NSTableView possible when using it via Cocoa bindings? Thanks, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Space-efficient saving for Versions?
Salutations, in my custom document package I'm always including a large-ish chunk of data that does not get modified as I change the document itself. Currently, I'm keeping this around as NSData-object and write it out when being asked by NSDocument to return my fileWrapper as one sub-file of the directory package. Can I do anything to make it more obvious to the Versions / autosave-mechanism that this file in the package is always the same? Or will it compare the files anyway and notice it's identical to the one used in the previous revision? Thanks, Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UI like Transmission BT
On 28 Jul 2011, at 10:16, Wilker wrote: Hi Guys, Which components of XCode 4 I should use in order to make an UI like the Transmission BT (http://www.transmissionbt.com/) Why don't you check yourself in the source-code: https://trac.transmissionbt.com/browser/trunk/macosx Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDocument: Read-only types and autosavesInPlace
Hello again, On 23 Jul 2011, at 13:00, Daniel Vollmer wrote: Oddly enough, the TextEdit example *should* end up with the same problem when I create a .rtf-document, drag an attachment into it (so it becomes .rtfd), and then close the document. Unfortunately, it works fine for TextEdit but I cannot see anything between my example and TextEdit that could cause it to behave differently, even after having put breakpoints onto every imaginable message. Can anyone see what I'm doing wrong or differently from TextEdit? It turns out that this machinery (i.e. the auto-renaming when changing file-types) only kicks in when you use UTI type declarations. Or at least that seems to be the case. Anyhow, one riddle solved... Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDocument: Read-only types and autosavesInPlace
After some more time on this, I still don't get it. =) I've given this a go, but it does not seem to work for me. I set the new fileType after [super readFromURL:...] is done. Then, when - (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *errorOrNil))completionHandler gets called, the arguments are as expected (i.e. the URL is still the original file with the incorrect extension and the type is the writable type I set myself), nevertheless, the URL is never changed and it ends up overwriting my original file in the wrong format. :( Could this be due to me using a NSFileWrapper-based directory package (whereas the read-only type is a simple flat-file)? I've made an example project showing my problem from the NSDocument-based application template, it can be found at http://www.maven.de/code/DiagSavingProblem.zip The example only overrides, fileWrapperOfType:error, readFromFileWrapper:ofType:error, saveToURL:ofType:forSaveOperation:completionHandler: as well as autosavingFileType and autosavesInPlace (and readFromURL to modify the edited state). Oddly enough, the TextEdit example *should* end up with the same problem when I create a .rtf-document, drag an attachment into it (so it becomes .rtfd), and then close the document. Unfortunately, it works fine for TextEdit but I cannot see anything between my example and TextEdit that could cause it to behave differently, even after having put breakpoints onto every imaginable message. Can anyone see what I'm doing wrong or differently from TextEdit? Thanks, Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSDocument: Read-only types and autosavesInPlace
Hello, I'm trying to add autosavesInPlace support to my NSDocument-based Application. It supports a read-only type that is internally converted (as suggested in https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/2954-1081265-BAJFDEGD) to my writable type. The viewer- and editor-roles are set correctly in the application's plist, +writableTypes also returns only what I can write. For reference, I can read .txt and read/write .wowplot. Now, this seems to interact badly with autosavesInPlace: YES. The following happens: 1) I open a document of the read-only type (.txt) 2) I convert this as suggested above to my writable type, using setFileType and setFileURL 3) I modify the document 4) I attempt to close the document 5) Now the autosave-Machinery jumps into action and I get the following error: [ERROR] genstore_storage.c:GSAddPathAsGeneration:980 copyfile /Volumes/Seerose/Users/maven/Desktop/110720 225338.wowplot to /Volumes/Seerose/Users/maven/Library/Autosave Information/2521980F-37BC-4E21-AF6A-001BE638AEFC.genstore.noindex/.genstore_staging/OUyU4Xi/staged failed with error 2 (No such file or directory) The errors make sense, as the file under that name never existed. Now I'm stuck in-between a rock in a hard place: If I change the type, autosavesInPlace tries to duplicate a non-existent file (because I modified the fileURL); if I don't change the type, NSDocument will ask me to write a file of a type I cannot support. Any ideas? Thanks, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSDocument: Read-only types and autosavesInPlace
On 22 Jul 2011, at 19:25, Kevin Perry wrote: On Jul 22, 2011, at 9:16 AM, Daniel Vollmer wrote: Hello, I'm trying to add autosavesInPlace support to my NSDocument-based Application. It supports a read-only type that is internally converted (as suggested in https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/2954-1081265-BAJFDEGD) to my writable type. The viewer- and editor-roles are set correctly in the application's plist, +writableTypes also returns only what I can write. For reference, I can read .txt and read/write .wowplot. Now, this seems to interact badly with autosavesInPlace: YES. The following happens: 1) I open a document of the read-only type (.txt) 2) I convert this as suggested above to my writable type, using setFileType and setFileURL 3) I modify the document 4) I attempt to close the document 5) Now the autosave-Machinery jumps into action and I get the following error: [ERROR] genstore_storage.c:GSAddPathAsGeneration:980 copyfile /Volumes/Seerose/Users/maven/Desktop/110720 225338.wowplot to /Volumes/Seerose/Users/maven/Library/Autosave Information/2521980F-37BC-4E21-AF6A-001BE638AEFC.genstore.noindex/.genstore_staging/OUyU4Xi/staged failed with error 2 (No such file or directory) The errors make sense, as the file under that name never existed. Now I'm stuck in-between a rock in a hard place: If I change the type, autosavesInPlace tries to duplicate a non-existent file (because I modified the fileURL); if I don't change the type, NSDocument will ask me to write a file of a type I cannot support. Any ideas? There's a tidbit in the AppKit release notes regarding this (Look for File Type Fixing in -[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]). While it doesn't say it right out, it suggests that you should give responsibility for changing to file URL to NSDocument. All you need to do is change the file type and NSDocument will take care of the file URL and avoid this error. (Note: you won't get this behavior if you're overriding the old -saveToURL:ofType:forSaveOperation:error: method.) I've given this a go, but it does not seem to work for me. I set the new fileType after [super readFromURL:...] is done. Then, when - (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *errorOrNil))completionHandler gets called, the arguments are as expected (i.e. the URL is still the original file with the incorrect extension and the type is the writable type I set myself), nevertheless, the URL is never changed and it ends up overwriting my original file in the wrong format. :( Could this be due to me using a NSFileWrapper-based directory package (whereas the read-only type is a simple flat-file)? Thanks, Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Best way to do static overlay over scrolling content?
Hello, I have a visualisation application that displays multiple graphs (currently using NSCollectionView, but possibly switching to an NSView-based NSTableView in the future) that looks like this: http://www.maven.de/code/wowplot/example_chains.png When you scroll sideways, the title of each graph stays in place, whereas the rest of the content scrolls as usual. Currently, I simply redraw the whole graph (well, the visible bit). This strikes me as rather inefficient, because I essentially need to redraw the complete visible portion onScroll instead of only the freshly revealed bit. There are some things I can think of, but I'm unsure on which would be the most appropriate way: - Put an NSTextLabel inside the NSScrollView's contentView and dynamically reposition it into the visibleRect. - Add a largely transparent subview to the NSScrollView (so it's the same size as the visible portion) and draw all titles in there, transforming coordinates as needed. Preferably, the compositing would only happen once when the visibleRect changes, not each frame (so the transparent blend doesn't each too much graphics memory bandwidth). Has anyone got any experience with this or suggestions on which way would be most appropriate? Thanks, Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSScrollView, centering document view?
Hi, On 30 Jan 2011, at 06:38, Todd Heberlein wrote: Is there an easy way to do this? Or should I make sure my document view is always at least as large as the content view and then just center my drawing inside my document view? Here's a sub-class of NSClipView that does that. I have to admit I don't quite remember where I got the pointers from (probably CocoaDev). SICenteringClipView.h Description: Binary data SICenteringClipView.m Description: Binary data Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Grand Central Strategy for Opening Multiple Files
I would like to open multiple files at the same time, but based on some logic that doesn't choke the OS by having 100s of files open and exceeding the hard drive's sustainable output. This blog post deals with similar issues on image files: http://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practicum.html The series is a good read about GCD (and blocks) in general. Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best technology to use for overlays?
On Apr 24, 2009, at 14:34 , Mike Abdullah wrote: Just position your overlay view as a sibling to the scrollview. If you're using NSCollectionView, you're targeting Leopard+, where overlapping views are properly supported. True, but I just remembered I don't see how I can support NSCollectionView's animation (e.g. when removing or adding a new item / row), but that's probably true for any overlay solution. Bah! Back to the drawing board... Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Best technology to use for overlays?
Hi, I want to optimise my drawing code a bit. Essentially, I have a custom NSView embedded in an NSCollectionView embedded in an NSScrollView. In my custom view, I always want to display an overlay (consisting of something like a description string of what is being displayed). This overlay is of course expected to be always visible no matter where I scroll, which usually leads me to redrawing the whole view when scrolling. What's the usual approach to this? Move the header drawing code to a subclass of NSScrollView? Conceptually, I think I want something that uses the same back-end as the window compositing, as that that's closest to what I want (the heading stays where it is, drawn on top of the NSScrollView, while the custom view only has to draw the given subRect that's being scrolled into the visible portion). An example of the views is here: http://maven.de/code/wowplot/example_chains.png . The description at the top-left of each plot always stays in the same position even when scrolling left or right. Thanks for any suggestions, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best technology to use for overlays?
On Apr 24, 2009, at 11:06 , Frederik Slijkerman wrote: Hi Daniel, Why not move the overlay drawing to a separate custom view, that you insert as a direct subview of the scroll view? In this way, the composition system takes care of all the redrawing in the most efficient way. The thing that makes this difficult is that I need to draw the heading for each of the subviews of the NSCollectionView, and thus the layout and current y-position of where to draw the headers is not really known in superviews of the collection view (although I could probably ask them =)). Also, somewhere in the back of my mind was the mention of a restriction that subviews were not allowed to overlap, but I may be wrong on that account. Best regards, Frederik Slijkerman. Daniel. Daniel Vollmer wrote: Hi, I want to optimise my drawing code a bit. Essentially, I have a custom NSView embedded in an NSCollectionView embedded in an NSScrollView. In my custom view, I always want to display an overlay (consisting of something like a description string of what is being displayed). This overlay is of course expected to be always visible no matter where I scroll, which usually leads me to redrawing the whole view when scrolling. What's the usual approach to this? Move the header drawing code to a subclass of NSScrollView? Conceptually, I think I want something that uses the same back-end as the window compositing, as that that's closest to what I want (the heading stays where it is, drawn on top of the NSScrollView, while the custom view only has to draw the given subRect that's being scrolled into the visible portion). An example of the views is here: http://maven.de/code/wowplot/example_chains.png . The description at the top-left of each plot always stays in the same position even when scrolling left or right. Thanks for any suggestions, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/fjs%40xs4all.nl This email sent to f...@xs4all.nl ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPredicateEditorTemplateRow , pop up with Core Data objects
Hello, On Apr 10, 2009, at 23:37 , Dan Waltin wrote: I'm trying to create a NSPredicateEditorTemplateRow where the last view is a popup, containing every item of a particular CoreData entity (named StudyVisit). I'm doing something similar (and it's working fine for me). Then I override the templateViews method, as follows: - (NSArray *)templateViews { NSArray *parentViews = [super templateViews]; NSMenu *menu = [[parentViews objectAtIndex:2] menu]; if (studyVisitsController != nil) { for (id studyVisit in [studyVisitsController arrangedObjects]) { [menu addItemWithTitle:[studyVisit valueForKey:@title] action:nil keyEquivalent:@]; } } return parentViews; } One possible pitfall I can think of is that studyVisitsController is indeed nil (e.g. directly after unarchiving). To force the predicateEditor to recreate its internal views / structures, I save its rowTemplates, set them to nil, and set them back to the original array once all the connections are valid (i.e. windowDidLoad for me). If you want to use more of the superclass-functionality, also make sure to set the representedObject of the menu-items to the value you want represented (e.g. [NSExpression expressionForConstantValue:value]. Last but not least, did you implement copyWithZone: so that copies of the template also have the controller? HTH, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Troubles with CollectionView and IKImageBrowserView
On Jun 12, 2008, at 00:25, Jens Alfke wrote: On 11 Jun '08, at 1:14 PM, Manuel wrote: But the IKImageBrowserView doesn't call these methods. I setup a testmethod in the MYNSCollectionViewItem like the following code, to verify that the imagebrowser outlet is set and to set again the datasource: Hm, I don't have any exact ideas, but I wonder if something's going wrong because CollectionViewItems get copied. (The one you wire up in the nib is a prototype, and the view makes a copy of it for every item it needs.) Perhaps the item is getting set as the image- browser's data source before the copy, so the instance being displayed isn't actually the one that's the data source? Jens is right in that copying the collection view is often a problem, as NSView does not support the NSCopying protocol. There's some more information on the way that NSCollectionView copies the view here:http://www.cocoadev.com/index.pl?NSCollectionView (near the bottom). I got it working like this: - put your custom view initialisation in initWithCoder: (as that is the one used to copy the original instance / unarchive your nib) - in your view, have an IBOutlet that's connected to the NSCollectionViewItem instance (called cvItem in my case) - in awakeFromNib bind the properties you're interested in (as these get restored / set correctly in the cloning process), e.g. - (void)awakeFromNib { [self bind:@plotRoot toObject:cvItem withKeyPath:@representedObject options:nil]; [self bind:@isSelected toObject:cvItem withKeyPath:@selected options:nil]; } This setup works fine for me (ignoring the other known bugs and documentation deficiencies of NSCollectionView — it's slightly disheartening when you file a bug on it, get a dup back and realise it's been known long enough for 1094954 other bugs to be filled..). HTH, Daniel.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: IB outlets and NSCollectionViews
On May 23, 2008, at 17:48, David Carlisle wrote: I solved a similar problem when putting a pop up menu into a collectionView item. There might be an easier way, but I assume that to put a button in a collectionViewItem, the button would have to send a message to a subclass of NSCollectionViewItem, which you would then cause to send a similar message along with a copy of the representedObject to a subclass of NSCollectionView. (Note that an NSCollectionViewItem knows both its representedObject and its NSCollectionView.) You would write your NSCollectionView subclass to have an outlet for File's Owner, so you could forward the message from the button to File's Owner, which could then take some action on the representedObject. On May 23, 2008, at 8:01 AM, Marcel Borsten wrote: Could you give a bit more information on how you solved this. I'm trying to do something similar, but I can't get it to work. Hm ...I had to bind it to a NSCollectionItemView subclass that routes to the AppController. cheers -- Torsten On Apr 7, 2008, at 18:04, Torsten Curdt wrote: Hm ...I was trying to bind a button inside a NSCollectionItemView view to an action in my AppController. This obviously does not work. Of course the view is only a prototype that gets cloned per item in the collection but I was expecting to just get the instance passed on the call. So how would I need to do something like this? cheers -- Torsten For sending button actions messages, don't bother with binding explicitly to your AppController, just send the required selector to firstResponder and pick that up in your AppController (it should already get these messages if you start from an NSDocument-based application IIRC). As for accessing properties of your represented object in your view, I simply do the following in my view, where cvItem is an IBOutlet to the prototype NSCollectionViewItem: - (void)awakeFromNib { [self bind:@plotRoot toObject:cvItem withKeyPath:@representedObject options:nil]; [self bind:@isSelected toObject:cvItem withKeyPath:@selected options:nil]; } This only binds the prototype view, but the bindings are properly set to the instantiated object by the obscure NSView-copying via NSCoder shenanigans (as described on cocoadev). Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSCollectionView problems
On May 25, 2008, at 18:44, Jens Alfke wrote: I remember having some similar funky issues with the scrollbar — IIRC, the scrolling range was always much too large for the number of items, and resizing the window didn't help. I can't remember now exactly what I did to fix it ... looking through the revision history and diffs, I think it may have been that I used to set the maxItemSize, and when I took that out it fixed the problem. I'm using minItemSize but I think they have the same problems. I'm not sure how I'd get the same behaviour without using it. You can observe the behaviour I want at with the beta of my program (http://www.maven.de/code/wowplot/ , some example data is at http://www.maven.de/code/wowplot/ extract.txt ). The relevant bit is the stretch and shrink timeline entries in the view menu, which in- or decrease the effective size of the NSCollectionView x-axis. —Jens Thanks, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Fighting NSCollectionView for first Responder
Hi all, I have an NSCollectionView in whose item-views I want to do some event handling (validateMenuItem: to enable / disable the events that currently make sense and a bit of keyboard / mouse input), but I'd also like the NSCollectionView to handle the selection of items. So I pass the mouseDown event to [super mouseDown] so that it eventually reaches the NSCollectionView so it can handle updating the selection. This makes the item-view lose firstResponder and my event handling ambitions are foiled. Now, I make the item-view firstResponder again in its setSelected setter (which is bound to the representedItem.selected property, so it gets called after the NSCollectionView handles the selection). Unfortunately, if I add a new item to the NSCollectionView (via its NSArrayController), I once again lose first responder* and I have no idea how to regain it, so my event handling / keyboard shortcuts work properly again... * backtrace for who causes my item-view to lose firstResponder: #1 0x95f9a355 in -[NSWindow makeFirstResponder:] () #2 0x964e4625 in _NSDiscardEditingForView () #3 0x9657ea69 in -[NSCollectionView _contentChanged:regenerate:] () #4 0x9657b2c5 in -[NSCollectionView setContent:] () #5 0x965651b2 in -[NSCollectionViewBinder _updateContent] () #6 0x96565260 in -[NSCollectionViewBinder _observeValueForKeyPath:ofObject:context:] () #7 0x93b9358e in NSKVONotify () #8 0x93b23e45 in -[NSObject(NSKeyValueObservingPrivate) _notifyObserversForKeyPath:change:] () #9 0x95e9e15e in -[NSController _notifyObserversForKeyPath:change:] () #10 0x95e9e05f in -[NSController didChangeValueForKey:] () #11 0x960b9e88 in -[NSArrayController didChangeValuesForArrangedKeys:objectKeys:indexKeys:] () #12 0x960b in -[NSArrayController _insertObject:atArrangedObjectIndex:objectHandler:] () #13 0x960b96e2 in -[NSArrayController insertObject:atArrangedObjectIndex:] () #14 0x960b9406 in -[NSArrayController addObject:] () The new firstResponder after the above incident is my main window. :( Any insight? Or is there a different way of handling things? Thanks, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSScrollView, NSCollectionView and zooming / resizing to the center
Hi all, the subject is vague, but I'm at a loss for how to describe my problem. I have an NSCollectionView inside an NSScrollView (as is usual). I display a bunch of items (in 1 column and multiple rows) in the collection view. The (custom views) inside the collection view are set to resize to take up all available space. I perform a zoom for the items in the collection view by setting its minimum item width to twice its frame width. This correctly enlarges the collection view (and makes the scroll view come into action — although it is bugged if it is set to autohide scrollers), but leaves the origin of the visible rect of the collection view as it is. Now, instead of the left hand side of the collection view's items staying at the same position, I would like the *center* to stay the same, but I'm not sure what and where to override to achieve that. Doing some explicit scrolling (scrollToPoint) right after increasing the minimum item size doesn't seem to work. Let's try some ASCII art. This is a row of my collection view displaying a view, with the square brackets [] indicating the visibleRect [1234] If I double the view's width by increasing the collection view's minItemSize to 2 * its width, I get [1122]3344, i.e. the right-hand side of the view is now outside of the visible rect and the left-hand side stays fixed at the origin. As I said, for what I'd *like* to happen is for [1234] to turn into 11[2233]44, i.e. for the center to stay the same. Any ideas? Thanks, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Create NSStrings from a mapped NSData object - safe?
Salutations! I'm parsing a rather large text-file (usually 20MB) and in doing so I'm iterating over its lines with [String getParagraphStart]. I've found a rather noticeable speed-up in the parsing operation if I create the string in question from an NSData object (created via initWithContentsOfMappedFile) using [String initWithData:encoding:]. Now to the questions: 1) Is this safe if the file in question is being moved / deleted / edited during parsing? 2) Are substrings created from the original string (e.g. substringWithRange etc.) still backed properly after the original string and the NSData object are released? Thanks for any pointers, Daniel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]