 |
 |
The green window at the top of iTunes...
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Hello,
I am currently trying to learn Objective-C and Cocoa in order to write an app I have in mind... I have programmed a little in C before, and am currently about two-thirds through Steve Kochan's excellent book, with Hillegass lined up next...
That said, whilst I've been learning the basics I have been playing around with Interface Builder just to see what's easy to set up and what isn't, just to get an idea of what is "free" for my app and what is going to take a lot of work.
One thing I would like to implement is a text field at the top of my app's main window that is set inside a window that looks like the rounded green window at the top of iTunes (where the currently playing song is displayed). Mellel has something similar to display the currently selected style.
I thought this would just entail setting NSTextView to rounded and setting the background colour, but it seems it will be more complicated than that (the height of NSTextView cannot be changed when it is set to rounded, even though it can when it is square; and moreover the background colour only affects the text itself, not the rounded parts at the edges). Does anybody know what type of view is used at the top of iTunes (or Mellel)? Would it entail subclassing a custom view and setting up the background colour and edges, and then making the NSTextField a subview of that, for instance? Or would it be more complicated (actually that's complicated enough at my stage)?
Apologies for leaping ahead of myself.
Thanks,
KB
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2003
Location: Atlanta, GA
Status:
Offline
|
|
Well, what you want to do violates the HIG, but you could do it anyway.
The easiest way to do it would be to make an image that has the rounded sides and green background (you could probably just use iTunes' image) and put that in a borderless imageView. Then, just put a textView on top of the image.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Many thanks for the reply.
If I put it in an image view, though, what when the window gets resized? In that case, the green window should get smaller but retain the rounded edges, but if it was just an image of a set size, one of the rounded ends would disappear when resizing... Or if the image was set to resize, then the rounded edges would resize too, which shouldn't happen... Or am I missing something?
As for the HIG, I have them printed off ready to go through them before starting my app proper - whereabouts does it say that what I am looking to do is in violation? I am guessing that this is going to be a balancing act between conforming and violating "sensibly", as from what I have seen and read, Apple themselves violate their own HIG regularly...
Thanks again,
KB
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
To further muddy the waters, iTunes is a Carbon app...
Steve W
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by techtrucker:
To further muddy the waters, iTunes is a Carbon app...
What does that have to do with anything?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2003
Location: Atlanta, GA
Status:
Offline
|
|
Originally posted by Ambit:
Many thanks for the reply.
If I put it in an image view, though, what when the window gets resized? In that case, the green window should get smaller but retain the rounded edges, but if it was just an image of a set size, one of the rounded ends would disappear when resizing... Or if the image was set to resize, then the rounded edges would resize too, which shouldn't happen... Or am I missing something?
Thanks again,
KB
What you could do is make 3 images; a left side, a middle, and a right side. The left and right side images would not stretch. The middle background would, and it would preserve the corners.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Originally posted by Angus_D:
What does that have to do with anything?
I thought this would just entail setting NSTextView to rounded and setting the background colour
Merely pointing out to the original poster that iTunes was not created with Cocoa/Interface Builder since he clearly states that he is working with Cocoa/Objective-C/IB. Believe it or not not everyone realizes iTunes is a Carbon app.
Steve W
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Allow me to apologize in advance for being a little testy. Angus_D, you are right, rather than posting a sentence like "to further muddy the waters..." I should have posted the fact that iTunes is a Carbon app, and one that doesn't use nib files. My intent was merely to keep him from looking in the wrong direction to solve his problem.
Being unemployed due to offshore outsourcing is taking its toll on me. Again I'm sorry, let's get back to trying to help Ambit out. I myself was always curious how Apple did that window, a quick peak into the package contents of iTunes revealed a couple of rsrc files but nothing useful. If it were a Cocoa app I would definitely take a look at using a custom view.
Steve W
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Yeah, but that's generally irrelevant. There's no magical standard iTunes control in Carbon, either (iTunes renders its UI itself for various reasons, one of which being cross-platform compatibility). Since he already stated he was using Cocoa, and people responded telling him how to do something similar in Cocoa, I don't see what the relevance of that statement is.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Thanks for the replies.
hyperb0le - thanks for the suggestions, I guess I'll try this out. I was hoping that there would be a simpler way of doing it, for instance by setting up a custom window that had rounded edges, a set colour background, and which could contain an NSTextField as a subview... I guess I'll have a crack at different methods (though like I say, I'm still learning Cocoa, so it's hard to figure the right tack).
Whilst searching the net to see if there was any info on how to do what I want to do, I did come across the fact that iTunes is written in Carbon. However, Mellel ( www.redlers.com) uses exactly the same sort of panel to display information on paragraph styles, and Mellel was written using Cocoa (according to their website, anyway), so I guess this doesn't make any difference (but thanks for mentioning it anyway).
Any other suggestions much appreciated.
Thanks,
KB
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status:
Offline
|
|
I kind of reverse engineered the iTunes display for my cocoa app. It's open source, feel free to take my images and nib stuff (the images were screengrabbed from iTunes). I forget if you have to use any code to creat the text fields; I don't think so.
http://metahoot.3ivx.com
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Ambit,
The following may or not be of any help at all, just trying to see if I can be of any assistance:
I downloaded and took a look at Mellel. Just in case you're not familiar with the process of looking into the contents of an app package: Right (or ctrl) click on Mellel, select Show Package Contents from the menu. Navigate through to Contents/Resources/English.lproj (or your language of choice). You'll find a nib file called DocumentWindow.nib, and it looks like this in IB:
And if you were to look at the tiffs in the Contents/Resources folder you will find three tiffs related to the style well:
So it appears that the suggestion of using 3 images was exactly what the authors of Mellel did.
Please understand that the above is not really telling you how to accomplish what you want to do, it is merely an indication of how someone else achieved the desired result. Perhaps creating your own set of tiffs and experimenting with custom views you can come up with an answer.
Steve W
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
Ambit,
I quickly set up a Cocoa app and in the nib file put the three images on a textured window as 3 separate borderless image views. I can get the center one to resize when the window resizes. The part I haven't figured out is "locking" the left and right images in place. As time permits I may play around with it some more, but I wanted to offer the project to you to download and check out. Be sure to let us know how you do.
Steve W
http://eagle.he.net/~sjwood/greencontrol.zip
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Thanks again for the replies.
An especially big thank you to hyperb0le and techtrucker - between you, you have put me on the right path, I really appreciate it.
techtrucker - many thanks for actually taking the time to look at Mellel and then throw together a quick app just to help - *really* appreciated. Actually, I had no idea I could look inside a program's contents like that. I only bought my first Mac about a month ago; the C experience I have was all on Windows, but as I liked my Mac so much and as it comes with free dev tools I thought I'd start trying to learn how to program for it right from the get-go, so I'm learning the simple things at the same time as the more complicated stuff.
And following on from techtrucker's explorations into Mellel (thanks again!), I have to say a big thank you to hyperb0le, who got it right all along. So I will indeed be using the three image approach.
Many thanks again for all the helpful replies,
KB
P.S. Thanks to Uncle Skeleton, too - I am going to check out your app, as it looks like it has some very useful stuff in there.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
I am admittedly weak on this kind of work, I'm primarily a database developer. But I take a keen interest in things that I don't know too much about, when it comes to software development I'm like a sponge.
Hey Ambit, I too got my start with C and Windows, developed Win16 and some early Win32 apps before discovering the Mac. Taking on some side jobs as a consultant while seeking full time work, and one of the projects is updating a Win32 app I wrote back in 96!
Being able to see the package contents is a missed blessing: As a developer you can almost feel violated! It can be a useful learning tool. BTW, if you ever want to turn on/off the metalized (textured) appearance in Cocoa apps you could do what I described above. I've been running a metalized Mail.app for a long time now...
There may be better ways to do what you want to do. But I hope what we were able to come up with here in this thread gets you going.
Again, be sure to keep us posted on your progress!
Steve W
|
|
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|