All Projects → juliettef → Imgui_markdown

juliettef / Imgui_markdown

Licence: zlib
Markdown for Dear ImGui

Projects that are alternatives of or similar to Imgui markdown

Iconfontcppheaders
C, C++ headers and C# classes for icon fonts: Font Awesome, Fork Awesome, Material Design, Kenney game icons and Fontaudio
Stars: ✭ 509 (-14.31%)
Mutual labels:  gamedev, library, gui, imgui
Ncine
A cross-platform 2D game engine
Stars: ✭ 372 (-37.37%)
Mutual labels:  game-development, gamedev, imgui
Imgui
Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
Stars: ✭ 33,574 (+5552.19%)
Mutual labels:  gamedev, gui, imgui
Cimgui
c-api for imgui (https://github.com/ocornut/imgui) Look at: https://github.com/cimgui for other widgets
Stars: ✭ 707 (+19.02%)
Mutual labels:  gamedev, gui, imgui
Imgui sdl
ImGuiSDL: SDL2 based renderer for Dear ImGui
Stars: ✭ 134 (-77.44%)
Mutual labels:  gamedev, gui, imgui
Gooi
LÖVE GUI Library
Stars: ✭ 168 (-71.72%)
Mutual labels:  gamedev, library, gui
Gwork
Skinnable GUI with useful widget collection. Fork of GWEN.
Stars: ✭ 179 (-69.87%)
Mutual labels:  gamedev, library, gui
Imgui
Bloat-free Immediate Mode Graphical User interface for JVM with minimal dependencies (rewrite of dear imgui)
Stars: ✭ 394 (-33.67%)
Mutual labels:  gamedev, gui, imgui
Verticaldissolve
Procedural vertical dissolve shader. Highly customizable. Tweak edge color, noisiness & waviness, rim light, emission scrolling and more.
Stars: ✭ 434 (-26.94%)
Mutual labels:  game-development, gamedev
Lambdahack
Haskell game engine library for roguelike dungeon crawlers; please offer feedback, e.g., after trying out the sample game with the web frontend at
Stars: ✭ 439 (-26.09%)
Mutual labels:  gamedev, library
Zep
Zep - An embeddable editor, with optional support for using vim keystrokes.
Stars: ✭ 477 (-19.7%)
Mutual labels:  game-development, imgui
Vortice.windows
.NET standard bindings for DirectX, WIC, Direct2D1, XInput, XAudio and X3DAudio
Stars: ✭ 427 (-28.11%)
Mutual labels:  game-development, gamedev
Rizz
Small C game development framework
Stars: ✭ 428 (-27.95%)
Mutual labels:  game-development, gamedev
Dxwrapper
Fixes compatibility issues with older games running on Windows 10 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
Stars: ✭ 460 (-22.56%)
Mutual labels:  game-development, gamedev
Nuklear
A single-header ANSI C immediate mode cross-platform GUI library
Stars: ✭ 5,055 (+751.01%)
Mutual labels:  gui, imgui
Imgui Go
Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)
Stars: ✭ 499 (-15.99%)
Mutual labels:  gui, imgui
Scheme Lib
鸭库 duck lib scheme for gui gles gl slib openal socket web mongodb box2d game glfw mysql libevent libuv uv json http client server android osx linux chezscheme scheme-lib
Stars: ✭ 406 (-31.65%)
Mutual labels:  library, gui
Tetra
🎮 A simple 2D game framework written in Rust
Stars: ✭ 492 (-17.17%)
Mutual labels:  game-development, gamedev
Imnodes
A small, dependency-free node editor for dear imgui
Stars: ✭ 591 (-0.51%)
Mutual labels:  gamedev, imgui
Anything about game
A wonderful list of Game Development resources.
Stars: ✭ 541 (-8.92%)
Mutual labels:  game-development, gamedev

Support development of imgui_markdown through our Patreon

Become a Patron

imgui_markdown

Markdown for Dear ImGui

A permissively licensed markdown single-header library for Dear ImGui.

Requires C++11 or above

imgui_markdown currently supports the following markdown functionality:

  • Wrapped text
  • Headers H1, H2, H3
  • Indented text, multi levels
  • Unordered lists and sub-lists
  • Links
  • Images

imgui_markdown demo live editing

Note - the gif above is heavily compressed due to GitHub limitations. There's a (slightly) better version of it on twitter.

Syntax

Wrapping

Text wraps automatically. To add a new line, use 'Return'.

Headers

# H1
## H2
### H3

Lists

Indents

On a new line, at the start of the line, add two spaces per indent.

Normal text
··Indent level 1
····Indent level 2
······Indent level 3
Normal text

Unordered lists

On a new line, at the start of the line, add two spaces, an asterisks and a space. For nested lists, add two additional spaces in front of the asterisk per list level increment.

Normal text
··*·Unordered List level 1
····*·Unordered List level 2
······*·Unordered List level 3
······*·Unordered List level 3
··*·Unordered List level 1
Normal text

Links

