Skip to content

Instantly share code, notes, and snippets.

@kudaba
kudaba / iminputvalue.cpp
Last active April 9, 2020 06:40
Improved number editing control for ImGui
// WARNING: Revision 5+ Requires unreleased code from imgui, stick to 3 or 2 for now (don't look at revision 4)
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>
#include "iminputvalue.h"
namespace ImGui
{
//-------------------------------------------------------------------------------------------------
@kudaba
kudaba / imcanvas.cpp
Last active June 7, 2020 04:36
Virtual canvas utility class.
#include "ImguiCanvas.h"
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
// Not true epsilon, this one is much more useful
constexpr float ImEpsilonf = 0.00001f;
//-------------------------------------------------------------------------------------------------
// Return -1 or +1 (0 returns +1)
@kudaba
kudaba / ImGuiStyleScope.h
Created October 3, 2019 05:48
Helper to set and forget imgui style changes.
//-------------------------------------------------------------------------------------------------
// Helper for managing style changes. Can set and forget.
// Usage 1: ImGuiStyleScope scope(ImGuiCol_Text, ImGuiColors::Red);
// Usage 2:
// ImGuiStyleScope scope;
// scope.Color(ImGuiCol_Text, ImGuiColors::Yellow)
// .Style(ImGuiStyleVar_Alpha, 0.4f);
//-------------------------------------------------------------------------------------------------
class ImGuiStyleScope : GC_NonCopyable
{