Code Monkey home page Code Monkey logo

mahi-gui's Introduction

mahi-gui

This library provides an lightweight, all-in-one package for making GUIs and 2D visualizations in C++. It bundles GLFW and glad for creating Windows and OpenGL contexts, Dear ImGui with several custom extension classes and methods for all your GUI needs, NanoVG and NanoSVG for drawing vector graphics, NFD for native file/folder dialogs, and a few custom utility classes such as Coroutines and Events to spice things up.

Integration

The library is small and intended to be used with CMake's FetchContent:

include(FetchContent) 
FetchContent_Declare(mahi-gui GIT_REPOSITORY https://github.com/mahilab/mahi-gui.git) 
FetchContent_MakeAvailable(mahi-gui)

add_executable(my_app "my_app.cpp")
target_link_libraries(my_app mahi::gui)

That's it! You should also be able to install or use the library as a git-submodule + CMake subdirectory if you prefer.

Example Usage

// my_app.cpp

#include <Mahi/Gui.hpp>
using namespace mahi::gui;

// Inherit from Application
class MyApp : public Application {
public:
    // 640x480 px window
    MyApp() : Application(640,480,"My App") { }
    // Override update (called once per frame)
    void update() override {
        // App logic and/or ImGui code goes here
        ImGui::Begin("Example");
        if (ImGui::Button("Press Me!"))
          print("Hello, World!"); 
        ImGui::End();
    }
};

int main() {
    MyApp app;
    app.run();
    return 0;
}

Run and consult the examples for other features. Pay particular attention to demo.cpp which shows all of the functionality of the ImGui library. It calls the ImGui::ShowDemoWindow() function from imgui_demo.cpp, which itself is the absolute best place for ImGui examples. For a real-world example, see Syntacts' GUI, which is built entirely using mahi gui.

Requirements

  • C++17 compiler (MSVC or Clang)

Building for Windows

On Windows, we recommend using to MSVC 2019:

> cd mahi-gui
> mkdir build
> cmake .. -G "Visual Studio 16 2019" -A x64
> cmake --build . --config Release

Building for macOS

On macOS, we will use LLVM clang to build mahi-gui. While Xcode uses an Apple flavored version of the clang compiler by default, the version you have installed my not be up to date with the required version of LLVM (> 8.0.0). Therefore, for this tutorial download the pre-built binaries for the latest version of LLVM from here.

> cd mahi-gui
> mkdir build
> cmake .. -DCMAKE_C_COMPILER="/path/to/clang/bin/clang" -DCMAKE_CXX_COMPILER="/path/to/clang/bin/clang++" -DCMAKE_BUILD_TYPE="Release"
> cmake --build . --config Release

See Also

mahi-gui's People

Contributors

epezent avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.