How to Host Apple's Pitch Shift Audio Unit plugin and the like - objective-c

How do you host the PitchShift Audio Unit plugin correctly in its own window?
I am developing a Mac app that hosts Apple's system supplied Audio Unit plugins. With the new OSX 10.7 Lion, some of the plugins have updated views. PitchShift is one of these.
PitchShift and a few others have new knobs to change there parameters. When a knob is being turned with the mouse, a horizontal bar showing the knob's parameter value is displayed below the knob.
This bar stays on screen after the knob is released and even after the window is closed. If I click one of the knobs, thus creating a rogue value bar, and move the window the PitchShift view is in, the bar stays where the window used to be. And if I click the knob again at this point, a new bar appears, but both bars are actively updated with the changing knob parameter value information. This happens every time I repeat this process with more bars staying on screen.
After a few times with this happening, my app exits with bad access at NSApplicaionMain() call in the main.m file.
I checked in Logic 9, and this does not happen there. The bar seems to be tied directly to the knob, and thus disappears immediately after you let the knob go with the mouse.
I set the PitchSHift view to be the contentView of a dedicated NSWindow.
How is Logic keeping this from happening, or just how can I?
I've tried seeing if the parameter value bars where subviews of the PitchShift view, but they don't seem to be.
Any help would be greatly appreciated.
EDIT: When the a value bar first appears, I get the following output in the console from my program: Circle and line do not intersect
So I've found that it is using core-animations CALayers. The problem now is that the value bar layers aren't a part of the PitchShiftView's layer hierarchy. In other words, I can find all the other layers that build up the pitchShiftView, but not the layers for the value bars. Which seems like it might be the whole problem to begin with.

I finally figured it out. The parameter value bars are child windows of the window that owns the audio unit view.
To solve the problem, I catch the mouse up events for the window in my subclass of NSApplication, and I then close the child window (aka the value bar) so that they don't stay on screen.
This did not stop the exit bad access. I now think that is a separate issue that only appeared to be related to these lingering child windows.

Related

First segment of my segment controller doesn't respond

I have a settings screen with a couple of segmented controls on it. All was well until I added a third. Now the new one works, and the top one works, but the one in the middle doesn't...
It used to work fine, but now the first segment doesn't respond. If I click on segments 2 through 4 my controller's method is called as expected. If I click on the first segment... nothing.
I suspect there is another flag somewhere that I hit by mistake, but I can't find it. Yes, all of the segments are Enabled. Any ideas?
I would suggest looking through the hierarchy in detail: the tap is possibly trapped by a partially overlapping view.
If a tap does not respond because the size of an element changes, it may because it is hidden by one of these:
an unconventionally long navigation item
a view with no visible content
a title view
This amazing tool has saved me time and again: Spark Inspector. It shows you the intricate overlapping layers of all your UIViews.

NSPopUpButton in NSToolbar such annoying

Problem solved!:
Just check the "Unified Title And Toolbar" option of the NSWindow and the 1pixel-down problem goes away!
To change the toolbar height just select the Toolbar Item - Custom View and change size in the Size inspector.
==============================
If you know Xcode 5s layout than you should recognise this:
I want to build it for my own. So I dragged a Toolbar in the Window and added a NSPopUpButton. Then I changed the PopUp Button Cell Style to Radio and turned off the Arrows. So far so good.
The first thing I noticed is that the Toolbars has different heights. Does anybody know how to change this behaviour (without subclassing NSToolbar)?
The second and more annoying thing I noticed is that if I choose an Item from the PopUp Button the Image for the NSMenuItem move 1 pixel down.
EDIT: Xcode NSMenuItems don't move 1pixel down
Any suggestions about that thing?
NSToolbar, sadly, can’t really be subclassed. It’s a poorly-written class that tries to be very “magic,” so it’s not even a subclass of NSView—you can’t control how it draws at all, it creates a private view.
You can set its “sizeMode” but I assume you’ve already done that and found that the number of pixels high isn’t what you want.
The easiest thing to do is just leave space for your widgets at the top of your window (above the document content) and have autolayout position your buttons for you. (I haven’t been able to use a real NSToolbar in years because of its limitations.)
As for the popUp menu being mis-aligned with the button: where the menu draws is basically hard-coded, so if you use a button style that NSPopUpButton doesn't expect then the menu will be offset some.
If you’ve already tried just unchecking the “draws border” flag on a default-style NSPopUpButton (one fresh off the palette), There are two solutions for to try: One is to keep trying different buttonStyles that look correct to your eye until you find one that’s not offset. Two is to leave the buttonStyle do the default for NSPopUpButtons but subclass the buttonCell and have it not draw the border (but still leave room for it).

