NSOutlineView click and bug

2015-01-07 Thread Leonardo
Hi, I'm struggling with a singular trouble.
In my window I have put an NSOutlineView and a NSScrollView containing a
NSClipView containing an NSView.

I subclassed the NSClipView and overrided the magnifyWithEvent method.
This way I can better control the zooming of the clipView and its
documentView. It works pretty well.

The trouble comes when I click on a row of the outlineView, then I pinch and
zoom the clipView. The zoom occurs so slowly... No matter whether I click
later. Even if I set the clipView or the documentView as first responder,
the zoom keeps on occurring so slowly. The only way to get back the correct
zoom speed is to activate a different application then re-activate my
application. And the zoom works well again. No matter whether the
outlineView is still the firstResponder.

So, what should I look for to fix this bug?


Regards
-- Leonardo


___

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: NSVisualEffectView NSVisualEffectBlendingModeBehindWindow transparency

2015-01-07 Thread Jacek Oleksy
On Tue, Jan 6, 2015 at 12:58 AM, Corbin Dunn corb...@apple.com wrote:

 On Dec 26, 2014, at 2:26 AM, Jacek Oleksy jole...@opera.com wrote:


 The popup that is created gets the vibrancy effect only from the
 window that is right below it.

 Any ideas on how to make it work for custom window?

 There is not any API to control this option. Please log a bug requesting this 
 ability.

 Thanks,
 corbin

Bug created: 19397005

/Jacek
___

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: URLByResolvingBookmarkData not case sensitive

2015-01-07 Thread Robert Martin
Since the file system is case insensitive, why not store the path in upper or 
lower case, and convert the path you’re comparing accordingly? 

 When adding new files, I need to make sure the file is not already in the
 database so I compare the paths. This works well except when the case
 changes.

___

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: Blurry is the New Sharp

2015-01-07 Thread Michael Crawford
The last time I reported a bug of any sort to anyone, I reported quite
a serious iOS security hole via Radar.

The Apple engineer who responded quite angrily closed my bug as works
as expected.  He didn't just close the bug - he expressed a great
deal of anger for having reported the exploit at all.

I'm not real clear what his reasoning was.

It wasn't just because of this one engineer that I stopped reporting
bugs, rather that was the end of a long series of failures of vendors
to fix bugs reported not just by myself but by others.

If my only problem was the software that ran on my own computer, I
could either select quality software, or use Free Software so I could
fix the bugs myself.  This yields no joy, because so many websites are
buggy.

I tell you, I have come to regard my Retina Display MacBook Pro as an
albatross around my neck.  I would like nothing more than to hurl it
off a bridge into the Willamette River.
Michael David Crawford, Consulting Software Engineer
mdcrawf...@gmail.com
http://www.warplife.com/mdc/

   Available for Software Development in the Portland, Oregon Metropolitan
Area.


On Wed, Jan 7, 2015 at 3:38 PM, Graham Cox graham@bigpond.com wrote:

 On 7 Jan 2015, at 9:56 am, Uli Kusterer witness.of.teacht...@gmx.net wrote:

 It's amazing how many people don't understand what the phrase leaving 
 aside means on this mailing list. :-p


 True, but it's also clear that it's a source of frustration for developers, 
 and one where there's no easy way to either vent that frustration, or more 
 constructively, let apple know how we feel collectively. It's no good filing 
 a bug, as they're always closed as behaves as expected.

 There's obviously a pent-up need to discuss the issue, so any thread like 
 this is seized on as an excuse. It may be useless, but it helps us feel that 
 a) we're not alone and b) better for having got it off our chests.

 --Graham



 ___

 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/mdcrawford%40gmail.com

 This email sent to mdcrawf...@gmail.com

___

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: Request for guidance re. CALayer

2015-01-07 Thread Graham Cox

 On 8 Jan 2015, at 2:02 am, Luc Van Bogaert luc.van.boga...@me.com wrote:
 
 I also have implemented a custom view class CanvasView representing the app’s 
 drawing canvas. I realise I could do all the drawing using this view’s 
 drawRect: method. But somehow I keep having this feeling that I should pursue 
 the usage of CALayer objects, possibly using them to form a composite object 
 as part of my Layer class. What I have been trying to do so far is adding a 
 CALayer property to my Layer class, so I can add a real CALayer object as a 
 sublayer in my custom CanvasView reating a one-on-one relation between my 
 Layers (that would contain the graphics data) and real CALayer objects (to 
 display the graphics). I have assigned the Layer object as the CALayer 
 object’s delegate…
 I’m exactly not sure why, but to me this seems to be a good strategy for 
 performance considerations and possibly offering other advantages later on...
 
 However, I am not at all sure if this is the best route to take, so I would 
 welcome any help or recommendations on this.
 


