Sub views in HUD Panel - objective-c

I am working on OSX 10.10
I am facing a strange problem of sub view colors getting inverted for HUD Panel.
For example the button when set to default button looks right in Xib file but when executed the look and feel of button is modified by the HUD panel.
I am having a HUD Panel in my Xib file as follows
But when executed the button looses its default button status. It looks as follows
How do I maintain the look and feel of the button after execution. User is not able to judge which action will be the default action due to this look and feel

Try
_defaultButton.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];

Interface Builder follows a set of rules but these rules are not context-dependent. The context I'm talking about is "being displayed in a HUD Panel".
The rule applied in this case is "draw a blueish button in Interface Builder if the button is a default button" even if it's not always what happens (cf. what you're seeing in your second screenshot).
I don't know since which OS X version it's working like that, but now controls in HUD Panels are displayed with a different style (which does not have a special color for default button).
You can confirm this Interface Builder comportment by adding a simple NSTextField in your HUD Panel, it'll draw with a white background in Interface Builder but it will have a black background when running with a gray focus ring.
Interface Builder:
OS X 10.10:
I've never found a way to disable this special styling for controls in HUD Panel but several workarounds (the default button is still working correctly even if not having a special color).
The special styling only occurs when your HUD Panel have a title bar.
self.panel.styleMask = (NSHUDWindowMask | NSTitledWindowMask | NSUtilityWindowMask | NSNonactivatingPanelMask);
If you remove the title bar, it'll display without any special styling:
self.panel.styleMask = (NSHUDWindowMask | NSUtilityWindowMask | NSNonactivatingPanelMask);
At this point, you can implement and draw your own title bar in the panel and mimic the default one. I don't really like this approach because first it's a lot of work for a simple button and the custom styling of controls make them prettier and more easy to read in a HUD Panel.
Another solution was the 'VLC' way. They use HUD Panels but their controls don't have any special styling. They're using BGHUDAppKit which was released when Apple provided HUD Panel without any special controls to go with it. They use it to force the bluish style instead of the greyish one which are now used by default in HUD Panels.
I didn't really like this approach too, I didn't want to add a library for a simple button, library not updated since 2011.
What I end up doing was drawing a custom button (with a simple subclass) for default buttons in a HUD Panel. This solution is quick and allow you to choose the color you want for default button in a HUD Panel (blueish may not be the best for a HUD Panel, your call).

Related

Yosemite Toolbar Style

How do I get the new toolbar item style of OSX Yosemite?
I created a standard toolbar, but the buttons don't have that button-like look. Do I need to drag actual buttons to the toolbar to get this look?
What I have:
What I want (that round bezel and white background):
There are two types of items in toolbars, image items and view items. It looks like you have an image item. You seem to want a view item where the view is an NSButton configured as a round textured button. So, yes, you should drag actual buttons to the toolbar.
I would not attempt to control the button background. You should use the button as-is to get the default system appearance. Apple recommends using a PDF template image (all black with the alpha channel used to make the image). The button itself would not have a title/label. Rather that would be on the containing toolbar item.
It looks like you may have applied an internal blue "glow" or highlight to your image. Generally, you should not do that. Let the frameworks apply appropriate effects to the template image automatically based on the button state and shows-state-by mode.
Toolbars in the Human Interface Guidelines
Controls which are appropriate to use in the window frame (including the toolbar)
Designing images for toolbar buttons
Works just fine for my Cocoa app under Yosemite -
are you actually setting the template property for your icon images..?
From the NSImage docs:
The 'template' property is metadata that allows clients to be smarter
about image processing. An image should be marked as a template if it
is basic glpyh-like black and white art that is intended to be
processed into derived images for use on screen.

Disable/Customize NSPopUpButton animation in 10.10 Yosemite

