Skip to content

Commit

Permalink
Notification rendering limit added
Browse files Browse the repository at this point in the history
  • Loading branch information
TyomaVader committed Jan 18, 2024
1 parent ad0df28 commit e54bf8a
Show file tree
Hide file tree
Showing 60 changed files with 2,624 additions and 9,154 deletions.
Empty file modified .github/workflows/c-cpp.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/codeql.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## WIP - 12.10.2023
## WIP - 18.01.2024

### Added
- Simultanious notification rendering limit (See ```NOTIFY_RENDER_LIMIT```)

### Changed
- README clarifications. ([#5](https://github.com/TyomaVader/ImGuiNotify/issues/5))
Expand Down
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified unixExample/CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified unixExample/LICENSE.txt
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions unixExample/Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#
# You will need GLFW (http://www.glfw.org):
# Linux:
# apt-get install libglfw-dev
# Ubuntu, Linux Mint:
# apt-get install libglfw-dev
# Fedora:
# dnf install glfw-devel
# dnf install vulkan-validation-layers
# Mac OS X:
# brew install glfw
# MSYS2:
# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
#

CXX = g++-12
CXX = g++
#CXX = clang++

EXE = test
Expand Down
Empty file modified unixExample/backends/IconsFontAwesome6.h
100644 → 100755
Empty file.
33 changes: 20 additions & 13 deletions unixExample/backends/ImGuiNotify.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Based on imgui-notify by patrickcjk
* https://github.com/patrickcjk/imgui-notify
*
* @version 0.0.1 by TyomaVader
* @date 28.07.2023
* @version 0.0.3 WIP by TyomaVader
* @date 18.01.2024
*/

#ifndef IMGUI_NOTIFY
Expand Down Expand Up @@ -36,16 +36,16 @@
* CONFIGURATION SECTION Start
*/

#define NOTIFY_MAX_MSG_LENGTH 4096 // Max message content length
#define NOTIFY_PADDING_X 20.f // Bottom-left X padding
#define NOTIFY_PADDING_Y 20.f // Bottom-left Y padding
#define NOTIFY_PADDING_MESSAGE_Y 10.f // Padding Y between each message
#define NOTIFY_FADE_IN_OUT_TIME 150 // Fade in and out duration
#define NOTIFY_DEFAULT_DISMISS 3000 // Auto dismiss after X ms (default, applied only of no data provided in constructors)
#define NOTIFY_OPACITY 0.8f // 0-1 Toast opacity
#define NOTIFY_USE_SEPARATOR false // If true, a separator will be rendered between the title and the content
#define NOTIFY_USE_DISMISS_BUTTON true // If true, a dismiss button will be rendered in the top right corner of the toast

#define NOTIFY_MAX_MSG_LENGTH 4096 // Max message content length
#define NOTIFY_PADDING_X 20.f // Bottom-left X padding
#define NOTIFY_PADDING_Y 20.f // Bottom-left Y padding
#define NOTIFY_PADDING_MESSAGE_Y 10.f // Padding Y between each message
#define NOTIFY_FADE_IN_OUT_TIME 150 // Fade in and out duration
#define NOTIFY_DEFAULT_DISMISS 3000 // Auto dismiss after X ms (default, applied only of no data provided in constructors)
#define NOTIFY_OPACITY 0.8f // 0-1 Toast opacity
#define NOTIFY_USE_SEPARATOR false // If true, a separator will be rendered between the title and the content
#define NOTIFY_USE_DISMISS_BUTTON true // If true, a dismiss button will be rendered in the top right corner of the toast
#define NOTIFY_RENDER_LIMIT 5 // Max number of toasts rendered at the same time. Set to 0 for unlimited

/**
* CONFIGURATION SECTION End
Expand Down Expand Up @@ -493,7 +493,7 @@ namespace ImGui

float height = 0.f;

for (size_t i = 0; i < notifications.size(); i++)
for (size_t i = 0; i < notifications.size(); ++i)
{
ImGuiToast* currentToast = &notifications[i];

Expand All @@ -504,6 +504,13 @@ namespace ImGui
continue;
}

#if NOTIFY_RENDER_LIMIT > 0
if (i > NOTIFY_RENDER_LIMIT)
{
continue;
}
#endif

// Get icon, title and other data
const char* icon = currentToast->getIcon();
const char* title = currentToast->getTitle();
Expand Down
Empty file modified unixExample/backends/fa_solid_900.h
100644 → 100755
Empty file.
615 changes: 80 additions & 535 deletions unixExample/backends/imgui_impl_glfw.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions unixExample/backends/imgui_impl_glfw.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.)

// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.

// Issues:
// [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand All @@ -35,6 +30,11 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool ins
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();

// Emscripten related initialization phase methods
#ifdef __EMSCRIPTEN__
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector);
#endif

// GLFW callbacks install
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
Expand Down
Loading

0 comments on commit e54bf8a

Please sign in to comment.