Is your drawing app for vector drawing?

If so, I've found CALayer a poor fit for vector objects, as it's essentially a 
pixel-pushing technology. It's very hard to scale a view and have CALayers draw 
without pixelisation, and even using CAShapeLayer, which appears to be designed 
to capture vector drawing, doesn't scale up well. I ran into severe limitations 
with these layers exceeding hard OpenGL limits when zooming in, though of 
course there's always the possibility I was Doing It Wrong™.

A more fruitful approach might be to use CATileLayers to break your canvas up 
into tileable regions which will improve rendering performance by eliminating 
unneeded drawing when zooming in, much like the Maps app. It's a good idea to 
design the entry point into drawing your canvas with this in mind by allowing 
it to render to an arbitrary CGContext rather than assuming that it's drawing 
in a view. Then it's easy to adapt to rendering to a layer or view with trivial 
changes to your drawing code.

--Graham



___

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: NSOutlineView click and bug

2015-01-07 Thread Graham Cox

 On 7 Jan 2015, at 8:01 pm, Leonardo mac.iphone@gmail.com wrote:
 
 The zoom occurs so slowly


On 10.10?

This is a bug in the OS. They changed it so that it would interpolate pinch 
events to create a smooth animation of the zoom, but it doesn't work. The 
events arrive at 90 per second so the graphics can never keep up and the event 
queue just gets longer and longer.

Do file a radar though, the more dupes they get, the sooner it will be fixed (I 
assume, probably more hopefully than experience should allow) .

--Graham
___

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: Saving NSAttributedString to a File

2015-01-07 Thread Jens Alfke

 On Jan 7, 2015, at 1:49 PM, Jeffrey Oleander jgo...@yahoo.com wrote:
 
 So, then the problem becomes, how do you get it to pass on those custom tags 
 as custom attributes, or to your custom attribute processor?

By writing your own RTF codec. Apple's doesn't support this.

—Jens
___

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

NSURLSession delegate not being called in iOS Simulator

2015-01-07 Thread Steve Christensen
An app I'm working on connects to our server with SSL. The production server 
has an SSL certificate but the development server does not. When testing new 
server code on the development server I initialize the NSURLSession with 
[NSURLSession sessionWithConfiguration:delegate:delegateQueue:], passing self 
as the delegate. The class implements 
-URLSession:didReceiveChallenge:completionHandler:, which diddles around to 
allow the connection to proceed without a certificate.

When I build and run the app in the Simulator, calls to -[session 
dataTaskWithRequest:completionHandler:] now complete with an error 
NSURLErrorDomain error -1005 (NSURLErrorNetworkConnectionLost) and the delegate 
method is not being called. The delegate method *does* get called when running 
on a real device.

This has worked fine in the past –both on real devices and in the Simulator– 
and still works fine on real devices running both iOS 7 and 8. I haven't had to 
connect to the development server for a while so the only change I can think of 
in that time is an update to Xcode 6.1.1. Have I missed something?


___

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: Blurry is the New Sharp

2015-01-07 Thread Graham Cox

 On 7 Jan 2015, at 9:56 am, Uli Kusterer witness.of.teacht...@gmx.net wrote:
 
 It’s amazing how many people don’t understand what the phrase “leaving aside” 
 means on this mailing list. :-p


True, but it's also clear that it's a source of frustration for developers, and 
one where there's no easy way to either vent that frustration, or more 
constructively, let apple know how we feel collectively. It's no good filing a 
bug, as they're always closed as behaves as expected.

There's obviously a pent-up need to discuss the issue, so any thread like this 
is seized on as an excuse. It may be useless, but it helps us feel that a) 
we're not alone and b) better for having got it off our chests.

--Graham



___

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

Displaying a scaling, relative time or date

