Aqua Enhancements
Marsee writes: "Mike Beam looks at two Aqua enhancements -- one seemingly frivolous and the other not: animated window resizing and drawers." O'Reilly's really invested in Mac OS X, and they often have nice articles for developers on a wide range of subjects in their Mac DevCenter.
Take your toy back to the shop and get a REAL computer!
"Why did they cancel my favorite Sci-Fi show? I downloaded ALL the episodes!"
Microsoft Windows has been able to resize windows for ... let's see ... at least 10 years.
Nice to see those Apple folks catching up with UI implementations.
(void)resizeWindowToSize:(NSSize)newSize
{
NSRect aFrame;
float newHeight = newSize.height;
float newWidth = newSize.width;
What sort of braindead window manager uses floating point to represent a discrete grid?
Actually, using floating points is a very good thing for GUI stuff. While it might seem pointless for window sizes, all coordinates in Quartz are floating point. This makes it posible to work in a resolution independant way.
Thinking of the screen as a discret grid is not the way to go if you want to handle anti-aliasing, sub-pixel text positioning, scaling for a screen with a different size/resolution, etc...
Remember that Quartz is used for handling on screen drawing, but also printing -- current printers can have 24 times more resolution than your screen (2400 DPI vs 100)- so if you use the discrete grid of your screen to describe stuff for your printer, you can only adress directly one pixel out of 576.
I think publishers like O"Reilly who dive head first into Mac OS X will be happy with the return on their investment. Look at Microsoft, who went great gonzos with their next Office version, which is Mac OS X only.
Other, more lukewarm publishers won't sell as many products, and in turn say "See, we were right! OS X isn't as cool as you all thought."
It is a self-fulfilling prophecy, but O'Reilly has seemed to fulfill a good one for themselves, rather than a bad one. Bravo, I say!
It's a well known fact that Apple, since its inception, has been a haven for "free thinkers" and "progressive thought," heralded by none other than famous acid-tripping Steve Jobs and his hippy buddies from California. It was on one of the famous beach parties, notorious for getting out of hand, that Clarus was born.
It was a balmy night in August, 1983, that Jobs held yet another beach party, this one with a special theme: who could come up with a mascot for the Mac development team? Of course the Apple II team was there and tensions, as always, were high. That didn't deter the Mac team from bringing their "pet," Clara, a cow they'd been raising on the Apple campus since birth.
Clara was birthed by the Mac team when they'd held a party on the Apple campus and had hired a bull-breeder as entertainment. All night long, the bull-breeder studded Hercules, his prize bull, with an assortment of cows. As the festivities continued on throughout the night, a strange moaning was coming from one of the trailers. One of the cows he'd brought with him was, unbeknownst to the bull-breeder, pregnant! The Mac development team, being the resourceful hackers they were, helped give birth to the calf, the mother losing its life in the process. The bull-breeder was so taken by the Mac dev team's efforts he let them keep the cow, which they named Clara.
Now, at the August 1983 beach party, the Mac team lobbied for Jobs to adopt Clara as the development mascot of the Macintosh. The Apple II team, spurned and bitter because of dwindling sales and neglect at the hand of Jobs, had brought their own mascot-- Cletus, a vicious Rotweiler they'd bought from a ruddy-faced streetman in the ghetto of Cupertino for $25. Cletus was a frothing, flea-and-mange ridden terror that barked at the least provocation. The Apple II team fed it raw goat meat and corrupted 5.25 floppies to make it mean. They also kicked it and made sure its chain was too tight at all time. Here at the party was their chance for revenge at Jobs and his favorite Mac development team.
As the night wore on, both the Apple II and Mac teams got drunker and drunker before Jobs called for a company vote on the mascot. What met the company's faces was something none of them could have imagined, however.
In their drunken, stoned stupor, the embittered Apple II team had snuck into Clara's trailer and cut the rear end of off Clara! Drugging her with ether to staunch her cries, they had used an electic chainsaw and cut her back legs and rectum cleanly off and taken them to the bonfire to cook and eat. They'd even fed some to the drunk Mac dev team! After they'd done this they forced their Cletus the foaming Rotweiler into the gaping hole in Clara's rear end. Eating away at his first real meal in months, Cletus became lodged in Clara's colon and couldn't break free. So when the Mac dev team opened Clara's trailer and led their pet down the ramp, they were met with a bloody, gut-strewn mess and a weird, unnatural animal call of "moof!"
The entire company was sickened by this and soon the sand was dotted with puddles of vomit. Cries of "moof, moof!" filled the air as the joined dog-cow trundled terribly along the beach, seizuring with each step, vomiting an icky mass of hair and blood, with a glazed look in its cow eyes. With a final shudder, the dog-cow fell and died, and the party-goers surrounded the putrid mess of bovine/canine flesh. Of course it didn't take long for the Mac dev team to discover the Apple II team's treachery and a bloody brawl ensued over the death of Clara. By the end of the night, the cow, the dog, and the Apple II team were simple piles of broken, bloody bones.
In light of the events that night, Jobs had no other choice to commemorate the tragic events that had unfurled and therefore made Apple's development mascot the dog-cow, "Clarus," a merging of the two animals names-- Cletus and Clara.
And that, for those who didn't know, is the origin of Clarus the dog-cow. Every time you click on a Mac OS easter-egg that utters "moof!" you can look back to the terrible events that August, 1983 night at the Apple beach party that brought you the Clarus, the dog-cow.
Suck it Trebek!
Also, typically floating point operations are much slower than equivalent integer operations
Erm. On a 386 maybe. These days FP mults and adds are as quick as (and sometimes faster than)integer ones.
If you really want not to use floating point calculation, then rational numbers are not the way to go. Instead you should use fixed point numbers. Old 68K based macintoshes (without FPUs) relied on those for fast calculation - in fact as far as I remember, the original Quickdraw toolbox relied of fixed point number for geometric calculations (arcs, slopes, etc.).
Basically, the idea is to use integers divided by a fixed number, so that the binary number has a fixed point. For instance if you have 32 bits numbers, you assume they are divided by 65536. This means that you have 16 bits before the point, and 16 bits after. This way for additions and substractions, you can use integer operations, calculation can also use the zero and sign flags of the processor. For mulitplication and division, you need to fiddle the integer system a bit (by multiplying or dividing by 2^16), but this could be done using shift operations, which are quite fast.
The rational structure you propose is not good because a simple addition requires many assembly level operations. For instance to calculate 6/5 + 2/3, you need to do the following calculation:
- Find the greatest common dividers of 5 and 3 (this is quite an expensive calculation)
- If none is found, multiply 3 by 5.
- Multiply 6 by 3 and 2 by 5.
- Add the result
So this basically for a single addition, you need to do perform at least a GCD calculation, one test, three multiplications and one addition. Multiplications and division are a little less costly, but you still need to check if the fraction is simplified.Rational numbers are good if you want absolute precision, but for they are not very fast - because there is no support for such a format in current processor instruction sets.
As for OS X using a vector format, this is, of course the case. Quarty relies on the PDF abstractions and it does support anti-aliasing, and sub-pixel positioning (I don't know for screen scaling). But having a vector format is not sufficient Quickdraw was also vector based, but used an integer coordinate system. This meant that lines, rectangles and arcs had to have their extremities on round coordinates of the Quickdraw grid - the result was not always very satisfactory.