2.7 KiB
2.7 KiB
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 subwidgetstruct _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 byMwLibraryInitto address and platform globals.- Note that all of those structs are actually unions. They should all start with their
MwLLCommon...equivalants.
- Fill out
Mw/LowLevel.happopriately, adding an include to your new file and the structs in the appropriate unions. These need to be guarded by aUSE_BACKENDNAMEmacro which you'll define later when you modify the build system. - 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 thenCALL(BackendName);, and somewhere you should have the impl forMwLLBackendNameCallInitImpl(void). - Prefer to keep the backend file to one file if you can, though obviously exceptions like the Wayland backend exist because it's simply too complex to sanely stuff into one file.
- Backends actually return a table of function pointers that you have to implement with static functions. Your file should end with
- Add
MwLLBackendNameCallInitImplto theMwLibraryInitimpl insrc/core.c. - Add a new enum variation to
MwLLBackendsinMw/Include/LowLevel.h; your impl ofMwLLCreateImplwill setcommon.typeto this so the user can check which backend they're on (important for platforms with multiple supported backends). - Either
- a.) Modify
CMakeLists.txtfor your platform. - b.) Add a new perl file in
pl/ostypethat./configurecan reference, and modifypl/rules.pl; If you don't know how to use perl it's fine, just copy a file like theLinux.plorWindows.pl, the functions you'll have to change for your platform are self explanatory. Ensure it ends with1;. - c.) Both.
- Both are recommended, but some platforms like Classic Mac OS can't be used with the
./configurescript, and that's fine.
- a.) Modify
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)).