2015-01-07 Thread Graham Cox
I want a label in my interface to display a relative time using a sensible 
approximate scale depending on the value. I'm not sure if I can use 
NSDateFormatter for this - it seems it's a bit too fixed in using only the 
units you assign.

For example, if the value is less than a minute, it should say x seconds ago, 
if it's in the range of 1-59 minutes, x minutes ago, about an hour ago, x 
hours ago, yesterday, x days ago, about a week ago, x weeks ago, 
about a month ago, x months ago - you get the picture. Is this possible 
using NSDateFormatter, or do I have to roll my own for this?

--Graham



___

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: Displaying a scaling, relative time or date

2015-01-07 Thread Ken Thomases
On Jan 7, 2015, at 6:18 PM, Graham Cox graham@bigpond.com wrote:

 I want a label in my interface to display a relative time using a sensible 
 approximate scale depending on the value. I'm not sure if I can use 
 NSDateFormatter for this - it seems it's a bit too fixed in using only the 
 units you assign.
 
 For example, if the value is less than a minute, it should say x seconds 
 ago, if it's in the range of 1-59 minutes, x minutes ago, about an hour 
 ago, x hours ago, yesterday, x days ago, about a week ago, x weeks 
 ago, about a month ago, x months ago - you get the picture. Is this 
 possible using NSDateFormatter, or do I have to roll my own for this?

If you can require 10.10 or iOS 8, there's a new class for this: 
NSDateComponentsFormatter.  There's no class reference for it yet.  It's 
described in the Foundation release notes 
https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/#10_10Formatters
 and in its header file.

If you can't require those versions of the OSes, then I think you have to roll 
your own.  Or find a third-party library/framework/class.

Regards,
Ken


___

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: Displaying a scaling, relative time or date

2015-01-07 Thread Graham Cox

 On 8 Jan 2015, at 11:52 am, Ken Thomases k...@codeweavers.com wrote:
 
 If you can require 10.10 or iOS 8, there's a new class for this: 
 NSDateComponentsFormatter.  There's no class reference for it yet.  It's 
 described in the Foundation release notes 
 https://developer.apple.com/library/mac/releasenotes/Foundation/RN-Foundation/#10_10Formatters
  and in its header file.
 
 If you can't require those versions of the OSes, then I think you have to 
 roll your own.  Or find a third-party library/framework/class.


Thanks Ken, I'll check it out. Not sure about requiring 10.10 at the moment.

--Graham



___

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: ARC query

2015-01-07 Thread Sean McBride
On Wed, 7 Jan 2015 12:02:16 -0600, Ken Thomases said:

Short answer: yes, the alert is retained.

Meaning that one must use the weak/strong dance pattern like this?

NSAlert *alert = [NSAlert new];
alert.alertStyle = NSWarningAlertStyle;
alert.messageText =  @“Do not touch!;
__weak NSAlert* weakAlert = alert;
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse 
returnCode) {
 NSAlert *strongAlert = weakAlert;
[strongAlert orderOut:self];
}];

I miss garbage collection.  None of that was necessary.  I still haven't got my 
head around dealing with this under ARC...

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada

___

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: ARC query

2015-01-07 Thread Mike Abdullah

 On 7 Jan 2015, at 20:55, Sean McBride s...@rogue-research.com wrote:
 
 On Wed, 7 Jan 2015 12:02:16 -0600, Ken Thomases said:
 
 Short answer: yes, the alert is retained.
 
 Meaning that one must use the weak/strong dance pattern like this?
 
 NSAlert *alert = [NSAlert new];
 alert.alertStyle = NSWarningAlertStyle;
 alert.messageText =  @“Do not touch!;
 __weak NSAlert* weakAlert = alert;
 [alert beginSheetModalForWindow:self.window 
 completionHandler:^(NSModalResponse returnCode) {
 NSAlert *strongAlert = weakAlert;
   [strongAlert orderOut:self];
 }];
 
 I miss garbage collection.  None of that was necessary.  I still haven't got 
 my head around dealing with this under ARC…

No, no dancing necessary. The completion block is only fired the once. After 
that it’s discarded, breaking the retain cycle.


___

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: URLByResolvingBookmarkData not case sensitive

