Embroidermodder
Embroidermodder copied to clipboard
The actuator system and UI rewrite.
Embroidermodder 2 was written in C++/Qt5 and it was far too complex. We had issues with people not able to build from source because the Qt5 libraries were so ungainly. So I decided to do a rewrite in C/SDL2 (originally FreeGLUT, but that was a mistake) with data stored as YAML. This means linking 4-7 libraries depending on your system which are all well supported and widely available.
This is going well, although it's slow progress as I'm trying to keep track of the design while also doing a ground up rewrite. I don't want to throw away good ideas. Since I also write code for libembroidery my time is divided.
Overview of the UI rewrite
(Problems to be solved in brackets.)
It's not much to look at because I'm trying to avoid using an external widgets system, which in turn means writing things like toolbars and menubars over. If you want to get the design the actuator is the heart of it.
Without Qt5 we need a way of assigning signals with actions, so this is what I've got: the user interacts with a UI element, this sends an integer to the actuator that does the thing using the current state of the main_window struct of which we expect there to be exactly one instance. The action is taken out by a jump table that calls the right function (most of which are missing in action and not connected up properly). It also logs the number, along with key parts of the main struct in the undo_history (an unsolved problem because we need to decide how much data to copy over per action). This means undo, redo and repeat actions can refer to this data.
Copying over some useful advice in the README on this topic.
KISS SDL
Rather than directly including the source code I think it would be informative to use the structures as inspiration for our own widget system.
Read the source code here: https://github.com/actsl/kiss_sdl
For example, it demonstrates how to use SDL_ttf to create a texture and copy it to the renderer. But we would want to style our own widget borders etc.
We would recommend that new developers hoping to help the project read this source code before diving into ours.
After the introduction of TinyScheme the actuator system is now "an action" is a C function that is callable from Scheme with a set of associated data that allow the creation of widgets like toolbars and menus.
The undo_history is, therefore a Scheme file of all of the commands issued by the user as scheme function calls.