RAD menu

28 march 2009


rad / xterm

Dunno why radial menus are such a rare thing to come by, only occasionally used in games or some apps like Kommando. Not that it's hard to implement one... probably just not too useful for users, who're used to that ugly rectraingular thingz outta windoze (tm).

I think of radials more like "mouse gestures with hints" - after several clicks you just move the mouse in the same direction and click, provided items stay in the same place (or rather at the same angle). Every item is equally easy to reach, besides, it's much easier to measure direction than distance with devices like touchpad or mouse, since sensitivity doesn't affect it.

I use the thing with fluxbox, where it's easy to remap everything, like desktop clicks, to call whatever you need instead of showing stock menu, and have no idea how it'll behave on gnome/kde or whatever else ubuntu users sing praises for. The menu plays nice with composing windows w/ quite unexpected "background black-out" effect... in fact, since (py)gtk is also available for ms-os I'd expect it to work out there too, not sure about the shape though.

Rad name might be quite self-explanatory (in a _rad_ way)), but actually just stands for "radial" and also might be borrowed from another standalone menu I've used - "ratmenu" (along w/ the ratpoison wm).

Implementation details

rads on top of streaming mplayer

Weird, but most "foreground" stuff I've seen used to take snapshot of the actual background, "freezing" it as a part (background) of the window. And about the only app using non-rectraingular window I can remember is a good ol' oclock, which been there since 80's - from the dawn of X11 itself.

oclock, makes use of xshape extension to "mask out" unused parts of the window, making them not just transparent, but actually not parts of the window at all - so you can click other windows thru these areas.

Rad menus are built on this extension as well, creating fullscreen window and cutting off everything but the actual menu petals. That means that the menus actually look good on top of anything - you can stream videos behind and it won't be overlapped any more than by the areas filled with menu, no composite extension or some weird qt tricks - it just works.

Implementation is (unsurprisingly) python. Initially, I've started to code it in C, but got bored by it pretty quickly, while py code is a pure vanilla to write and tweak. I've actually expected it to be quite slow, especially on reacting to cursor motion events, but it certainly exceeded my expectations yet again.

Only problem I've encountered so far is a momentary flicker of some underlying windows, when the new shape mask is applied. Not a critical thing for me, but prehaps there's some easy workaround. Btw, if you know of any, I'd appreciate if you share the secret :)

Size, tilt, basic geometry, colors, and, of course, items themselves are easily configurable via yaml-like configuration file. It can actually be parsed as a valid yaml, but I've written my own parser to preserve items' sequence w/o wrapping them in some ugly yaml lists, so it's not quite yaml, after all.

Whole code by now is less then four hundred meaningful lines, so feel free to hack it up to your own needs as a public domain stuff. I'll probably add some nicey animation to it someday, too.

Oh, and I use some great stuff like named tuples and (probably) 2.6-specific syntax here and there, which might not be compatible w/ py2.5 (outta-the-box), sorry. As a solution I'd suggest using py2.6 or higher (3.X should work as well, as '-3' flag tells me).




2.6 at least, shouldn't play nice with 2.5
GTK+ py bindings, required
extensively used to draw everything
used to render the text on cairo canvas

Related stuff

nice feature if you're bored of damn rectraingles on screen ;)
great data format for usage by human beings (not the weirdos who like xml)
Neverwinter Nights style wheelmenus for KDE