Re: UI to allow user to scale and crop image within a circle

2016-02-24 Thread David Duncan

> On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>  wrote:
> 
> On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote:
>> 
>> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> passed in to drawRect(). I must not understand what that parameter is for.
> 
> From the UIView documentation for ‘drawRect’:
> 
>> The portion of the view’s bounds that needs to be updated. The first time 
>> your view is drawn, this rectangle is typically the entire visible bounds of 
>> your view. However, during subsequent drawing operations, the rectangle may 
>> specify only part of your view.
> 
> 
> So, yes, your code is right now. :)
> 

Its almost right – drawing should be done based on the bounds not the frame 
(this will be an issue if you either use the frame.origin or if you transform 
the view).

> ___
> 
> 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

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

IB and size class-based constraints

2016-02-24 Thread Rick Mann
I have a size class-enabled storyboard with a view controller that contains two 
view. They are to be stacked in everything except a compact height situation, 
in which case they should be side-by-side.

So, the lower view has two top constraints. One specifies the space to the 
other view, the other specifies the space to the container.

The first of these is installed only for "w Any h R", and the other installed 
only for "w Any h C". But when I put IB into "w Any h Any" mode, it complains 
that the Y position is not set for that view.

Am I missing something?

-- 
Rick Mann
rm...@latencyzero.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: ARC code in a non ARC app. iOS

2016-02-24 Thread Dave
Also, beware subclassing a Non-ARC Class in an ARC Project - you have to have 
the subclass Non-ARC too.



___

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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread Charles Jenkins
Good tip! Thanks, Dave and Quincey. I was pretty sure the problem was something 
embarrassingly basic.

The next step is to redesign the CircleOverlayView to fill its view with black 
except for the center of the circle. I already learned that filling the view 
with black and then filling the circle with clearColor() doesn’t work! My guess 
is, you do this by adding a mask layer; but you probably don’t redraw the mask 
in drawRect(), hm? It should never need to be refreshed unless the bounds 
change.

Assuming I can figure out how to make a mask layer, what is the correct way to 
monitor for a bounds change in order to recreate the mask?

-- 

Charles

On February 24, 2016 at 03:16:00, David Duncan (david.dun...@apple.com) wrote:


> On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>  wrote:  
>  
> On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote:  
>>  
>> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> passed in to drawRect(). I must not understand what that parameter is for.  
>  
> From the UIView documentation for ‘drawRect’:  
>  
>> The portion of the view’s bounds that needs to be updated. The first time 
>> your view is drawn, this rectangle is typically the entire visible bounds of 
>> your view. However, during subsequent drawing operations, the rectangle may 
>> specify only part of your view.  
>  
>  
> So, yes, your code is right now. :)  
>  

Its almost right – drawing should be done based on the bounds not the frame 
(this will be an issue if you either use the frame.origin or if you transform 
the view).  

> ___  
>  
> 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/david.duncan%40apple.com  
>  
> This email sent to david.dun...@apple.com  

--  
David Duncan  

___

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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 4:08 AM, Charles Jenkins  wrote:
> 
> Good tip! Thanks, Dave and Quincey. I was pretty sure the problem was 
> something embarrassingly basic.
> 
> The next step is to redesign the CircleOverlayView to fill its view with 
> black except for the center of the circle. I already learned that filling the 
> view with black and then filling the circle with clearColor() doesn’t work! 
> My guess is, you do this by adding a mask layer; but you probably don’t 
> redraw the mask in drawRect(), hm? It should never need to be refreshed 
> unless the bounds change.
> 
> Assuming I can figure out how to make a mask layer, what is the correct way 
> to monitor for a bounds change in order to recreate the mask?

You can’t fill with clear color with normal blending because clear color has 0 
alpha. You can however fill it with the copy blend mode.