2015-01-07 Thread Robert Martin
Ignore my previous post - I hadn’t looked at the thread!

 On Jan 7, 2015, at 8:40 AM, Robert Martin robmar...@frontiernet.net wrote:
 
 Since the file system is case insensitive, why not store the path in upper or 
 lower case, and convert the path you’re comparing accordingly? 
 
 When adding new files, I need to make sure the file is not already in the
 database so I compare the paths. This works well except when the case
 changes.


___

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: URLByResolvingBookmarkData not case sensitive

2015-01-07 Thread Ken Thomases
On Jan 6, 2015, at 11:37 PM, Trygve Inda cocoa...@xericdesign.com wrote:

 On Jan 6, 2015, at 8:43 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 Ultimately what I need to able to do is compare a bookmark to a path.
 
 Why? Or rather, what is the reason underlying that one?
 
 I am keeping a database of files that the user adds to a database.
 Internally I keep the bookmark to each file but also cache the file's path
 as it is faster to work with.
 
 When adding new files, I need to make sure the file is not already in the
 database so I compare the paths. This works well except when the case
 changes. In that situation a file might be added that is already in the
 database and since the bookmark is resolving to an old path (same path but
 different case), the compare method fails unless it is made case
 insensitive... But not all file systems are case insensitive.
 
 So it needs to be fast... When I add a file, I might already have a few
 thousand files in the database.

I think you should only store bookmark data in the database.  When you load the 
database at program start, it may make sense to resolve the bookmark data to a 
URL, although the user could move or rename a file while your app is running so 
you would need a way to fall back to the bookmark data in any case.

As Stephen Butler suggested, all subsequent comparisons to see if two URLs 
refer to the same file should be done using the file resource identifier 
obtained using NSURLFileResourceIdentifierKey.  That's what it's for; it's 
meant to be the _right_ way to compare references to files, bypassing issues 
with symlinks, hard links, case differences vs. file system case 
(in)sensitivity, etc.  The URL object will cache the value making it fast to 
obtain.  If you don't think it's fast enough, you can cache that yourself, too.

You should be able to obtain the file resource identifier from just the 
bookmark data without resolving, if that is helpful.  See +[NSURL 
resourceValuesForKeys:fromBookmarkData:].

Regards,
Ken


___

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: Saving NSAttributedString to a File

2015-01-07 Thread Jeffrey Oleander



On 2014 Dec 19, at 17:00, Jens Alfke wrote:
On Dec 19, 2014, at 1:39 PM, Charles Jenkins cejw...@gmail.com 
wrote:
But when it comes time to save to a file format selected from AppKit 
additions (e.g. RTFFromRange:documentAttributes:), any unusual, 
application-specific attributes will be lost. There is no built-in 
file format you can select that will save just any arbitrarily named 
attribute.


Am I right?


Yes, as far as I know. How would AppKit store your arbitrary 
attributes into an HTML document? It would have to be a nasty hack 
like adding a magic HTML attribute (like nsattributedstringmetadata) 
whose value was a base64 string of an NSArchive of the attribute 
dictionary. O_o


