Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you build a "pixel perfect" GUI on Linux?

I'd like build a GUI where every single pixel is under my control (i.e. not using the standard widgets that something like GTK+ provides). Renoise is a good example of what I'm looking to produce.

Is getting down to the Xlib or XCB level the best way to go, or is it possible to achieve this with higher level frameworks like GTK+ (maybe even PyGTK)? Should I be looking at Cairo for the drawing?

I'd like to work in Python or Ruby if possible, but C is fine too.

like image 622
splicer Avatar asked May 03 '10 08:05

splicer


3 Answers

With Clutter toolkit (or some other canvas widget/toolkit) you can build such an interface. I would not advise going to the level of Xlib/XCB or DrawingArea because it would require implementing much of generic functionality already present in canvases.

like image 168
dmitry_vk Avatar answered Sep 23 '22 23:09

dmitry_vk


In X there is one problem with this approach which you might not have taken into consideration. The font size is measured in points (one point being 1/72 of an inch) and thus varies in (pixel) size with resolution and monitor size. The text strings will also vary in length depending on the language so it's not really possible to determine how large buttons and such need to be. The common GUI toolkits for X are designed with this in mind. Apart from that it would be easy to just write your own theme engine for GTK that draws all widgets exactly as you want them (using Cairo[1] or GDK[2]) and make your application always use that theme. Perhaps it would also be possible for your application to set the default font size (in points) based on the DPI to always get the same size in pixels (and of course not making your application translatable).

There are at least a couple of GUIs using this pixel perfect approach based on SDL[3], for example AGAR[4], PicoGUI[5] and Guichan[6]. Most of them are written in C++ and some in C and as far as I know none of them have bindings for Python nor Ruby. Then using SDL you can only have one top-level window which means your application (or the GUI toolkit you use) have to do its own window managing for various dialogs and such. But I guess that was what you intended anyway.

[1] cairographics.org/
[2] library.gnome.org/devel/gdk/unstable/index.html
[3] www.libsdl.org/
[4] libagar.org/
[5] picogui.org/
[6] guichan.sourceforge.net/wiki/index.php/Main_Page

like image 36
Grim Avatar answered Sep 23 '22 23:09

Grim


You'll probably want something like pygame then.

like image 30
Ignacio Vazquez-Abrams Avatar answered Sep 19 '22 23:09

Ignacio Vazquez-Abrams