Compiling the library

To compile the library, make sure that imgui.h is set correctly in your include path, so that it can be included like this:

#include <imgui.h>

Then, you can statically compile UTheme.cpp, Common.h and UTheme.hpp into your project.

Additionally, we also provide a C API under the C folder. To use it, statically compile C/CUTheme.cpp and C/CUTheme.h.

The library uses the rapidyaml library to read YAML. If you don't use it already, you can easily use the git submodule under the rapidyaml folder.

After all that setup is finished, include the UTheme.hpp header into one of your files and start using the library.

Exporting symbols out of a DLL

To export symbols out of a DLL, define the MLS_EXPORT_LIBRARY macro and when compiling the library that you want to export the symbols out of, define the MLS_LIB_COMPILE macro.

API

The UTheme.hpp header defines the Theme class. It has 3 member functions:

  1. load - Given a string that points to a file location, loads the file. Returns 0 on success and -1 when the file cannot be read
  2. save - Given a string that points to a file location, saves the current style to the specified file.
  3. showThemeEditor - Renders a window that you can use to modify the current style. Takes a bOpen argument for the close button on the window
  4. showThemeEditorInline - Renders the contents of the function above, without the window

The load and save functions also take an optional pointer of type SemanticColourData. When pointing to a valid instance, the struct will be filled with semantic colour data. The struct looks like this:

struct SemanticColourData
{
    ThemeVec4 DestructiveColor;
    ThemeVec4 DestructiveColorActive;
    ThemeVec4 SuccessColor;
    ThemeVec4 SuccessColorActive;
    ThemeVec4 WarningColor;
    ThemeVec4 WarningColorActive;
};

C API

The C API is the same as the C++ API, except that default arguments have to be filled in manually and that all functions and types are prefixed by their namespace and class separated by _. For example, UImGui::Theme::load becomes UImGui_Theme_load.