mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Update imgui to 1.52.
This commit is contained in:
parent
fbfe625828
commit
97fad073d9
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015 Omar Cornut and ImGui contributors
|
||||
Copyright (c) 2014-2017 Omar Cornut and ImGui contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -13,24 +13,27 @@
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
||||
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
|
||||
|
||||
//---- Don't implement test window functionality (ShowTestWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
|
||||
//---- It is very strongly recommended to NOT disable the test windows. Please read the comment at the top of imgui_demo.cpp to learn why.
|
||||
//#define IMGUI_DISABLE_TEST_WINDOWS
|
||||
|
||||
//---- Don't define obsolete functions names. Consider enabling from time to time or when updating to reduce like hood of using already obsolete function/names
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//---- Don't implement ImFormatString(), ImFormatStringV() so you can reimplement them yourself.
|
||||
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
|
||||
|
||||
//---- Pack colors to BGRA instead of RGBA (remove need to post process vertex buffer in back ends)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Implement STB libraries in a namespace to avoid conflicts
|
||||
//---- Implement STB libraries in a namespace to avoid linkage conflicts
|
||||
//#define IMGUI_STB_NAMESPACE ImGuiStb
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
|
||||
|
2065
imgui/imgui.cpp
2065
imgui/imgui.cpp
File diff suppressed because it is too large
Load Diff
329
imgui/imgui.h
329
imgui/imgui.h
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.51
|
||||
// dear imgui, v1.52
|
||||
// (headers)
|
||||
|
||||
// See imgui.cpp file for documentation.
|
||||
@ -16,7 +16,7 @@
|
||||
#include <stddef.h> // ptrdiff_t, NULL
|
||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||
|
||||
#define IMGUI_VERSION "1.51"
|
||||
#define IMGUI_VERSION "1.52"
|
||||
|
||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
#ifndef IMGUI_API
|
||||
@ -29,12 +29,16 @@
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||
#endif
|
||||
|
||||
// Helpers
|
||||
// Some compilers support applying printf-style warnings to user functions.
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define IM_PRINTFARGS(FMT) __attribute__((format(printf, FMT, (FMT+1))))
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#else
|
||||
#define IM_PRINTFARGS(FMT)
|
||||
#define IM_FMTARGS(FMT)
|
||||
#define IM_FMTLIST(FMT)
|
||||
#endif
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
@ -67,17 +71,18 @@ typedef unsigned int ImU32; // 32-bit unsigned integer (typically used t
|
||||
typedef unsigned int ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
|
||||
typedef unsigned short ImWchar; // character for keyboard input/display
|
||||
typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
|
||||
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
|
||||
typedef int ImGuiKey; // a key identifier (ImGui-side enum) // enum ImGuiKey_
|
||||
typedef int ImGuiColorEditFlags; // color edit flags for Color*() // enum ImGuiColorEditFlags_
|
||||
typedef int ImGuiMouseCursor; // a mouse cursor identifier // enum ImGuiMouseCursor_
|
||||
typedef int ImGuiWindowFlags; // window flags for Begin*() // enum ImGuiWindowFlags_
|
||||
typedef int ImGuiCond; // condition flags for Set*() // enum ImGuiCond_
|
||||
typedef int ImGuiColumnsFlags; // flags for *Columns*() // enum ImGuiColumnsFlags_
|
||||
typedef int ImGuiInputTextFlags; // flags for InputText*() // enum ImGuiInputTextFlags_
|
||||
typedef int ImGuiSelectableFlags; // flags for Selectable() // enum ImGuiSelectableFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // flags for TreeNode*(), Collapsing*() // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiCol; // enum: a color identifier for styling // enum ImGuiCol_
|
||||
typedef int ImGuiStyleVar; // enum: a variable identifier for styling // enum ImGuiStyleVar_
|
||||
typedef int ImGuiKey; // enum: a key identifier (ImGui-side enum) // enum ImGuiKey_
|
||||
typedef int ImGuiMouseCursor; // enum: a mouse cursor identifier // enum ImGuiMouseCursor_
|
||||
typedef int ImGuiCond; // enum: a condition for Set*() // enum ImGuiCond_
|
||||
typedef int ImGuiColorEditFlags; // flags: color edit flags for Color*() // enum ImGuiColorEditFlags_
|
||||
typedef int ImGuiWindowFlags; // flags: window flags for Begin*() // enum ImGuiWindowFlags_
|
||||
typedef int ImGuiColumnsFlags; // flags: for *Columns*() // enum ImGuiColumnsFlags_
|
||||
typedef int ImGuiInputTextFlags; // flags: for InputText*() // enum ImGuiInputTextFlags_
|
||||
typedef int ImGuiSelectableFlags; // flags: for Selectable() // enum ImGuiSelectableFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // flags: for TreeNode*(), Collapsing*() // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiHoveredFlags; // flags: for IsItemHovered() // enum ImGuiHoveredFlags_
|
||||
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
|
||||
typedef void (*ImGuiSizeConstraintCallback)(ImGuiSizeConstraintCallbackData* data);
|
||||
#ifdef _MSC_VER
|
||||
@ -130,7 +135,6 @@ namespace ImGui
|
||||
|
||||
// Window
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // OBSOLETE. this is the older/longer API. the extra parameters aren't very relevant. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! might obsolete this API eventually.
|
||||
IMGUI_API void End(); // finish appending to current window, pop it off the window stack.
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
||||
@ -147,10 +151,10 @@ namespace ImGui
|
||||
IMGUI_API float GetWindowWidth();
|
||||
IMGUI_API float GetWindowHeight();
|
||||
IMGUI_API bool IsWindowCollapsed();
|
||||
IMGUI_API bool IsWindowAppearing();
|
||||
IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
|
||||
|
||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // set next window position. call before Begin()
|
||||
IMGUI_API void SetNextWindowPosCenter(ImGuiCond cond = 0); // set next window position to be centered on screen. call before Begin()
|
||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0,0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeConstraintCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Use callback to apply non-trivial programmatic constraints.
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (enforce the range of scrollbars). set axis to 0.0f to leave it automatic. call before Begin()
|
||||
@ -174,7 +178,7 @@ namespace ImGui
|
||||
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
||||
IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
|
||||
IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
|
||||
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use negative 'offset' to access previous widgets.
|
||||
IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget.
|
||||
IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
|
||||
IMGUI_API ImGuiStorage* GetStateStorage();
|
||||
|
||||
@ -201,13 +205,13 @@ namespace ImGui
|
||||
IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
|
||||
IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
|
||||
IMGUI_API void PopTextWrapPos();
|
||||
IMGUI_API void PushAllowKeyboardFocus(bool v); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
|
||||
IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
|
||||
IMGUI_API void PopAllowKeyboardFocus();
|
||||
IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (uses io.KeyRepeatDelay/io.KeyRepeatRate for now). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
|
||||
IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
|
||||
IMGUI_API void PopButtonRepeat();
|
||||
|
||||
// Cursor / Layout
|
||||
IMGUI_API void Separator(); // horizontal line
|
||||
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
|
||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void NewLine(); // undo a SameLine()
|
||||
IMGUI_API void Spacing(); // add vertical spacing
|
||||
@ -225,7 +229,7 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
|
||||
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
|
||||
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
||||
IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets
|
||||
IMGUI_API void AlignTextToFramePadding(); // vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets)
|
||||
IMGUI_API float GetTextLineHeight(); // height of font == GetWindowFontSize()
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
|
||||
@ -242,34 +246,36 @@ namespace ImGui
|
||||
IMGUI_API int GetColumnsCount();
|
||||
|
||||
// ID scopes
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them.
|
||||
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
|
||||
IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the *entire* stack!
|
||||
IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the entire stack!
|
||||
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end);
|
||||
IMGUI_API void PushID(const void* ptr_id);
|
||||
IMGUI_API void PushID(int int_id);
|
||||
IMGUI_API void PopID();
|
||||
IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). useful if you want to query into ImGuiStorage yourself
|
||||
IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
|
||||
IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
|
||||
IMGUI_API ImGuiID GetID(const void* ptr_id);
|
||||
|
||||
// Widgets
|
||||
IMGUI_API void Text(const char* fmt, ...) IM_PRINTFARGS(1);
|
||||
IMGUI_API void TextV(const char* fmt, va_list args);
|
||||
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
||||
IMGUI_API void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
|
||||
IMGUI_API void TextDisabledV(const char* fmt, va_list args);
|
||||
IMGUI_API void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
|
||||
IMGUI_API void TextWrappedV(const char* fmt, va_list args);
|
||||
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text
|
||||
IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); // display text+label aligned the same way as value+label widgets
|
||||
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args);
|
||||
// Widgets: Text
|
||||
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done, no limits, recommended for long chunks of text
|
||||
IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text
|
||||
IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
|
||||
IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
|
||||
IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets
|
||||
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text()
|
||||
IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||
IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for Bullet()+Text()
|
||||
IMGUI_API void BulletTextV(const char* fmt, va_list args);
|
||||
|
||||
// Widgets: Main
|
||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
|
||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed in text
|
||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size);
|
||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
|
||||
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
|
||||
@ -335,15 +341,15 @@ namespace ImGui
|
||||
|
||||
// Widgets: Trees
|
||||
IMGUI_API bool TreeNode(const char* label); // if returning 'true' the node is open and the tree id is pushed into the id stack. user is responsible for calling TreePop().
|
||||
IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2); // read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
|
||||
IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2); // "
|
||||
IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
||||
IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
||||
IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
|
||||
IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // "
|
||||
IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0);
|
||||
IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_PRINTFARGS(3);
|
||||
IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_PRINTFARGS(3);
|
||||
IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
|
||||
IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args);
|
||||
IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API void TreePush(const char* str_id = NULL); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose
|
||||
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
|
||||
IMGUI_API void TreePop(); // ~ Unindent()+PopId()
|
||||
@ -369,15 +375,15 @@ namespace ImGui
|
||||
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
|
||||
|
||||
// Tooltips
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip().
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip().
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of contents).
|
||||
IMGUI_API void EndTooltip();
|
||||
|
||||
// Menus
|
||||
IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true!
|
||||
IMGUI_API void EndMainMenuBar();
|
||||
IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set). only call EndMenuBar() if this returns true!
|
||||
IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). only call EndMenuBar() if this returns true!
|
||||
IMGUI_API void EndMenuBar();
|
||||
IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
|
||||
IMGUI_API void EndMenu();
|
||||
@ -386,11 +392,12 @@ namespace ImGui
|
||||
|
||||
// Popups
|
||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, int mouse_button = 1); // helper to open popup when clicked on last item. return true when just opened.
|
||||
IMGUI_API bool BeginPopup(const char* str_id); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside)
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // helper to open and begin popup when clicked on last item. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, int mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
|
||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (no window).
|
||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
|
||||
IMGUI_API void EndPopup();
|
||||
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open
|
||||
IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
|
||||
@ -401,18 +408,20 @@ namespace ImGui
|
||||
IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
|
||||
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
|
||||
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
|
||||
IMGUI_API void LogText(const char* fmt, ...) IM_PRINTFARGS(1); // pass text data straight to log (without being displayed)
|
||||
IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
|
||||
|
||||
// Clipping
|
||||
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect);
|
||||
IMGUI_API void PopClipRect();
|
||||
|
||||
// Styles
|
||||
IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL);
|
||||
|
||||
// Utilities
|
||||
IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse?
|
||||
IMGUI_API bool IsItemRectHovered(); // was the last item hovered by mouse? even if another item is active or window is blocked by popup while we are hovering this
|
||||
IMGUI_API bool IsItemActive(); // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
|
||||
IMGUI_API bool IsItemClicked(int mouse_button = 0); // was the last item clicked? (e.g. button/node just clicked on)
|
||||
IMGUI_API bool IsItemVisible(); // was the last item visible? (aka not out of sight due to clipping/scrolling.)
|
||||
IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered by mouse (and usable)?
|
||||
IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
|
||||
IMGUI_API bool IsItemClicked(int mouse_button = 0); // is the last item clicked? (e.g. button/node just clicked on)
|
||||
IMGUI_API bool IsItemVisible(); // is the last item visible? (aka not out of sight due to clipping/scrolling.)
|
||||
IMGUI_API bool IsAnyItemHovered();
|
||||
IMGUI_API bool IsAnyItemActive();
|
||||
IMGUI_API ImVec2 GetItemRectMin(); // get bounding rect of last item in screen space
|
||||
@ -420,11 +429,10 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 GetItemRectSize(); // "
|
||||
IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
|
||||
IMGUI_API bool IsWindowFocused(); // is current window focused
|
||||
IMGUI_API bool IsWindowHovered(); // is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others)
|
||||
IMGUI_API bool IsWindowRectHovered(); // is current window rectnagle hovered, disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
|
||||
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags = 0); // is current window hovered (and typically: not blocked by a popup/modal)
|
||||
IMGUI_API bool IsRootWindowFocused(); // is current root window focused (root = top-most parent of a child, otherwise self)
|
||||
IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
|
||||
IMGUI_API bool IsRootWindowOrAnyChildHovered(); // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
|
||||
IMGUI_API bool IsRootWindowOrAnyChildHovered(ImGuiHoveredFlags flags = 0); // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
|
||||
IMGUI_API bool IsAnyWindowHovered(); // is mouse hovering any visible window
|
||||
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
||||
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
|
||||
@ -448,12 +456,14 @@ namespace ImGui
|
||||
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]!
|
||||
IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
|
||||
IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)..
|
||||
IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
|
||||
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
||||
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
||||
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); //
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||
IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
@ -477,20 +487,6 @@ namespace ImGui
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
||||
|
||||
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline bool IsItemHoveredRect() { return IsItemRectHovered(); } // OBSOLETE 1.51+
|
||||
static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
|
||||
static inline bool IsMouseHoveringAnyWindow() { return IsAnyWindowHovered(); } // OBSOLETE 1.51+
|
||||
static inline bool IsMouseHoveringWindow() { return IsWindowRectHovered(); } // OBSOLETE 1.51+
|
||||
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1<<5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
|
||||
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
||||
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
|
||||
static inline void SetScrollPosHere() { SetScrollHere(); } // OBSOLETE 1.42+
|
||||
static inline bool GetWindowCollapsed() { return ImGui::IsWindowCollapsed(); } // OBSOLETE 1.39+
|
||||
static inline bool IsRectClipped(const ImVec2& size) { return !IsRectVisible(size); } // OBSOLETE 1.39+
|
||||
#endif
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
// Flags for ImGui::Begin()
|
||||
@ -506,7 +502,7 @@ enum ImGuiWindowFlags_
|
||||
ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
|
||||
ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items
|
||||
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
|
||||
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs
|
||||
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs, hovering test with pass through.
|
||||
ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
|
||||
ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
|
||||
ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
|
||||
@ -560,8 +556,9 @@ enum ImGuiTreeNodeFlags_
|
||||
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
|
||||
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
|
||||
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 10, // FIXME: TODO: Extend hit box horizontally even if not framed
|
||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
||||
ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
|
||||
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
|
||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
||||
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
||||
};
|
||||
|
||||
@ -574,6 +571,17 @@ enum ImGuiSelectableFlags_
|
||||
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2 // Generate press events on double clicks too
|
||||
};
|
||||
|
||||
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
|
||||
enum ImGuiHoveredFlags_
|
||||
{
|
||||
ImGuiHoveredFlags_Default = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 0, // Return true even if a popup window is normally blocking access to this item/window
|
||||
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 1, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 2, // Return true even if an active item is blocking access to this item/window
|
||||
ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 3, // Return true even if the position is overlapped by another window
|
||||
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped
|
||||
};
|
||||
|
||||
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
||||
enum ImGuiKey_
|
||||
{
|
||||
@ -613,8 +621,8 @@ enum ImGuiCol_
|
||||
ImGuiCol_FrameBgHovered,
|
||||
ImGuiCol_FrameBgActive,
|
||||
ImGuiCol_TitleBg,
|
||||
ImGuiCol_TitleBgCollapsed,
|
||||
ImGuiCol_TitleBgActive,
|
||||
ImGuiCol_TitleBgCollapsed,
|
||||
ImGuiCol_MenuBarBg,
|
||||
ImGuiCol_ScrollbarBg,
|
||||
ImGuiCol_ScrollbarGrab,
|
||||
@ -718,8 +726,8 @@ enum ImGuiMouseCursor_
|
||||
ImGuiMouseCursor_Count_
|
||||
};
|
||||
|
||||
// Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
|
||||
// All those functions treat 0 as a shortcut to ImGuiCond_Always
|
||||
// Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
|
||||
// All those functions treat 0 as a shortcut to ImGuiCond_Always. From the point of view of the user use this as an enum (don't combine multiple values into flags).
|
||||
enum ImGuiCond_
|
||||
{
|
||||
ImGuiCond_Always = 1 << 0, // Set the variable
|
||||
@ -761,6 +769,7 @@ struct ImGuiStyle
|
||||
ImVec4 Colors[ImGuiCol_COUNT];
|
||||
|
||||
IMGUI_API ImGuiStyle();
|
||||
IMGUI_API void ScaleAllSizes(float scale_factor);
|
||||
};
|
||||
|
||||
// This is where your app communicate with ImGui. Access via ImGui::GetIO().
|
||||
@ -781,7 +790,7 @@ struct ImGuiIO
|
||||
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging
|
||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
||||
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
|
||||
float KeyRepeatRate; // = 0.020f // When holding a key/button, rate at which it repeats, in seconds.
|
||||
float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
|
||||
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
||||
|
||||
ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
|
||||
@ -824,7 +833,7 @@ struct ImGuiIO
|
||||
// Input - Fill before calling NewFrame()
|
||||
//------------------------------------------------------------------
|
||||
|
||||
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||
ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (on another screen, etc.)
|
||||
bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
||||
float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
|
||||
bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
|
||||
@ -847,6 +856,7 @@ struct ImGuiIO
|
||||
bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input). Use to hide mouse from the rest of your application
|
||||
bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input). Use to hide keyboard from the rest of your application
|
||||
bool WantTextInput; // Some text input widget is active, which will read input characters from the InputCharacters array. Use to activate on screen keyboard if your system needs one
|
||||
bool WantMoveMouse; // [BETA-NAV] MousePos has been altered. back-end should reposition mouse on next frame. used only if 'NavMovesMouse=true'.
|
||||
float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
|
||||
int MetricsAllocs; // Number of active memory allocations
|
||||
int MetricsRenderVertices; // Vertices output during last call to Render()
|
||||
@ -855,13 +865,13 @@ struct ImGuiIO
|
||||
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are negative, so a disappearing/reappearing mouse won't have a huge delta for one frame.
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// [Private] ImGui will maintain those fields. Forward compatibility not guaranteed!
|
||||
// [Internal] ImGui will maintain those fields. Forward compatibility not guaranteed!
|
||||
//------------------------------------------------------------------
|
||||
|
||||
ImVec2 MousePosPrev; // Previous mouse position temporary storage (nb: not for public use, set to MousePos in NewFrame())
|
||||
bool MouseClicked[5]; // Mouse button went from !Down to Down
|
||||
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
||||
float MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
||||
bool MouseClicked[5]; // Mouse button went from !Down to Down
|
||||
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
|
||||
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
||||
bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||
@ -874,6 +884,27 @@ struct ImGuiIO
|
||||
IMGUI_API ImGuiIO();
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Obsolete functions (Will be removed! Also see 'API BREAKING CHANGES' section in imgui.cpp)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
namespace ImGui
|
||||
{
|
||||
bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // OBSOLETE 1.52+. use SetNextWindowSize() instead if you want to set a window size.
|
||||
static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); } // OBSOLETE 1.52+
|
||||
static inline void SetNextWindowPosCenter(ImGuiCond cond = 0) { SetNextWindowPos(ImVec2(GetIO().DisplaySize.x * 0.5f, GetIO().DisplaySize.y * 0.5f), cond, ImVec2(0.5f, 0.5f)); } // OBSOLETE 1.52+
|
||||
static inline bool IsItemHoveredRect() { return IsItemHovered(ImGuiHoveredFlags_RectOnly); } // OBSOLETE 1.51+
|
||||
static inline bool IsPosHoveringAnyWindow(const ImVec2&) { IM_ASSERT(0); return false; } // OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
|
||||
static inline bool IsMouseHoveringAnyWindow() { return IsAnyWindowHovered(); } // OBSOLETE 1.51+
|
||||
static inline bool IsMouseHoveringWindow() { return IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); } // OBSOLETE 1.51+
|
||||
static inline bool CollapsingHeader(const char* label, const char* str_id, bool framed = true, bool default_open = false) { (void)str_id; (void)framed; ImGuiTreeNodeFlags default_open_flags = 1 << 5; return CollapsingHeader(label, (default_open ? default_open_flags : 0)); } // OBSOLETE 1.49+
|
||||
static inline ImFont* GetWindowFont() { return GetFont(); } // OBSOLETE 1.48+
|
||||
static inline float GetWindowFontSize() { return GetFontSize(); } // OBSOLETE 1.48+
|
||||
static inline void SetScrollPosHere() { SetScrollHere(); } // OBSOLETE 1.42+
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -916,12 +947,13 @@ public:
|
||||
inline int _grow_capacity(int size) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > size ? new_capacity : size; }
|
||||
|
||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||
inline void resize(int new_size, const T& v){ if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) Data[n] = v; Size = new_size; }
|
||||
inline void reserve(int new_capacity)
|
||||
{
|
||||
if (new_capacity <= Capacity) return;
|
||||
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
||||
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T));
|
||||
if (Data)
|
||||
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
||||
memcpy(new_data, Data, (size_t)Size * sizeof(T));
|
||||
ImGui::MemFree(Data);
|
||||
Data = new_data;
|
||||
Capacity = new_capacity;
|
||||
@ -996,8 +1028,8 @@ struct ImGuiTextBuffer
|
||||
bool empty() { return Buf.Size <= 1; }
|
||||
void clear() { Buf.clear(); Buf.push_back(0); }
|
||||
const char* c_str() const { return Buf.Data; }
|
||||
IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2);
|
||||
IMGUI_API void appendv(const char* fmt, va_list args);
|
||||
IMGUI_API void append(const char* fmt, ...) IM_FMTARGS(2);
|
||||
IMGUI_API void appendv(const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
};
|
||||
|
||||
// Helper: Simple Key->value storage
|
||||
@ -1317,15 +1349,17 @@ struct ImFontConfig
|
||||
{
|
||||
void* FontData; // // TTF/OTF data
|
||||
int FontDataSize; // // TTF/OTF data size
|
||||
bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
|
||||
bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself).
|
||||
int FontNo; // 0 // Index of font within TTF/OTF file
|
||||
float SizePixels; // // Size in pixels for rasterizer
|
||||
float SizePixels; // // Size in pixels for rasterizer.
|
||||
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
||||
bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
|
||||
ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
|
||||
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input
|
||||
const ImWchar* GlyphRanges; // // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
|
||||
ImVec2 GlyphExtraSpacing; // 1, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
|
||||
ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
|
||||
const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
|
||||
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
|
||||
unsigned int RasterizerFlags; // 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one.
|
||||
float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
|
||||
|
||||
// [Internal]
|
||||
char Name[32]; // Name (strictly to ease debugging)
|
||||
@ -1334,6 +1368,14 @@ struct ImFontConfig
|
||||
IMGUI_API ImFontConfig();
|
||||
};
|
||||
|
||||
struct ImFontGlyph
|
||||
{
|
||||
ImWchar Codepoint; // 0x0000..0xFFFF
|
||||
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
|
||||
float X0, Y0, X1, Y1; // Glyph corners
|
||||
float U0, V0, U1, V1; // Texture coordinates
|
||||
};
|
||||
|
||||
// Load and rasterize multiple TTF/OTF fonts into a same texture.
|
||||
// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
|
||||
// We also add custom graphic data into the texture that serves for ImGui.
|
||||
@ -1357,25 +1399,29 @@ struct ImFontAtlas
|
||||
IMGUI_API void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates)
|
||||
IMGUI_API void Clear(); // Clear all
|
||||
|
||||
// Retrieve texture data
|
||||
// User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
|
||||
// After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
|
||||
// RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
|
||||
// Build atlas, retrieve pixel data.
|
||||
// User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
|
||||
// RGBA32 format is provided for convenience and compatibility, but note that unless you use CustomRect to draw color data, the RGB pixels emitted from Fonts will all be white (~75% of waste).
|
||||
// Pitch = Width * BytesPerPixels
|
||||
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||
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
|
||||
void SetTexID(ImTextureID id) { TexID = id; }
|
||||
|
||||
//-------------------------------------------
|
||||
// Glyph Ranges
|
||||
//-------------------------------------------
|
||||
|
||||
// Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
|
||||
// NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
|
||||
IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
|
||||
IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters
|
||||
IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
|
||||
IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
|
||||
IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Default + Japanese + full set of about 21000 CJK Unified Ideographs
|
||||
IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
|
||||
IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters
|
||||
|
||||
// Helpers to build glyph ranges from text data. Feed all your application strings/characters to it then call BuildRanges().
|
||||
// Helpers to build glyph ranges from text data. Feed your application strings/characters to it then call BuildRanges().
|
||||
struct GlyphRangesBuilder
|
||||
{
|
||||
ImVector<unsigned char> UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
|
||||
@ -1388,57 +1434,63 @@ struct ImFontAtlas
|
||||
IMGUI_API void BuildRanges(ImVector<ImWchar>* out_ranges); // Output new ranges
|
||||
};
|
||||
|
||||
//-------------------------------------------
|
||||
// Custom Rectangles/Glyphs API
|
||||
//-------------------------------------------
|
||||
|
||||
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes. After calling Build(), you can query the rectangle position and render your pixels.
|
||||
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||
struct CustomRect
|
||||
{
|
||||
unsigned int ID; // Input // User ID. Use <0x10000 to map into a font glyph, >=0x10000 for other/internal/custom texture data.
|
||||
unsigned short Width, Height; // Input // Desired rectangle dimension
|
||||
unsigned short X, Y; // Output // Packed position in Atlas
|
||||
float GlyphAdvanceX; // Input // For custom font glyphs only (ID<0x10000): glyph xadvance
|
||||
ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID<0x10000): glyph display offset
|
||||
ImFont* Font; // Input // For custom font glyphs only (ID<0x10000): target font
|
||||
CustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
|
||||
bool IsPacked() const { return X != 0xFFFF; }
|
||||
};
|
||||
|
||||
IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font.
|
||||
IMGUI_API void CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
|
||||
const CustomRect* GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||
|
||||
//-------------------------------------------
|
||||
// Members
|
||||
// (Access texture data via GetTexData*() calls which will setup a default font for you.)
|
||||
//-------------------------------------------
|
||||
|
||||
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.
|
||||
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; // Padding between glyphs within texture in pixels. Defaults to 1.
|
||||
|
||||
// [Internal]
|
||||
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
|
||||
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
||||
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
||||
int TexWidth; // Texture width calculated during Build().
|
||||
int TexHeight; // Texture height calculated during Build().
|
||||
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; // Padding between glyphs within texture in pixels. Defaults to 1.
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
||||
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
||||
|
||||
// [Private] User rectangle for packing custom texture data into the atlas.
|
||||
struct CustomRect
|
||||
{
|
||||
unsigned int ID; // Input // User ID. <0x10000 for font mapped data (WIP/UNSUPPORTED), >=0x10000 for other texture data
|
||||
unsigned short Width, Height; // Input // Desired rectangle dimension
|
||||
unsigned short X, Y; // Output // Packed position in Atlas
|
||||
CustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; }
|
||||
bool IsPacked() const { return X != 0xFFFF; }
|
||||
};
|
||||
|
||||
// [Private] Members
|
||||
ImVector<CustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
|
||||
ImVector<ImFontConfig> ConfigData; // Internal data
|
||||
IMGUI_API bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
|
||||
IMGUI_API int CustomRectRegister(unsigned int id, int width, int height);
|
||||
IMGUI_API void CustomRectCalcUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max);
|
||||
int CustomRectIds[1]; // Identifiers of custom texture rectangle used by ImFontAtlas/ImDrawList
|
||||
};
|
||||
|
||||
// Font runtime data and rendering
|
||||
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
|
||||
struct ImFont
|
||||
{
|
||||
struct Glyph
|
||||
{
|
||||
ImWchar Codepoint;
|
||||
float XAdvance;
|
||||
float X0, Y0, X1, Y1;
|
||||
float U0, V0, U1, V1; // Texture coordinates
|
||||
};
|
||||
|
||||
// Members: Hot ~62/78 bytes
|
||||
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
|
||||
float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
||||
ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels
|
||||
ImVector<Glyph> Glyphs; // // All glyphs.
|
||||
ImVector<float> IndexXAdvance; // // Sparse. Glyphs->XAdvance in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
||||
ImVector<ImFontGlyph> Glyphs; // // All glyphs.
|
||||
ImVector<float> IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
|
||||
ImVector<unsigned short> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
|
||||
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
||||
float FallbackXAdvance; // == FallbackGlyph->XAdvance
|
||||
const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
|
||||
float FallbackAdvanceX; // == FallbackGlyph->AdvanceX
|
||||
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
|
||||
|
||||
// Members: Cold ~18/26 bytes
|
||||
@ -1451,11 +1503,11 @@ struct ImFont
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
IMGUI_API ~ImFont();
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void ClearOutputData();
|
||||
IMGUI_API void BuildLookupTable();
|
||||
IMGUI_API const Glyph* FindGlyph(ImWchar c) const;
|
||||
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
|
||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexXAdvance.Size) ? IndexXAdvance[(int)c] : FallbackXAdvance; }
|
||||
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
|
||||
bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
|
||||
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
||||
@ -1465,9 +1517,14 @@ struct ImFont
|
||||
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const;
|
||||
IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
|
||||
|
||||
// Private
|
||||
// [Internal]
|
||||
IMGUI_API void GrowIndex(int new_size);
|
||||
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
||||
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
typedef ImFontGlyph Glyph; // OBSOLETE 1.52+
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__clang__)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.51
|
||||
// dear imgui, v1.52
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||
@ -260,7 +260,6 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
|
||||
if (ImGui::CollapsingHeader("Widgets"))
|
||||
{
|
||||
|
||||
if (ImGui::TreeNode("Basic"))
|
||||
{
|
||||
static int clicked = 0;
|
||||
@ -430,7 +429,8 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
else
|
||||
{
|
||||
// Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
|
||||
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen, "Selectable Leaf %d", i);
|
||||
node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
|
||||
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
|
||||
if (ImGui::IsItemClicked())
|
||||
node_clicked = i;
|
||||
}
|
||||
@ -454,14 +454,16 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
if (ImGui::TreeNode("Collapsing Headers"))
|
||||
{
|
||||
static bool closable_group = true;
|
||||
ImGui::Checkbox("Enable extra group", &closable_group);
|
||||
if (ImGui::CollapsingHeader("Header"))
|
||||
{
|
||||
ImGui::Checkbox("Enable extra group", &closable_group);
|
||||
ImGui::Text("IsItemHovered: %d", IsItemHovered());
|
||||
for (int i = 0; i < 5; i++)
|
||||
ImGui::Text("Some content %d", i);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Header with a close button", &closable_group))
|
||||
{
|
||||
ImGui::Text("IsItemHovered: %d", IsItemHovered());
|
||||
for (int i = 0; i < 5; i++)
|
||||
ImGui::Text("More content %d", i);
|
||||
}
|
||||
@ -809,7 +811,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
}
|
||||
|
||||
ImGui::Text("Color button only:");
|
||||
ImGui::ColorButton("MyColor##3b", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
|
||||
ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
|
||||
|
||||
ImGui::Text("Color picker:");
|
||||
static bool alpha = true;
|
||||
@ -1054,7 +1056,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::TextColored(ImVec4(1,1,0,1), "Sailor");
|
||||
|
||||
// Button
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Normal buttons"); ImGui::SameLine();
|
||||
ImGui::Button("Banana"); ImGui::SameLine();
|
||||
ImGui::Button("Apple"); ImGui::SameLine();
|
||||
@ -1127,11 +1129,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Button("CCC");
|
||||
ImGui::Button("DDD");
|
||||
ImGui::EndGroup();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Group hovered");
|
||||
ImGui::SameLine();
|
||||
ImGui::Button("EEE");
|
||||
ImGui::EndGroup();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("First group hovered");
|
||||
}
|
||||
// Capture the group size and create widgets using the same size
|
||||
ImVec2 size = ImGui::GetItemRectSize();
|
||||
@ -1180,11 +1182,12 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("TEST"); ImGui::SameLine();
|
||||
ImGui::SmallButton("TEST##2");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // If your line starts with text, call this to align it to upcoming widgets.
|
||||
ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
|
||||
ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
|
||||
ImGui::Button("Widget##1"); ImGui::SameLine();
|
||||
ImGui::Text("Widget"); ImGui::SameLine();
|
||||
ImGui::SmallButton("Widget##2");
|
||||
ImGui::SmallButton("Widget##2"); ImGui::SameLine();
|
||||
ImGui::Button("Widget##3");
|
||||
|
||||
// Tree
|
||||
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
@ -1192,7 +1195,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
|
||||
bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
|
||||
if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
|
||||
@ -1202,7 +1205,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
ImGui::BulletText("Bullet text");
|
||||
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::BulletText("Node");
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
|
||||
|
||||
@ -1380,41 +1383,32 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
|
||||
ImGui::Separator();
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
|
||||
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
|
||||
ImGui::PushID("foo");
|
||||
ImGui::MenuItem("Menu item", "CTRL+M");
|
||||
if (ImGui::BeginMenu("Menu inside a regular window"))
|
||||
{
|
||||
ShowExampleMenuFile();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Context menus"))
|
||||
{
|
||||
// BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing:
|
||||
// if (IsItemHovered() && IsMouseClicked(0))
|
||||
// OpenPopup(id);
|
||||
// return BeginPopup(id);
|
||||
// For more advanced uses you may want to replicate and cuztomize this code. This the comments inside BeginPopupContextItem() implementation.
|
||||
static float value = 0.5f;
|
||||
ImGui::Text("Value = %.3f (<-- right-click here)", value);
|
||||
if (ImGui::BeginPopupContextItem("item context menu"))
|
||||
{
|
||||
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
||||
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
||||
ImGui::DragFloat("Value", &value, 0.1f, 0.0f, 0.0f);
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
static char name[32] = "Label1";
|
||||
char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceeding label
|
||||
char buf[64]; sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label
|
||||
ImGui::Button(buf);
|
||||
if (ImGui::BeginPopupContextItem("rename context menu"))
|
||||
if (ImGui::BeginPopupContextItem()) // When used after an item that has an ID (here the Button), we can skip providing an ID to BeginPopupContextItem().
|
||||
{
|
||||
ImGui::Text("Edit name:");
|
||||
ImGui::InputText("##edit", name, IM_ARRAYSIZE(name));
|
||||
@ -1459,6 +1453,8 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDarkening] for darkening.");
|
||||
static int item = 1;
|
||||
ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
||||
static float color[4] = { 0.4f,0.7f,0.0f,0.5f };
|
||||
ImGui::ColorEdit4("color", color); // This is to test behavior of stacked regular popups over a modal
|
||||
|
||||
if (ImGui::Button("Add another modal.."))
|
||||
ImGui::OpenPopup("Stacked 2");
|
||||
@ -1477,6 +1473,25 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Menus inside a regular window"))
|
||||
{
|
||||
ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!");
|
||||
ImGui::Separator();
|
||||
// NB: As a quirk in this very specific example, we want to differentiate the parent of this menu from the parent of the various popup menus above.
|
||||
// To do so we are encloding the items in a PushID()/PopID() block to make them two different menusets. If we don't, opening any popup above and hovering our menu here
|
||||
// would open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, which is the desired behavior for regular menus.
|
||||
ImGui::PushID("foo");
|
||||
ImGui::MenuItem("Menu item", "CTRL+M");
|
||||
if (ImGui::BeginMenu("Menu inside a regular window"))
|
||||
{
|
||||
ShowExampleMenuFile();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::Separator();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Columns"))
|
||||
@ -1506,7 +1521,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Text("Hovered"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
@ -1517,10 +1532,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
bool hovered = ImGui::IsItemHovered();
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
ImGui::Text("%d", hovered); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
@ -1550,9 +1566,9 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
||||
if (ImGui::CollapsingHeader("Category B")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
||||
if (ImGui::CollapsingHeader("Category C")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
||||
if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
|
||||
if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
|
||||
if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn();
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
ImGui::TreePop();
|
||||
@ -1677,6 +1693,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse);
|
||||
ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
|
||||
ImGui::Text("WantTextInput: %d", io.WantTextInput);
|
||||
ImGui::Text("WantMoveMouse: %d", io.WantMoveMouse);
|
||||
|
||||
if (ImGui::TreeNode("Keyboard & Mouse State"))
|
||||
{
|
||||
@ -1748,6 +1765,34 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Hovering"))
|
||||
{
|
||||
// Testing IsWindowHovered() function
|
||||
ImGui::BulletText(
|
||||
"IsWindowHovered() = %d\n"
|
||||
"IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n"
|
||||
"IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n",
|
||||
ImGui::IsWindowHovered(),
|
||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
||||
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem));
|
||||
|
||||
// Testing IsItemHovered() function (because BulletText is an item itself and that would affect the output of IsItemHovered, we pass all lines in a single items to shorten the code)
|
||||
ImGui::Button("ITEM");
|
||||
ImGui::BulletText(
|
||||
"IsItemHovered() = %d\n"
|
||||
"IsItemHovered(_AllowWhenBlockedByPopup) = %d\n"
|
||||
"IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
||||
"IsItemHovered(_AllowWhenOverlapped) = %d\n"
|
||||
"IsItemhovered(_RectOnly) = %d\n",
|
||||
ImGui::IsItemHovered(),
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly));
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Dragging"))
|
||||
{
|
||||
ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
|
||||
@ -1847,13 +1892,13 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::LogToClipboard();
|
||||
else
|
||||
ImGui::LogToTTY();
|
||||
ImGui::LogText("ImGuiStyle& style = ImGui::GetStyle();" IM_NEWLINE);
|
||||
ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
|
||||
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
||||
{
|
||||
const ImVec4& col = style.Colors[i];
|
||||
const char* name = ImGui::GetStyleColorName(i);
|
||||
if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &default_style.Colors[i]), sizeof(ImVec4)) != 0)
|
||||
ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
|
||||
ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 23-(int)strlen(name), "", col.x, col.y, col.z, col.w);
|
||||
}
|
||||
ImGui::LogFinish();
|
||||
}
|
||||
@ -1906,6 +1951,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||
{
|
||||
ImFont* font = atlas->Fonts[i];
|
||||
ImGui::PushID(font);
|
||||
bool font_details_opened = ImGui::TreeNode(font, "Font %d: \'%s\', %.2f px, %d glyphs", i, font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size);
|
||||
ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) ImGui::GetIO().FontDefault = font;
|
||||
if (font_details_opened)
|
||||
@ -1926,7 +1972,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
||||
{
|
||||
// Display all glyphs of the fonts in separate pages of 256 characters
|
||||
const ImFont::Glyph* glyph_fallback = font->FallbackGlyph; // Forcefully/dodgily make FindGlyph() return NULL on fallback, which isn't the default behavior.
|
||||
const ImFontGlyph* glyph_fallback = font->FallbackGlyph; // Forcefully/dodgily make FindGlyph() return NULL on fallback, which isn't the default behavior.
|
||||
font->FallbackGlyph = NULL;
|
||||
for (int base = 0; base < 0x10000; base += 256)
|
||||
{
|
||||
@ -1943,7 +1989,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
{
|
||||
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size.x + cell_spacing), base_pos.y + (n / 16) * (cell_size.y + cell_spacing));
|
||||
ImVec2 cell_p2(cell_p1.x + cell_size.x, cell_p1.y + cell_size.y);
|
||||
const ImFont::Glyph* glyph = font->FindGlyph((ImWchar)(base+n));;
|
||||
const ImFontGlyph* glyph = font->FindGlyph((ImWchar)(base+n));;
|
||||
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50));
|
||||
font->RenderChar(draw_list, cell_size.x, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
|
||||
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
|
||||
@ -1951,7 +1997,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Codepoint: U+%04X", base+n);
|
||||
ImGui::Separator();
|
||||
ImGui::Text("XAdvance+1: %.1f", glyph->XAdvance);
|
||||
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
|
||||
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
|
||||
ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
|
||||
ImGui::EndTooltip();
|
||||
@ -1966,6 +2012,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
static float window_scale = 1.0f;
|
||||
ImGui::DragFloat("this window scale", &window_scale, 0.005f, 0.3f, 2.0f, "%.1f"); // scale only this window
|
||||
@ -2105,28 +2152,40 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
||||
"Custom: Fixed Steps (100)",
|
||||
};
|
||||
ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
|
||||
if (ImGui::Button("200x200")) ImGui::SetWindowSize(ImVec2(200,200)); ImGui::SameLine();
|
||||
if (ImGui::Button("500x500")) ImGui::SetWindowSize(ImVec2(500,500)); ImGui::SameLine();
|
||||
if (ImGui::Button("800x200")) ImGui::SetWindowSize(ImVec2(800,200));
|
||||
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200,200)); } ImGui::SameLine();
|
||||
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500,500)); } ImGui::SameLine();
|
||||
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800,200)); }
|
||||
for (int i = 0; i < 10; i++)
|
||||
ImGui::Text("Hello, sailor! Making this line long enough for the example.");
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Demonstrate creating a simple static window with no decoration.
|
||||
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
|
||||
static void ShowExampleAppFixedOverlay(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(10,10));
|
||||
if (!ImGui::Begin("Example: Fixed Overlay", p_open, ImVec2(0,0), 0.3f, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings))
|
||||
const float DISTANCE = 10.0f;
|
||||
static int corner = 0;
|
||||
ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
|
||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); // Transparent background
|
||||
if (ImGui::Begin("Example: Fixed Overlay", p_open, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
ImGui::Text("Simple overlay\non the top-left side of the screen.");
|
||||
ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
|
||||
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
||||
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
||||
if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
// Demonstrate using "##" and "###" in identifiers to manipulate ID generation.
|
||||
@ -2298,8 +2357,9 @@ struct ExampleAppConsole
|
||||
ScrollToBottom = true;
|
||||
}
|
||||
|
||||
void AddLog(const char* fmt, ...) IM_PRINTFARGS(2)
|
||||
void AddLog(const char* fmt, ...) IM_FMTARGS(2)
|
||||
{
|
||||
// FIXME-OPT
|
||||
char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
@ -2325,8 +2385,8 @@ struct ExampleAppConsole
|
||||
// TODO: display items starting from the bottom
|
||||
|
||||
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Clear")) ClearLog(); ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
|
||||
bool copy_to_clipboard = ImGui::SmallButton("Copy"); ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Scroll to bottom")) ScrollToBottom = true;
|
||||
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
||||
@ -2385,7 +2445,7 @@ struct ExampleAppConsole
|
||||
if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
|
||||
{
|
||||
char* input_end = InputBuf+strlen(InputBuf);
|
||||
while (input_end > InputBuf && input_end[-1] == ' ') input_end--; *input_end = 0;
|
||||
while (input_end > InputBuf && input_end[-1] == ' ') { input_end--; } *input_end = 0;
|
||||
if (InputBuf[0])
|
||||
ExecCommand(InputBuf);
|
||||
strcpy(InputBuf, "");
|
||||
@ -2426,7 +2486,8 @@ struct ExampleAppConsole
|
||||
}
|
||||
else if (Stricmp(command_line, "HISTORY") == 0)
|
||||
{
|
||||
for (int i = History.Size >= 10 ? History.Size - 10 : 0; i < History.Size; i++)
|
||||
int first = History.Size - 10;
|
||||
for (int i = first > 0 ? first : 0; i < History.Size; i++)
|
||||
AddLog("%3d: %s\n", i, History[i]);
|
||||
}
|
||||
else
|
||||
@ -2560,7 +2621,7 @@ struct ExampleAppLog
|
||||
|
||||
void Clear() { Buf.clear(); LineOffsets.clear(); }
|
||||
|
||||
void AddLog(const char* fmt, ...) IM_PRINTFARGS(2)
|
||||
void AddLog(const char* fmt, ...) IM_FMTARGS(2)
|
||||
{
|
||||
int old_size = Buf.size();
|
||||
va_list args;
|
||||
@ -2696,10 +2757,10 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
static void ShowDummyObject(const char* prefix, int uid)
|
||||
{
|
||||
ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
||||
ImGui::AlignFirstTextHeightToWidgets(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
|
||||
ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high.
|
||||
bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
|
||||
ImGui::NextColumn();
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("my sailor is rich");
|
||||
ImGui::NextColumn();
|
||||
if (node_open)
|
||||
@ -2714,7 +2775,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::AlignFirstTextHeightToWidgets();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
// Here we use a Selectable (instead of Text) to highlight on hover
|
||||
//ImGui::Text("Field_%d", i);
|
||||
char label[32];
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.51
|
||||
// dear imgui, v1.52
|
||||
// (drawing and font code)
|
||||
|
||||
// Contains implementation for
|
||||
@ -21,10 +21,10 @@
|
||||
#if !defined(alloca)
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h> // alloca
|
||||
#elif (defined(__FreeBSD__) || defined(FreeBSD_kernel) || defined(__DragonFly__)) && !defined(__GLIBC__)
|
||||
#include <stdlib.h> // alloca. FreeBSD uses stdlib.h unless GLIBC
|
||||
#else
|
||||
#elif defined(__GLIBC__) || defined(__sun)
|
||||
#include <alloca.h> // alloca
|
||||
#else
|
||||
#include <stdlib.h> // alloca
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -42,6 +42,9 @@
|
||||
#if __has_warning("-Wreserved-id-macro")
|
||||
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
|
||||
#endif
|
||||
#if __has_warning("-Wdouble-promotion")
|
||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
|
||||
@ -69,7 +72,6 @@ namespace IMGUI_STB_NAMESPACE
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
#endif
|
||||
@ -220,7 +222,7 @@ void ImDrawList::UpdateTextureID()
|
||||
|
||||
// Try to merge with previous command if it matches, else use current command
|
||||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
|
||||
if (prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL)
|
||||
if (curr_cmd->ElemCount == 0 && prev_cmd && prev_cmd->TextureId == curr_texture_id && memcmp(&prev_cmd->ClipRect, &GetCurrentClipRect(), sizeof(ImVec4)) == 0 && prev_cmd->UserCallback == NULL)
|
||||
CmdBuffer.pop_back();
|
||||
else
|
||||
curr_cmd->TextureId = curr_texture_id;
|
||||
@ -337,7 +339,7 @@ void ImDrawList::ChannelsMerge()
|
||||
if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
|
||||
if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; }
|
||||
}
|
||||
AddDrawCmd();
|
||||
UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
||||
_ChannelsCount = 1;
|
||||
}
|
||||
|
||||
@ -694,30 +696,30 @@ void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int a_min_of_
|
||||
circle_vtx_builds = true;
|
||||
}
|
||||
|
||||
if (a_min_of_12 > a_max_of_12) return;
|
||||
if (radius == 0.0f)
|
||||
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
||||
{
|
||||
_Path.push_back(centre);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
|
||||
for (int a = a_min_of_12; a <= a_max_of_12; a++)
|
||||
{
|
||||
const ImVec2& c = circle_vtx[a % circle_vtx_count];
|
||||
_Path.push_back(ImVec2(centre.x + c.x * radius, centre.y + c.y * radius));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float amin, float amax, int num_segments)
|
||||
void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments)
|
||||
{
|
||||
if (radius == 0.0f)
|
||||
{
|
||||
_Path.push_back(centre);
|
||||
return;
|
||||
}
|
||||
_Path.reserve(_Path.Size + (num_segments + 1));
|
||||
for (int i = 0; i <= num_segments; i++)
|
||||
{
|
||||
const float a = amin + ((float)i / (float)num_segments) * (amax - amin);
|
||||
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
||||
_Path.push_back(ImVec2(centre.x + cosf(a) * radius, centre.y + sinf(a) * radius));
|
||||
}
|
||||
}
|
||||
@ -775,31 +777,30 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
|
||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
||||
{
|
||||
const int corners_top = ImGuiCorner_TopLeft | ImGuiCorner_TopRight;
|
||||
const int corners_bottom = ImGuiCorner_BottomLeft | ImGuiCorner_BottomRight;
|
||||
const int corners_left = ImGuiCorner_TopLeft | ImGuiCorner_BottomLeft;
|
||||
const int corners_right = ImGuiCorner_TopRight | ImGuiCorner_BottomRight;
|
||||
const int corners_bottom = ImGuiCorner_BotLeft | ImGuiCorner_BotRight;
|
||||
const int corners_left = ImGuiCorner_TopLeft | ImGuiCorner_BotLeft;
|
||||
const int corners_right = ImGuiCorner_TopRight | ImGuiCorner_BotRight;
|
||||
|
||||
float r = rounding;
|
||||
r = ImMin(r, fabsf(b.x-a.x) * ( ((rounding_corners & corners_top) == corners_top) || ((rounding_corners & corners_bottom) == corners_bottom) ? 0.5f : 1.0f ) - 1.0f);
|
||||
r = ImMin(r, fabsf(b.y-a.y) * ( ((rounding_corners & corners_left) == corners_left) || ((rounding_corners & corners_right) == corners_right) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, fabsf(b.x - a.x) * ( ((rounding_corners & corners_top) == corners_top) || ((rounding_corners & corners_bottom) == corners_bottom) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, fabsf(b.y - a.y) * ( ((rounding_corners & corners_left) == corners_left) || ((rounding_corners & corners_right) == corners_right) ? 0.5f : 1.0f ) - 1.0f);
|
||||
|
||||
if (r <= 0.0f || rounding_corners == 0)
|
||||
if (rounding <= 0.0f || rounding_corners == 0)
|
||||
{
|
||||
PathLineTo(a);
|
||||
PathLineTo(ImVec2(b.x,a.y));
|
||||
PathLineTo(ImVec2(b.x, a.y));
|
||||
PathLineTo(b);
|
||||
PathLineTo(ImVec2(a.x,b.y));
|
||||
PathLineTo(ImVec2(a.x, b.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
const float r0 = (rounding_corners & ImGuiCorner_TopLeft) ? r : 0.0f;
|
||||
const float r1 = (rounding_corners & ImGuiCorner_TopRight) ? r : 0.0f;
|
||||
const float r2 = (rounding_corners & ImGuiCorner_BottomRight) ? r : 0.0f;
|
||||
const float r3 = (rounding_corners & ImGuiCorner_BottomLeft) ? r : 0.0f;
|
||||
PathArcToFast(ImVec2(a.x+r0,a.y+r0), r0, 6, 9);
|
||||
PathArcToFast(ImVec2(b.x-r1,a.y+r1), r1, 9, 12);
|
||||
PathArcToFast(ImVec2(b.x-r2,b.y-r2), r2, 0, 3);
|
||||
PathArcToFast(ImVec2(a.x+r3,b.y-r3), r3, 3, 6);
|
||||
const float rounding_tl = (rounding_corners & ImGuiCorner_TopLeft) ? rounding : 0.0f;
|
||||
const float rounding_tr = (rounding_corners & ImGuiCorner_TopRight) ? rounding : 0.0f;
|
||||
const float rounding_br = (rounding_corners & ImGuiCorner_BotRight) ? rounding : 0.0f;
|
||||
const float rounding_bl = (rounding_corners & ImGuiCorner_BotLeft) ? rounding : 0.0f;
|
||||
PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9);
|
||||
PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12);
|
||||
PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3);
|
||||
PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1033,6 +1034,43 @@ void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Shade functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generic linear color gradient, write to RGB fields, leave A untouched.
|
||||
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
|
||||
{
|
||||
ImVec2 gradient_extent = gradient_p1 - gradient_p0;
|
||||
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
||||
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
|
||||
{
|
||||
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
|
||||
float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
|
||||
int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t);
|
||||
int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t);
|
||||
int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t);
|
||||
vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
// Scan and shade backward from the end of given vertices. Assume vertices are text only (= vert_start..vert_end going left to right) so we can break as soon as we are out the gradient bounds.
|
||||
void ImGui::ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x)
|
||||
{
|
||||
float gradient_extent_x = gradient_p1_x - gradient_p0_x;
|
||||
float gradient_inv_length2 = 1.0f / (gradient_extent_x * gradient_extent_x);
|
||||
int full_alpha_count = 0;
|
||||
for (ImDrawVert* vert = vert_end - 1; vert >= vert_start; vert--)
|
||||
{
|
||||
float d = (vert->pos.x - gradient_p0_x) * (gradient_extent_x);
|
||||
float alpha_mul = 1.0f - ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
|
||||
if (alpha_mul >= 1.0f && ++full_alpha_count > 2)
|
||||
return; // Early out
|
||||
int a = (int)(((vert->col >> IM_COL32_A_SHIFT) & 0xFF) * alpha_mul);
|
||||
vert->col = (vert->col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImFontConfig
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1051,8 +1089,10 @@ ImFontConfig::ImFontConfig()
|
||||
GlyphOffset = ImVec2(0.0f, 0.0f);
|
||||
GlyphRanges = NULL;
|
||||
MergeMode = false;
|
||||
DstFont = NULL;
|
||||
RasterizerFlags = 0x00;
|
||||
RasterizerMultiply = 1.0f;
|
||||
memset(Name, 0, sizeof(Name));
|
||||
DstFont = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1063,7 +1103,7 @@ ImFontConfig::ImFontConfig()
|
||||
// The white texels on the top left are the ones we'll use everywhere in ImGui to render filled shapes.
|
||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 90;
|
||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0xF0000;
|
||||
const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
|
||||
const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
|
||||
{
|
||||
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX"
|
||||
@ -1098,11 +1138,14 @@ const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF
|
||||
ImFontAtlas::ImFontAtlas()
|
||||
{
|
||||
TexID = NULL;
|
||||
TexDesiredWidth = 0;
|
||||
TexGlyphPadding = 1;
|
||||
TexPixelsAlpha8 = NULL;
|
||||
TexPixelsRGBA32 = NULL;
|
||||
TexWidth = TexHeight = TexDesiredWidth = 0;
|
||||
TexGlyphPadding = 1;
|
||||
TexWidth = TexHeight = 0;
|
||||
TexUvWhitePixel = ImVec2(0, 0);
|
||||
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
||||
CustomRectIds[n] = -1;
|
||||
}
|
||||
|
||||
ImFontAtlas::~ImFontAtlas()
|
||||
@ -1128,6 +1171,8 @@ void ImFontAtlas::ClearInputData()
|
||||
}
|
||||
ConfigData.clear();
|
||||
CustomRects.clear();
|
||||
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
||||
CustomRectIds[n] = -1;
|
||||
}
|
||||
|
||||
void ImFontAtlas::ClearTexData()
|
||||
@ -1280,7 +1325,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||
return AddFontFromMemoryTTF(data, data_size, size_pixels, &font_cfg, glyph_ranges);
|
||||
}
|
||||
|
||||
// NBM Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
|
||||
// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||
@ -1315,8 +1360,9 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
||||
return font;
|
||||
}
|
||||
|
||||
int ImFontAtlas::CustomRectRegister(unsigned int id, int width, int height)
|
||||
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||
{
|
||||
IM_ASSERT(id >= 0x10000);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||
CustomRect r;
|
||||
@ -1327,7 +1373,23 @@ int ImFontAtlas::CustomRectRegister(unsigned int id, int width, int height)
|
||||
return CustomRects.Size - 1; // Return index
|
||||
}
|
||||
|
||||
void ImFontAtlas::CustomRectCalcUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max)
|
||||
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
|
||||
{
|
||||
IM_ASSERT(font != NULL);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||
CustomRect r;
|
||||
r.ID = id;
|
||||
r.Width = (unsigned short)width;
|
||||
r.Height = (unsigned short)height;
|
||||
r.GlyphAdvanceX = advance_x;
|
||||
r.GlyphOffset = offset;
|
||||
r.Font = font;
|
||||
CustomRects.push_back(r);
|
||||
return CustomRects.Size - 1; // Return index
|
||||
}
|
||||
|
||||
void ImFontAtlas::CalcCustomRectUV(const CustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max)
|
||||
{
|
||||
IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates
|
||||
IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed
|
||||
@ -1340,6 +1402,23 @@ bool ImFontAtlas::Build()
|
||||
return ImFontAtlasBuildWithStbTruetype(this);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor)
|
||||
{
|
||||
for (unsigned int i = 0; i < 256; i++)
|
||||
{
|
||||
unsigned int value = (unsigned int)(i * in_brighten_factor);
|
||||
out_table[i] = value > 255 ? 255 : (value & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride)
|
||||
{
|
||||
unsigned char* data = pixels + x + y * stride;
|
||||
for (int j = h; j > 0; j--, data += stride)
|
||||
for (int i = 0; i < w; i++)
|
||||
data[i] = table[data[i]];
|
||||
}
|
||||
|
||||
bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
{
|
||||
IM_ASSERT(atlas->ConfigData.Size > 0);
|
||||
@ -1382,6 +1461,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
{
|
||||
stbtt_fontinfo FontInfo;
|
||||
stbrp_rect* Rects;
|
||||
int RectsCount;
|
||||
stbtt_pack_range* Ranges;
|
||||
int RangesCount;
|
||||
};
|
||||
@ -1395,8 +1475,11 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo);
|
||||
IM_ASSERT(font_offset >= 0);
|
||||
if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset))
|
||||
{
|
||||
ImGui::MemFree(tmp_array);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0)
|
||||
int buf_packedchars_n = 0, buf_rects_n = 0, buf_ranges_n = 0;
|
||||
@ -1434,6 +1517,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
|
||||
// Pack
|
||||
tmp.Rects = buf_rects + buf_rects_n;
|
||||
tmp.RectsCount = font_glyphs_count;
|
||||
buf_rects_n += font_glyphs_count;
|
||||
stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV);
|
||||
int n = stbtt_PackFontRangesGatherRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects);
|
||||
@ -1463,6 +1547,14 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
ImFontTempBuildData& tmp = tmp_array[input_i];
|
||||
stbtt_PackSetOversampling(&spc, cfg.OversampleH, cfg.OversampleV);
|
||||
stbtt_PackFontRangesRenderIntoRects(&spc, &tmp.FontInfo, tmp.Ranges, tmp.RangesCount, tmp.Rects);
|
||||
if (cfg.RasterizerMultiply != 1.0f)
|
||||
{
|
||||
unsigned char multiply_table[256];
|
||||
ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply);
|
||||
for (const stbrp_rect* r = tmp.Rects; r != tmp.Rects + tmp.RectsCount; r++)
|
||||
if (r->was_packed)
|
||||
ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, spc.pixels, r->x, r->y, r->w, r->h, spc.stride_in_bytes);
|
||||
}
|
||||
tmp.Rects = NULL;
|
||||
}
|
||||
|
||||
@ -1478,17 +1570,16 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
ImFontTempBuildData& tmp = tmp_array[input_i];
|
||||
ImFont* dst_font = cfg.DstFont; // We can have multiple input fonts writing into a same destination font (when using MergeMode=true)
|
||||
|
||||
float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels);
|
||||
const float font_scale = stbtt_ScaleForPixelHeight(&tmp.FontInfo, cfg.SizePixels);
|
||||
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
||||
stbtt_GetFontVMetrics(&tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
|
||||
|
||||
float ascent = unscaled_ascent * font_scale;
|
||||
float descent = unscaled_descent * font_scale;
|
||||
const float ascent = unscaled_ascent * font_scale;
|
||||
const float descent = unscaled_descent * font_scale;
|
||||
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
|
||||
float off_x = cfg.GlyphOffset.x;
|
||||
float off_y = cfg.GlyphOffset.y + (float)(int)(dst_font->Ascent + 0.5f);
|
||||
const float off_x = cfg.GlyphOffset.x;
|
||||
const float off_y = cfg.GlyphOffset.y + (float)(int)(dst_font->Ascent + 0.5f);
|
||||
|
||||
dst_font->FallbackGlyph = NULL; // Always clear fallback so FindGlyph can return NULL. It will be set again in BuildLookupTable()
|
||||
for (int i = 0; i < tmp.RangesCount; i++)
|
||||
{
|
||||
stbtt_pack_range& range = tmp.Ranges[i];
|
||||
@ -1505,26 +1596,9 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
stbtt_aligned_quad q;
|
||||
float dummy_x = 0.0f, dummy_y = 0.0f;
|
||||
stbtt_GetPackedQuad(range.chardata_for_range, atlas->TexWidth, atlas->TexHeight, char_idx, &dummy_x, &dummy_y, &q, 0);
|
||||
|
||||
dst_font->Glyphs.resize(dst_font->Glyphs.Size + 1);
|
||||
ImFont::Glyph& glyph = dst_font->Glyphs.back();
|
||||
glyph.Codepoint = (ImWchar)codepoint;
|
||||
glyph.X0 = q.x0 + off_x;
|
||||
glyph.Y0 = q.y0 + off_y;
|
||||
glyph.X1 = q.x1 + off_x;
|
||||
glyph.Y1 = q.y1 + off_y;
|
||||
glyph.U0 = q.s0;
|
||||
glyph.V0 = q.t0;
|
||||
glyph.U1 = q.s1;
|
||||
glyph.V1 = q.t1;
|
||||
glyph.XAdvance = (pc.xadvance + cfg.GlyphExtraSpacing.x); // Bake spacing into XAdvance
|
||||
|
||||
if (cfg.PixelSnapH)
|
||||
glyph.XAdvance = (float)(int)(glyph.XAdvance + 0.5f);
|
||||
dst_font->MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * atlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * atlas->TexHeight + 1.99f); // +1 to account for average padding, +0.99 to round
|
||||
dst_font->AddGlyph((ImWchar)codepoint, q.x0 + off_x, q.y0 + off_y, q.x1 + off_x, q.y1 + off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
|
||||
}
|
||||
}
|
||||
cfg.DstFont->BuildLookupTable();
|
||||
}
|
||||
|
||||
// Cleanup temporaries
|
||||
@ -1532,31 +1606,27 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
ImGui::MemFree(buf_ranges);
|
||||
ImGui::MemFree(tmp_array);
|
||||
|
||||
// Render into our custom data block
|
||||
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
||||
ImFontAtlasBuildFinish(atlas);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
|
||||
{
|
||||
// FIXME-WIP: We should register in the constructor (but cannot because our static instances may not have allocator ready by the time they initialize). This needs to be fixed because we can expose CustomRects.
|
||||
if (atlas->CustomRects.empty())
|
||||
atlas->CustomRectRegister(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||
if (atlas->CustomRectIds[0] < 0)
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||
{
|
||||
if (!font_config->MergeMode)
|
||||
{
|
||||
font->ContainerAtlas = atlas;
|
||||
font->ConfigData = font_config;
|
||||
font->ConfigDataCount = 0;
|
||||
font->ClearOutputData();
|
||||
font->FontSize = font_config->SizePixels;
|
||||
font->ConfigData = font_config;
|
||||
font->ContainerAtlas = atlas;
|
||||
font->Ascent = ascent;
|
||||
font->Descent = descent;
|
||||
font->Glyphs.resize(0);
|
||||
font->MetricsTotalSurface = 0;
|
||||
}
|
||||
font->ConfigDataCount++;
|
||||
}
|
||||
@ -1566,6 +1636,8 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaq
|
||||
stbrp_context* pack_context = (stbrp_context*)pack_context_opaque;
|
||||
|
||||
ImVector<ImFontAtlas::CustomRect>& user_rects = atlas->CustomRects;
|
||||
IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
|
||||
|
||||
ImVector<stbrp_rect> pack_rects;
|
||||
pack_rects.resize(user_rects.Size);
|
||||
memset(pack_rects.Data, 0, sizeof(stbrp_rect) * user_rects.Size);
|
||||
@ -1585,9 +1657,10 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaq
|
||||
}
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||
{
|
||||
ImFontAtlas::CustomRect& r = atlas->CustomRects[0];
|
||||
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
||||
ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||
IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1);
|
||||
IM_ASSERT(r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||
@ -1635,6 +1708,29 @@ void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||
}
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||
{
|
||||
// Render into our custom data block
|
||||
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
||||
|
||||
// Register custom rectangle glyphs
|
||||
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
||||
{
|
||||
const ImFontAtlas::CustomRect& r = atlas->CustomRects[i];
|
||||
if (r.Font == NULL || r.ID > 0x10000)
|
||||
continue;
|
||||
|
||||
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
||||
ImVec2 uv0, uv1;
|
||||
atlas->CalcCustomRectUV(&r, &uv0, &uv1);
|
||||
r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
|
||||
}
|
||||
|
||||
// Build all fonts lookup tables
|
||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||
atlas->Fonts[i]->BuildLookupTable();
|
||||
}
|
||||
|
||||
// Retrieve list of range (2 int per range, values are inclusive)
|
||||
const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
|
||||
{
|
||||
@ -1675,7 +1771,10 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChinese()
|
||||
const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
|
||||
{
|
||||
// Store the 1946 ideograms code points as successive offsets from the initial unicode codepoint 0x4E00. Each offset has an implicit +1.
|
||||
// This encoding helps us reduce the source code size.
|
||||
// This encoding is designed to helps us reduce the source code size.
|
||||
// FIXME: Source a list of the revised 2136 joyo kanji list from 2010 and rebuild this.
|
||||
// The current list was sourced from http://theinstructionlimit.com/author/renaudbedardrenaudbedard/page/3
|
||||
// Note that you may use ImFontAtlas::GlyphRangesBuilder to create your own ranges, by merging existing ranges or adding new characters.
|
||||
static const short offsets_from_0x4E00[] =
|
||||
{
|
||||
-1,0,1,3,0,0,0,0,1,0,5,1,1,0,7,4,6,10,0,1,9,9,7,1,3,19,1,10,7,1,0,1,0,5,1,0,6,4,2,6,0,0,12,6,8,0,3,5,0,1,0,9,0,0,8,1,1,3,4,5,13,0,0,8,2,17,
|
||||
@ -1804,7 +1903,8 @@ ImFont::ImFont()
|
||||
{
|
||||
Scale = 1.0f;
|
||||
FallbackChar = (ImWchar)'?';
|
||||
Clear();
|
||||
DisplayOffset = ImVec2(0.0f, 1.0f);
|
||||
ClearOutputData();
|
||||
}
|
||||
|
||||
ImFont::~ImFont()
|
||||
@ -1817,18 +1917,17 @@ ImFont::~ImFont()
|
||||
if (g.Font == this)
|
||||
g.Font = NULL;
|
||||
*/
|
||||
Clear();
|
||||
ClearOutputData();
|
||||
}
|
||||
|
||||
void ImFont::Clear()
|
||||
void ImFont::ClearOutputData()
|
||||
{
|
||||
FontSize = 0.0f;
|
||||
DisplayOffset = ImVec2(0.0f, 1.0f);
|
||||
Glyphs.clear();
|
||||
IndexXAdvance.clear();
|
||||
IndexAdvanceX.clear();
|
||||
IndexLookup.clear();
|
||||
FallbackGlyph = NULL;
|
||||
FallbackXAdvance = 0.0f;
|
||||
FallbackAdvanceX = 0.0f;
|
||||
ConfigDataCount = 0;
|
||||
ConfigData = NULL;
|
||||
ContainerAtlas = NULL;
|
||||
@ -1843,13 +1942,13 @@ void ImFont::BuildLookupTable()
|
||||
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
|
||||
|
||||
IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
|
||||
IndexXAdvance.clear();
|
||||
IndexAdvanceX.clear();
|
||||
IndexLookup.clear();
|
||||
GrowIndex(max_codepoint + 1);
|
||||
for (int i = 0; i < Glyphs.Size; i++)
|
||||
{
|
||||
int codepoint = (int)Glyphs[i].Codepoint;
|
||||
IndexXAdvance[codepoint] = Glyphs[i].XAdvance;
|
||||
IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX;
|
||||
IndexLookup[codepoint] = (unsigned short)i;
|
||||
}
|
||||
|
||||
@ -1859,20 +1958,20 @@ void ImFont::BuildLookupTable()
|
||||
{
|
||||
if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times
|
||||
Glyphs.resize(Glyphs.Size + 1);
|
||||
ImFont::Glyph& tab_glyph = Glyphs.back();
|
||||
ImFontGlyph& tab_glyph = Glyphs.back();
|
||||
tab_glyph = *FindGlyph((unsigned short)' ');
|
||||
tab_glyph.Codepoint = '\t';
|
||||
tab_glyph.XAdvance *= 4;
|
||||
IndexXAdvance[(int)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance;
|
||||
tab_glyph.AdvanceX *= 4;
|
||||
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
|
||||
IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1);
|
||||
}
|
||||
|
||||
FallbackGlyph = NULL;
|
||||
FallbackGlyph = FindGlyph(FallbackChar);
|
||||
FallbackXAdvance = FallbackGlyph ? FallbackGlyph->XAdvance : 0.0f;
|
||||
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexXAdvance[i] < 0.0f)
|
||||
IndexXAdvance[i] = FallbackXAdvance;
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||
}
|
||||
|
||||
void ImFont::SetFallbackChar(ImWchar c)
|
||||
@ -1883,17 +1982,33 @@ void ImFont::SetFallbackChar(ImWchar c)
|
||||
|
||||
void ImFont::GrowIndex(int new_size)
|
||||
{
|
||||
IM_ASSERT(IndexXAdvance.Size == IndexLookup.Size);
|
||||
int old_size = IndexLookup.Size;
|
||||
if (new_size <= old_size)
|
||||
IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size);
|
||||
if (new_size <= IndexLookup.Size)
|
||||
return;
|
||||
IndexXAdvance.resize(new_size);
|
||||
IndexLookup.resize(new_size);
|
||||
for (int i = old_size; i < new_size; i++)
|
||||
{
|
||||
IndexXAdvance[i] = -1.0f;
|
||||
IndexLookup[i] = (unsigned short)-1;
|
||||
}
|
||||
IndexAdvanceX.resize(new_size, -1.0f);
|
||||
IndexLookup.resize(new_size, (unsigned short)-1);
|
||||
}
|
||||
|
||||
void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
|
||||
{
|
||||
Glyphs.resize(Glyphs.Size + 1);
|
||||
ImFontGlyph& glyph = Glyphs.back();
|
||||
glyph.Codepoint = (ImWchar)codepoint;
|
||||
glyph.X0 = x0;
|
||||
glyph.Y0 = y0;
|
||||
glyph.X1 = x1;
|
||||
glyph.Y1 = y1;
|
||||
glyph.U0 = u0;
|
||||
glyph.V0 = v0;
|
||||
glyph.U1 = u1;
|
||||
glyph.V1 = v1;
|
||||
glyph.AdvanceX = advance_x + ConfigData->GlyphExtraSpacing.x; // Bake spacing into AdvanceX
|
||||
|
||||
if (ConfigData->PixelSnapH)
|
||||
glyph.AdvanceX = (float)(int)(glyph.AdvanceX + 0.5f);
|
||||
|
||||
// Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round)
|
||||
MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f);
|
||||
}
|
||||
|
||||
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
@ -1908,10 +2023,10 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
|
||||
GrowIndex(dst + 1);
|
||||
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1;
|
||||
IndexXAdvance[dst] = (src < index_size) ? IndexXAdvance.Data[src] : 1.0f;
|
||||
IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
|
||||
}
|
||||
|
||||
const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const
|
||||
const ImFontGlyph* ImFont::FindGlyph(unsigned short c) const
|
||||
{
|
||||
if (c < IndexLookup.Size)
|
||||
{
|
||||
@ -1976,7 +2091,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
}
|
||||
}
|
||||
|
||||
const float char_width = ((int)c < IndexXAdvance.Size ? IndexXAdvance[(int)c] : FallbackXAdvance);
|
||||
const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX[(int)c] : FallbackAdvanceX);
|
||||
if (ImCharIsSpace(c))
|
||||
{
|
||||
if (inside_word)
|
||||
@ -2093,7 +2208,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
continue;
|
||||
}
|
||||
|
||||
const float char_width = ((int)c < IndexXAdvance.Size ? IndexXAdvance[(int)c] : FallbackXAdvance) * scale;
|
||||
const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX[(int)c] : FallbackAdvanceX) * scale;
|
||||
if (line_width + char_width >= max_width)
|
||||
{
|
||||
s = prev_s;
|
||||
@ -2119,7 +2234,7 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
{
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
|
||||
return;
|
||||
if (const Glyph* glyph = FindGlyph(c))
|
||||
if (const ImFontGlyph* glyph = FindGlyph(c))
|
||||
{
|
||||
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
||||
pos.x = (float)(int)pos.x + DisplayOffset.x;
|
||||
@ -2223,9 +2338,9 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
}
|
||||
|
||||
float char_width = 0.0f;
|
||||
if (const Glyph* glyph = FindGlyph((unsigned short)c))
|
||||
if (const ImFontGlyph* glyph = FindGlyph((unsigned short)c))
|
||||
{
|
||||
char_width = glyph->XAdvance * scale;
|
||||
char_width = glyph->AdvanceX * scale;
|
||||
|
||||
// Arbitrarily assume that both space and tabs are empty glyphs as an optimization
|
||||
if (c != ' ' && c != '\t')
|
||||
@ -2301,6 +2416,78 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
draw_list->_VtxCurrentIdx = (unsigned int)draw_list->VtxBuffer.Size;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internals Drawing Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static inline float ImAcos01(float x)
|
||||
{
|
||||
if (x <= 0.0f) return IM_PI * 0.5f;
|
||||
if (x >= 1.0f) return 0.0f;
|
||||
return acosf(x);
|
||||
//return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
|
||||
}
|
||||
|
||||
// FIXME: Cleanup and move code to ImDrawList.
|
||||
void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding)
|
||||
{
|
||||
if (x_end_norm == x_start_norm)
|
||||
return;
|
||||
if (x_start_norm > x_end_norm)
|
||||
ImSwap(x_start_norm, x_end_norm);
|
||||
|
||||
ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y);
|
||||
ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y);
|
||||
if (rounding == 0.0f)
|
||||
{
|
||||
draw_list->AddRectFilled(p0, p1, col, 0.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding);
|
||||
const float inv_rounding = 1.0f / rounding;
|
||||
const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding);
|
||||
const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding);
|
||||
const float x0 = ImMax(p0.x, rect.Min.x + rounding);
|
||||
if (arc0_b == arc0_e)
|
||||
{
|
||||
draw_list->PathLineTo(ImVec2(x0, p1.y));
|
||||
draw_list->PathLineTo(ImVec2(x0, p0.y));
|
||||
}
|
||||
else if (arc0_b == 0.0f && arc0_e == IM_PI*0.5f)
|
||||
{
|
||||
draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL
|
||||
draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL
|
||||
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR
|
||||
}
|
||||
if (p1.x > rect.Min.x + rounding)
|
||||
{
|
||||
const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding);
|
||||
const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding);
|
||||
const float x1 = ImMin(p1.x, rect.Max.x - rounding);
|
||||
if (arc1_b == arc1_e)
|
||||
{
|
||||
draw_list->PathLineTo(ImVec2(x1, p0.y));
|
||||
draw_list->PathLineTo(ImVec2(x1, p1.y));
|
||||
}
|
||||
else if (arc1_b == 0.0f && arc1_e == IM_PI*0.5f)
|
||||
{
|
||||
draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR
|
||||
draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR
|
||||
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR
|
||||
}
|
||||
}
|
||||
draw_list->PathFillConvex(col);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DEFAULT FONT DATA
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.51
|
||||
// dear imgui, v1.52
|
||||
// (internals)
|
||||
|
||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||
@ -44,10 +44,11 @@ struct ImGuiMouseCursorData;
|
||||
struct ImGuiPopupRef;
|
||||
struct ImGuiWindow;
|
||||
|
||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||
typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_
|
||||
typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_
|
||||
typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// STB libraries
|
||||
@ -77,7 +78,6 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
|
||||
@ -105,12 +105,13 @@ IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec
|
||||
// Helpers: String
|
||||
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
||||
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, int count);
|
||||
IMGUI_API void ImStrncpy(char* dst, const char* src, int count);
|
||||
IMGUI_API char* ImStrdup(const char* str);
|
||||
IMGUI_API int ImStrlenW(const ImWchar* str);
|
||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||
IMGUI_API int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
|
||||
IMGUI_API int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
|
||||
// Helpers: Math
|
||||
// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
|
||||
@ -125,7 +126,9 @@ static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)
|
||||
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
|
||||
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
||||
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
|
||||
#endif
|
||||
|
||||
static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
|
||||
@ -138,10 +141,13 @@ static inline int ImClamp(int v, int mn, int mx)
|
||||
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||
static inline void ImSwap(int& a, int& b) { int tmp = a; a = b; b = tmp; }
|
||||
static inline void ImSwap(float& a, float& b) { float tmp = a; a = b; b = tmp; }
|
||||
static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); }
|
||||
static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
||||
@ -149,6 +155,7 @@ static inline float ImFloor(float f)
|
||||
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||||
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||||
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||||
|
||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||
@ -166,16 +173,17 @@ inline void operator delete(void*, ImPlacementNewDummy, void*) {}
|
||||
enum ImGuiButtonFlags_
|
||||
{
|
||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // (default) return pressed on click+release on same item (default if no PressedOn** flag is set)
|
||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return pressed on click (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return pressed on release (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return pressed on double-click (default requires click+release)
|
||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interaction even if a child window is overlapping
|
||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press
|
||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interaction
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline - ButtonEx() only
|
||||
ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
|
||||
ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
|
||||
ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
|
||||
ImGuiButtonFlags_FlattenChilds = 1 << 5, // allow interactions even if a child window is overlapping
|
||||
ImGuiButtonFlags_DontClosePopups = 1 << 6, // disable automatically closing parent popup on press // [UNUSED]
|
||||
ImGuiButtonFlags_Disabled = 1 << 7, // disable interactions
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 8, // vertically align button to match text baseline (ButtonEx() only)
|
||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 9, // disable interaction if a key modifier is held
|
||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10 // require previous frame HoveredId to either match id or be null before being usable
|
||||
ImGuiButtonFlags_AllowOverlapMode = 1 << 10, // require previous frame HoveredId to either match id or be null before being usable
|
||||
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11 // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||
};
|
||||
|
||||
enum ImGuiSliderFlags_
|
||||
@ -201,6 +209,12 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
||||
};
|
||||
|
||||
enum ImGuiSeparatorFlags_
|
||||
{
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||
};
|
||||
|
||||
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
||||
enum ImGuiLayoutType_
|
||||
{
|
||||
@ -218,7 +232,7 @@ enum ImGuiDataType
|
||||
{
|
||||
ImGuiDataType_Int,
|
||||
ImGuiDataType_Float,
|
||||
ImGuiDataType_Float2,
|
||||
ImGuiDataType_Float2
|
||||
};
|
||||
|
||||
enum ImGuiDir
|
||||
@ -227,15 +241,15 @@ enum ImGuiDir
|
||||
ImGuiDir_Left = 0,
|
||||
ImGuiDir_Right = 1,
|
||||
ImGuiDir_Up = 2,
|
||||
ImGuiDir_Down = 3,
|
||||
ImGuiDir_Down = 3
|
||||
};
|
||||
|
||||
enum ImGuiCorner
|
||||
{
|
||||
ImGuiCorner_TopLeft = 1 << 0, // 1
|
||||
ImGuiCorner_TopRight = 1 << 1, // 2
|
||||
ImGuiCorner_BottomRight = 1 << 2, // 4
|
||||
ImGuiCorner_BottomLeft = 1 << 3, // 8
|
||||
ImGuiCorner_BotRight = 1 << 2, // 4
|
||||
ImGuiCorner_BotLeft = 1 << 3, // 8
|
||||
ImGuiCorner_All = 0x0F
|
||||
};
|
||||
|
||||
@ -420,11 +434,10 @@ struct ImGuiContext
|
||||
bool ActiveIdIsAlive; // Active widget has been seen this frame
|
||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||
|
||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
||||
ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
@ -435,6 +448,7 @@ struct ImGuiContext
|
||||
|
||||
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
||||
ImVec2 SetNextWindowPosVal;
|
||||
ImVec2 SetNextWindowPosPivot;
|
||||
ImVec2 SetNextWindowSizeVal;
|
||||
ImVec2 SetNextWindowContentSizeVal;
|
||||
bool SetNextWindowCollapsedVal;
|
||||
@ -485,8 +499,9 @@ struct ImGuiContext
|
||||
float FramerateSecPerFrame[120]; // calculate estimate of framerate for user
|
||||
int FramerateSecPerFrameIdx;
|
||||
float FramerateSecPerFrameAccum;
|
||||
int CaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
||||
int CaptureKeyboardNextFrame;
|
||||
int WantCaptureMouseNextFrame; // explicit capture via CaptureInputs() sets those flags
|
||||
int WantCaptureKeyboardNextFrame;
|
||||
int WantTextInputNextFrame;
|
||||
char TempBuffer[1024*3+1]; // temporary text buffer
|
||||
|
||||
ImGuiContext()
|
||||
@ -513,8 +528,8 @@ struct ImGuiContext
|
||||
ActiveIdAllowOverlap = false;
|
||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = NULL;
|
||||
MovedWindow = NULL;
|
||||
MovedWindowMoveId = 0;
|
||||
MovingWindow = NULL;
|
||||
MovingWindowMoveId = 0;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
|
||||
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
|
||||
@ -537,7 +552,7 @@ struct ImGuiContext
|
||||
DragCurrentValue = 0.0f;
|
||||
DragLastMouseDelta = ImVec2(0.0f, 0.0f);
|
||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||
DragSpeedScaleSlow = 0.01f;
|
||||
DragSpeedScaleSlow = 1.0f / 100.0f;
|
||||
DragSpeedScaleFast = 10.0f;
|
||||
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
||||
TooltipOverrideCount = 0;
|
||||
@ -557,11 +572,23 @@ struct ImGuiContext
|
||||
memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
|
||||
FramerateSecPerFrameIdx = 0;
|
||||
FramerateSecPerFrameAccum = 0.0f;
|
||||
CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1;
|
||||
WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
|
||||
memset(TempBuffer, 0, sizeof(TempBuffer));
|
||||
}
|
||||
};
|
||||
|
||||
// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||
ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP)
|
||||
//ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||
//ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||
};
|
||||
|
||||
// Transient per-window data, reset at the beginning of the frame
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
|
||||
struct IMGUI_API ImGuiDrawContext
|
||||
@ -578,8 +605,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
int TreeDepth;
|
||||
ImGuiID LastItemId;
|
||||
ImRect LastItemRect;
|
||||
bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
|
||||
bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
|
||||
bool LastItemRectHoveredRect;
|
||||
bool MenuBarAppending;
|
||||
float MenuBarOffsetX;
|
||||
ImVector<ImGuiWindow*> ChildWindows;
|
||||
@ -587,14 +613,12 @@ struct IMGUI_API ImGuiDrawContext
|
||||
ImGuiLayoutType LayoutType;
|
||||
|
||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||
ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
|
||||
float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
|
||||
float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
|
||||
bool AllowKeyboardFocus; // == AllowKeyboardFocusStack.back() [empty == true]
|
||||
bool ButtonRepeat; // == ButtonRepeatStack.back() [empty == false]
|
||||
ImVector<ImGuiItemFlags>ItemFlagsStack;
|
||||
ImVector<float> ItemWidthStack;
|
||||
ImVector<float> TextWrapPosStack;
|
||||
ImVector<bool> AllowKeyboardFocusStack;
|
||||
ImVector<bool> ButtonRepeatStack;
|
||||
ImVector<ImGuiGroupData>GroupStack;
|
||||
int StackSizesBackup[6]; // Store size of various stacks for asserting
|
||||
|
||||
@ -621,15 +645,14 @@ struct IMGUI_API ImGuiDrawContext
|
||||
LogLinePosY = -1.0f;
|
||||
TreeDepth = 0;
|
||||
LastItemId = 0;
|
||||
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
|
||||
LastItemHoveredAndUsable = LastItemHoveredRect = false;
|
||||
LastItemRect = ImRect();
|
||||
LastItemRectHoveredRect = false;
|
||||
MenuBarAppending = false;
|
||||
MenuBarOffsetX = 0.0f;
|
||||
StateStorage = NULL;
|
||||
LayoutType = ImGuiLayoutType_Vertical;
|
||||
ItemWidth = 0.0f;
|
||||
ButtonRepeat = false;
|
||||
AllowKeyboardFocus = true;
|
||||
ItemFlags = ImGuiItemFlags_Default_;
|
||||
TextWrapPos = -1.0f;
|
||||
memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
|
||||
|
||||
@ -673,7 +696,8 @@ struct IMGUI_API ImGuiWindow
|
||||
bool WasActive;
|
||||
bool Accessed; // Set to true when any widget access the current window
|
||||
bool Collapsed; // Set when collapsing window to become only title-bar
|
||||
bool SkipItems; // == Visible && !Collapsed
|
||||
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
int AutoFitFramesX, AutoFitFramesY;
|
||||
@ -684,21 +708,23 @@ struct IMGUI_API ImGuiWindow
|
||||
ImGuiCond SetWindowPosAllowFlags; // store condition flags for next SetWindowPos() call.
|
||||
ImGuiCond SetWindowSizeAllowFlags; // store condition flags for next SetWindowSize() call.
|
||||
ImGuiCond SetWindowCollapsedAllowFlags; // store condition flags for next SetWindowCollapsed() call.
|
||||
bool SetWindowPosCenterWanted;
|
||||
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
|
||||
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
|
||||
|
||||
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
||||
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
||||
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||
ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
|
||||
ImRect InnerRect;
|
||||
int LastFrameActive;
|
||||
float ItemWidthDefault;
|
||||
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
||||
ImGuiStorage StateStorage;
|
||||
float FontWindowScale; // Scale multiplier per-window
|
||||
ImDrawList* DrawList;
|
||||
ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
|
||||
ImGuiWindow* RootNonPopupWindow; // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
|
||||
ImGuiWindow* ParentWindow; // If we are a child window, this is pointing to our parent window. Else point to NULL.
|
||||
ImGuiWindow* ParentWindow; // Immediate parent in the window stack *regardless* of whether this window is a child window or not)
|
||||
ImGuiWindow* RootWindow; // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
|
||||
ImGuiWindow* RootNonPopupWindow; // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
|
||||
|
||||
// Navigation / Focus
|
||||
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
|
||||
@ -724,6 +750,17 @@ public:
|
||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||
};
|
||||
|
||||
// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
|
||||
struct ImGuiItemHoveredDataBackup
|
||||
{
|
||||
ImGuiID LastItemId;
|
||||
ImRect LastItemRect;
|
||||
bool LastItemRectHoveredRect;
|
||||
|
||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; }
|
||||
void Restore() { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Internal API
|
||||
// No guarantee of forward compatibility here.
|
||||
@ -741,6 +778,7 @@ namespace ImGui
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void Initialize();
|
||||
IMGUI_API void EndFrame(); // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
|
||||
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
@ -750,22 +788,37 @@ namespace ImGui
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||
IMGUI_API bool IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
|
||||
IMGUI_API bool IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs = false);
|
||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop = true); // Return true if focus is requested
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id);
|
||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
|
||||
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
|
||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||
IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
|
||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||
IMGUI_API void PopItemFlag();
|
||||
|
||||
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
|
||||
IMGUI_API void ClosePopup(ImGuiID id);
|
||||
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
|
||||
|
||||
// New Columns API
|
||||
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
|
||||
|
||||
IMGUI_API void Scrollbar(ImGuiLayoutType direction);
|
||||
IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout.
|
||||
|
||||
// FIXME-WIP: New Columns API
|
||||
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void EndColumns(); // close columns
|
||||
IMGUI_API void PushColumnClipRect(int column_index = -1);
|
||||
|
||||
// FIXME-WIP: New Combo API
|
||||
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImVec2 popup_size = ImVec2(0.0f,0.0f));
|
||||
IMGUI_API void EndCombo();
|
||||
|
||||
// NB: All position are in absolute pixels coordinates (never using window coordinates internally)
|
||||
// AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
|
||||
IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
|
||||
@ -774,9 +827,10 @@ namespace ImGui
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
||||
IMGUI_API void RenderTriangle(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
|
||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
|
||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
|
||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||
@ -797,7 +851,8 @@ namespace ImGui
|
||||
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
||||
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
||||
|
||||
IMGUI_API void ColorTooltip(const char* text, const float col[4], ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
|
||||
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
||||
@ -808,6 +863,10 @@ namespace ImGui
|
||||
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
||||
IMGUI_API float RoundScalar(float value, int decimal_precision);
|
||||
|
||||
// Shade functions
|
||||
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||
IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x);
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
// ImFontAtlas internals
|
||||
@ -815,7 +874,9 @@ IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
||||
IMGUI_API void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
||||
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
|
Loading…
Reference in New Issue
Block a user