A (very) simple notification wrapper for Dear ImGui

Overview

imgui-notify

Is a header-only wrapper made to create notifications with Dear ImGui. As I couldn't find any library for this I just decided to create my own. We will use Font Awesome 5 for icons.

forthebadge forthebadge

Usage

#include "notify.h"

// Initialisation, once at the beggining of your code, usually after ImGui_ImplDX12_Init()
notify::init();

// Add a new toast
if (ImGui::Button("success!"))
{
    notify::insert({ toast_type::toast_type_success, 3000, "Hello World! This is a success! %s", "We can also format here:)" });
}

if (ImGui::Button("warning!"))
{
    notify::insert({ toast_type::toast_type_warning, 3000, "Hello World! This is a warning!" });
}

if (ImGui::Button("error!"))
{
    notify::insert({ toast_type::toast_type_error, 3000, "Hello World! This is an error!" });
}

if (ImGui::Button("info!"))
{
    notify::insert({ toast_type::toast_type_info, 3000, "Hello World! This is an info!" });
}

if (ImGui::Button("info!"))
{
    notify::insert({ toast_type::toast_type_info, 3000, "Hello World! This is an info! Yes I also support multiline text! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation" });
}

// Render toasts, at the end of your rendering
notify::render();

TODO

Add a fade in and out movement...

Result

Image from Gyazo

License

MIT license

Comments
  • GetMainViewport not defined

    GetMainViewport not defined

    GetMainViewport seems to be undefined, couldn't figure out why. Could it be an issue with my ImGUI version? I'm using v1.69.

    const auto vp_size = GetMainViewport()->Size;

    opened by sxck1337 1
  • NOTIFY_FORMAT doesn't compile

    NOTIFY_FORMAT doesn't compile

    i.e.

    imgui_notify.h:205:83: error: expected expression
        ImGuiToast(ImGuiToastType type, const char* format, ...) : ImGuiToast(type) { NOTIFY_FORMAT(this->set_content, format); }
    
    imgui_notify.h:23:120: note: expanded from macro 'NOTIFY_FORMAT'
    #define NOTIFY_FORMAT(fn, format, ...)  if (format) { va_list args; va_start(args, format); fn(format, args, __VA_ARGS__); va_end(args); }
    

    That's what my clangd 14.0.0 says image

    Clangd config: -Wno-unused-variable,-Wno-infinite-recursion,-Werror=implicit-function-declaration,-Wshadow,-Wno-shadow-field-in-constructor-modified,-Wno-shadow-ivar,-Wuninitialized,-Wunused-label,-Wunused-lambda-capture, ,--target=aarch64

    opened by caxapexac 3
  • sprintf_s in code

    sprintf_s in code

    line about 260-270

    char window_name[50];
    sprintf_s(window_name, "##TOAST%d", i);
    

    I'd suggest to replace it with ImFormat cuz not everyone has sprintf_s function

    opened by caxapexac 0
  • Icons aren't working

    Icons aren't working

    Hey, I followed your instructions and everything works fine except the Icons. I tried it with different fonts, but instead of an Icon it shows a colored Question mark "?". The font applys tho as the text changes the font style based on the Font that I use.

    I use the following code after the Init:

    writefont = io.Fonts->AddFontFromMemoryCompressedTTF(Font_Font_data, Font_Font_size, 16.f); ImFontConfig font_cfg; font_cfg.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryCompressedTTF(Font_Font_data, Font_Font_size, 16.f, &font_cfg); ImGui::MergeIconsWithLatestFont(16.f, false);

    To use the font I do:

    ImGui::PushFont(writefont); //apply font ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.f); ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(43.f / 255.f, 43.f / 255.f, 43.f / 255.f, 255.f / 255.f)); ImGui::RenderNotifications(); ImGui::PopStyleVar(1); ImGui::PopStyleColor(1); ImGui::PopFont();

    opened by Baseult 0
  • Do you know if it requires C++17?

    Do you know if it requires C++17?

    Hey @patrickcjk , thanks for sharing this.

    I am trying to use it in an openFrameworks project without success... I am on VS 2017, and OF is bundled with C++ 11/14.

    After getting these errors:

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	C7525	inline variables require at least '/std:c++17' (compiling source file src\main.cpp)	1_7_Notify	f:\openframeworks\addons\ofxsurfingimgui\1_widgets\1_7_notify\src\imgui_notify.h	220	
    

    I "forced" the VS project to C++17. But I am getting OF related errors like:

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	C2757	'filesystem': a symbol with this name already exists and therefore this name cannot be used as a namespace name (compiling source file src\main.cpp)	1_7_Notify	c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\fstream	24	
    

    Any idea?

    https://github.com/moebiussurfing/ofxSurfingImGui/tree/master/1_Widgets/1_7_Notify/src

    opened by moebiussurfing 0