Context:
In OS 10.10, Apple added some new subtle animations to various controls. For example, when you check a checkbox, the blue "checked" state now animates in by expanding outward from the center of the checkbox rather than abruptly switching to the "checked" image.
Similarly, when you open an NSPopUpButton and choose an item from the menu, the menu animates closed and the selected item appears to "zoom into" the popUpButton.
The Problem:
I have customized NSPopUpButtons that draw themselves differently than the default NSPopUpButton:
When I select an item in the pop-up menu, the new animation in 10.10 briefly shows the system-default popUpButton style while animating in (blue right-hand side, etc.).
Here's a screenshot of the animation in progress, showing the system-default popUpButton animating in. (The dark-grey rectangle in the back is the "pressed" state of my custom NSPopUpButton):
What I Need
This animation obviously looks terrible with customized controls. Is there any way to disable it or to customize it? I have been unable to find one.
Turning off the Bordered property in Interface Builder seems to do the trick.
Here’s a comparison of Bordered on and Bordered off.
Please note that the Bordered property was showing as being off by default, when it’s actually on. I just had to check then uncheck it to disable it.

Make an NSToolbar's fullScreenAccessoryView visible at launch

I am trying to make an application with a toolbar controller which view is shown, and for each view shown I want to include a second 'row' for the toolbar, and I found out that to do this you had to do [toolbar setFullScreenAccessoryView:view]. However, the view does not appear until the user toggles fullscreen mode and the accessory view remains after toggling the window back to windowed mode. I would like it to look like the following examples from Mail.app, Preview.app, Dictionary.app:
just place a custom view underneath the NSToolbarView .. so at the top of the window.
dont misuse the fullscreenAccessory view. it if meant for something else.
see How to create a toolbar with "Search" Finder style, rounded buttons working like radio
(it could be any other view too btw :D)

Cocoa - Replicate mail button bar

How do I replicate the appearance of the button bar in the Mail App? I'm pretty close, but I cannot seem to get the colors to work the way I want.
If I set the background color for the view containing the buttons, it won't look the same as the NSTableView above it when the window loses focus.
Here is my app with focus:
My app without focus:
Mail.app with focus:
Mail.app without focus:
So in short, I want the same behaviour as the mail button bar with or without focus. How would one do that?
After spending a lot of time on this and then after finally asks a question here, I manage to fix it.
What I did was adding a bottom bar in IB and then programmatically setting the same color on the bottom bar as the background color on the NSTableView.

iOS layout: alternative to tabs?

I'm working on a iPhone app which shows an mobile webform in a UIWebView. I'm using a default iOS layout with a navigation and tab bar.
The mobile webform is displayed in a UIWebView in the white area. Since the webform has a lot of input fields, we really need as must space for it as possible. Because of this, we are planing to remove the tabs in the bottom. Over time, there will be more tabs/sections, so it is not a solution to just add a button for each section in the left side of the navigation bar. On a iPad a popover could easily be used to handle this.
Is there a standard iOS layout mechanism to handle this change of sections/views without using tabs?
You could do something long the lines of Path or the new Facebook app and have the "table of contents" behind the Navbar and the navbar slides away (along with the child view) to reveal it. When done right (ie smoothly) I think the effect is really cool.
This would also work great as you add more and more options, since the table could just scroll.
Here is a framework that might be you started: http://www.cocoacontrols.com/platforms/ios/controls/iiviewdeckcontroller
I would consider replacing the navigation bar's title with a control that lets you switch between tabs. You can assign the bar's titleView property to a control or a button and it will generally do the right thing.
If you're limited to 2-3 tabs, you could simply use a UISegmentedControl.
If you want more, you could use a button which, when tapped, pops up a view that allows you to select the view you want. This could be a modal table view, or you could slide up a UIPickerView from the bottom of the screen, similar to the keyboard.
I use this technique in an app of my own, screenshots here. Tapping the button cycles between views (in this case, I'm changing the contents of the table cells); tap-and-hold slides up a picker.
Another possibility would be to arrange your different forms on pages in a scroll view with a page control at the bottom, à la Weather. The best option, though, if you’re going to have a particularly long list and want to keep your screen real estate, is probably the FB/Path-style sidebar table.
I ended up using a UIActionSheet but I think it in other situations would be more stylish to use a controller like the IIViewDeckController.