cat /dev/maxilys

A glance in the mind of a KDE/Linux developer to see how ideas turn into code.

2006-09-17

KDE: Total look

That's it. There are no widget left to style. I already said this more than once but this time, I think I did it. I reached the total serene look.

The last remaining widget was the tiny menu button in Kicker's panel. I wanted to change those 80 pixels that hurt my eyes but the first time I look in Kicker's sources, I couldn't figure how to do it. So I forgot about it... until yesterday. I scratched the surface (digging is exaggerated in this case), found the class name of the widget, polished it and intercepted its drawing in the event filter. So easy. Except, that I had no obvious way to retrieve the direction in which I should draw the little arrow. Whatever, I drew a little "+" sign that fits any direction. Nice! ;-)

And before that, I gave something unique to Serenity: Big tree expanders. I changed KDE's default 9x9 size to a gigantic 15x15. From a usability point of view, that make a big difference. And visually too! I had to draw very special bigger "+/-" symbol to fit in this gigantic space.

Any way, that was fun to do because I did something I enjoyed: ripping KDE's sources and improving them --well, at least, adapting them to Serenity. But let's start from the beginning. I first tried to enlarge the tree expanders beyond the provided rectangle. 1 pixel... 3 pixels... And I realized "somebody" was drawing the branches over the expanders. Not good. A little trip around Qt's and KDE's sources told me that the culprit was "kstyles.cpp". I just ripped the intersting part --the drawing of CC_ListView-- and applied my coding style to it. I already knew I'll have to implement it in Serenity and that gave me time to understand what was going on in there.

In a way, KDE's method is not that bad. It walks along the branches of the tree, draw the expanders and collects the branches to draw them at once. --More or less.-- The problem is that the size of the expanders is hardcoded and even if there is plenty of space around, the drawing of the branches after the drawing of the expanders prevents any change. For Serenity, I removed all the system to store the branches in order to draw them directly. I also removed any calculation for the size of the branches around the expanders because any expander will now be drawn over its branch. That was becoming better.

I built it and tested it. Nice! ...until I decided to check the "+/-" symbols. They looked thin but huge. It was the time to restart counting in binary to draw two nice bitmaps. Re-build and re-test. Nicer! I also changed the arrows a.k.a. triangular expanders to their bigger size available in Serenity. I tuned a little the colors so that the expanders don't disappear on a white background and I could go on... to the next task.

While I was playing with the tree view in Konqueror and aKregator, I noticed that I couldn't stand the column headers any more. Too big, too whatever. I decided to make them totally flat with little separators and that led me to crashing KDevDesigner more than once.

For some reason, when you click on a column (or row) header in a QTable, not exactly the same parameters than everywhere else are passed to the style to draw this header --especially the parent QHeader isn't provided. Serenity which wasn't aware of that and used the QHeader to retrieve pieces of information just exploded. I put a safety guard and no more crashing happened. I also gave another color to the headers and that was it.

Before all this, after my previous blog, I made up my mind and removed a few options from the configuration dialog so that I can point the finger and say "This is the way Serenity is". First, the so-called serene groupboxes are always activated, as well as the menu bar groove and the toolbar handles --for usability reasons. Last detail, the separators are always solid lines now. Less code, more speed. While I was at it, I totally broke apart the configuration dialog. No more groupboxes with meaningless captions. I just kept the two columns but with a simple separator in between then and I added other separators in between "logical" groups of options. That's better.

Last thing I did was to get rid of an old legacy that Serenity was carrying around like a ball and chain. The routines behind the configuration dialog were spending their time converting options from text to number, back to text, and so on. I changed all this in order to use only numbers. That allowed me to remove quite a lot of lines of code and few in Serenity itself. But that doesn't prevent it from growing bigger and bigger. The first source of the version 0.2 weighted only 112 KB to reach... 196 KB now. A diet is impossible since it would only mean loosing bones, errr, widgets. ;-) And it will grow a little more because I want to add a new gradient style beside "serene" and "zen", one that would allow you to use the same color for the background and the buttons without making them disappear. My attempts have been unsatisfying so far. I'll take care of that for the next version.

Already?! :-D

Well, time to go packing, snapshooting, whatever...

0 Comments:

Post a Comment

<< Home