[link description](https://...)

Images

![image alt text](image identifier e.g. filename)

Example use of imgui_markdown with icon fonts

Example use on Windows with links opening in a browser


#include "ImGui.h"                // https://github.com/ocornut/imgui
#include "imgui_markdown.h"       // https://github.com/juliettef/imgui_markdown
#include "IconsFontAwesome5.h"    // https://github.com/juliettef/IconFontCppHeaders

// Following includes for Windows LinkCallback
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Shellapi.h"
#include <string>

void LinkCallback( ImGui::MarkdownLinkCallbackData data_ );
inline ImGui::MarkdownImageData ImageCallback( ImGui::MarkdownLinkCallbackData data_ );

static ImFont* H1 = NULL;
static ImFont* H2 = NULL;
static ImFont* H3 = NULL;

static ImGui::MarkdownConfig mdConfig; 


void LinkCallback( ImGui::MarkdownLinkCallbackData data_ )
{
    std::string url( data_.link, data_.linkLength );
    if( !data_.isImage )
    {
        ShellExecuteA( NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL );
    }
}

inline ImGui::MarkdownImageData ImageCallback( ImGui::MarkdownLinkCallbackData data_ )
{
    // In your application you would load an image based on data_ input. Here we just use the imgui font texture.
    ImTextureID image = ImGui::GetIO().Fonts->TexID;
    // > C++14 can use ImGui::MarkdownImageData imageData{ true, false, image, ImVec2( 40.0f, 20.0f ) };
    ImGui::MarkdownImageData imageData;
    imageData.isValid =         true;
    imageData.useLinkCallback = false;
    imageData.user_texture_id = image;
    imageData.size =            ImVec2( 40.0f, 20.0f );

    // For image resize when available size.x > image width, add
    ImVec2 const contentSize = ImGui::GetContentRegionAvail();
    if( imageData.size.x > contentSize.x )
    {
        float const ratio = imageData.size.y/imageData.size.x;
        imageData.size.x = contentSize.x;
        imageData.size.y = contentSize.x*ratio;
    }

    return imageData;
}

void LoadFonts( float fontSize_ = 12.0f )
{
    ImGuiIO& io = ImGui::GetIO();
    io.Fonts->Clear();
    // Base font
    io.Fonts->AddFontFromFileTTF( "myfont.ttf", fontSize_ );
    // Bold headings H2 and H3
    H2 = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSize_ );
    H3 = mdConfig.headingFormats[ 1 ].font;
    // bold heading H1
    float fontSizeH1 = fontSize_ * 1.1f;
    H1 = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSizeH1 );
}

void ExampleMarkdownFormatCallback( const ImGui::MarkdownFormatInfo& markdownFormatInfo_, bool start_ )
{
    // Call the default first so any settings can be overwritten by our implementation.
    // Alternatively could be called or not called in a switch statement on a case by case basis.
    // See defaultMarkdownFormatCallback definition for furhter examples of how to use it.
    ImGui::defaultMarkdownFormatCallback( markdownFormatInfo_, start_ );        
       
    switch( markdownFormatInfo_.type )
    {
    // example: change the colour of heading level 2
    case ImGui::MarkdownFormatType::HEADING:
    {
        if( markdownFormatInfo_.level == 2 )
        {
            if( start_ )
            {
                ImGui::PushStyleColor( ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled] );
            }
            else
            {
                ImGui::PopStyleColor();
            }
        }
        break;
    }
    default:
    {
        break;
    }
    }
}

void Markdown( const std::string& markdown_ )
{
    // You can make your own Markdown function with your prefered string container and markdown config.
    // > C++14 can use ImGui::MarkdownConfig mdConfig{ LinkCallback, NULL, ImageCallback, ICON_FA_LINK, { { H1, true }, { H2, true }, { H3, false } }, NULL };
    mdConfig.linkCallback =         LinkCallback;
    mdConfig.tooltipCallback =      NULL;
    mdConfig.imageCallback =        ImageCallback;
    mdConfig.linkIcon =             ICON_FA_LINK;
    mdConfig.headingFormats[0] =    { H1, true };
    mdConfig.headingFormats[1] =    { H2, true };
    mdConfig.headingFormats[2] =    { H3, false };
    mdConfig.userData =             NULL;
    mdConfig.formatCallback =       ExampleMarkdownFormatCallback;
    ImGui::Markdown( markdown_.c_str(), markdown_.length(), mdConfig );
}

void MarkdownExample()
{
    const std::string markdownText = u8R"(
# H1 Header: Text and Links
You can add [links like this one to enkisoftware](https://www.enkisoftware.com/) and lines will wrap well.
## H2 Header: indented text.
  This text has an indent (two leading spaces).
    This one has two.
### H3 Header: Lists
  * Unordered lists
    * Lists can be indented with two extra spaces.
  * Lists can have [links like this one to Avoyd](https://www.avoyd.com/)
)";
    Markdown( markdownText );
}

Projects using imgui_markdown

Avoyd

Avoyd is an abstract 6 degrees of freedom voxel game.
www.avoyd.com

The game and the voxel editor's help and tutorials use imgui_markdown with Dear ImGui.

Avoyd screenshot

bgfx

Cross-platform rendering library.
bkaradzic.github.io/bgfx/overview

Imogen

GPU/CPU Texture Generator
skaven.fr/imogen

Imogen screenshot

Light Tracer

Experimental GPU ray tracer for web

Light Tracer screenshot

Visual 6502 Remix

Transistor level 6502 Hardware Simulation
hfloooh.github.io/visual6502remix

Using imgui_markdown as help viewer for Visual 6502 Remix with internal and external links:

Using imgui_markdown as help viewer for Visual 6502 Remix with internal and external links - animated gif Using imgui_markdown as help viewer for Visual 6502 Remix - screenshot

Using imgui_markdown in the About page for Visual 6502 Remix - screenshot

Credits

Design and implementation - Doug Binks - @dougbinks
Implementation and maintenance - Juliette Foucaut - @juliettef
Image resize example code - Soufiane Khiat
Thanks to Omar Cornut for Dear ImGui

License (zlib)

Copyright (c) 2019 Juliette Foucaut and Doug Binks

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].