Skip to content

Commit

Permalink
imconfig: Added IMGUI_STB_TRUETYPE_FILENAME, IMGUI_STB_RECT_PACK_FILE…
Browse files Browse the repository at this point in the history
…NAME + documenting IMGUI_DISABLE_STB_XXX flags and hiding IMGUI_STB_NAMESPACE which is misleading.

Fixed typos in todo list.
  • Loading branch information
ocornut committed Mar 20, 2018
1 parent 74b7dce commit fe5347e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Breaking Changes:
Other Changes:
(IN PROGRESS, WILL ADD TO THIS LIST AS WE WORK ON 1.60)

- Doc: Added a Changelog file in the repository to ease comparing versions (it goes back to dear imgui 1.48), until now it was only on GitHub.
- Navigation: merged in the gamepad/keyboard navigation (about one million changes!). (#787, #323)
The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
- To use Keyboard Navigation:
Expand Down Expand Up @@ -138,12 +139,13 @@ Other Changes:
- ImDrawList: Fixed AddRect() with antialiasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646)
- ImDrawList: Added CloneOutput() helper to facilitate the cloning of ImDrawData or ImDrawList for multi-threaded rendering.
- Misc: Functions passed to libc qsort are explicitely marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul]
- Misc: ImVec2: added [] operator. This is becoming desirable for some types of code, better added sooner than later.
- Misc: Exposed IM_OFFSETOF() helper in imgui.h.
- Misc: ImVec2: added [] operator. This is becoming desirable for some code working of either axes independently. Better adding it sooner than later.
- Misc: NewFrame(): Added an assert to detect incorrect filling of the io.KeyMap[] array earlier. (#1555)
- Misc: Added IM_OFFSETOF() helper in imgui.h (previously was in imgui_internal.h)
- Misc: Added obsolete redirection function GetItemsLineHeightWithSpacing() (which redirects to GetFrameHeightWithSpacing()), as intended and stated in docs of 1.53.
- Misc: Added misc/natvis/imgui.natvis for visual studio debugger users to easily visualizer imgui internal types. Added to examples projects.
- Misc: Added misc/natvis/imgui.natvis for visual studio debugger users to easily visualize imgui internal types. Added to examples projects.
- Misc: Added IMGUI_USER_CONFIG to define a custom configuration filename. (#255, #1573, #1144, #41)
- Misc: Added IMGUI_STB_TRUETYPE_FILENAME and IMGUI_STB_RECT_PACK_FILENAME compile time directives to use another version of the stb_ files.
- Misc: Updated stb_rect_pack from 0.10 to 0.11 (minor changes).
- Misc: Added ImGuiConfigFlags_IsSRGB and ImGuiConfigFlags_IsTouchScreen user flags (for io.ConfigFlags).
(Those flags are not used by ImGui itself, they only exists to make it easy for the engine/back-end to pass information to the application in a standard manner.)
Expand Down
8 changes: 6 additions & 2 deletions imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
//---- Pack colors to BGRA8 instead of RGBA8 (if you needed to convert from one to another anyway)
//#define IMGUI_USE_BGRA_PACKED_COLOR

//---- Implement STB libraries in a namespace to avoid linkage conflicts (defaults to global namespace)
//#define IMGUI_STB_NAMESPACE ImGuiStb
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION

//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
Expand Down
19 changes: 15 additions & 4 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@
// STB libraries implementation
//-------------------------------------------------------------------------

//#define IMGUI_STB_NAMESPACE ImGuiStb
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
// Compile time options:
//#define IMGUI_STB_NAMESPACE ImGuiStb
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION

#ifdef IMGUI_STB_NAMESPACE
namespace IMGUI_STB_NAMESPACE
Expand All @@ -87,23 +90,31 @@ namespace IMGUI_STB_NAMESPACE
#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
#endif

#define STBRP_ASSERT(x) IM_ASSERT(x)
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#define STBRP_STATIC
#define STBRP_ASSERT(x) IM_ASSERT(x)
#define STB_RECT_PACK_IMPLEMENTATION
#endif
#ifdef IMGUI_STB_RECT_PACK_FILENAME
#include IMGUI_STB_RECT_PACK_FILENAME
#else
#include "stb_rect_pack.h"
#endif

#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
#define STBTT_malloc(x,u) ((void)(u), ImGui::MemAlloc(x))
#define STBTT_free(x,u) ((void)(u), ImGui::MemFree(x))
#define STBTT_assert(x) IM_ASSERT(x)
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
#define STBTT_STATIC
#define STB_TRUETYPE_IMPLEMENTATION
#else
#define STBTT_DEF extern
#endif
#ifdef IMGUI_STB_TRUETYPE_FILENAME
#include IMGUI_STB_TRUETYPE_FILENAME
#else
#include "stb_truetype.h"
#endif

#ifdef __GNUC__
#pragma GCC diagnostic pop
Expand Down

0 comments on commit fe5347e

Please sign in to comment.