Easy layer mode changing in GIMP (Shallow Thoughts)

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Sun, 17 Feb 2008

Easy layer mode changing in GIMP

There's been some discussion on the gimp-developer list about that unwieldy layer mode option menu you see in both the Layers dialog and in drawing tool options.

Bill introduced the topic by suggesting a redesign of the menu to use two side-by-side columns instead of one. That makes the menu more compact and vastly shortens the average mouse movement needed to change modes.

But Sven didn't like the side by side option, pointing out that it implies some equivalence to modes that end up listed next to each other.

More discussion ensued, with Bill posting a screenshot of the unwieldy menu to illustrate how bad it is (including the bizarre gtk "the top half of the menu is blank" misfeature that always looks like a bug but is apparently intentional).

That Mode menu has always bothered me. Typically when I'm using layer modes, I try lots of them one by one to see which mode works best. But that's difficult with the current very tall menu, especially (as Bill pointed out on IRC) if you need to jump back and forth between two modes that aren't close to each other in the menu. And gtk option menu's behavior doesn't help, where clicking on it pops up the menu but not necessarily with the current item selected -- sometimes the previous item is selected, so you can't just arrow down once and assume you'll get the next mode.

That night after going to bed I got to thinking about it. I realized that the Mode menu problem was similar to the problem selecting a font from the combo box in the Text tool options -- I usually find it much easier to bring up the Fonts dialog and choose a font from there. What I really wanted for layer modes was a "Modes dialog".

And suddenly it came to me that I could solve most of my problem with a simple "Next mode" script. Once I had that, I could bind it to a key, or "tear off" the menu it was in so that it would stay visible and I could click it repeatedly. It took about ten minutes the following morning to write the script in python.


I posted my solution back to the list, and some discussion ensued on IRC. Bill pointed out that enabling tear-offs for the existing Mode option menu (which can be done in two lines of C code) gives essentially the Fonts dialog I wanted. Several of us thought that was a great idea. But when Bill posted to the list, Sven nixed the idea, saying tear-offs were deprecated. (They're not officially deprecated in GTK, or at least the GTK documentation doesn't say so and I can't find anything with google; but in any case Sven apparently doesn't like tear-offs and won't allow adding any new ones in GIMP.)

Fortunately, gimp-python comes to the rescue here too. Writing a mode-dialog.py turned out to be a little trickier than "next mode", only because it took me a while to realize I needed to call pdb.gimp_displays_flush() to update the display after changing the mode of the current layer (thanks Alexia and Bill).

So now I have both "next mode" and a separate mode dialog, making layer mode operations so much easier!

[ 12:50 Feb 17, 2008    More gimp | permalink to this entry | comments ]
(Commenting requires Javascript from ShallowSky.com and Disqus.com, and a cookie from Disqus.com.)
blog comments powered by Disqus