ImGuiNotify 项目使用教程

ImGuiNotify 项目使用教程

imgui-notifyA (very) simple notification wrapper for Dear ImGui项目地址:https://gitcode.com/gh_mirrors/im/imgui-notify

1. 项目的目录结构及介绍

ImGuiNotify 是一个用于 Dear ImGui 的简单通知包装库。以下是其目录结构和各部分的简要介绍:

imgui-notify/
├── example/
│   ├── example.cpp
│   ├── example.sln
│   └── gitignore
├── LICENSE
├── README.md
└── src/
    └── imgui_notify.h
  • example/: 包含示例代码和解决方案文件。
    • example.cpp: 示例代码文件,展示了如何使用 ImGuiNotify。
    • example.sln: Visual Studio 解决方案文件。
    • gitignore: Git 忽略文件。
  • LICENSE: 项目许可证文件,采用 MIT 许可证。
  • README.md: 项目说明文档。
  • src/: 源代码目录。
    • imgui_notify.h: 主要头文件,包含了通知系统的实现。

2. 项目的启动文件介绍

项目的启动文件是 example/example.cpp。这个文件包含了如何初始化和使用 ImGuiNotify 的示例代码。以下是该文件的关键部分:

#include "src/imgui_notify.h"
#include "tahoma.h" // 必需的字体

// 初始化 ImGui 和 ImGuiNotify
ImGuiIO* io = &ImGui::GetIO();
ImFontConfig font_cfg;
font_cfg.FontDataOwnedByAtlas = false;
io->Fonts->AddFontFromMemoryTTF((void*)tahoma, sizeof(tahoma), 17.0f, &font_cfg);

// 创建通知
ImGuiToast toast(ImGuiToastType::Success, 3000);
toast.setTitle("This is a %s title", "wonderful");
toast.setContent("Lorem ipsum dolor sit amet");
ImGui::InsertNotification(toast);

// 渲染通知
ImGui::RenderNotifications();

3. 项目的配置文件介绍

ImGuiNotify 项目没有专门的配置文件,其配置主要通过代码进行。以下是一些关键的配置步骤:

  1. 字体配置:

    ImFontConfig font_cfg;
    font_cfg.FontDataOwnedByAtlas = false;
    io->Fonts->AddFontFromMemoryTTF((void*)tahoma, sizeof(tahoma), 17.0f, &font_cfg);
    
  2. 通知样式配置:

    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); // 禁用圆角边框
    ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); // 禁用边框
    ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.10f, 0.10f, 0.10f, 1.00f)); // 背景颜色
    
  3. 渲染通知:

    ImGui::RenderNotifications();
    

通过以上步骤,您可以配置和使用 ImGuiNotify 来创建和管理通知。

imgui-notifyA (very) simple notification wrapper for Dear ImGui项目地址:https://gitcode.com/gh_mirrors/im/imgui-notify

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

范准琰Wise

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值