Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Tue Jul 16, 2019 11:46 am

For creating LV2 UI's I end up more and more writing the same code, so I decided to wrote a Layer for it.
It's supposed to create, manage, draw, and destroy X11 widgets with a cairo surface to draw.
Additional to subscribe to and handle events.

I decided to put it in the Public Domain, so everyone could do what ever he /she want's with it.
Image

Now, here is the usual "hello world":

Code: Select all

#include "xputty.h"

static void draw_window(void *w_, void* user_data) {
    Widget_t *w = (Widget_t*)w_;
    cairo_push_group (w->cr);
    cairo_set_source_rgb (w->cr, 1, 1, 1);
    cairo_paint (w->cr);
    cairo_pop_group_to_source (w->cr);
    cairo_paint (w->cr);
}

int main (int argc, char ** argv)
{
    Display *dpy = XOpenDisplay(0);
    XContext context =  XUniqueContext();
    Widget_t *w;

    w = create_window(dpy, DefaultRootWindow(dpy), context, 0, 0, 300, 200);
    XStoreName(dpy, w->widget, "Xputty Hello world");
    w->func.expose_callback = draw_window;
    bool run = true;
    loop(w,context,&run);
    destroy_widget( w, context);
    XCloseDisplay(dpy);
    return 0;
}


producing this window:
Image

The repository contain a example folder showing some of the features supported by the layer.
It's a tiny, but powerful abstraction of the X11 low level API to easier the process to create nice GUI's.
Documentation is included in the source code, it's a single header and a single c file.
All together just 654 lines, were most lines taken by documentation.

So, here you go:
https://github.com/brummer10/Xputty
On the road again.

User avatar
sadko4u
Established Member
Posts: 697
Joined: Mon Sep 28, 2015 9:03 pm

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby sadko4u » Wed Jul 17, 2019 5:05 pm

Good start. Exploring your latest plugins, I wondered why you haven't done it already previously.
LSP (Linux Studio Plugins) Developer and Maintainer.

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Wed Jul 17, 2019 6:03 pm

Up to the MatchEQ all GxPlugins just use a single window, all the rest is done with a bit of maths and a lot of cairo. :)
I used to use a generator for the GUI's, so the source may look like copy and past, but nope, they are simply generated from a skeleton bundle package. Some small edit's afterwards, and done. That's why I never had the pressure to do a real widget toolkit.
Now, with the MatchEQ that has changed, there I need dynamic menu's, button's, text-input boxes, well, the usual widget stuff.
As I long wanted to port the guitarix plugis as well to X11, I've now started to do the frame work.
On the road again.

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Wed Jul 24, 2019 6:34 pm

Nearly there, most of the base is set up now, I guess one or two day's more, and the fun begins. :twisted:
On the road again.

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Sun Jul 28, 2019 7:19 pm

. . and now the first widget's been implemented, like buttons, sliders and knob. Also a theming engine is in place.
A example for how to use it is in the examples folder.
On the road again.

folderol
Established Member
Posts: 925
Joined: Mon Sep 28, 2015 8:06 pm
Location: Here, of course!
Contact:

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby folderol » Mon Jul 29, 2019 9:46 pm

Looks interesting

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Sat Aug 03, 2019 4:45 pm

. . slowly growing, now have menus, check and radio menus, and a png to binary link in and read out struct.
On the road again.

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Thu Aug 22, 2019 12:37 pm

. . . and now have a example LV2 plugin which shows how to use Xputty to create LV2 plugin UI's.
On the road again.

tramp
Established Member
Posts: 1421
Joined: Mon Jul 01, 2013 8:13 am

Re: Xputty - damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces

Postby tramp » Wed Oct 23, 2019 7:52 am

. . . and that's how it looks now.

Image
On the road again.


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 1 guest