Skip to content

Commit

Permalink
Update docs + ImGui version (#15)
Browse files Browse the repository at this point in the history
* update docs about fonts

* update changelog

* Update CHANGELOG.md

* win example imgui update

* update imgui in unix example
  • Loading branch information
TyomaVader authored Sep 12, 2024
1 parent bb8b24c commit c294570
Show file tree
Hide file tree
Showing 36 changed files with 8,680 additions and 18,445 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## WIP

### Changed
- Switched to compressed fonts ([#14](https://github.com/TyomaVader/ImGuiNotify/pull/14))
Thanks to [OlegSirenko](https://github.com/OlegSirenko)
- Upgraded Dear ImGui version used in example to [v1.91.2](https://github.com/ocornut/imgui/commit/68aa9a86ec933510073932980a0940742ecc833c)

## [0.0.3] - 07.07.2024

### Added
Expand Down Expand Up @@ -53,4 +60,4 @@ Thanks to [@sjy0727](https://github.com/sjy0727) and [@starlight-traveler](https

[0.0.3]: https://github.com/TyomaVader/ImGuiNotify/releases/tag/v0.0.3
[0.0.2]: https://github.com/TyomaVader/ImGuiNotify/releases/tag/v0.0.2
[0.0.1]: https://github.com/TyomaVader/ImGuiNotify/releases/tag/v0.0.1
[0.0.1]: https://github.com/TyomaVader/ImGuiNotify/releases/tag/v0.0.1
30 changes: 8 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ Thanks to [@sjy0727](https://github.com/sjy0727) and [@starlight-traveler](https
- Default Dear ImGui theme changed to *Embrace The Darkness* by [janekb04](https://github.com/janekb04)
- Switched from classic enums to scoped enums
- README clarifications. ([#5](https://github.com/TyomaVader/ImGuiNotify/issues/5))
- Upgraded Dear ImGui version used in example to [v1.90.9](https://github.com/ocornut/imgui/releases/tag/v1.90.9)
- Upgraded Dear ImGui version used in example to [v1.91.2](https://github.com/ocornut/imgui/commit/68aa9a86ec933510073932980a0940742ecc833c)
- Upgraded Font Awesome version
- Switched to compressed fonts ([#14](https://github.com/TyomaVader/ImGuiNotify/pull/14))
Thanks to [OlegSirenko](https://github.com/OlegSirenko)

## [FULL CHANGELOG](https://github.com/TyomaVader/ImGuiNotify/blob/Dev/CHANGELOG.md)

Expand All @@ -49,33 +51,23 @@ Thanks to [@sjy0727](https://github.com/sjy0727) and [@starlight-traveler](https
```c++
#include "ImGuiNotify.hpp"
#include "IconsFontAwesome6.h"
#include "fa-solid-900.h"
```
### Initialisation (after impl call: ImGui_ImplDX12_Init, ImGui_ImplVulkan_Init, etc.)
```c++
io.Fonts->AddFontDefault();

float baseFontSize = 16.0f; // Default font size
float baseFontSize = 16.0f;
float iconFontSize = baseFontSize * 2.0f / 3.0f; // FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly

// Check if FONT_ICON_FILE_NAME_FAS is a valid path
std::ifstream fontAwesomeFile(FONT_ICON_FILE_NAME_FAS);

if (!fontAwesomeFile.good())
{
// If it's not good, then we can't find the font and should abort
std::cerr << "Could not find the FontAwesome font file." << std::endl;
abort();
}

static const ImWchar iconsRanges[] = {ICON_MIN_FA, ICON_MAX_16_FA, 0};
static constexpr ImWchar iconsRanges[] = {ICON_MIN_FA, ICON_MAX_16_FA, 0};
ImFontConfig iconsConfig;
iconsConfig.MergeMode = true;
iconsConfig.PixelSnapH = true;
iconsConfig.GlyphMinAdvanceX = iconFontSize;
io.Fonts->AddFontFromFileTTF(FONT_ICON_FILE_NAME_FAS, iconFontSize, &iconsConfig, iconsRanges);
io.Fonts->AddFontFromMemoryCompressedTTF(fa_solid_900_compressed_data, fa_solid_900_compressed_size, iconFontSize, &iconsConfig, iconsRanges);
```
> [!WARNING]
> `FONT_ICON_FILE_NAME_FAS` may require a different path depending on your project structure, see ```IconsFontAwesome6.h``` for details. Incorrect path will result in a runtime error.
### Create notifications
- Success
```c++
Expand Down Expand Up @@ -131,11 +123,9 @@ ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.f); // Disable borders
// Notifications color setup
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.10f, 0.10f, 0.10f, 1.00f)); // Background color


// Main rendering function
ImGui::RenderNotifications();


//——————————————————————————————— WARNING ———————————————————————————————
// Argument MUST match the amount of ImGui::PushStyleVar() calls
ImGui::PopStyleVar(2);
Expand All @@ -151,7 +141,3 @@ https://github.com/TyomaVader/ImGuiNotify/assets/67346255/c4d9ee3c-5725-4d8d-89e
## License
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/TyomaVader/ImGuiNotify/blob/Dev/LICENSE)
14 changes: 3 additions & 11 deletions unixExample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#[===[
WARNING
The compiled binary HAS to be in the example directory, NOT in the build directory.
Check IconsFontAwesome.h for fix.
]===]

cmake_minimum_required(VERSION 3.10)

project(ImGuiNotify VERSION 0.0.2 LANGUAGES CXX)
project(ImGuiNotify VERSION 0.0.3 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -40,6 +32,7 @@ target_include_directories(test PRIVATE
${IMGUI_DIR}/backends
${IMGUI_DIR}/src/sources
${IMGUI_DIR}/src/headers
${IMGUI_DIR}/fonts
)

find_package(glfw3 REQUIRED)
Expand All @@ -52,7 +45,6 @@ if(UNIX AND NOT APPLE)
endif()

# CMake MacOS Support for unixExample, when installing VulkanSDK choose "Global Source Headers"
# Change unixExample/backends/IconsFontAwesome6.h appropriately as well

if(APPLE)
find_package(Vulkan REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions unixExample/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CXX = g++
#CXX = clang++

EXE = test
IMGUI_DIR = ./
IMGUI_DIR = .
SOURCES = main.cpp


Expand All @@ -29,7 +29,7 @@ OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
LINUX_VULKAN_LIBS = -lvulkan -lpthread -ldl -lX11 -lXrandr

CXXFLAGS = -std=c++23 -I$(IMGUI_DIR)/imgui -I$(IMGUI_DIR)/backends -I$(IMGUI_DIR)/src/sources -I$(IMGUI_DIR)/src/headers
CXXFLAGS = -std=c++23 -I$(IMGUI_DIR)/imgui -I$(IMGUI_DIR)/backends -I$(IMGUI_DIR)/src/sources -I$(IMGUI_DIR)/src/headers -I$(IMGUI_DIR)/fonts
CXXFLAGS += -g -Wall -Wformat
LIBS =

Expand Down
Loading

0 comments on commit c294570

Please sign in to comment.