Except that the last time I looked, the MSFT RTF pseudo-standard 
allowed any tag compatible with the scheme (slash whatever).  And if 
you're importing the file and don't recognize it, you're supposed to 
just drop it and move on (which can have some interesting results when 
you're nested in several attributes, but...).  Whatever attribute is in 
the attributed text in memory should cause generation of a tag with 
that name.


So, then the problem becomes, how do you get it to pass on those custom 
tags as custom attributes, or to your custom attribute processor?


___

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: ARC query

2015-01-07 Thread Clark S. Cox III

 On Jan 7, 2015, at 12:55, Sean McBride s...@rogue-research.com wrote:
 
 On Wed, 7 Jan 2015 12:02:16 -0600, Ken Thomases said:
 
 Short answer: yes, the alert is retained.
 
 Meaning that one must use the weak/strong dance pattern like this?

No. The weak/strong dance would only be needed if NSAlert held on to the 
completion handler for multiple calls. This is not the case here, the 
completion handler is called once and is then discarded

 NSAlert *alert = [NSAlert new];
 alert.alertStyle = NSWarningAlertStyle;
 alert.messageText =  @“Do not touch!;
 __weak NSAlert* weakAlert = alert;
 [alert beginSheetModalForWindow:self.window 
 completionHandler:^(NSModalResponse returnCode) {
 NSAlert *strongAlert = weakAlert;
   [strongAlert orderOut:self];
 }];
 
 I miss garbage collection.  None of that was necessary.  I still haven't got 
 my head around dealing with this under ARC...


-- 
Clark Smith Cox III
clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic signature
___

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

Request for guidance re. CALayer

2015-01-07 Thread Luc Van Bogaert
Hello,

I’ve been working on a drawing app for OS X in Objective-C for personal 
educational purposes. Thanks to the help I’ve received from various people in 
this list, this is coming along very nicely, but now I am once again calling 
for your help on a more complex subject.

My aim for this app is to provide some kind of “layer” functionality. I’ve 
already implemented a Layer class as an NSObject subclass, and I also have a 
panel to manage Layer objects, including creation, deletion, renaming, 
reordering, editing various attributes (locked, hidden, etc.).

I also have implemented a custom view class CanvasView representing the app’s 
drawing canvas. I realise I could do all the drawing using this view’s 
drawRect: method. But somehow I keep having this feeling that I should pursue 
the usage of CALayer objects, possibly using them to form a composite object as 
part of my Layer class. What I have been trying to do so far is adding a 
CALayer property to my Layer class, so I can add a real CALayer object as a 
sublayer in my custom CanvasView reating a one-on-one relation between my 
Layers (that would contain the graphics data) and real CALayer objects (to 
display the graphics). I have assigned the Layer object as the CALayer object’s 
delegate…
I’m exactly not sure why, but to me this seems to be a good strategy for 
performance considerations and possibly offering other advantages later on...

However, I am not at all sure if this is the best route to take, so I would 
welcome any help or recommendations on this.

Wether or not this is the best approach for my drawing app, I could also use 
some basic expert advise on Core Animation programming in general, and 
specifically on the usage of the CALayer class. I’ve read some of Apple’s docs 
and I will read them again and again, but maybe someone here could summarise 
some important basic concepts for me or touch on some misconceptions that 
beginners should watch out for.

For instance, I have already been able to create and add sublayers to a 
layer-backed view, but it is still unclear to me how to draw graphic content in 
these layers. I know that there are various methods, but I still don’t have a 
clear picture of how layers generally fit together with custom views. I’ve read 
about the CALayer delegate property and the drawLayer:inContext: method, but 
I’m not sure who, when or how this method should be called.

Thanks for any help,

-- 
Luc Van Bogaert



smime.p7s
Description: S/MIME cryptographic signature
___

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 autolayout (10.10)

2015-01-07 Thread Ken Thomases
On Jan 7, 2015, at 6:26 AM, Roland King r...@rols.org wrote:

 I want an NSStackView which can be scrolled. I dragged an NSScrollView out in 
 IB, that gives me a scrollview, the scrollers, a clip view and a child NSView 
 of the clip view, which IB doesn’t want you to delete. I dragged my 
 NSStackView out and made it a child of that view
 
 +- NSScrollview
  +- NSClipView
  +- NSView
   +- NSStackView
 
 There were no constraints set up initially between anything and anything 
 else. After a large amount of messing about I constrained the NSStackView to 
 all 4 sides of its parent, non-deletable NSView. I then constrained that 
 NSView top, left and right (but not bottom) to its parent, the ClipView. This 
 almost worked, except the StackView grew from the bottom up, not the top 
 down, so I subclassed NSClipView to return YES for isFlipped. 
 
 This appears to actually work but I don’t entirely understand every piece of 
 why. I think I understand why the NSView ends up being the intrinsic content 
 size of the StackView, which is what I want, and why the clipview is allowed 
 to be independent of that piece of content (only pinned on three sides). But 
 I don’t understand what’s driving the contentSize of the scrollview for me. 

If you didn't constrain the scroll view itself relative to its superview or 
sibling views, then constraints would have been generated at build time.  
(Select the scroll view and then the Size inspector.  It will have a note to 
that effect.)  Those constraints may not be appropriate for how you want it to 
behave (as you resize the window, for example).  Better to add such constraints 
yourself.  The scroll view's contentSize is implied by the scroll view's frame 
plus some of its properties.  For example, that calculation is what 
+contentSizeForFrameSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:
 does.


 More generally, is this how you’re supposed to set up a view which has 
 intrinsic content size inside a scroll view in IB, pin that view to the 
 NSView IB gives you, then pin that to the clipview on 3 sides only and flip 
 the clip (why?). 
 
 I did try changing the class of the NSView I can’t delete to NSStackView and 
 avoid the middle man, very bad things happened, constraints were generated in 
 constraint language which didn’t parse, so I decided to put it back where it 
 was. 

For what it's worth, I dragged an NSStackView into a window.  Then, I chose 
Editor  Embed In  Scroll View.  That resulted in:

+- NSScrollview
 +- NSClipView
 +- NSStackView

Then I selected Reset to Suggested Constraints for the whole window.  That 
added leading, trailing, top, and bottom constraints for the scroll view to its 
superview and the same for the stack view to the clip view.  The fact that the 
stack view was constrained on all sides meant that it would never scroll.  
Rather, the scroll view would grow to fit it and the window would grow to fit 
that.  I then deleted the bottom constraint between the stack view and the clip 
view, similar to what you have.  That resulted in what you described: the stack 
view was positioned at the bottom of the clip view when it was shorter than the 
scroll view's content height.

I didn't try subclassing NSClipView to make it flipped.  (I had thought that 
clip views were flipped by default, but that may not apply with auto layout.)  
I assume it would fix the placement of the stack view as you described.

