Re: Trying to create a 1px width NSBox

2015-03-10 Thread Uli Kusterer
On 09 Mar 2015, at 01:22, Patrick J. Collins  
wrote:
>> Not sure why you'd waste time trying to bend unsuitable UI components to 
>> your will instead of building a custom view.
>> It's super easy and it always does exactly what you design it to do.
> 
> Well I guess I can ask the reverse question of, why does Apple waste
> their time creating and offering a "vertical line", if it's not useful?
> I mean, all I want is a vertical line.  I don't understand why something
> like that exists if it's not customizable.

 It’s not intended as a generic vertical line. The same control used to be 
called a “separator” in Carbon, which might make it more clear what this is 
intended for: It is a line that separates two groups of UI elements, just like 
NSBox. In fact, as you noticed, the view created when you drag a “vertical 
line” actually *is* just an NSBox in a special “draw a straight line” mode.

 But really, who cares if the view is 5pt wide as long as it draws the line 1px 
wide? In fact, it’s a good thing this view is 5pt wide, because if you’ve ever 
tried to hit a 1pt object with a mouse, you’ll have noticed that it is very 
hard to do. Which is exactly why the HIG has been recommending a minimum 8pt 
width for clickable objects. Look at the 1-line pane separators in Mail.app: 
They actually accept clicks several pixels to their left and right.

 Also, given NSBox has a “custom” drawing mode, have you tried just setting it 
to “Custom” using the respective NSBox methods on the view and set its line 
color?

 That said, are you sure you want to hard-code this to be a line? Usually one 
creates an image file containing the appearance of the image and then uses a 
layer or a layer-backed NSImageView to draw it. That way, if your graphics 
designer wants to give the line an emboss, or make it thicker, or give it a bit 
of shading, your code doesn’t need to change. Since you probably want to be 
able to drag it, you’d need a custom view to handle the tracking anyway, so I’d 
recommend a custom NSView. Make it layer-backed and set its layer’s contents to 
your image (setting the anchor so the image is centered in the view). That way, 
the GPU will take care of compositing the image, and won’t have to re-upload 
the entire window contents whenever the user drags, saving laptop users battery.

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


___

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: Trying to create a 1px width NSBox

2015-03-08 Thread Jonathan Hull
If you have layers enabled, you can just use an ordinary 1pt wide NSView and 
set the background color of its layer to black (or whatever color you want).  
No need to subclass.

Thanks,
Jon


> On Mar 8, 2015, at 12:02 PM, Patrick J. Collins 
>  wrote:
> 
> I am trying to create a "playhead" that will move across a waveform, and
> IB shows a "Vertical line" component which looks exactly what I want..
> Except it seems to have a default unchangable width of 5px... ???
> I tried setting the borderType property to NSNoBorder but that
> made no difference.
> 
> How can I get a simple 1px solid colored object that I can use for
> this purpose?
> 
> Patrick J. Collins
> http://collinatorstudios.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/jhull%40gbis.com
> 
> This email sent to jh...@gbis.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: Trying to create a 1px width NSBox

2015-03-08 Thread Jerry Krinock
I did this cheesy hack – used a “Vertical Line” from the IB library to get a 
black line – until Yosemite when it became a gray line :(

Do as Graham says.  Draw your own line instead.


___

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: Trying to create a 1px width NSBox

2015-03-08 Thread Graham Cox

> On 9 Mar 2015, at 11:22 am, Patrick J. Collins 
>  wrote:
> 
> Well I guess I can ask the reverse question of, why does Apple waste
> their time creating and offering a "vertical line", if it's not useful?
> I mean, all I want is a vertical line.  I don't understand why something
> like that exists if it's not customizable.


It exists for its designed purpose, which is to create a visual separator 
between controls (in a dialog box, say), should you want that. In other words, 
a piece of window decoration. It's not designed to move (other than with the 
controls it's associated with if the window is resized), and it's definitely 
not intended to be used as a playhead in a sound playback situation.

Drawing a vertical line is trivial: +[NSBezierPath 
strokeLineFromPoint:toPoint:] for example, or CGContextStrokeLineSegments(),  
so why you'd go looking for a much more complicated object (an entire NSView 
subclass with all its attendant properties) to do that I can't think.