Move Insertion point of an NSTextView and make the written content visible

I am working on one Mac app. In which I want to play few tricks with insertion point of an NSTextView.
![NSTextView with overlay on it][2]
What am I doing is, I have an NSTextView (The whole image screen is of NSTextView) and above that I have placed one overlay (as you can see at the bottom of the image). There are two Labels at the extreme Left and Right end and has a white gradient view too. All these three I have placed above NSTextView.
Now when User types in, textview gets scrolled and at one point, typed letters goes below the overlay.
I have to manage this stuff only. I want to keep track that user has reached to the overlay border and if yes, I want to move the insertion point to little upside so that user can see the content which he/she is writing.
Will anyone suggest me, how to make this possible ?
I have tried many things, but its not working. Kindly help.

How to create an "Add to reading list" animation effect

I'm trying to make an animation effect similar to the one on Safari(iPhone) when you add an element to the reading list. It's similar to the one that appears when starting to download an item from App Store application: the application item drops to the dock to start downloading.
First it bounces up and then goes to the dock. It's a very nice effect that Apple uses on their OS.
I have an image view on screen that I want to drop with this kind of animation to my toolbar in my application.
If there is someone who did it or know what's the name of the effect, could please tell me how to do it.
Thank you.
"Add to reading list" shows no animation on my phone but of your description it sounds like the "Open in background"-animation in Safari (iPhone). My answer describes that animation.
I wrote a thing like that a few months ago and much of it is doable while some of it is not. Your questions showed me that more people are to know how it is done so I wrote a blog post about it. I will describe the high level approach and challenges here but you can read more about it in that post.
Getting to content to animate
If you choose to animate the view that is on screen down to the (in your case) tool bar then you will only have to access its layer. If you want the original view to remain and animate a visual copy (like the "open in background"-Safari animation) down to the bar item then you should create a new layer and draw the content of your layer into an image and set that image as the content of the layer that you are animating
Calculating the end position
The start position of the animation is simply the frame of the view. The end position is very tricky since bar items (both tool bar items and tab bar items) are not UIView subclasses and doesn't have a public view property. This causes problems when you want to shake the bar item later on.
I decided to make a visual approximation of the end position using some simple heuristics. If you know before hand that you will only animate to a single bar item then the end position can be hard coded to a suitable frame.
Animating along a path
There is nothing special to moving, scaling and rotating the layer from the start to the end position. If you want to read more about how I did it you can look at the post I wrote.
Shaking the bar item
This cannot be done without a lot of custom code or using private API at the moment. Since bar items doesn't have a view or a layer there is no accessible layer for you to animate. I guess that you could have a custom animating image that does the shake and set that during the animation and set the new image afterwards. The approach of drawing into an image and animating that doesn't work that well either since there is no accessible layer who can draw its content into the image (you want this for the special effect of the tool bar item and tab bar item).
...put all this together and tweak it to your special needs and you will have an animation that resembles the animation you are looking for.

Possible bug in Interface Builder?

I've a window with a horizontal split view. On the bottom pane of the split view, I have a nssegmentedcontrol, aligned to the center. On the bottom of the nssegmentedcontrol I have 5 tabs that are controlled by the segmented control - click in one of the cells and the corresponding tab opens.
My problem is, if I completely minimize the bottom pane, to the point where the dividing line touches the bottom of the window, the segmented control gets pushed on top of the table header and never goes back to its original place.
I've tried fiddling with IB to get this to work, but no luck. Has anyone experienced this?
Following what's on the comments, I replaced the default split view with the one found in BWToolkit that allows for the definition of minimum and maximum height of each view.
BWTookit is a no go, the framework leakes a lot.
You should use RBSplitView (google it), it also gives you option for min and max height
and I started using it because of a bug in the split view as well, I used it for a chat window
but the split view didn't autosave as it should, every time it got like 2px smaller,
RBSplitView is great, and doesn't leak.