Skip to content
/ imjson Public

A C++ library for defining Dear ImGui styles using JSON

License

Notifications You must be signed in to change notification settings

moleium/imjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imjson

imjson is a small C++ utility that allows theme definition for Dear ImGui through JSON files.

Features

  • Define ImGui style colors and variables using JSON objects
  • Load themes from files, strings, or JSON objects
  • Load fonts from JSON objects
  • Proper style stack management

Dependencies

Usage

Include imjson.h and imjson.cpp in your project:

#include "imjson.h"

int main() {
  imjson::load_file("my_theme.json");  

  // Or from a string
  imjson::load_string(R"(
  {
    "Colors": {
      "Text": [1.0, 0.0, 0.0, 1.0]
    },
    "Rounding": {
      "WindowRounding": 8.0,
      "FrameRounding": 4.0
    },
    "WindowPadding": [8, 8]
  }
  )");  
  
  imjson::pop_colors();
  imjson::pop_vars();
}

Example

A complete example is provided in the example/ directory. To build it:

mkdir build && cd build
cmake ..
cmake --build .

Theme Format

{
  "Colors": {
    "Text": [0.9, 0.9, 0.9, 1.0],
    "WindowBg": [0.1, 0.1, 0.1, 1.0]
  },
  "Rounding": {
    "WindowRounding": 4.0,
    "FrameRounding": 2.0
  },
  "WindowPadding": [8, 8]
}

About

A C++ library for defining Dear ImGui styles using JSON

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages