Mildly Hurtful Sarcasm

Meaningless ranting, just like everybody else.

Tuesday, January 23, 2007

Quest for a nicer desktop II - Transparency

So I wanted to jazz up the look of my windows and I wanted to stick with Windows XP. I was thinking transparency and shadows. Transparency has been supported since Windows 2000, but you don't see alot of that in Windows applications; my guess: cause it's only good for look, other than chewing up cycles.

Anyway, to make it translucent, I use layered window, give it about 78% opacity (0xc8):


LONG_PTR lStyle = GetWindowLongPtr(GetSafeHwnd(), GWL_EXSTYLE);
SetWindowLongPtr(GetSafeHwnd(), GWL_EXSTYLE,
lStyle WS_EX_LAYERED);
SetLayeredWindowAttributes(GetSafeHwnd(), RGB(0x0, 0x0, 0x0),
0xc8, LWA_ALPHA);

Voi la, I get my translucent window:



But just as I have predicted, transparency is trouble. Some of the text is obscure, the buttons become see through and muxed up. It did more bad than good. Then I remember Aero in Vista, where only the so called non-client area is see through, I need to do that. I can think of 2 ways: per pixel transparency in layered windows, or literally layering windows. I will go ahead and do the latter - detaching widgets like buttons and make them toplevel windows so that they won't be affected by the parent window's opacity - which will take up more resources but is easier to code.

I make my window widgets, such as the list box, the buttons and the minimize and close window manager buttons top level windows. The minimize and close buttons are round, so I need to clip them to a round region. It works, sort of. Notice that Windows' region is a path of pixel, hence these buttons appear with a zig-zag edge.



It's all about look so I need to solve this. The solution is to first paint color rings right where the buttons are supposed to be, before overlaying buttons on them. They are painted anti-alias and will be see through because they are on the parent window, but that's barely noticable and the result is satifying.



Next stop, shadows...

Labels:

1 Comments:

At 12:47 PM, Anonymous Anonymous said...

It's like hammering a Toyota to look like a Porche. Windows' target audience is not design conscious. So they stick with boring, old, least common denominator. Their APIs, however many shodow/transparency calls these might "support", probably haven't even been tested. People like you are doing their QA. And few Windows users really care about your results. Have you actually used Mac OS X for, say, a week? Of course, what you are trying to morph a clunky Windows look into, has been standard on the Mac since kingdom come. And I don't even want to mention their Dock/Dashboard. Puh..leeese let a Toyota be a Toyota. ( or a Motel6 with Four Seasons, blah, blha)

 

Post a Comment

<< Home