How to use the default color picker in NSToolbar? - objective-c

I'm learning Cocoa. And this is my simple OS X app:
It contains a custom view, where the white rect is drown, a toolbar, and a slider. I want to change the rect's fill color by clicking on the 'Colors' item in the toolbar and choosing new color in the color palette.
How can I get the new color from the palette? I know it has the "NSToolbarShowColorsItem" identifier, but don't know how to use it.
Can you please help me? Thanks.

You should probably consider walking through a couple of basic Cocoa tutorials to learn about fundamental Cocoa concepts.
A number of resources to check out:
CocoaDevCentral
Cocoa Fundamentals Guide
Tutorials on CocoaDev

Related

How to draw colors over a UIImage

I was wondering how you draw colors over a UIImage in objective-c?
The same way that snapchat does it.
I want to make a button that enables the painting with a scroll bar to change the color.
Does anyone know the way that snapchat implements the paint feature?
There's no out-of-the-box way to do this. You'll want to (a) track touch positions over time, and (b) draw them on the screen in a user-selected colour.
There are open-source implementations of this idea, for example https://bitbucket.org/nwoolls/simpledrawing/wiki/Home
Also a bunch of color-picker components here:
https://maniacdev.com/2011/11/open-source-ios-color-picker-components-roundup

Custom Titlebar in a Cocoa Application

I need to create a (very) custom titlebar in a cocoa app. I read about the INAppStoreWindow library, but it seems it doesn't have the feature that I need. So here's what I have need to do (see image for clarification):
My titlebar is the thing between the green and red circle
The text (Text1 - Text3) are all images
The black circle with the exclamation mark is also an image
The grey area below the title bar is a webview. It expands from the left border all the way to the right edge of the reddish sidebar. (This is actually where why I think that the INAppStoreWindow won't work, as I cannot specify a width for the title bar)
The images should have an Action
Text1 through Text3 as well as the black circle load some URL into the webview
Red circle closes the app
My app has no borders and no shadows. Right know in order to be able to move the app I drew a Box element at the top where the title bar should be. I think I can draw something in it as well, but as I'm very knew to cocoa development here are my questions:
How can I draw some images in the Box element?
Is there a better element to draw the titlebar in?
I know that are two questions, but they are closely relatated. It's generally: How to draw a simple titlebar like this?
As the problem inside the titlebar is the same for every item I need to draw (they are all images) I belive there is a quite simple solution for that, but because I lack the experience of how to solve this I'd need your help. You can also point me the the right direction in the comments and I'll answer this question myself after I've got it right.

Gradient button bar like the one found in Xcode 4

The bar I’m looking for is the separator bar between the editor area and the debug area:
Specifically, I want the buttons to have no borders and I want to have the vertical separator (to the left of ‘No Selection’).
I haven’t done any AppKit stuff in Mountain Lion yet, so before I start implementing my own custom control, I was wondering if I have overlooked a new control (or options for existing controls), or otherwise if somebody has already implemented a custom control that does this?
Its just NSButtons with a custom background image (which is the silver effect) and the "Image" which is the control image.
A quick look inside Xcode.app/Contents/OtherFrameworks/DevToolsInterface.framework/Versions/A/Resources will show you the relevant images.

Zoom in and Out through a NSView or Magnify

I am hoping to be able to make something similar to the universal access zoom window shown below. I have already created an NSView and using a fill operation I made a rect with a clear "see through" composite to see through my window and show the desktop. Now I am wondering if it is possible to zoom in and out inside my view just like the picture below. I was thinking this might be an IkImageView or something I could apply but i wasent sure how it was done. Does anyone know how to do this or show me where I could find this in the docs? Some code would be great. Thanks!
Take a look at Apple's example CIAnnotation. In this example is magnifying image but I think You can achieve what You want. You can download sample code from here.
CIAnnotation app example:
References and guides which can help You with this:
Core Image Programming guide
Quartz 2D Programming Guide
NSGraphicsContext Class Reference
NSView supports zoom through - (void)scaleUnitSquareToSize:(NSSize)newUnitSize
This zooms the content of the view, so to use this you would have to set the Desktop behind the mouse as view content (NSImage maybe?) and then zoom the view. It will have to update when the mouse is dragged.
Check the ImageKit part of Quartz, in particular the class IKImageView. It has zoom features, but I have not worked with it myself yet.

Xcode/iTunes/Instruments central toolbar item; what's it called and how do I create one?

I'd like to create a toolbar item like the central item seen in Xcode/iTune/Instruments/etc:
Can anyone tell me what it's called and how to go about creating my own?
Also, will I face problems getting my app approved by Apple when I submit it to the Mac App Store, for imitating Apple's own apps too much?
I finally implemented the solution from here:
iTunes or Xcode style information box at top of window
Here are the initial results:
This is an Apple's private control, but you cannot create it as a NSToolbarItem. Check this other Q/A to know how to add a custom view in the window's main frame.
Is it possible to draw in the label area of NSToolbar?
I've noticed some interesting things about Instruments:
If you make the window narrow such that the overflow menu is triggered, the items in that menu are all blank.
You can't change the icon size or turn labels on/off.
Colors does not have a label when you add it to the toolbar.
The labels on Space, Flexible Space, and Colors do not line up with the other items' labels.
These are interesting because they seem to fit an idea I had for implementing this: turn labels off, and give all your items custom views, where normal-looking items actually have manually drawn labels. It would obviously be a lot of work, but it gives you enough freedom to effectively do full-height items.
The nice thing is that, unlike the view/window hack that Xcode seems to use, you still have a customizable toolbar with draggable items.