OSX-like toolbar in window chrome? - macos

Many OS X apps use some sort of iconized-tabs in the chrome of the menubar for their preference dialogs. For an wxPython app I would like to create such a preference dialog. Dropbox appears to be using wxPython (see also screenshot), so how would I create such a dialog myself?
Update: After fiddling with wx.Frame.CreateToolBar, the frame begins to resemble the original. However, the style of the radio button (which I probably need for a wx.Notebook) is not what it should be. See also the gradient and borders of the 'General' tab in the image above. (source code)

Dropbox doesn't use wx I'm pretty sure, but you can get this native toolbar with wx. You have to use ctypes and load in some core and carbon frameworks.
There is an article in the wx wiki on how to do it

I think what you want is a custom wx.Dialog with a wx.Toolbook in it. See the wxPython demo package for an example or you can read my tutorial: http://www.blog.pythonlibrary.org/2009/12/03/the-book-controls-of-wxpython-part-1-of-2/3/
UPDATE: I'm not sure if this still applies, but there is a wiki entry on something that sounds a lot like what the OP wants: http://wiki.wxpython.org/NativeMacOSXToolbarSelection

Related

Text tabbed interface new to Lion

I like the new tab interface displayed in the Lion “About This Mac” window. It's not gorgeous, but I think it's extremely useful in presenting information where icons would most probably fail to do a good job.
Question is: is that UI available from standard Cocoa components? I.e., can something similar to it be built with Xcode, without resorting to custom classes with custom drawing code?
Isn't that just a toolbar without images?

wxpython AUI panels dockable but not floatable

I'm having some undesired behavior with movable panels in wxpython. I'm using the wxpython Cocoa build 2.9.2.3 for Python 2.7 on Mac OS X 10.6.7. I'm importing wx.aui and trying to create dockable panels.
I have a panel that I've created a wx.aui.AuiManager on and have added two panels, one on top and one on below. For both of them I have disabled the close button. Right now, the panels can be dragged into different dockable positions on the frame or off of the frame to create a floating window. This window shows up as the Mac native MiniFrame with a disabled close button. I do not want users to be able to separate the panels from the main frame.
I have passed .Floatable(False) to each pane's PaneInfo, but this won't allow the panels to be moved around at all, even if I pass a .Dockable(True)
Can I have panes in AUI that are dockable and movable, but not floatable?
I don't know if there's a way to do that or not. It may be a limitation of wx.aui. You should ask on the wxPython mailing list. Or you could try the mostly drop-in replacement: wx.agw.aui (http://xoomer.virgilio.it/infinity77/AGW_Docs/aui_module.html#aui). It fixes a bunch of bugs in the default wx.aui and is written in pure Python.

How can I create an iOS-style toolbar in my Mac Cocoa application?

Several iLife '11 applications on the Mac use iOS-style black toolbars. For instance, the toolbar at the bottom of this screenshot of iPhoto:
(source: pocket-lint.com)
This sort of look is available in the iOS SDK as "UITabBar."
I am wondering if there is an easy way to achieve this in my ordinary, non-iOS Mac application. If not, what would be the best way to go about creating this effect?
There's nothing that will give you this view out of the box. You'll need to build it yourself.
The simplest method would be to create a custom view with a gradient background and place monochrome buttons in it.
Better would be to create a set of classes similar to NSToolBar that handle positioning, highlighting etc. Even better, build it and then open-source it :-)
However, you'll have to build it yourself. Apart from NSButton there's not much that will help in the pre-existing objects.

Premade Cocoa component for a UI control like this? (rounded rectangle showing a stack of items)

Update
Luckily, the code that WebKit uses to make this control draws onto a canvas using basic drawing operations, so it shouldn't be too hard to convert into a Cocoa control. This is what I have so far:Development progress so far http://img413.imageshack.us/img413/8418/capturedcran20100623074.png
I'll update here again once I get it finished.
Original question
I don't know what to call this sort of control, so I'll show pictures (from the iTunes dialog for a media player and the WebKit Web Inspector's Resource panel):
iTunes showing disk usage using this control http://img13.imageshack.us/img13/8245/capturedcran20100622144.png
Google Chrome's use of the control to show resource download speed http://img695.imageshack.us/img695/8245/capturedcran20100622144.png
I'm interested in using this sort of control in my Cocoa application. I've searched all over the Internets but haven't found much, seeing as I don't know its name - is there some sort of shared component that I can use for this?
Thanks!
On Safari it's implemented using javascript, see: SummaryBar.js.
That's a totally custom control, and I don't know of any open source counterpart (other than the one inside the Webkit source). Would you care to provide one? :)

Window docking advice for Mac