Owner
Patrick
French student, learning reverse engineering and ASP.NET but mainly programing in C and C++.
Patrick
A file dialog library for Dear ImGui

ImFileDialog A simple file dialog library for Dear ImGui. This library supports favorites, actual Windows icons, image previews, zooming in, etc... DI

dfranx 361 Sep 19, 2022
dear imgui + glfw framework

ImFrame ImFrame is a lightweight framework designed to provide you with a window and graphical backend for the Dear ImGui library. Unlike more traditi

null 54 Sep 20, 2022
Markdown renderer for Dear ImGui using MD4C parser

imgui_md Markdown renderer for Dear ImGui using MD4C parser. C++11 or above imgui_md currently supports the following markdown functionality: Wrapped

Dmitry Mekhontsev 64 Aug 31, 2022
Example program for integrating Dear ImGui and GLFW into Source's App System

This is an example program for integrating Dear ImGui and GLFW into Source's app system, the same thing Source's tools use. Feel free to do with this

null 9 Apr 16, 2022
X11 + GLFW + Dear ImGUI Overlay

Dear ImGUI Overlay X11 + GLFW + Dear ImGUI Overlay made by rdbo Based on https://github.com/rdbo/glfw-overlay How to use? In main.c, there is a window

Rdbo 4 Mar 30, 2022
Minimal example of prototyping CLAP audio plugins using Dear ImGui as the user interface.

clap-imgui Minimal example of prototyping CLAP audio plugins using Dear ImGui as the user interface. This is intended as an example of presenting a UI

schwa 40 Sep 20, 2022
ImGuiFileDialog is a file selection dialog built for (and using only) Dear ImGui

ImGuiFileDialog Purpose ImGuiFileDialog is a file selection dialog built for (and using only) Dear ImGui. My primary goal was to have a custom pane wi

Aiekick 727 Sep 24, 2022
A cross-platform wrapper for using SDL2 with ImGui

ImSDL2 ImSDL2 is an open source "wrapper" of imgui backends available for SDL2. It aims to provide a backend-independent yet simple interface for inte

terens 5 Feb 2, 2022
o/ ImGui Builder is a graphical framework for assembling imgui codes in your interface easily

IMGUI BUILDER The project consists a gui editor of the Imgui framework EDITOR Menu Export 1 - Export cpp file 2 - Cpp file Credits Credits for Shadowy

Code Building 372 Sep 21, 2022
A simple API wrapper that generates images & facts of any animal

animality.h A simple API wrapper that generates images & facts of any animal Required dependencies: libcurl for sending HTTPS requests. pthreads for t

animality 5 Jun 23, 2022
Very fast C++ .PNG writer for 24/32bpp images.

fpng Very fast C++ .PNG writer for 24/32bpp images. fpng.cpp was written to see just how fast you can write .PNG's without sacrificing too much compre

Rich Geldreich 611 Sep 17, 2022
Simpler ImGui Backend Implementation for VulkanHpp.

ImGui-VulkanHpp Simpler ImGui Backend Implementation for VulkanHpp.

takiyu 25 Jul 3, 2022
ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages.

ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages. By zig contained I mean that ZT is intend

null 86 Sep 18, 2022
ImTricks is a collection of useful functions for expanding / improving the functionality of the ImGui.

ImTricks ImTricks is a collection of useful functions for expanding / improving the functionality of the ImGui. At the moment it has in itself: Functi

Alexander Pers0na2 22 Jun 13, 2022
A ImGui Application with Multi Viewports and Docking using D3D11

ImGui-Application Informations A ImGui Application with Multi Viewports and Docking using D3D11 Build You need the DirectX SDK, here the Download link

Argon Projects 10 Sep 23, 2022
Expose the ImGui framework to clasp

Expose the ImGui framework to clasp Installing in the clasp source tree cd clasp/extensions git clone https://github.com/clasp-developers/imgui-clasp

clasp 4 Oct 11, 2021
Growtopia android modmenu with ImGui

Growtopia Android ImGUI Growtopia android modmenu with ImGUI. Features Built with ImGUI. Coming Soon None Requirements The following dependencies are

ZTz 53 Sep 13, 2022
Partial source of the ImGui interfaces used in the Rocket League version of CodeRed.

CodeRed-ImGui Raw source of the ImGui interfaces used in the Rocket League version of CodeRed. About This repo is just part of the ImGui source used i

CodeRed 7 Jun 18, 2022
Sample project to use ImGui + GLFW + OpenGL3

About just a sample project to use ImGui ( https://github.com/ocornut/imgui ) Note Windows 11 Visual Studio 2019 + cmake-gui WSL2 on Windows 11 apt in

iwatake 4 Dec 23, 2021