|
@@ -37,7 +37,7 @@
|
|
|
Index of this file:
|
|
|
// [SECTION] Header mess
|
|
|
// [SECTION] Forward declarations and basic types
|
|
|
-// [SECTION] Texture identifier (ImTextureID)
|
|
|
+// [SECTION] Texture identifiers (ImTextureID, ImTextureRef)
|
|
|
// [SECTION] Dear ImGui end-user API functions
|
|
|
// [SECTION] Flags & Enumerations
|
|
|
// [SECTION] Tables API flags and structures (ImGuiTableFlags, ImGuiTableColumnFlags, ImGuiTableRowFlags, ImGuiTableBgTarget, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs)
|
|
@@ -301,18 +301,38 @@ struct ImVec4
|
|
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// [SECTION] Texture identifier (ImTextureID)
|
|
|
+// [SECTION] Texture identifiers (ImTextureID, ImTextureRef)
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
-// ImTexture: user data for renderer backend to identify a texture [Compile-time configurable type]
|
|
|
+// ImTextureID: user data for renderer backend to identify a texture [Compile-time configurable type]
|
|
|
// - To use something else than an opaque void* pointer: override with e.g. '#define ImTextureID MyTextureType*' in your imconfig.h file.
|
|
|
// - This can be whatever to you want it to be! read the FAQ about ImTextureID for details.
|
|
|
// - You can make this a structure with various constructors if you need. You will have to implement ==/!= operators.
|
|
|
// - (note: before v1.91.4 (2024/10/08) the default type for ImTextureID was void*. Use intermediary intptr_t cast and read FAQ if you have casting warnings)
|
|
|
#ifndef ImTextureID
|
|
|
-typedef ImU64 ImTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that)
|
|
|
+typedef ImU64 ImTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that)
|
|
|
#endif
|
|
|
|
|
|
+// ImTextureRef contains:
|
|
|
+// - a texture/atlas pointer, typically when created by Dear ImGui itself.
|
|
|
+// - OR a raw ImTextureID value (user/backend identifier), typically when created by user code to load images.
|
|
|
+// There is no constructor to create a ImTextureID from a ImTextureData* as we don't expect this to be useful to the end-user.
|
|
|
+IM_MSVC_RUNTIME_CHECKS_OFF
|
|
|
+struct ImTextureRef
|
|
|
+{
|
|
|
+ ImTextureRef() { memset(this, 0, sizeof(*this)); }
|
|
|
+ ImTextureRef(ImTextureID tex_id) { memset(this, 0, sizeof(*this)); _TexID = tex_id; }
|
|
|
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
+ ImTextureRef(void* tex_id) { memset(this, 0, sizeof(*this)); _TexID = (ImTextureID)(size_t)tex_id; } // For legacy backends casting to ImTextureID
|
|
|
+ //inline operator intptr_t() const { return (intptr_t)_TexID; } // For legacy backends casting to ImTextureID
|
|
|
+#endif
|
|
|
+
|
|
|
+ // Members
|
|
|
+ ImFontAtlas* _Atlas; // Texture/Atlas pointer
|
|
|
+ ImTextureID _TexID; // _OR_ Underlying user/backend texture identifier, or zero if not yet uploaded.
|
|
|
+};
|
|
|
+IM_MSVC_RUNTIME_CHECKS_RESTORE
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// [SECTION] Dear ImGui end-user API functions
|
|
|
// (Note that ImGui:: being a namespace, you can add extra ImGui:: functions in your own separate file. Please don't modify imgui source files!)
|
|
@@ -567,9 +587,9 @@ namespace ImGui
|
|
|
// - Image() pads adds style.ImageBorderSize on each side, ImageButton() adds style.FramePadding on each side.
|
|
|
// - ImageButton() draws a background based on regular Button() color + optionally an inner background if specified.
|
|
|
// - An obsolete version of Image(), before 1.91.9 (March 2025), had a 'tint_col' parameter which is now supported by the ImageWithBg() function.
|
|
|
- IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1));
|
|
|
- IMGUI_API void ImageWithBg(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
|
|
- IMGUI_API bool ImageButton(const char* str_id, ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
|
|
+ IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1));
|
|
|
+ IMGUI_API void ImageWithBg(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
|
|
+ IMGUI_API bool ImageButton(const char* str_id, ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
|
|
|
|
|
// Widgets: Combo Box (Dropdown)
|
|
|
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
|
@@ -3004,11 +3024,11 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
|
|
|
// - VtxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled,
|
|
|
// this fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
|
|
|
// Backends made for <1.71. will typically ignore the VtxOffset fields.
|
|
|
-// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
|
|
|
+// - The ClipRect/TexRef/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
|
|
|
struct ImDrawCmd
|
|
|
{
|
|
|
ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
|
|
|
- ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
|
|
+ ImTextureRef TexRef; // 16 // User-provided texture ID. Set by user in ImFontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
|
|
unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices.
|
|
|
unsigned int IdxOffset; // 4 // Start offset in index buffer.
|
|
|
unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
|
@@ -3020,7 +3040,8 @@ struct ImDrawCmd
|
|
|
ImDrawCmd() { memset(this, 0, sizeof(*this)); } // Also ensure our padding fields are zeroed
|
|
|
|
|
|
// Since 1.83: returns ImTextureID associated with this draw call. Warning: DO NOT assume this is always same as 'TextureId' (we will change this function for an upcoming feature)
|
|
|
- inline ImTextureID GetTexID() const { return TextureId; }
|
|
|
+ // Since 1.92: removed ImDrawCmd::TextureId field, the getter function must be used!
|
|
|
+ inline ImTextureID GetTexID() const { return TexRef._TexID; }
|
|
|
};
|
|
|
|
|
|
// Vertex layout
|
|
@@ -3043,7 +3064,7 @@ IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
|
|
|
struct ImDrawCmdHeader
|
|
|
{
|
|
|
ImVec4 ClipRect;
|
|
|
- ImTextureID TextureId;
|
|
|
+ ImTextureRef TexRef;
|
|
|
unsigned int VtxOffset;
|
|
|
};
|
|
|
|
|
@@ -3128,7 +3149,7 @@ struct ImDrawList
|
|
|
ImDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back().
|
|
|
ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!)
|
|
|
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
|
|
- ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
|
|
+ ImVector<ImTextureRef> _TextureStack; // [Internal]
|
|
|
ImVector<ImU8> _CallbacksDataBuf; // [Internal]
|
|
|
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content
|
|
|
const char* _OwnerName; // Pointer to owner window's name for debugging
|
|
@@ -3141,8 +3162,8 @@ struct ImDrawList
|
|
|
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
|
|
IMGUI_API void PushClipRectFullScreen();
|
|
|
IMGUI_API void PopClipRect();
|
|
|
- IMGUI_API void PushTextureID(ImTextureID texture_id);
|
|
|
- IMGUI_API void PopTextureID();
|
|
|
+ IMGUI_API void PushTexture(ImTextureRef tex_ref);
|
|
|
+ IMGUI_API void PopTexture();
|
|
|
inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); }
|
|
|
inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); }
|
|
|
|
|
@@ -3180,12 +3201,12 @@ struct ImDrawList
|
|
|
IMGUI_API void AddConcavePolyFilled(const ImVec2* points, int num_points, ImU32 col);
|
|
|
|
|
|
// Image primitives
|
|
|
- // - Read FAQ to understand what ImTextureID is.
|
|
|
+ // - Read FAQ to understand what ImTextureID/ImTextureRef are.
|
|
|
// - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle.
|
|
|
// - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture.
|
|
|
- IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE);
|
|
|
- IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE);
|
|
|
- IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0);
|
|
|
+ IMGUI_API void AddImage(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE);
|
|
|
+ IMGUI_API void AddImageQuad(ImTextureRef tex_ref, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE);
|
|
|
+ IMGUI_API void AddImageRounded(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0);
|
|
|
|
|
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
|
|
// - Important: filled shapes must always use clockwise winding order! The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
|
|
@@ -3241,6 +3262,10 @@ struct ImDrawList
|
|
|
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
|
|
|
|
|
// Obsolete names
|
|
|
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
+ //IMGUI_API void PushTextureID(ImTextureRef tex_ref) { PushTexture(tex_ref); } // RENAMED in 1.92.x
|
|
|
+ //IMGUI_API void PopTextureID() { PopTexture(); } // RENAMED in 1.92.x
|
|
|
+#endif
|
|
|
//inline void AddEllipse(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0, float thickness = 1.0f) { AddEllipse(center, ImVec2(radius_x, radius_y), col, rot, num_segments, thickness); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
|
//inline void AddEllipseFilled(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0) { AddEllipseFilled(center, ImVec2(radius_x, radius_y), col, rot, num_segments); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
|
//inline void PathEllipticalArcTo(const ImVec2& center, float radius_x, float radius_y, float rot, float a_min, float a_max, int num_segments = 0) { PathEllipticalArcTo(center, ImVec2(radius_x, radius_y), rot, a_min, a_max, num_segments); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
@@ -3253,9 +3278,9 @@ struct ImDrawList
|
|
|
IMGUI_API void _PopUnusedDrawCmd();
|
|
|
IMGUI_API void _TryMergeDrawCmds();
|
|
|
IMGUI_API void _OnChangedClipRect();
|
|
|
- IMGUI_API void _OnChangedTextureID();
|
|
|
+ IMGUI_API void _OnChangedTexture();
|
|
|
IMGUI_API void _OnChangedVtxOffset();
|
|
|
- IMGUI_API void _SetTextureID(ImTextureID texture_id);
|
|
|
+ IMGUI_API void _SetTexture(ImTextureRef tex_ref);
|
|
|
IMGUI_API int _CalcCircleAutoSegmentCount(float radius) const;
|
|
|
IMGUI_API void _PathArcToFastEx(const ImVec2& center, float radius, int a_min_sample, int a_max_sample, int a_step);
|
|
|
IMGUI_API void _PathArcToN(const ImVec2& center, float radius, float a_min, float a_max, int num_segments);
|
|
@@ -3412,7 +3437,11 @@ struct ImFontAtlas
|
|
|
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
|
|
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
|
|
bool IsBuilt() const { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when user didn't build texture but effectively we should check TexID != 0 except that would be backend dependent...
|
|
|
- void SetTexID(ImTextureID id) { TexID = id; }
|
|
|
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
+ void SetTexID(ImTextureID id){ TexID._Atlas = this; TexID._TexID = id; } // FIXME-NEWATLAS: Called by legacy backends.
|
|
|
+ void SetTexID(ImTextureRef id) { TexID = id; } // FIXME-NEWATLAS: Called by legacy backends.
|
|
|
+#endif
|
|
|
+
|
|
|
|
|
|
//-------------------------------------------
|
|
|
// Glyph Ranges
|
|
@@ -3456,7 +3485,7 @@ struct ImFontAtlas
|
|
|
|
|
|
// Input
|
|
|
ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_)
|
|
|
- ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
|
|
|
+ ImTextureRef TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
|
|
|
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
|
|
int TexGlyphPadding; // FIXME: Should be called "TexPackPadding". Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0 (will also need to set AntiAliasedLinesUseTex = false).
|
|
|
void* UserData; // Store your own atlas related user-data (if e.g. you have multiple font atlas).
|
|
@@ -3654,7 +3683,7 @@ struct ImGuiPlatformImeData
|
|
|
namespace ImGui
|
|
|
{
|
|
|
// OBSOLETED in 1.91.9 (from February 2025)
|
|
|
- IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
|
|
+ IMGUI_API void Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col); // <-- 'border_col' was removed in favor of ImGuiCol_ImageBorder. If you use 'tint_col', use ImageWithBg() instead.
|
|
|
// OBSOLETED in 1.91.0 (from July 2024)
|
|
|
static inline void PushButtonRepeat(bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); }
|
|
|
static inline void PopButtonRepeat() { PopItemFlag(); }
|