From c0c64ad677a448432b0d00d22bdcd18e5737dd6a Mon Sep 17 00:00:00 2001 From: IoIxD Date: Sun, 26 Apr 2026 21:51:29 -0700 Subject: [PATCH] backenddev.md --- doc/BACKENDDEV.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 doc/BACKENDDEV.md diff --git a/doc/BACKENDDEV.md b/doc/BACKENDDEV.md new file mode 100644 index 0000000..b77564b --- /dev/null +++ b/doc/BACKENDDEV.md @@ -0,0 +1,22 @@ +# Backend dev + +The basic process of creating a new Milsko backend is + +- Adding a new include header into `include/Mw/LowLevel`. It must include; + - `struct _MwLLBackendName`: Any details about a window or a subwidget + - `struct _MwLLBackendNameColor`: An 8-bit RGB Color. You'll probably never impl this, this is for platforms like X11/GDI where they have a secondary color representation that can be stored. + - `struct _MwLLBackendNamePixmap`: Self-explanatory. This is also used for the soft gradients in the modern theme. + - `MwLLBackendNameCallInitImpl(void)` called by `MwLibraryInit` to address and platform globals. + - Note that all of those structs are actually unions. They should all start with their `MwLLCommon...` equivalants. +- Creating a new impl file in `src/backend` + - Backends actually return a table of function pointers that you have to implement with static functions. Your file should end with `#include "call.c"` and then `CALL(BackendName);`, and somewhere you should have the impl for `MwLLBackendNameCallInitImpl(void)`. +- Add `MwLLBackendNameCallInitImpl` to the `MwLibraryInit` impl in `src/core.c`. +- Either + - a.) Modify `CMakeLists.txt` for your platform. + - b.) Add a new perl file in `pl/ostype` that `./configure` can reference, and modify `pl/rules.pl`; If you don't know how to use perl it's fine, just copy a file like the `Linux.pl` or `Windows.pl`, the functions you'll have to change for your platform are self explanatory. Ensure it ends with `1;`. + - c.) Both. + - Both are recommended, but some platforms like Classic Mac OS can't be used with the `./configure` script, and that's fine. + +The functions you'll have to impl are too many to list here so you should start by just copying `x11.c` and then replacing all the function impls with your own. + +\*\*Pay attention to some of these functions' comments in LowLevel.h as they might not be as you expect; for example, `MwLLSetDarkThemeImpl` is for setting the accent color to dark theme on platforms like modern Windows (dark theme itself is set with `MwSetInteger(handle, MwNdarktheme, 1)`).