There's another way to fix that, though.  Rather than removing the bottom 
constraint between the stack view and the clip view, change it to an 
inequality.  Make it so that the stack view is _at least_ as tall as the clip 
view (stack view bottom is greater than or equal to the clip view bottom).  
When the scroll view is taller than needed to show the stack view's intrinsic 
height, the stack view is made taller to fill the content size and thus 
subviews in its top section will appear at the top of the scroll view.  When 
the scroll view is shorter than needed (either because the stack view grows or 
because the window is made smaller), the stack view is not forced to be 
shorter.  Rather, it is allowed to scroll vertically, since the document 
(stack) view is taller than the content (clip) view.

Anyway, I didn't notice any problems with not having an extra NSView in the 
hierarchy between the clip view and the stack view.


By the way, there's an issue with the trailing constraint that's similar to the 
bottom constraint.  If you leave the trailing constraint as an equality, then 
the window and scroll view won't be allowed to go narrower than the stack view. 
 Conversely, if the stack view becomes wider because of one of its subviews, 
the window will increase in width to accommodate it.  This may be desirable, 
but there are alternatives that you may prefer, depending on your design.

If you remove the constraint, the stack view will only be as wide as 

Re: ARC query

2015-01-07 Thread Ken Thomases
On Jan 7, 2015, at 9:32 AM, Jonathan Mitchell jonat...@mugginsoft.com wrote:

 I use this construct quite a lot without really thinking about it under ARC
 I don’t retain a reference to the alert.
 
 Does -beginSheetModalForWindow: completionHandler: cause the receiver to be 
 retained until after the completion handler returns?
 
   NSAlert *alert = [NSAlert new];
alert.alertStyle = NSWarningAlertStyle;
alert.messageText =  @“Do not touch!;
[alert beginSheetModalForWindow:self.window 
 completionHandler:^(NSModalResponse returnCode) {
[alert orderOut:self];
}];

Well, given your code, it is retained indirectly at least.  
-beginSheetModalForWindow:completionHandler: has to copy the block, since it 
survives past its scope.  The block has a reference to alert, so, when it is 
copied, it retains alert until the block copy is fully released and deallocated.

By the way, the documentation for -beginSheetModalForWindow:completionHandler: 
specifically says that you don't need to call -orderOut: in your completion 
handler.  It will be done after your completion handler exits.  Which, by the 
way, indicates that the alert is retained until then, too.

Short answer: yes, the alert is retained.

Regards,
Ken


___

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: Request for guidance re. CALayer

2015-01-07 Thread Richard Charles
 On Jan 7, 2015, at 8:02 AM, Luc Van Bogaert luc.van.boga...@me.com wrote:
 
 For instance, I have already been able to create and add sublayers to a 
 layer-backed view, but it is still unclear to me how to draw graphic content 
 in these layers.

I would start by drawing something to a single layer. You can draw using 
CALayer or CAOpenGLLayer. Use one of Apple’s sample code projects to get 
yourself up and running.