> 
> -- 
> 
> Charles
> 
> On February 24, 2016 at 03:16:00, David Duncan (david.dun...@apple.com 
> ) wrote:
> 
>> 
>> > On Feb 23, 2016, at 7:17 PM, Quincey Morris 
>> >  wrote: 
>> >  
>> > On Feb 23, 2016, at 18:50 , Charles Jenkins  wrote: 
>> >>  
>> >> I draw based on the overlay view’s frame, NOT based on the rect that gets 
>> >> passed in to drawRect(). I must not understand what that parameter is 
>> >> for. 
>> >  
>> > From the UIView documentation for ‘drawRect’: 
>> >  
>> >> The portion of the view’s bounds that needs to be updated. The first time 
>> >> your view is drawn, this rectangle is typically the entire visible bounds 
>> >> of your view. However, during subsequent drawing operations, the 
>> >> rectangle may specify only part of your view. 
>> >  
>> >  
>> > So, yes, your code is right now. :) 
>> >  
>> 
>> Its almost right – drawing should be done based on the bounds not the frame 
>> (this will be an issue if you either use the frame.origin or if you 
>> transform the view). 
>> 
>> > ___ 
>> >  
>> > 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/david.duncan%40apple.com 
>> >  
>> > This email sent to david.dun...@apple.com 
>> 
>> -- 
>> David Duncan

--
David Duncan

___

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

When to remove Gesture Recognizers

2016-02-24 Thread Dave
Hi All,

I’m adding a Gesture Recognizer to a view in the awakeFromNIB method. This 
works ok but I’m getting crashes sometimes and I’m wonder it its because I’m 
not removing it? If so, when is the best place to call RemoveGestureRecognizer?

Thanks a lot
All the Best
Dave


___

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: When to remove Gesture Recognizers

2016-02-24 Thread Quincey Morris
On Feb 24, 2016, at 12:17 , Dave  wrote:
> 
> I’m adding a Gesture Recognizer to a view in the awakeFromNIB method. This 
> works ok but I’m getting crashes sometimes and I’m wonder it its because I’m 
> not removing it? If so, when is the best place to call 
> RemoveGestureRecognizer?

I add them in viewWillAppear and remove them in viewDidDisappear (of the 
relevant view controller, of course). I don’t see any point in adding them when 
the view loads, since they’re only effective when the view is present in the 
“live” view hierarchy, hence appear/disappear seems appropriate.

I dunno what anyone else thinks, but in may mind the trend is away from doing 
anything in awakeFromNIB, if for no other reason than you don’t know for sure 
how many times it will be called. For things that need to be done after NIB 
loading, viewDidLoad (or windowDidLoad) seems like a better choice.

___

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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread Graham Cox

> On 24 Feb 2016, at 11:08 PM, Charles Jenkins  wrote:
> 
> My guess is, you do this by adding a mask layer; but you probably don’t 
> redraw the mask in drawRect(), hm? It should never need to be refreshed 
> unless the bounds change.


Can you not just use a clipping path? They’re usually much easier to set up 
especially for simple cases like this than a mask layer.

e.g. the simplest way I can think of drawing this is a) draw your image at the 
correct size and position, b) form a clipping path from the bounds rect plus 
the desired circle, setting the winding rule if necessary so that the path 
includes all of the area of your view EXCEPT the circle. c) paint over the 
entire view in a solid colour (black I think you said). The clipping path 
ensures that you won’t paint over the circular aperture that shows the image.

> Assuming I can figure out how to make a mask layer, what is the correct way 
> to monitor for a bounds change in order to recreate the mask?


Override -setFrame:, call super then do what you need to do.

However, if you use a clipping path, you can just create this on the fly as 
part of -drawRect: and so it’ll always be correct, and you won’t need to do 
this. There’s no reason to cache this path unless it’s really complex and 
expensive. Hint: it’s not, it’s a circle.