I'm from a Windows programming background when writing tools, but have been programming using Carbon and Cocoa for the past year. I have introduced myself to Mac by, I admit it, hiding from UI programming. I've been basically wapping my OpenGL code in a view, then staying in my comfort zone using my platform agnostic OpenGL C++ code as usual.
However, now I want to start porting one of my more sophisticated applications to Mac OS.
Typically I use the standard Visual Studio dockable MDI approach, which is excellent, but very Windows-like. From using a Mac primarily now for a while, I don't tend to see this sort of method used for Mac UIs. Even Xcode doesn't support the idea of drag and drop/dockable views, unfortunately. I see docked views with splitter panels, but that's about it.
The closest thing I've seen to the Visual Studio approach is Photoshop CS4, which is pretty nice.
So what is the general consensus on this? Is there are more Mac-like way of achieving the same thing that I haven't seen? If not, I'm happy to write a window manager in Cocoa myself, so that I can finally delve in an learn what looks like an excellent API.
Note, I don't want to use QT or any other cross-platform libraries. The whole point is that I want to make a Mac app look like a Mac app, leave the Windows app looking like a Windows app. I always find the cross-platform libraries tend to lose this effect, and when I see a native Mac UI, with fancy Cocoa transitions and animations, I always smile. It's also a good excuse for me to learn Cocoa.
That being said, if there is an Open Source Cocoa library to do this, I'd love to know about it! I'd love to see how someone else achieves this, and would help smooth the Cocoa learning curve.
Cheers,
Shane
UPDATE: I forgot to mention a critical point. I support plugins, which can have their own UI to display various plugin specific information. I don't know which plugins will be loaded and I don't know where their UI will live, if I don't support docking. I'd love to hear people's thoughts on this, specifically: How do I support a plugin view architecture, if the UI can't change? Where do I put the plugin views?
Coming from a Windows background, you feel the need to have docking windows, but is it really essential to the app? Apple's philosophy (in my opinion) is that the designer knows better than the user how things should look and work. For example, iTunes is a pretty sophisticated app, but it doesn't let you change the UI around, change the skin, etc., because Apple wants to keep it consistent. They offer the full view, the mini player, and a handful of different viewing options, but they don't let you pull the source list off into a separate window, or dock it in other positions. They think it should be on the left, so there it stays...
You said you "want to make a Mac app look like a Mac app", and as you pointed out, Mac apps don't tend to have docking windows. Therefore, implementing your own docking windows is probably a step in the wrong direction ;)
+1 to Ken's answer.
From a user perspective unless its integral to the app like it is in Adobe CS or Eclipse i want everything as concise as possible and all the different options and displays out of my way so i can focus on the document.
I think you will find with mac users that those who have the "user skill" to make use of rearranging panels will in most cases opt for hot key bindings instead, and those who dont have that level of "skill" youre just going to confuse.
I would recommend keeping it as simple as possible.
One thing that's common among many Mac apps is the ability to hide all the chrome and focus on your content. That's the point behind the "tic tac" toolbar control in the top right corner of many windows. A serious weakness of many docking UIs is that they expect you to have the window take up most of the screen, because the docked panels can obscure content. Even if docked panels are collapsable, the space left by them is often just wasted and filled with white space. So, if you build a docking panel into your interface, you should expect it to be visible most of the time. For example, iTunes' source list is clearly designed to be visible all the time, but you can double-click a playlist to open it in a new window.
To get used to the range of Mac controls, I'd suggest you try doing some serious work with some apps that don't have a cross-platform UI; for example, the iWork apps, Interface Builder or Preview. Take note of where controls appear and why—in toolbars, in bottom bars, in inspectors, in source lists/sidebars, in panels such as IB's Library or the Font and Color panels, in contextual HUDs. Don't forget the menu bar either. Get an idea of the feel of controls—their responsiveness, modality, sizing, grouping and consistency. Try to develop some taste—not everything is perfect; just try iCal if you want to have something to make fun of.
Note that there's no "one size fits all" for controls, which can be an issue with docking UIs. It's important to think about workflow: how commonly used the control would be, whether you can replace it with direct manipulation, whether a visible indication of its state is necessary, whether it's operable from the keyboard and mouse where appropriate, and so forth. Figure out how the control's placement and behavior lets the user work more efficiently.
As a simple example of example of a good versus bad control placement and behavior in otherwise-decent applications, compare image masking in OmniGraffle and Keynote. In OmniGraffle, this uses the Image inspector where you have to first click on an unlabeled button ("Natural size") in order to enable the appropriate controls, then adjust size and position away in a low-fidelity fashion with an image thumbnail or by typing percentages into fields. Trying to resize the frame directly behaves in a bizarre and counterintuitive fashion.
In Keynote, masking starts with a sensibly named menu item or toolbar item, uses a HUD which pops up the instant you click on a masked image and allows for direct manipulation including a sensible display of the extent of the image you're masking. While you're dragging a masked image around, it even follows the guides. Advanced users can ignore the HUD entirely, just double-clicking the image to toggle mask editing and using the handles for sizing. It should be easy to see, with a few caveats (e.g. the state of "Edit Mask" mode should be visible in the HUD rather than just from the image; the outer border of the image you're masking should be more effectively used) Keynote is substantially better at this, in part because it doesn't use an inspector.
That said, if you do have a huge number of options and the standard tabbed inspector layout doesn't work for you, check out the Omni Group's OmniInspector framework. Try to use it for good, and hopefully you'll figure out how to obsess over UI as much as you do over graphics now :-)
(running in slow motion, reaching out in panic) Nnnnnoooooooo!!!!!
:-) Seriously, as I mentioned in reply to Ken's excellent answer, trying to force a "Windowsism" on an OS X UI is definitely a bad idea. In my opinion, the biggest problem with Windows UI is third-party developers inventing new and inconsistent ways of presenting UI, rather than being consistent and following established conventions. To a Mac user, that's the sign of a terrible application. It's that way for a reason.
I encourage you to rethink your UI app's implementation from the ground up with the Mac OS in mind. If you've done your job well, the architecture and model (sans platform-specific implementation) should clearly translate to any platform.
In terms of UI, you've been using a Mac for a year, so you should have a pretty good idea of "the norm". If you have doubts, it's best to post a question specifically detailing what you need to present and your thoughts on how you might do it (or asking how if you have no idea).
Just don't whack your app with the ugly stick by forcing it to behave as if it were running in Windows when it's clearly not. That's the kiss of death for an app to Mac users.

Resources