When using CALayer, subclass and override drawInContext: to draw something.

When using CAOpenGLLayer it is more difficult but basically you subclass and 
override drawInCGLContext:pixelFormat:forLayerTime:displayTime: to draw 
something.

For a “drawing application” you would most likely have a multitude of model 
objects drawn using a single layer.

Richard Charles
___

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: Request for guidance re. CALayer

2015-01-07 Thread Corbin Dunn

 On Jan 7, 2015, at 7:02 AM, Luc Van Bogaert luc.van.boga...@me.com wrote:
 
 Hello,
 
 I’ve been working on a drawing app for OS X in Objective-C for personal 
 educational purposes. Thanks to the help I’ve received from various people in 
 this list, this is coming along very nicely, but now I am once again calling 
 for your help on a more complex subject.
 
 My aim for this app is to provide some kind of “layer” functionality. I’ve 
 already implemented a Layer class as an NSObject subclass, and I also have a 
 panel to manage Layer objects, including creation, deletion, renaming, 
 reordering, editing various attributes (locked, hidden, etc.).
 
 I also have implemented a custom view class CanvasView representing the app’s 
 drawing canvas. I realise I could do all the drawing using this view’s 
 drawRect: method. But somehow I keep having this feeling that I should pursue 
 the usage of CALayer objects, possibly using them to form a composite object 
 as part of my Layer class. What I have been trying to do so far is adding a 
 CALayer property to my Layer class, so I can add a real CALayer object as a 
 sublayer in my custom CanvasView reating a one-on-one relation between my 
 Layers (that would contain the graphics data) and real CALayer objects (to 
 display the graphics). I have assigned the Layer object as the CALayer 
 object’s delegate…
 I’m exactly not sure why, but to me this seems to be a good strategy for 
 performance considerations and possibly offering other advantages later on...
 
 However, I am not at all sure if this is the best route to take, so I would 
 welcome any help or recommendations on this.
 
 Wether or not this is the best approach for my drawing app, I could also use 
 some basic expert advise on Core Animation programming in general, and 
 specifically on the usage of the CALayer class. I’ve read some of Apple’s 
 docs and I will read them again and again, but maybe someone here could 
 summarise some important basic concepts for me or touch on some 
 misconceptions that beginners should watch out for.
 
 For instance, I have already been able to create and add sublayers to a 
 layer-backed view, but it is still unclear to me how to draw graphic content 
 in these layers. I know that there are various methods, but I still don’t 
 have a clear picture of how layers generally fit together with custom views. 
 I’ve read about the CALayer delegate property and the drawLayer:inContext: 
 method, but I’m not sure who, when or how this method should be called.
 
 Thanks for any help,


Hi Luc,

You don’t need to go directly to using CALayers, and in fact, I don’t recommend 
this. You can still get the power of CoreAnimation by using layer-backed 
NSViews. On your view that contains the majority of your subviews (i.e.: your 
“drawing layers”), call setWantsLayer:YES. All subviews will now be 
layer-backed. 

Each virtual layer that you want the user to draw into should be a custom 
NSView subclass. Each of these views should override drawRect: and implement 
the drawing for that particular layer.

Under the hood, AppKit sets the delegate and implements drawLayer:inContext:, 
and call your NSView’s drawRect:.

If you need to access specific CALayer properties, ideally use the NSView cover 
methods (such as compositingFilter, backgroundFilters, etc), but you can 
fallback to directly setting the view.layer property yourself. Just be careful, 
as AppKit “owns” certain properties (frame, bounds, position, flipped, etc).

-corbin

 
 -- 
 Luc Van Bogaert
 
 ___
 
 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/corbind%40apple.com
 
 This email sent to corb...@apple.com


___

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: NSOutlineView click and bug

2015-01-07 Thread Corbin Dunn
Hi Leornardo,

Please log this as a bug. You are running Mac OS 10.10, right?

