I am currently in the process of developing a toolkit for making GUI-based applications in C++ using both Ndless and SDL.
This project, done on my free time, is initially for my own needs and is focused on mitigating the lack of GUI toolkit, but while coding it, I realize it may help other developers.
The root of the project is coming from Vogtinator's pyWrite, with now major changes and additions. I use this opportunity to thank him very much cause I learnt a lot while reading his code .
This is far from being finished (if a version number is required, I would says I am currently at 0.2beta ), but if there is an interest, I can push the development bit further than what I just actually need and hence make something more "generic".
This is how it looks like right now :
Many things are still done by hand (by instance the positioning of widgets, but it can be improved significantly by additional work of mine).
The following window is achieved just by coding this :
- Code: Select all
// Creation of the application
WidgetApplication *MyApp = new WidgetApplication();
MyApp->setbackgroundpicture( "/documents/Widget/002.bmp.tns" ); // with a wallpaper cause it's cool !!!
// this is the window frame
WindowWidget *window = new WindowWidget( "This is a Window", 20, 30, 250, 150, nullptr );
// in which we add widgets by connecting to the window as a parent-child relationship
InputWidget *input = new InputWidget( "Test 2", 25, 60, 240, 15, window );
input->setcontent( "Hello World !!! This is the best widget I have ever seen in my Life !!!");
ButtonWidget *button = new ButtonWidget( "Active Button", 30, 150, 110, 15, window );
ButtonWidget *button2 = new ButtonWidget( "Disabled Button", 150, 150, 110, 15, window );
CheckBoxWidget * check1 = new CheckBoxWidget ("Checkbox Square tick", 25, 85, 200, 12, window );
check1->settype( Square_Tick );
CheckBoxWidget * check2 = new CheckBoxWidget ("Checkbox Cross tick", 25, 105, 200, 12, window );
check2->settype( Cross_Tick );
CheckBoxWidget * check3 = new CheckBoxWidget ("Checkbox unchecked", 25, 125, 200, 12, window );
check3->settype( Cross_Tick );
// when it's done we connect the window to the application
MyApp->addchild( window );
// we check is something is happening with the mouse or the keyboard (this is spread hierarchically to childrens)
// Here is the loop for detecting keypressed and exit if needed
// and we render (this is also cascaded to childrens widgets)
It has some good things inside (I think ), such as triggered functions from the widget (if connected by the adequate call) when it is clicked/released/hovered. No need to say we can also just get the properties of the different widgets by using usual getters/setters functions/methods.
What I would like to add in the coming revisions :
- some more widgets (label, radiobuttons, frame, combobox, sliders, multiline inputbox, ...)
- create a simple system for automatic positioning of the widget (using default relative calculations and positioning in "transparent" grid containers)
- move / fold / unfold / expand / shrink windows
- ... many other things (but not to compete with GTK/KDE/Wxwidgets toolkits )
And of course some demonstration programs to check whether everything is working properly...
Let me know your thoughts and if a public release could be beneficial to some of you.