—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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 1:44 PM, Graham Cox  wrote:
> 
> 
>> On 24 Feb 2016, at 11:08 PM, Charles Jenkins  wrote:
>> 
>> My guess is, you do this by adding a mask layer; but you probably don’t 
>> redraw the mask in drawRect(), hm? It should never need to be refreshed 
>> unless the bounds change.
> 
> 
> Can you not just use a clipping path? They’re usually much easier to set up 
> especially for simple cases like this than a mask layer.
> 
> e.g. the simplest way I can think of drawing this is a) draw your image at 
> the correct size and position, b) form a clipping path from the bounds rect 
> plus the desired circle, setting the winding rule if necessary so that the 
> path includes all of the area of your view EXCEPT the circle. c) paint over 
> the entire view in a solid colour (black I think you said). The clipping path 
> ensures that you won’t paint over the circular aperture that shows the image.
> 
>> Assuming I can figure out how to make a mask layer, what is the correct way 
>> to monitor for a bounds change in order to recreate the mask?
> 
> 
> Override -setFrame:, call super then do what you need to do.

-layoutSubviews would be better, as in general if you need to override 
-setFrame: for something, you also need to override -setCenter: and 
-setBounds:. If you need to ensure animation works, you can call 
-layoutIfNeeded inside of your animation block.

But since your drawing something, a clipping view isn’t necessary – you can 
just clip your drawing.

> 
> However, if you use a clipping path, you can just create this on the fly as 
> part of -drawRect: and so it’ll always be correct, and you won’t need to do 
> this. There’s no reason to cache this path unless it’s really complex and 
> expensive. Hint: it’s not, it’s a circle.
> 
> —Graham
> 
> 

--
David Duncan


___

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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread Quincey Morris
On Feb 24, 2016, at 13:44 , Graham Cox  wrote:
> 
> However, if you use a clipping path, you can just create this on the fly as 
> part of -drawRect: and so it’ll always be correct

I don’t recall Charles’s drawing code exactly, but I think this is just part of 
the solution. It’ll always be correct for the part of the view being drawn, but 
there’s no guarantee that the whole view will be redrawn if the relationship 
between the bounds origin and the circle changes. I think Charles still needs 
something to force redrawing of the whole view when the view geometry changes.

Of course, if the view geometry never changes, or the relationship of the 
circle to the bounds origin never changes, then I think the forced redrawing 
isn’t necessary.

___

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: UI to allow user to scale and crop image within a circle

2016-02-24 Thread David Duncan

> On Feb 24, 2016, at 3:47 PM, Quincey Morris 
>  wrote:
> 
> On Feb 24, 2016, at 13:44 , Graham Cox  > wrote:
>> 
>> However, if you use a clipping path, you can just create this on the fly as 
>> part of -drawRect: and so it’ll always be correct
> 
> I don’t recall Charles’s drawing code exactly, but I think this is just part 
> of the solution. It’ll always be correct for the part of the view being 
> drawn, but there’s no guarantee that the whole view will be redrawn if the 
> relationship between the bounds origin and the circle changes. I think 
> Charles still needs something to force redrawing of the whole view when the 
> view geometry changes.

By default -setNeedsDisplay will dirty the entire view for redraw. 
-setNeedsDisplayInRect: can be used for partial updates, but typically you will 
call that directly. If you always draw inside of the whole bounds of the view 
however, you are generally insulated from origin changes (as either 
setNeedsDisplay method should do the right thing in these circumstances).

> 
> Of course, if the view geometry never changes, or the relationship of the 
> circle to the bounds origin never changes, then I think the forced redrawing 
> isn’t necessary.
> 

--
David Duncan

___

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 code in a non ARC app. iOS

2016-02-24 Thread Greg Parker

> On Feb 24, 2016, at 2:31 AM, Dave  wrote:
> 
> Also, beware subclassing a Non-ARC Class in an ARC Project - you have to have 
> the subclass Non-ARC too.

This is not true. For example, NSView is not ARC but you can write ARC 
subclasses of it.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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 code in a non ARC app. iOS

2016-02-24 Thread Britt Durbrow
Tangentially related: 

I have a bug ( rdar://10894595 ) open on the Developer Tools (Xcode/clang) to 
add a #pragma to turn on/off ARC in the source code, for dealing with just such 
situations.

I dunno’ how much work it would be to implement… I imagine not all that much 
for somebody familiar with the internals of clang, but I could be wrong…


:-)
___

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