--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: Trying to create a 1px width NSBox

2015-03-08 Thread Patrick J. Collins
> Not sure why you'd waste time trying to bend unsuitable UI components to your 
> will instead of building a custom view.
> It's super easy and it always does exactly what you design it to do.

Well I guess I can ask the reverse question of, why does Apple waste
their time creating and offering a "vertical line", if it's not useful?
I mean, all I want is a vertical line.  I don't understand why something
like that exists if it's not customizable.

Patrick J. Collins
http://collinatorstudios.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: Trying to create a 1px width NSBox

2015-03-08 Thread Graham Cox

> On 9 Mar 2015, at 6:09 am, Steve Mills  wrote:
> 
>> On Mar 8, 2015, at 14:02, Patrick J. Collins  
>> wrote:
>> 
>> I am trying to create a "playhead" that will move across a waveform, and
>> IB shows a "Vertical line" component which looks exactly what I want..
>> Except it seems to have a default unchangable width of 5px... ???
>> I tried setting the borderType property to NSNoBorder but that
>> made no difference.
>> 
>> How can I get a simple 1px solid colored object that I can use for
>> this purpose?
> 
> For a playhead, I think you'd be better off either creating a custom view 
> subclass and handling drawRect:, or put an overlay on top of you waveform 
> view and draw the playhead there.


+1

Not sure why you'd waste time trying to bend unsuitable UI components to your 
will instead of building a custom view. 
It's super easy and it always does exactly what you design it to do.

--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: Trying to create a 1px width NSBox

2015-03-08 Thread Quincey Morris
On Mar 8, 2015, at 12:02 , Patrick J. Collins  
wrote:
> 
> Except it seems to have a default unchangable width of 5px... ???

In IB, if you set the metrics inspector tab to “Alignment” rather than “Frame”, 
it shows as 1, not 5. The actual frame of the NSBox view isn’t important, if 
the view draws the line thickness you want and is transparent elsewhere.

> How can I get a simple 1px solid colored object that I can use for
> this purpose?


You don’t want 1 px, you want 1 pt. Thinking in pixels is going to get you 
messed up when it comes to retina displays.

A different approach is to use an image view, and design your own vertical line 
as an image. If you design the image properly, when you bring the image into 
your Xcode .xcassets file, you can get it sliced so that it’s stretchable 
vertically. (This is 10.10 only. In earlier versions of OS X you have to use 
the 3- or 9-part image drawing API to get the same result, which means you’d 
need a custom view.)

That way you can have a line that will adapt to any height, and can have a nice 
gradient treatment (for example) at the top and bottom. You could also make it 
wider than 1pt and partially transparent, except perhaps for a 1pt center line, 
so that it’s easier to see than a simple 1pt-wide shape, but it won't obscure 
much of what’s under it.



___

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: Trying to create a 1px width NSBox

2015-03-08 Thread edward taffel
derive your own custom class from NSView & render how you like in - 
(void)drawRect:(NSRect)dirtyRect

> On Mar 8, 2015, at 3:02 PM, Patrick J. Collins 
>  wrote:
> 
> I am trying to create a "playhead" that will move across a waveform, and
> IB shows a "Vertical line" component which looks exactly what I want..
> Except it seems to have a default unchangable width of 5px... ???
> I tried setting the borderType property to NSNoBorder but that
> made no difference.
> 
> How can I get a simple 1px solid colored object that I can use for
> this purpose?
> 
> Patrick J. Collins
> http://collinatorstudios.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/etaffel%40me.com
> 
> This email sent to etaf...@me.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: Trying to create a 1px width NSBox

2015-03-08 Thread Steve Mills
> On Mar 8, 2015, at 14:02, Patrick J. Collins  
> wrote:
> 
> I am trying to create a "playhead" that will move across a waveform, and
> IB shows a "Vertical line" component which looks exactly what I want..
> Except it seems to have a default unchangable width of 5px... ???
> I tried setting the borderType property to NSNoBorder but that
> made no difference.
> 
> How can I get a simple 1px solid colored object that I can use for
> this purpose?

For a playhead, I think you'd be better off either creating a custom view 
subclass and handling drawRect:, or put an overlay on top of you waveform view 
and draw the playhead there.

Steve via iPad


___

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