corbin

 On Jan 7, 2015, at 1:01 AM, Leonardo mac.iphone@gmail.com wrote:
 
 Hi, I'm struggling with a singular trouble.
 In my window I have put an NSOutlineView and a NSScrollView containing a
 NSClipView containing an NSView.
 
 I subclassed the NSClipView and overrided the magnifyWithEvent method.
 This way I can better control the zooming of the clipView and its
 documentView. It works pretty well.
 
 The trouble comes when I click on a row of the outlineView, then I pinch and
 zoom the clipView. The zoom occurs so slowly... No matter whether I click
 later. Even if I set the clipView or the documentView as first responder,
 the zoom keeps on occurring so slowly. The only way to get back the correct
 zoom speed is to activate a different application then re-activate my
 application. And the zoom works well again. No matter whether the
 outlineView is still the firstResponder.
 
 So, what should I look for to fix this bug?
 
 
 Regards
 -- Leonardo
 
 
 ___
 
 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/corbind%40apple.com
 
 This email sent to corb...@apple.com


___

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: Request for guidance re. CALayer

2015-01-07 Thread Gordon Apple
We have a Mac application that uses CALayers (subclassed) for layered
drawing. Our drawing view uses a drawing delegate for drawing (rendering)
and a Edit delegate for interaction. The latter is in a view controller that
is also inserted into the view¹s responder chain. (Edit Delegate methods are
mainly for drag/drop methods, which are not forwarded in the responder
chain.) The Edit delegate knows which CALayer is the top layer, and
addresses the appropriate model layer.  This works very well, and, in fact,
our CALayer architecture is considerably more complex than that, having
background layers, annotation layer, and other things.

Using CALayers gives you a lot of power to do things like include movie
layers, QClayers, live-video capture layers, etc. into individual layers
which can be overlaid by other CALayers, i.e., things you just can¹t easily
do by layering views.

My advice is to adhere as strictly as possible to the MVC model. Let your
Layers observe that they need and act accordingly, rather than trying to
actively control them. Then, if you want a second view of the same data (in
our case, a presentation screen), you can easily replicate an
identical-content view.

Another neat trick is to use a centralized invalidation rect, which relevant
screens can observe. That way, when you change one screen, the others
immediately track the changes.


On 1/7/15 1:39 PM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:

 My aim for this app is to provide some kind of ³layer² functionality. I¹ve
 already implemented a Layer class as an NSObject subclass, and I also have a
 panel to manage Layer objects, including creation, deletion, renaming,
 reordering, editing various attributes (locked, hidden, etc.).


___

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

NSScrollView autolayout (10.10)

2015-01-07 Thread Roland King
I want an NSStackView which can be scrolled. I dragged an NSScrollView out in 
IB, that gives me a scrollview, the scrollers, a clip view and a child NSView 
of the clip view, which IB doesn’t want you to delete. I dragged my NSStackView 
out and made it a child of that view

+- NSScrollview
  +- NSClipView
  +- NSView
   +- NSStackView

There were no constraints set up initially between anything and anything else. 
After a large amount of messing about I constrained the NSStackView to all 4 
sides of its parent, non-deletable NSView. I then constrained that NSView top, 
left and right (but not bottom) to its parent, the ClipView. This almost 
worked, except the StackView grew from the bottom up, not the top down, so I 
subclassed NSClipView to return YES for isFlipped. 

This appears to actually work but I don’t entirely understand every piece of 
why. I think I understand why the NSView ends up being the intrinsic content 
size of the StackView, which is what I want, and why the clipview is allowed to 
be independent of that piece of content (only pinned on three sides). But I 
don’t understand what’s driving the contentSize of the scrollview for me. 

More generally, is this how you’re supposed to set up a view which has 
intrinsic content size inside a scroll view in IB, pin that view to the NSView 
IB gives you, then pin that to the clipview on 3 sides only and flip the clip 
(why?). 

I did try changing the class of the NSView I can’t delete to NSStackView and 
avoid the middle man, very bad things happened, constraints were generated in 
constraint language which didn’t parse, so I decided to put it back where it 
was. 
___

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

ARC query

2015-01-07 Thread Jonathan Mitchell
I use this construct quite a lot without really thinking about it under ARC
I don’t retain a reference to the alert.

Does -beginSheetModalForWindow: completionHandler: cause the receiver to be 
retained until after the completion handler returns?

   NSAlert *alert = [NSAlert new];
alert.alertStyle = NSWarningAlertStyle;
alert.messageText =  @“Do not touch!;
[alert beginSheetModalForWindow:self.window 
completionHandler:^(NSModalResponse returnCode) {
[alert orderOut:self];
}];

Jonathan













___

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