Update imgui to latest table branch commit
This commit is contained in:
parent
ab82f014ae
commit
cebd07a939
10 changed files with 4202 additions and 2878 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,10 @@
|
||||||
// dear imgui, v1.76 WIP
|
// dear imgui, v1.78 WIP
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
// - Read FAQ at http://dearimgui.org/faq
|
// - Read FAQ at http://dearimgui.org/faq
|
||||||
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
|
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||||
// Read imgui.cpp for details, links and comments.
|
// Read imgui.cpp for details, links and comments.
|
||||||
|
|
||||||
// Resources:
|
// Resources:
|
||||||
|
@ -61,8 +61,8 @@ Index of this file:
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.76 WIP"
|
#define IMGUI_VERSION "1.78 WIP"
|
||||||
#define IMGUI_VERSION_NUM 17502
|
#define IMGUI_VERSION_NUM 17702
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
|
|
||||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||||
|
@ -87,8 +87,8 @@ Index of this file:
|
||||||
#define IM_FMTARGS(FMT)
|
#define IM_FMTARGS(FMT)
|
||||||
#define IM_FMTLIST(FMT)
|
#define IM_FMTLIST(FMT)
|
||||||
#endif
|
#endif
|
||||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
|
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
|
||||||
#define IM_UNUSED(_VAR) ((void)_VAR) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||||
#if (__cplusplus >= 201100)
|
#if (__cplusplus >= 201100)
|
||||||
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
||||||
#else
|
#else
|
||||||
|
@ -166,6 +166,7 @@ typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: f
|
||||||
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
||||||
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
||||||
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
||||||
|
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||||
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||||
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
||||||
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
||||||
|
@ -180,7 +181,7 @@ typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: f
|
||||||
typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
|
typedef void* ImTextureID; // User data for rendering back-end to identify a texture. This is whatever to you want it to be! read the FAQ about ImTextureID for details.
|
||||||
#endif
|
#endif
|
||||||
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
||||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
|
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data);
|
||||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
||||||
|
|
||||||
// Decoded character types
|
// Decoded character types
|
||||||
|
@ -276,9 +277,10 @@ namespace ImGui
|
||||||
|
|
||||||
// Windows
|
// Windows
|
||||||
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
|
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
|
||||||
// - You may append multiple times to the same window during the same frame.
|
|
||||||
// - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
|
// - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
|
||||||
// which clicking will set the boolean to false when clicked.
|
// which clicking will set the boolean to false when clicked.
|
||||||
|
// - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
|
||||||
|
// Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
|
||||||
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
||||||
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
||||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
||||||
|
@ -293,8 +295,8 @@ namespace ImGui
|
||||||
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
||||||
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
||||||
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value [as with Begin: this is due to legacy reason and inconsistent with most BeginXXX functions apart from the regular Begin() which behaves like BeginChild().]
|
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value [as with Begin: this is due to legacy reason and inconsistent with most BeginXXX functions apart from the regular Begin() which behaves like BeginChild().]
|
||||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
|
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
|
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||||
IMGUI_API void EndChild();
|
IMGUI_API void EndChild();
|
||||||
|
|
||||||
// Windows Utilities
|
// Windows Utilities
|
||||||
|
@ -310,7 +312,7 @@ namespace ImGui
|
||||||
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
||||||
|
|
||||||
// Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
// Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after 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 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 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, ImGuiSizeCallback 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. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
|
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback 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. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
|
||||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
|
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
|
||||||
|
@ -318,7 +320,7 @@ namespace ImGui
|
||||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
||||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
||||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
||||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||||
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
||||||
IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
IMGUI_API void SetWindowFontScale(float scale); // set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
||||||
|
@ -379,7 +381,7 @@ namespace ImGui
|
||||||
// Cursor / Layout
|
// Cursor / Layout
|
||||||
// - By "cursor" we mean the current output position.
|
// - By "cursor" we mean the current output position.
|
||||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||||
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget.
|
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget.
|
||||||
// - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
|
// - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
|
||||||
// Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
|
// Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
|
||||||
// Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions.
|
// Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions.
|
||||||
|
@ -441,17 +443,17 @@ namespace ImGui
|
||||||
// Widgets: Main
|
// Widgets: Main
|
||||||
// - Most widgets return true when the value has been changed or when pressed/selected
|
// - Most widgets return true when the value has been changed or when pressed/selected
|
||||||
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
||||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
|
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 within 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); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||||
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
||||||
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 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
|
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
|
||||||
IMGUI_API bool Checkbox(const char* label, bool* v);
|
IMGUI_API bool Checkbox(const char* label, bool* v);
|
||||||
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||||
IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
||||||
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
||||||
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1,0), const char* overlay = NULL);
|
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-1, 0), const char* overlay = NULL);
|
||||||
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 Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||||
|
|
||||||
// Widgets: Combo Box
|
// Widgets: Combo Box
|
||||||
|
@ -506,7 +508,7 @@ namespace ImGui
|
||||||
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
|
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
|
||||||
// - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
|
// - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
|
||||||
IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||||
IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||||
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||||
IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||||
IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||||
|
@ -527,7 +529,7 @@ namespace ImGui
|
||||||
IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0);
|
IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0);
|
||||||
IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
|
IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
|
||||||
IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL);
|
IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL);
|
||||||
IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed.
|
IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0)); // display a colored square/button, hover for details, return true when pressed.
|
||||||
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.
|
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.
|
||||||
|
|
||||||
// Widgets: Trees
|
// Widgets: Trees
|
||||||
|
@ -553,14 +555,14 @@ namespace ImGui
|
||||||
// Widgets: Selectables
|
// Widgets: Selectables
|
||||||
// - A selectable highlights when hovered, and can display another color when selected.
|
// - A selectable highlights when hovered, and can display another color when selected.
|
||||||
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
|
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
|
||||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||||
|
|
||||||
// Widgets: List Boxes
|
// Widgets: List Boxes
|
||||||
// - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them.
|
// - FIXME: To be consistent with all the newer API, ListBoxHeader/ListBoxFooter should in reality be called BeginListBox/EndListBox. Will rename them.
|
||||||
IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
|
IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
|
||||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
|
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
|
||||||
IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards.
|
IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)); // use if you want to reimplement ListBox() will custom data or interactions. if the function return true, you can output elements then call ListBoxFooter() afterwards.
|
||||||
IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
|
IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
|
||||||
IMGUI_API void ListBoxFooter(); // terminate the scrolling region. only call ListBoxFooter() if ListBoxHeader() returned true!
|
IMGUI_API void ListBoxFooter(); // terminate the scrolling region. only call ListBoxFooter() if ListBoxHeader() returned true!
|
||||||
|
|
||||||
|
@ -598,24 +600,41 @@ namespace ImGui
|
||||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||||
|
|
||||||
// Popups, Modals
|
// Popups, Modals
|
||||||
// The properties of popups windows are:
|
// - They block normal mouse hovering detection (and therefore most mouse interactions) behind them.
|
||||||
// - They block normal mouse hovering detection outside them. (*)
|
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||||
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
// - Their visibility state (~bool) is held internally instead of being held by the programmer as we are used to with regular Begin*() calls.
|
||||||
// - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
|
// - The 3 properties above are related: we need to retain popup visibility state in the library because popups may be closed as any time.
|
||||||
// User can manipulate the visibility state by calling OpenPopup().
|
// - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
||||||
// - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions.
|
// - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack.
|
||||||
// (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
|
// This is sometimes leading to confusing mistakes. May rework this in the future.
|
||||||
// Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
|
// Popups: begin/end functions
|
||||||
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).
|
// - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window.
|
||||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
|
// - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar.
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton 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 BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1, bool also_over_items = true); // helper to open and begin popup when clicked on current window.
|
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked in void (where there are no imgui windows).
|
|
||||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // modal dialog (regular window with title bar, block interactions behind the modal window, can't close the modal window by clicking outside)
|
|
||||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||||
IMGUI_API bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open popup when clicked on last item (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors). return true when just opened.
|
// Popups: open/close functions
|
||||||
IMGUI_API bool IsPopupOpen(const char* str_id); // return true if the popup is open at the current begin-ed level of the popup stack.
|
// - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options.
|
||||||
IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.
|
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||||
|
// - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
|
||||||
|
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||||
|
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||||
|
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||||
|
IMGUI_API bool OpenPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
|
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||||
|
// Popups: open+begin combined functions helpers
|
||||||
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
|
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||||
|
// - We exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter. Passing a mouse button to ImGuiPopupFlags is guaranteed to be legal.
|
||||||
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+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, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
|
// Popups: test function
|
||||||
|
// - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
|
||||||
|
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
|
||||||
|
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open.
|
||||||
|
IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
||||||
|
|
||||||
// Columns
|
// Columns
|
||||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||||
|
@ -638,7 +657,7 @@ namespace ImGui
|
||||||
// - If you are using tables as a sort of grid, populating every columns with the same type of contents,
|
// - If you are using tables as a sort of grid, populating every columns with the same type of contents,
|
||||||
// you may prefer using TableNextCell() instead of TableNextRow() + TableSetColumnIndex().
|
// you may prefer using TableNextCell() instead of TableNextRow() + TableSetColumnIndex().
|
||||||
// - See Demo->Tables for details.
|
// - See Demo->Tables for details.
|
||||||
// - See ImGuiTableFlags_ enums for a description of available flags.
|
// - See ImGuiTableFlags_ and ImGuiTableColumnsFlags_ enums for a description of available flags.
|
||||||
#define IMGUI_HAS_TABLE 1
|
#define IMGUI_HAS_TABLE 1
|
||||||
IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
|
IMGUI_API bool BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
|
||||||
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
|
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
|
||||||
|
@ -649,11 +668,12 @@ namespace ImGui
|
||||||
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return NULL if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return NULL if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
||||||
IMGUI_API bool TableGetColumnIsVisible(int column_n = -1); // return true if column is visible. Same value is also returned by TableNextCell() and TableSetColumnIndex(). Pass -1 to use current column.
|
IMGUI_API bool TableGetColumnIsVisible(int column_n = -1); // return true if column is visible. Same value is also returned by TableNextCell() and TableSetColumnIndex(). Pass -1 to use current column.
|
||||||
IMGUI_API bool TableGetColumnIsSorted(int column_n = -1); // return true if column is included in the sort specs. Rarely used, can be useful to tell if a data change should trigger resort. Equivalent to test ImGuiTableSortSpecs's ->ColumnsMask & (1 << column_n). Pass -1 to use current column.
|
IMGUI_API bool TableGetColumnIsSorted(int column_n = -1); // return true if column is included in the sort specs. Rarely used, can be useful to tell if a data change should trigger resort. Equivalent to test ImGuiTableSortSpecs's ->ColumnsMask & (1 << column_n). Pass -1 to use current column.
|
||||||
|
IMGUI_API int TableGetHoveredColumn(); // return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||||
// Tables: Headers & Columns declaration
|
// Tables: Headers & Columns declaration
|
||||||
// - Use TableSetupColumn() to specify label, resizing policy, default width, id, various other flags etc.
|
// - Use TableSetupColumn() to specify label, resizing policy, default width, id, various other flags etc.
|
||||||
// - The name passed to TableSetupColumn() is used by TableAutoHeaders() and by the context-menu
|
// - The name passed to TableSetupColumn() is used by TableAutoHeaders() and by the context-menu
|
||||||
// - Use TableAutoHeaders() to submit the whole header row, otherwise you may treat the header row as a regular row, manually call TableHeader() and other widgets.
|
// - Use TableAutoHeaders() to submit the whole header row, otherwise you may treat the header row as a regular row, manually call TableHeader() and other widgets.
|
||||||
// - Headers are required to perform some interactions: reordering, sorting, context menu // FIXME-TABLE: remove context from this list!
|
// - Headers are required to perform some interactions: reordering, sorting, context menu (FIXME-TABLE: context menu should work without!)
|
||||||
IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0);
|
IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = -1.0f, ImU32 user_id = 0);
|
||||||
IMGUI_API void TableAutoHeaders(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
|
IMGUI_API void TableAutoHeaders(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
|
||||||
IMGUI_API void TableHeader(const char* label); // submit one header cell manually.
|
IMGUI_API void TableHeader(const char* label); // submit one header cell manually.
|
||||||
|
@ -681,6 +701,7 @@ namespace ImGui
|
||||||
|
|
||||||
// Drag and Drop
|
// Drag and Drop
|
||||||
// - [BETA API] API may evolve!
|
// - [BETA API] API may evolve!
|
||||||
|
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement)
|
||||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
||||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
||||||
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
||||||
|
@ -760,7 +781,7 @@ namespace ImGui
|
||||||
IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held?
|
IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held?
|
||||||
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down)
|
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down)
|
||||||
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down)
|
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down)
|
||||||
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? (note that a double-click will also report IsMouseClicked() == true)
|
||||||
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, but disregarding of other consideration of focus/window ordering/popup-block.
|
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, but disregarding of other consideration of focus/window ordering/popup-block.
|
||||||
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
|
||||||
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
|
IMGUI_API bool IsAnyMouseDown(); // is any mouse button held?
|
||||||
|
@ -893,6 +914,26 @@ enum ImGuiTreeNodeFlags_
|
||||||
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
|
||||||
|
// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat
|
||||||
|
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
||||||
|
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
||||||
|
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
||||||
|
enum ImGuiPopupFlags_
|
||||||
|
{
|
||||||
|
ImGuiPopupFlags_None = 0,
|
||||||
|
ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranted to always be == 0 (same as ImGuiMouseButton_Left)
|
||||||
|
ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranted to always be == 1 (same as ImGuiMouseButton_Right)
|
||||||
|
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranted to always be == 2 (same as ImGuiMouseButton_Middle)
|
||||||
|
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
||||||
|
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
||||||
|
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
||||||
|
ImGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
|
||||||
|
ImGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup.
|
||||||
|
ImGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
|
||||||
|
ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel
|
||||||
|
};
|
||||||
|
|
||||||
// Flags for ImGui::Selectable()
|
// Flags for ImGui::Selectable()
|
||||||
enum ImGuiSelectableFlags_
|
enum ImGuiSelectableFlags_
|
||||||
{
|
{
|
||||||
|
@ -941,7 +982,8 @@ enum ImGuiTabItemFlags_
|
||||||
ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
|
ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
|
||||||
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
|
||||||
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
||||||
ImGuiTabItemFlags_NoPushId = 1 << 3 // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
|
||||||
|
ImGuiTabItemFlags_NoTooltip = 1 << 4 // Disable tooltip for the given tab
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginTable()
|
// Flags for ImGui::BeginTable()
|
||||||
|
@ -973,8 +1015,8 @@ enum ImGuiTableFlags_
|
||||||
ImGuiTableFlags_BordersVFullHeight = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows.
|
ImGuiTableFlags_BordersVFullHeight = 1 << 11, // Borders covers all rows even when Headers are being used. Allow resizing from any rows.
|
||||||
// Padding, Sizing
|
// Padding, Sizing
|
||||||
ImGuiTableFlags_NoClipX = 1 << 12, // Disable pushing clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow)
|
ImGuiTableFlags_NoClipX = 1 << 12, // Disable pushing clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow)
|
||||||
ImGuiTableFlags_SizingPolicyFixedX = 1 << 13, // Default if ScrollX is on. Columns will default to use WidthFixed or WidthAlwaysAutoResize policy. Read description above for more details.
|
ImGuiTableFlags_SizingPolicyFixedX = 1 << 13, // Default if ScrollX is on. Columns will default to use _WidthFixed or _WidthAlwaysAutoResize policy. Read description above for more details.
|
||||||
ImGuiTableFlags_SizingPolicyStretchX = 1 << 14, // Default if ScrollX is off. Columns will default to use WidthStretch policy. Read description above for more details.
|
ImGuiTableFlags_SizingPolicyStretchX = 1 << 14, // Default if ScrollX is off. Columns will default to use _WidthStretch policy. Read description above for more details.
|
||||||
ImGuiTableFlags_NoHeadersWidth = 1 << 15, // Disable header width contribution to automatic width calculation.
|
ImGuiTableFlags_NoHeadersWidth = 1 << 15, // Disable header width contribution to automatic width calculation.
|
||||||
ImGuiTableFlags_NoHostExtendY = 1 << 16, // (FIXME-TABLE: Reword as SizingPolicy?) Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
|
ImGuiTableFlags_NoHostExtendY = 1 << 16, // (FIXME-TABLE: Reword as SizingPolicy?) Disable extending past the limit set by outer_size.y, only meaningful when neither of ScrollX|ScrollY are set (data below the limit will be clipped and not visible)
|
||||||
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small.
|
ImGuiTableFlags_NoKeepColumnsVisible = 1 << 17, // (FIXME-TABLE) Disable code that keeps column always minimally visible when table width gets too small.
|
||||||
|
@ -1039,12 +1081,12 @@ enum ImGuiFocusedFlags_
|
||||||
ImGuiFocusedFlags_None = 0,
|
ImGuiFocusedFlags_None = 0,
|
||||||
ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
|
ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
|
||||||
ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
|
ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
|
||||||
ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead.
|
ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
|
||||||
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
|
ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
|
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
|
||||||
// Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ!
|
// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ!
|
||||||
// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
|
// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
|
||||||
enum ImGuiHoveredFlags_
|
enum ImGuiHoveredFlags_
|
||||||
{
|
{
|
||||||
|
@ -1156,7 +1198,7 @@ enum ImGuiKeyModFlags_
|
||||||
ImGuiKeyModFlags_Super = 1 << 3
|
ImGuiKeyModFlags_Super = 1 << 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gamepad/Keyboard directional navigation
|
// Gamepad/Keyboard navigation
|
||||||
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
|
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
|
||||||
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||||
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW.
|
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW.
|
||||||
|
@ -1356,13 +1398,13 @@ enum ImGuiColorEditFlags_
|
||||||
|
|
||||||
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
// Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
|
||||||
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
// override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
|
||||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar,
|
||||||
|
|
||||||
// [Internal] Masks
|
// [Internal] Masks
|
||||||
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_DisplayHSV|ImGuiColorEditFlags_DisplayHex,
|
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex,
|
||||||
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
|
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float,
|
||||||
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
|
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar,
|
||||||
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB|ImGuiColorEditFlags_InputHSV
|
ImGuiColorEditFlags__InputMask = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV
|
||||||
|
|
||||||
// Obsolete names (will be removed)
|
// Obsolete names (will be removed)
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
@ -1407,8 +1449,9 @@ enum ImGuiMouseCursor_
|
||||||
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
|
// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always.
|
||||||
enum ImGuiCond_
|
enum ImGuiCond_
|
||||||
{
|
{
|
||||||
ImGuiCond_Always = 1 << 0, // Set the variable
|
ImGuiCond_None = 0, // No condition (always set the variable), same as _Always
|
||||||
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
|
ImGuiCond_Always = 1 << 0, // No condition (always set the variable)
|
||||||
|
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
|
||||||
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
|
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
|
||||||
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
|
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
|
||||||
};
|
};
|
||||||
|
@ -1476,7 +1519,7 @@ struct ImVector
|
||||||
inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; }
|
||||||
inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
inline void swap(ImVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
||||||
|
|
||||||
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; }
|
||||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_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++) memcpy(&Data[n], &v, sizeof(v)); 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++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
|
||||||
inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
|
inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
|
||||||
|
@ -1486,10 +1529,10 @@ struct ImVector
|
||||||
inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
|
inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
|
||||||
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
||||||
inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
|
inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
|
||||||
inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
|
inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
|
||||||
inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data+Size && it_last > it && it_last <= Data+Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; }
|
inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data + Size && it_last > it && it_last <= Data + Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; }
|
||||||
inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; if (it < Data+Size-1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
|
inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; if (it < Data + Size - 1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
|
||||||
inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
|
inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data + Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
|
||||||
inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
|
inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
|
||||||
inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
||||||
inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
|
||||||
|
@ -1509,7 +1552,7 @@ struct ImGuiStyle
|
||||||
{
|
{
|
||||||
float Alpha; // Global alpha applies to everything in Dear ImGui.
|
float Alpha; // Global alpha applies to everything in Dear ImGui.
|
||||||
ImVec2 WindowPadding; // Padding within a window.
|
ImVec2 WindowPadding; // Padding within a window.
|
||||||
float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows.
|
float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended.
|
||||||
float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
||||||
ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints().
|
ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints().
|
||||||
ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered.
|
ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered.
|
||||||
|
@ -1533,6 +1576,7 @@ struct ImGuiStyle
|
||||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||||
float TabBorderSize; // Thickness of border around tabs.
|
float TabBorderSize; // Thickness of border around tabs.
|
||||||
|
float TabMinWidthForUnselectedCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||||
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
||||||
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||||
|
@ -1626,8 +1670,8 @@ struct ImGuiIO
|
||||||
// Input - Fill before calling NewFrame()
|
// Input - Fill before calling NewFrame()
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX,-FLT_MAX) if mouse is unavailable (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: 0=left, 1=right, 2=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.
|
bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. 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 Vertical: 1 unit scrolls about 5 lines text.
|
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
|
||||||
float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends.
|
float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all back-ends.
|
||||||
bool KeyCtrl; // Keyboard modifier pressed: Control
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
||||||
|
@ -1644,17 +1688,19 @@ struct ImGuiIO
|
||||||
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Output - Retrieve after calling NewFrame()
|
// Output - Updated by NewFrame() or EndFrame()/Render()
|
||||||
|
// (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
|
||||||
|
// generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
bool WantCaptureMouse; // When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
|
bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
|
||||||
bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
|
bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
|
||||||
bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
||||||
bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
||||||
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
|
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
|
||||||
bool NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
||||||
bool NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
||||||
float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
|
float Framerate; // Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
|
||||||
int MetricsRenderVertices; // Vertices output during last call to Render()
|
int MetricsRenderVertices; // Vertices output during last call to Render()
|
||||||
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
|
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
|
||||||
int MetricsRenderWindows; // Number of visible windows
|
int MetricsRenderWindows; // Number of visible windows
|
||||||
|
@ -1683,6 +1729,7 @@ struct ImGuiIO
|
||||||
float KeysDownDurationPrev[512]; // Previous duration the key has been down
|
float KeysDownDurationPrev[512]; // Previous duration the key has been down
|
||||||
float NavInputsDownDuration[ImGuiNavInput_COUNT];
|
float NavInputsDownDuration[ImGuiNavInput_COUNT];
|
||||||
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
|
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
|
||||||
|
float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
|
||||||
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16
|
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16
|
||||||
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper.
|
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform back-end). Fill using AddInputCharacter() helper.
|
||||||
|
|
||||||
|
@ -1749,7 +1796,7 @@ struct ImGuiPayload
|
||||||
ImGuiID SourceId; // Source item id
|
ImGuiID SourceId; // Source item id
|
||||||
ImGuiID SourceParentId; // Source parent id (if available)
|
ImGuiID SourceParentId; // Source parent id (if available)
|
||||||
int DataFrameCount; // Data timestamp
|
int DataFrameCount; // Data timestamp
|
||||||
char DataType[32+1]; // Data type tag (short user-supplied string, 32 characters max)
|
char DataType[32 + 1]; // Data type tag (short user-supplied string, 32 characters max)
|
||||||
bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
|
bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
|
||||||
bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
|
bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
|
||||||
|
|
||||||
|
@ -1791,6 +1838,9 @@ struct ImGuiTableSortSpecs
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
|
// OBSOLETED in 1.77 (from June 2020)
|
||||||
|
static inline bool OpenPopupOnItemClick(const char* str_id = NULL, ImGuiMouseButton mb = 1) { return OpenPopupContextItem(str_id, mb); } // Passing a mouse button to ImGuiPopupFlags is legal
|
||||||
|
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||||
// OBSOLETED in 1.72 (from July 2019)
|
// OBSOLETED in 1.72 (from July 2019)
|
||||||
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); }
|
||||||
// OBSOLETED in 1.71 (from June 2019)
|
// OBSOLETED in 1.71 (from June 2019)
|
||||||
|
@ -1811,7 +1861,6 @@ namespace ImGui
|
||||||
// OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
// OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
||||||
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
|
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
|
||||||
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
|
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
|
||||||
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; }
|
|
||||||
}
|
}
|
||||||
typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent
|
typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent
|
||||||
typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
|
typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
|
||||||
|
@ -1998,8 +2047,8 @@ struct ImColor
|
||||||
ImVec4 Value;
|
ImVec4 Value;
|
||||||
|
|
||||||
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
|
||||||
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
||||||
ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; }
|
ImColor(ImU32 rgba) { float sc = 1.0f / 255.0f; Value.x = (float)((rgba >> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; }
|
||||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||||
ImColor(const ImVec4& col) { Value = col; }
|
ImColor(const ImVec4& col) { Value = col; }
|
||||||
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||||
|
@ -2007,7 +2056,7 @@ struct ImColor
|
||||||
|
|
||||||
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
|
// FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
|
||||||
inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
|
||||||
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
|
static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r, g, b, a); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -2033,19 +2082,21 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
|
||||||
#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1)
|
#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1)
|
||||||
|
|
||||||
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
|
// Typically, 1 command = 1 GPU draw call (unless command is a callback)
|
||||||
// Pre 1.71 back-ends will typically ignore the VtxOffset/IdxOffset fields. When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset'
|
// - VtxOffset/IdxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled,
|
||||||
// is enabled, those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
|
// those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
|
||||||
|
// Pre-1.71 back-ends will typically ignore the VtxOffset/IdxOffset fields.
|
||||||
|
// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
|
||||||
struct ImDrawCmd
|
struct ImDrawCmd
|
||||||
{
|
{
|
||||||
unsigned int ElemCount; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
|
||||||
ImVec4 ClipRect; // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
|
ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
||||||
ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices.
|
||||||
unsigned int VtxOffset; // Start offset in vertex buffer. Pre-1.71 or without ImGuiBackendFlags_RendererHasVtxOffset: always 0. With ImGuiBackendFlags_RendererHasVtxOffset: may be >0 to support meshes larger than 64K vertices with 16-bit indices.
|
unsigned int IdxOffset; // 4 // Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
|
||||||
unsigned int IdxOffset; // Start offset in index buffer. Always equal to sum of ElemCount drawn so far.
|
unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
|
||||||
ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
ImDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
||||||
void* UserCallbackData; // The draw callback code can access this.
|
void* UserCallbackData; // 4-8 // The draw callback code can access this.
|
||||||
|
|
||||||
ImDrawCmd() { ElemCount = 0; TextureId = (ImTextureID)NULL; VtxOffset = IdxOffset = 0; UserCallback = NULL; UserCallbackData = NULL; }
|
ImDrawCmd() { memset(this, 0, sizeof(*this)); } // Also ensure our padding fields are zeroed
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vertex index, default to 16-bit
|
// Vertex index, default to 16-bit
|
||||||
|
@ -2136,18 +2187,19 @@ struct ImDrawList
|
||||||
// [Internal, used while building lists]
|
// [Internal, used while building lists]
|
||||||
const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
|
const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
|
||||||
const char* _OwnerName; // Pointer to owner window's name for debugging
|
const char* _OwnerName; // Pointer to owner window's name for debugging
|
||||||
unsigned int _VtxCurrentOffset; // [Internal] Always 0 unless 'Flags & ImDrawListFlags_AllowVtxOffset'.
|
|
||||||
unsigned int _VtxCurrentIdx; // [Internal] Generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0.
|
unsigned int _VtxCurrentIdx; // [Internal] Generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0.
|
||||||
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
||||||
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
||||||
ImVector<ImVec2> _Path; // [Internal] current path building
|
ImVector<ImVec2> _Path; // [Internal] current path building
|
||||||
ImDrawListSplitter _Splitter; // [Internal] for channels api
|
ImDrawCmd _CmdHeader; // [Internal] Template of active commands. Fields should match those of CmdBuffer.back().
|
||||||
|
ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!)
|
||||||
|
|
||||||
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
||||||
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); }
|
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; Flags = ImDrawListFlags_None; _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _OwnerName = NULL; }
|
||||||
~ImDrawList() { ClearFreeMemory(); }
|
|
||||||
|
~ImDrawList() { _ClearFreeMemory(); }
|
||||||
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||||
IMGUI_API void PushClipRectFullScreen();
|
IMGUI_API void PushClipRectFullScreen();
|
||||||
IMGUI_API void PopClipRect();
|
IMGUI_API void PopClipRect();
|
||||||
|
@ -2190,7 +2242,7 @@ struct ImDrawList
|
||||||
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||||
inline void PathClear() { _Path.Size = 0; }
|
inline void PathClear() { _Path.Size = 0; }
|
||||||
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||||
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||||
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||||
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
||||||
|
@ -2207,26 +2259,31 @@ struct ImDrawList
|
||||||
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
// - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
|
||||||
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
|
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||||
// - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place!
|
// - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place!
|
||||||
// Prefer using your own persistent copy of ImDrawListSplitter as you can stack them.
|
// Prefer using your own persistent instance of ImDrawListSplitter as you can stack them.
|
||||||
// Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
|
// Using the ImDrawList::ChannelsXXXX you cannot stack a split over another.
|
||||||
inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
|
inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
|
||||||
inline void ChannelsMerge() { _Splitter.Merge(this); }
|
inline void ChannelsMerge() { _Splitter.Merge(this); }
|
||||||
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
|
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
|
||||||
|
|
||||||
// Internal helpers
|
// Advanced: Primitives allocations
|
||||||
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
|
// - We render triangles (three vertices)
|
||||||
IMGUI_API void Clear();
|
// - All primitives needs to be reserved via PrimReserve() beforehand.
|
||||||
IMGUI_API void ClearFreeMemory();
|
|
||||||
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
|
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
|
||||||
IMGUI_API void PrimUnreserve(int idx_count, int vtx_count);
|
IMGUI_API void PrimUnreserve(int idx_count, int vtx_count);
|
||||||
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
|
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
|
||||||
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
|
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
|
||||||
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
|
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
|
||||||
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
|
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
|
||||||
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
|
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
|
||||||
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
|
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
||||||
IMGUI_API void UpdateClipRect();
|
|
||||||
IMGUI_API void UpdateTextureID();
|
// [Internal helpers]
|
||||||
|
IMGUI_API void _ResetForNewFrame();
|
||||||
|
IMGUI_API void _ClearFreeMemory();
|
||||||
|
IMGUI_API void _PopUnusedDrawCmd();
|
||||||
|
IMGUI_API void _OnChangedClipRect();
|
||||||
|
IMGUI_API void _OnChangedTextureID();
|
||||||
|
IMGUI_API void _OnChangedVtxOffset();
|
||||||
};
|
};
|
||||||
|
|
||||||
// All draw data to render a Dear ImGui frame
|
// All draw data to render a Dear ImGui frame
|
||||||
|
@ -2312,13 +2369,13 @@ struct ImFontGlyphRangesBuilder
|
||||||
// See ImFontAtlas::AddCustomRectXXX functions.
|
// See ImFontAtlas::AddCustomRectXXX functions.
|
||||||
struct ImFontAtlasCustomRect
|
struct ImFontAtlasCustomRect
|
||||||
{
|
{
|
||||||
unsigned int ID; // Input // User ID. Use < 0x110000 to map into a font glyph, >= 0x110000 for other/internal/custom texture data.
|
|
||||||
unsigned short Width, Height; // Input // Desired rectangle dimension
|
unsigned short Width, Height; // Input // Desired rectangle dimension
|
||||||
unsigned short X, Y; // Output // Packed position in Atlas
|
unsigned short X, Y; // Output // Packed position in Atlas
|
||||||
float GlyphAdvanceX; // Input // For custom font glyphs only (ID < 0x110000): glyph xadvance
|
unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000)
|
||||||
ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID < 0x110000): glyph display offset
|
float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance
|
||||||
ImFont* Font; // Input // For custom font glyphs only (ID < 0x110000): target font
|
ImVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset
|
||||||
ImFontAtlasCustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
|
ImFont* Font; // Input // For custom font glyphs only: target font
|
||||||
|
ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0, 0); Font = NULL; }
|
||||||
bool IsPacked() const { return X != 0xFFFF; }
|
bool IsPacked() const { return X != 0xFFFF; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2396,9 +2453,10 @@ struct ImFontAtlas
|
||||||
// After calling Build(), you can query the rectangle position and render your pixels.
|
// 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),
|
// 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.
|
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||||
// Read docs/FONTS.txt for more details about using colorful icons.
|
// Read docs/FONTS.md for more details about using colorful icons.
|
||||||
IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x110000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
|
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
||||||
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 < 0x110000 to register a rectangle to map into a specific font.
|
IMGUI_API int AddCustomRectRegular(int width, int height);
|
||||||
|
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0));
|
||||||
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
|
@ -2459,7 +2517,7 @@ struct ImFont
|
||||||
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||||
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||||
ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations accross all used codepoints.
|
ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints.
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
IMGUI_API ImFont();
|
IMGUI_API ImFont();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
||||||
// dear imgui, v1.76 WIP
|
// dear imgui, v1.78 WIP
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,7 +36,7 @@ Index of this file:
|
||||||
|
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#if !defined(alloca)
|
#if !defined(alloca)
|
||||||
#if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__SWITCH__)
|
#if defined(__GLIBC__) || defined(__sun) || defined(__APPLE__) || defined(__NEWLIB__)
|
||||||
#include <alloca.h> // alloca (glibc uses <alloca.h>. Note that Cygwin may have _WIN32 defined, so the order matters here)
|
#include <alloca.h> // alloca (glibc uses <alloca.h>. Note that Cygwin may have _WIN32 defined, so the order matters here)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <malloc.h> // alloca
|
#include <malloc.h> // alloca
|
||||||
|
@ -57,22 +57,19 @@ Index of this file:
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
// Clang/GCC warnings with -Weverything
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
|
#if __has_warning("-Wunknown-warning-option")
|
||||||
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
|
#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great!
|
||||||
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is.
|
|
||||||
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
|
|
||||||
#if __has_warning("-Wzero-as-null-pointer-constant")
|
|
||||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0
|
|
||||||
#endif
|
#endif
|
||||||
#if __has_warning("-Wcomma")
|
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
|
||||||
#pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here //
|
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse.
|
||||||
#endif
|
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
|
||||||
#if __has_warning("-Wreserved-id-macro")
|
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is.
|
||||||
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier //
|
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
|
||||||
#endif
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0
|
||||||
#if __has_warning("-Wdouble-promotion")
|
#pragma clang diagnostic ignored "-Wcomma" // warning: possible misuse of comma operator here
|
||||||
|
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#endif
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||||
|
@ -108,7 +105,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
#pragma clang diagnostic ignored "-Wunused-function"
|
||||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
|
||||||
#pragma clang diagnostic ignored "-Wcast-qual" // warning : cast from 'const xxxx *' to 'xxx *' drops const qualifier //
|
#pragma clang diagnostic ignored "-Wcast-qual" // warning: cast from 'const xxxx *' to 'xxx *' drops const qualifier
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
@ -120,7 +117,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||||
#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
||||||
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||||
#define STBRP_STATIC
|
#define STBRP_STATIC
|
||||||
#define STBRP_ASSERT(x) IM_ASSERT(x)
|
#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0)
|
||||||
#define STBRP_SORT ImQsort
|
#define STBRP_SORT ImQsort
|
||||||
#define STB_RECT_PACK_IMPLEMENTATION
|
#define STB_RECT_PACK_IMPLEMENTATION
|
||||||
#endif
|
#endif
|
||||||
|
@ -135,7 +132,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||||
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||||
#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x))
|
#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x))
|
||||||
#define STBTT_free(x,u) ((void)(u), IM_FREE(x))
|
#define STBTT_free(x,u) ((void)(u), IM_FREE(x))
|
||||||
#define STBTT_assert(x) IM_ASSERT(x)
|
#define STBTT_assert(x) do { IM_ASSERT(x); } while(0)
|
||||||
#define STBTT_fmod(x,y) ImFmod(x,y)
|
#define STBTT_fmod(x,y) ImFmod(x,y)
|
||||||
#define STBTT_sqrt(x) ImSqrt(x)
|
#define STBTT_sqrt(x) ImSqrt(x)
|
||||||
#define STBTT_pow(x,y) ImPow(x,y)
|
#define STBTT_pow(x,y) ImPow(x,y)
|
||||||
|
@ -391,13 +388,20 @@ void ImDrawListSharedData::SetCircleSegmentMaxError(float max_error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::Clear()
|
// Initialize before use in a new frame. We always have a command ready in the buffer.
|
||||||
|
void ImDrawList::_ResetForNewFrame()
|
||||||
{
|
{
|
||||||
|
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
||||||
|
// (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC)
|
||||||
|
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, ClipRect) == 0);
|
||||||
|
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, TextureId) == sizeof(ImVec4));
|
||||||
|
IM_ASSERT(IM_OFFSETOF(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureID));
|
||||||
|
|
||||||
CmdBuffer.resize(0);
|
CmdBuffer.resize(0);
|
||||||
IdxBuffer.resize(0);
|
IdxBuffer.resize(0);
|
||||||
VtxBuffer.resize(0);
|
VtxBuffer.resize(0);
|
||||||
Flags = _Data ? _Data->InitialFlags : ImDrawListFlags_None;
|
Flags = _Data->InitialFlags;
|
||||||
_VtxCurrentOffset = 0;
|
memset(&_CmdHeader, 0, sizeof(_CmdHeader));
|
||||||
_VtxCurrentIdx = 0;
|
_VtxCurrentIdx = 0;
|
||||||
_VtxWritePtr = NULL;
|
_VtxWritePtr = NULL;
|
||||||
_IdxWritePtr = NULL;
|
_IdxWritePtr = NULL;
|
||||||
|
@ -405,13 +409,15 @@ void ImDrawList::Clear()
|
||||||
_TextureIdStack.resize(0);
|
_TextureIdStack.resize(0);
|
||||||
_Path.resize(0);
|
_Path.resize(0);
|
||||||
_Splitter.Clear();
|
_Splitter.Clear();
|
||||||
|
CmdBuffer.push_back(ImDrawCmd());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::ClearFreeMemory()
|
void ImDrawList::_ClearFreeMemory()
|
||||||
{
|
{
|
||||||
CmdBuffer.clear();
|
CmdBuffer.clear();
|
||||||
IdxBuffer.clear();
|
IdxBuffer.clear();
|
||||||
VtxBuffer.clear();
|
VtxBuffer.clear();
|
||||||
|
Flags = ImDrawListFlags_None;
|
||||||
_VtxCurrentIdx = 0;
|
_VtxCurrentIdx = 0;
|
||||||
_VtxWritePtr = NULL;
|
_VtxWritePtr = NULL;
|
||||||
_IdxWritePtr = NULL;
|
_IdxWritePtr = NULL;
|
||||||
|
@ -431,86 +437,117 @@ ImDrawList* ImDrawList::CloneOutput() const
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds
|
|
||||||
#define GetCurrentClipRect() (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1] : _Data->ClipRectFullscreen)
|
|
||||||
#define GetCurrentTextureId() (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : (ImTextureID)NULL)
|
|
||||||
|
|
||||||
void ImDrawList::AddDrawCmd()
|
void ImDrawList::AddDrawCmd()
|
||||||
{
|
{
|
||||||
ImDrawCmd draw_cmd;
|
ImDrawCmd draw_cmd;
|
||||||
draw_cmd.ClipRect = GetCurrentClipRect();
|
draw_cmd.ClipRect = _CmdHeader.ClipRect; // Same as calling ImDrawCmd_HeaderCopy()
|
||||||
draw_cmd.TextureId = GetCurrentTextureId();
|
draw_cmd.TextureId = _CmdHeader.TextureId;
|
||||||
draw_cmd.VtxOffset = _VtxCurrentOffset;
|
draw_cmd.VtxOffset = _CmdHeader.VtxOffset;
|
||||||
draw_cmd.IdxOffset = IdxBuffer.Size;
|
draw_cmd.IdxOffset = IdxBuffer.Size;
|
||||||
|
|
||||||
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
|
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
|
||||||
CmdBuffer.push_back(draw_cmd);
|
CmdBuffer.push_back(draw_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pop trailing draw command (used before merging or presenting to user)
|
||||||
|
// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
|
||||||
|
void ImDrawList::_PopUnusedDrawCmd()
|
||||||
|
{
|
||||||
|
if (CmdBuffer.Size == 0)
|
||||||
|
return;
|
||||||
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
if (curr_cmd->ElemCount == 0 && curr_cmd->UserCallback == NULL)
|
||||||
|
CmdBuffer.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
||||||
{
|
{
|
||||||
ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL;
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL)
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
|
if (curr_cmd->ElemCount != 0)
|
||||||
{
|
{
|
||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
current_cmd = &CmdBuffer.back();
|
curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
}
|
}
|
||||||
current_cmd->UserCallback = callback;
|
curr_cmd->UserCallback = callback;
|
||||||
current_cmd->UserCallbackData = callback_data;
|
curr_cmd->UserCallbackData = callback_data;
|
||||||
|
|
||||||
AddDrawCmd(); // Force a new command after us (see comment below)
|
AddDrawCmd(); // Force a new command after us (see comment below)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compare ClipRect, TextureId and VtxOffset with a single memcmp()
|
||||||
|
#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
|
||||||
|
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
||||||
|
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
|
||||||
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
|
||||||
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
|
||||||
void ImDrawList::UpdateClipRect()
|
void ImDrawList::_OnChangedClipRect()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
const ImVec4 curr_clip_rect = GetCurrentClipRect();
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
ImDrawCmd* curr_cmd = CmdBuffer.Size > 0 ? &CmdBuffer.Data[CmdBuffer.Size-1] : NULL;
|
if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0)
|
||||||
if (!curr_cmd || (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) != 0) || curr_cmd->UserCallback != NULL)
|
|
||||||
{
|
{
|
||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
||||||
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
else
|
return;
|
||||||
curr_cmd->ClipRect = curr_clip_rect;
|
}
|
||||||
|
|
||||||
|
curr_cmd->ClipRect = _CmdHeader.ClipRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::UpdateTextureID()
|
void ImDrawList::_OnChangedTextureID()
|
||||||
{
|
{
|
||||||
// If current command is used with different settings we need to add a new command
|
// If current command is used with different settings we need to add a new command
|
||||||
const ImTextureID curr_texture_id = GetCurrentTextureId();
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
ImDrawCmd* curr_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL;
|
if (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != _CmdHeader.TextureId)
|
||||||
if (!curr_cmd || (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != curr_texture_id) || curr_cmd->UserCallback != NULL)
|
|
||||||
{
|
{
|
||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
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)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
||||||
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
else
|
return;
|
||||||
curr_cmd->TextureId = curr_texture_id;
|
}
|
||||||
|
|
||||||
|
curr_cmd->TextureId = _CmdHeader.TextureId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef GetCurrentClipRect
|
void ImDrawList::_OnChangedVtxOffset()
|
||||||
#undef GetCurrentTextureId
|
{
|
||||||
|
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
|
||||||
|
_VtxCurrentIdx = 0;
|
||||||
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
|
IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset);
|
||||||
|
if (curr_cmd->ElemCount != 0)
|
||||||
|
{
|
||||||
|
AddDrawCmd();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IM_ASSERT(curr_cmd->UserCallback == NULL);
|
||||||
|
curr_cmd->VtxOffset = _CmdHeader.VtxOffset;
|
||||||
|
}
|
||||||
|
|
||||||
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
|
||||||
void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
|
void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect)
|
||||||
{
|
{
|
||||||
ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y);
|
ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y);
|
||||||
if (intersect_with_current_clip_rect && _ClipRectStack.Size)
|
if (intersect_with_current_clip_rect)
|
||||||
{
|
{
|
||||||
ImVec4 current = _ClipRectStack.Data[_ClipRectStack.Size-1];
|
ImVec4 current = _CmdHeader.ClipRect;
|
||||||
if (cr.x < current.x) cr.x = current.x;
|
if (cr.x < current.x) cr.x = current.x;
|
||||||
if (cr.y < current.y) cr.y = current.y;
|
if (cr.y < current.y) cr.y = current.y;
|
||||||
if (cr.z > current.z) cr.z = current.z;
|
if (cr.z > current.z) cr.z = current.z;
|
||||||
|
@ -520,7 +557,8 @@ void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_
|
||||||
cr.w = ImMax(cr.y, cr.w);
|
cr.w = ImMax(cr.y, cr.w);
|
||||||
|
|
||||||
_ClipRectStack.push_back(cr);
|
_ClipRectStack.push_back(cr);
|
||||||
UpdateClipRect();
|
_CmdHeader.ClipRect = cr;
|
||||||
|
_OnChangedClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PushClipRectFullScreen()
|
void ImDrawList::PushClipRectFullScreen()
|
||||||
|
@ -530,22 +568,23 @@ void ImDrawList::PushClipRectFullScreen()
|
||||||
|
|
||||||
void ImDrawList::PopClipRect()
|
void ImDrawList::PopClipRect()
|
||||||
{
|
{
|
||||||
IM_ASSERT(_ClipRectStack.Size > 0);
|
|
||||||
_ClipRectStack.pop_back();
|
_ClipRectStack.pop_back();
|
||||||
UpdateClipRect();
|
_CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1];
|
||||||
|
_OnChangedClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PushTextureID(ImTextureID texture_id)
|
void ImDrawList::PushTextureID(ImTextureID texture_id)
|
||||||
{
|
{
|
||||||
_TextureIdStack.push_back(texture_id);
|
_TextureIdStack.push_back(texture_id);
|
||||||
UpdateTextureID();
|
_CmdHeader.TextureId = texture_id;
|
||||||
|
_OnChangedTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PopTextureID()
|
void ImDrawList::PopTextureID()
|
||||||
{
|
{
|
||||||
IM_ASSERT(_TextureIdStack.Size > 0);
|
|
||||||
_TextureIdStack.pop_back();
|
_TextureIdStack.pop_back();
|
||||||
UpdateTextureID();
|
_CmdHeader.TextureId = (_TextureIdStack.Size == 0) ? (ImTextureID)NULL : _TextureIdStack.Data[_TextureIdStack.Size - 1];
|
||||||
|
_OnChangedTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reserve space for a number of vertices and indices.
|
// Reserve space for a number of vertices and indices.
|
||||||
|
@ -557,13 +596,12 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||||
{
|
{
|
||||||
_VtxCurrentOffset = VtxBuffer.Size;
|
_CmdHeader.VtxOffset = VtxBuffer.Size;
|
||||||
_VtxCurrentIdx = 0;
|
_OnChangedVtxOffset();
|
||||||
AddDrawCmd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
draw_cmd.ElemCount += idx_count;
|
draw_cmd->ElemCount += idx_count;
|
||||||
|
|
||||||
int vtx_buffer_old_size = VtxBuffer.Size;
|
int vtx_buffer_old_size = VtxBuffer.Size;
|
||||||
VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
|
VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
|
||||||
|
@ -579,8 +617,8 @@ void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
||||||
{
|
{
|
||||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
|
|
||||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
draw_cmd.ElemCount -= idx_count;
|
draw_cmd->ElemCount -= idx_count;
|
||||||
VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
|
VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
|
||||||
IdxBuffer.shrink(IdxBuffer.Size - idx_count);
|
IdxBuffer.shrink(IdxBuffer.Size - idx_count);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +668,7 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
|
||||||
_IdxWritePtr += 6;
|
_IdxWritePtr += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
|
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds.
|
||||||
// Those macros expects l-values.
|
// Those macros expects l-values.
|
||||||
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
||||||
#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0)
|
#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0)
|
||||||
|
@ -642,21 +680,20 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
if (points_count < 2)
|
if (points_count < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const ImVec2 uv = _Data->TexUvWhitePixel;
|
const ImVec2 opaque_uv = _Data->TexUvWhitePixel;
|
||||||
|
|
||||||
int count = points_count;
|
int count = points_count;
|
||||||
if (!closed)
|
if (!closed)
|
||||||
count = points_count-1;
|
count = points_count - 1;
|
||||||
|
|
||||||
const bool thick_line = thickness > 1.0f;
|
const bool thick_line = (thickness > 1.0f);
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
{
|
{
|
||||||
// Anti-aliased stroke
|
// Anti-aliased stroke
|
||||||
const float AA_SIZE = 1.0f;
|
const float AA_SIZE = 1.0f;
|
||||||
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
||||||
|
|
||||||
const int idx_count = thick_line ? count*18 : count*12;
|
const int idx_count = thick_line ? count * 18 : count * 12;
|
||||||
const int vtx_count = thick_line ? points_count*4 : points_count*3;
|
const int vtx_count = thick_line ? points_count * 4 : points_count * 3;
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
// Temporary buffer
|
// Temporary buffer
|
||||||
|
@ -665,7 +702,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
|
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
|
||||||
float dx = points[i2].x - points[i1].x;
|
float dx = points[i2].x - points[i1].x;
|
||||||
float dy = points[i2].y - points[i1].y;
|
float dy = points[i2].y - points[i1].y;
|
||||||
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
|
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
|
||||||
|
@ -673,7 +710,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
temp_normals[i1].y = -dx;
|
temp_normals[i1].y = -dx;
|
||||||
}
|
}
|
||||||
if (!closed)
|
if (!closed)
|
||||||
temp_normals[points_count-1] = temp_normals[points_count-2];
|
temp_normals[points_count - 1] = temp_normals[points_count - 2];
|
||||||
|
|
||||||
if (!thick_line)
|
if (!thick_line)
|
||||||
{
|
{
|
||||||
|
@ -689,8 +726,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
unsigned int idx1 = _VtxCurrentIdx;
|
unsigned int idx1 = _VtxCurrentIdx;
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
|
||||||
unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+3;
|
unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : idx1 + 3;
|
||||||
|
|
||||||
// Average normals
|
// Average normals
|
||||||
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
||||||
|
@ -699,8 +736,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
dm_x *= AA_SIZE;
|
dm_x *= AA_SIZE;
|
||||||
dm_y *= AA_SIZE;
|
dm_y *= AA_SIZE;
|
||||||
|
|
||||||
// Add temporary vertexes
|
// Add temporary vertices
|
||||||
ImVec2* out_vtx = &temp_points[i2*2];
|
ImVec2* out_vtx = &temp_points[i2 * 2];
|
||||||
out_vtx[0].x = points[i2].x + dm_x;
|
out_vtx[0].x = points[i2].x + dm_x;
|
||||||
out_vtx[0].y = points[i2].y + dm_y;
|
out_vtx[0].y = points[i2].y + dm_y;
|
||||||
out_vtx[1].x = points[i2].x - dm_x;
|
out_vtx[1].x = points[i2].x - dm_x;
|
||||||
|
@ -716,12 +753,12 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
idx1 = idx2;
|
idx1 = idx2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add vertexes
|
// Add vertices
|
||||||
for (int i = 0; i < points_count; i++)
|
for (int i = 0; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col;
|
||||||
_VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans;
|
_VtxWritePtr[1].pos = temp_points[i*2+0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans;
|
||||||
_VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col_trans;
|
_VtxWritePtr[2].pos = temp_points[i*2+1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans;
|
||||||
_VtxWritePtr += 3;
|
_VtxWritePtr += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,22 +767,23 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
|
const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
|
||||||
if (!closed)
|
if (!closed)
|
||||||
{
|
{
|
||||||
|
const int points_last = points_count - 1;
|
||||||
temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE);
|
temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE);
|
||||||
temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness);
|
temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness);
|
||||||
temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness);
|
temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness);
|
||||||
temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE);
|
temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE);
|
||||||
temp_points[(points_count-1)*4+0] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE);
|
temp_points[points_last * 4 + 0] = points[points_last] + temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
|
||||||
temp_points[(points_count-1)*4+1] = points[points_count-1] + temp_normals[points_count-1] * (half_inner_thickness);
|
temp_points[points_last * 4 + 1] = points[points_last] + temp_normals[points_last] * (half_inner_thickness);
|
||||||
temp_points[(points_count-1)*4+2] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness);
|
temp_points[points_last * 4 + 2] = points[points_last] - temp_normals[points_last] * (half_inner_thickness);
|
||||||
temp_points[(points_count-1)*4+3] = points[points_count-1] - temp_normals[points_count-1] * (half_inner_thickness + AA_SIZE);
|
temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
|
||||||
unsigned int idx1 = _VtxCurrentIdx;
|
unsigned int idx1 = _VtxCurrentIdx;
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment
|
||||||
unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4;
|
const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment
|
||||||
|
|
||||||
// Average normals
|
// Average normals
|
||||||
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
||||||
|
@ -756,8 +794,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
float dm_in_x = dm_x * half_inner_thickness;
|
float dm_in_x = dm_x * half_inner_thickness;
|
||||||
float dm_in_y = dm_y * half_inner_thickness;
|
float dm_in_y = dm_y * half_inner_thickness;
|
||||||
|
|
||||||
// Add temporary vertexes
|
// Add temporary vertices
|
||||||
ImVec2* out_vtx = &temp_points[i2*4];
|
ImVec2* out_vtx = &temp_points[i2 * 4];
|
||||||
out_vtx[0].x = points[i2].x + dm_out_x;
|
out_vtx[0].x = points[i2].x + dm_out_x;
|
||||||
out_vtx[0].y = points[i2].y + dm_out_y;
|
out_vtx[0].y = points[i2].y + dm_out_y;
|
||||||
out_vtx[1].x = points[i2].x + dm_in_x;
|
out_vtx[1].x = points[i2].x + dm_in_x;
|
||||||
|
@ -768,24 +806,24 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
out_vtx[3].y = points[i2].y - dm_out_y;
|
out_vtx[3].y = points[i2].y - dm_out_y;
|
||||||
|
|
||||||
// Add indexes
|
// Add indexes
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(idx2+1); _IdxWritePtr[1] = (ImDrawIdx)(idx1+1); _IdxWritePtr[2] = (ImDrawIdx)(idx1+2);
|
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2);
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(idx1+2); _IdxWritePtr[4] = (ImDrawIdx)(idx2+2); _IdxWritePtr[5] = (ImDrawIdx)(idx2+1);
|
_IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 1);
|
||||||
_IdxWritePtr[6] = (ImDrawIdx)(idx2+1); _IdxWritePtr[7] = (ImDrawIdx)(idx1+1); _IdxWritePtr[8] = (ImDrawIdx)(idx1+0);
|
_IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0);
|
||||||
_IdxWritePtr[9] = (ImDrawIdx)(idx1+0); _IdxWritePtr[10] = (ImDrawIdx)(idx2+0); _IdxWritePtr[11] = (ImDrawIdx)(idx2+1);
|
_IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1);
|
||||||
_IdxWritePtr[12] = (ImDrawIdx)(idx2+2); _IdxWritePtr[13] = (ImDrawIdx)(idx1+2); _IdxWritePtr[14] = (ImDrawIdx)(idx1+3);
|
_IdxWritePtr[12] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[13] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[14] = (ImDrawIdx)(idx1 + 3);
|
||||||
_IdxWritePtr[15] = (ImDrawIdx)(idx1+3); _IdxWritePtr[16] = (ImDrawIdx)(idx2+3); _IdxWritePtr[17] = (ImDrawIdx)(idx2+2);
|
_IdxWritePtr[15] = (ImDrawIdx)(idx1 + 3); _IdxWritePtr[16] = (ImDrawIdx)(idx2 + 3); _IdxWritePtr[17] = (ImDrawIdx)(idx2 + 2);
|
||||||
_IdxWritePtr += 18;
|
_IdxWritePtr += 18;
|
||||||
|
|
||||||
idx1 = idx2;
|
idx1 = idx2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add vertexes
|
// Add vertices
|
||||||
for (int i = 0; i < points_count; i++)
|
for (int i = 0; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_VtxWritePtr[0].pos = temp_points[i*4+0]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col_trans;
|
_VtxWritePtr[0].pos = temp_points[i * 4 + 0]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col_trans;
|
||||||
_VtxWritePtr[1].pos = temp_points[i*4+1]; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
|
_VtxWritePtr[1].pos = temp_points[i * 4 + 1]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col;
|
||||||
_VtxWritePtr[2].pos = temp_points[i*4+2]; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
|
_VtxWritePtr[2].pos = temp_points[i * 4 + 2]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col;
|
||||||
_VtxWritePtr[3].pos = temp_points[i*4+3]; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col_trans;
|
_VtxWritePtr[3].pos = temp_points[i * 4 + 3]; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col_trans;
|
||||||
_VtxWritePtr += 4;
|
_VtxWritePtr += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -794,13 +832,13 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Non Anti-aliased Stroke
|
// Non Anti-aliased Stroke
|
||||||
const int idx_count = count*6;
|
const int idx_count = count * 6;
|
||||||
const int vtx_count = count*4; // FIXME-OPT: Not sharing edges
|
const int vtx_count = count * 4; // FIXME-OPT: Not sharing edges
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
|
||||||
const ImVec2& p1 = points[i1];
|
const ImVec2& p1 = points[i1];
|
||||||
const ImVec2& p2 = points[i2];
|
const ImVec2& p2 = points[i2];
|
||||||
|
|
||||||
|
@ -810,14 +848,14 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||||
dx *= (thickness * 0.5f);
|
dx *= (thickness * 0.5f);
|
||||||
dy *= (thickness * 0.5f);
|
dy *= (thickness * 0.5f);
|
||||||
|
|
||||||
_VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
_VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col;
|
||||||
_VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
|
_VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col;
|
||||||
_VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
|
_VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col;
|
||||||
_VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
|
_VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col;
|
||||||
_VtxWritePtr += 4;
|
_VtxWritePtr += 4;
|
||||||
|
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + 2);
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx + 2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx + 3);
|
||||||
_IdxWritePtr += 6;
|
_IdxWritePtr += 6;
|
||||||
_VtxCurrentIdx += 4;
|
_VtxCurrentIdx += 4;
|
||||||
}
|
}
|
||||||
|
@ -837,22 +875,22 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||||
// Anti-aliased Fill
|
// Anti-aliased Fill
|
||||||
const float AA_SIZE = 1.0f;
|
const float AA_SIZE = 1.0f;
|
||||||
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
||||||
const int idx_count = (points_count-2)*3 + points_count*6;
|
const int idx_count = (points_count - 2)*3 + points_count * 6;
|
||||||
const int vtx_count = (points_count*2);
|
const int vtx_count = (points_count * 2);
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
|
|
||||||
// Add indexes for fill
|
// Add indexes for fill
|
||||||
unsigned int vtx_inner_idx = _VtxCurrentIdx;
|
unsigned int vtx_inner_idx = _VtxCurrentIdx;
|
||||||
unsigned int vtx_outer_idx = _VtxCurrentIdx+1;
|
unsigned int vtx_outer_idx = _VtxCurrentIdx + 1;
|
||||||
for (int i = 2; i < points_count; i++)
|
for (int i = 2; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1));
|
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + ((i - 1) << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (i << 1));
|
||||||
_IdxWritePtr += 3;
|
_IdxWritePtr += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute normals
|
// Compute normals
|
||||||
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630
|
||||||
for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
|
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
||||||
{
|
{
|
||||||
const ImVec2& p0 = points[i0];
|
const ImVec2& p0 = points[i0];
|
||||||
const ImVec2& p1 = points[i1];
|
const ImVec2& p1 = points[i1];
|
||||||
|
@ -863,7 +901,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||||
temp_normals[i0].y = -dx;
|
temp_normals[i0].y = -dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
|
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
||||||
{
|
{
|
||||||
// Average normals
|
// Average normals
|
||||||
const ImVec2& n0 = temp_normals[i0];
|
const ImVec2& n0 = temp_normals[i0];
|
||||||
|
@ -880,8 +918,8 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||||
_VtxWritePtr += 2;
|
_VtxWritePtr += 2;
|
||||||
|
|
||||||
// Add indexes for fringes
|
// Add indexes for fringes
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1));
|
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1));
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1));
|
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1));
|
||||||
_IdxWritePtr += 6;
|
_IdxWritePtr += 6;
|
||||||
}
|
}
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
||||||
|
@ -889,7 +927,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Non Anti-aliased Fill
|
// Non Anti-aliased Fill
|
||||||
const int idx_count = (points_count-2)*3;
|
const int idx_count = (points_count - 2)*3;
|
||||||
const int vtx_count = points_count;
|
const int vtx_count = points_count;
|
||||||
PrimReserve(idx_count, vtx_count);
|
PrimReserve(idx_count, vtx_count);
|
||||||
for (int i = 0; i < vtx_count; i++)
|
for (int i = 0; i < vtx_count; i++)
|
||||||
|
@ -899,7 +937,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
||||||
}
|
}
|
||||||
for (int i = 2; i < points_count; i++)
|
for (int i = 2; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + i - 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + i);
|
||||||
_IdxWritePtr += 3;
|
_IdxWritePtr += 3;
|
||||||
}
|
}
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
||||||
|
@ -966,20 +1004,20 @@ static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, fl
|
||||||
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||||
d2 = (d2 >= 0) ? d2 : -d2;
|
d2 = (d2 >= 0) ? d2 : -d2;
|
||||||
d3 = (d3 >= 0) ? d3 : -d3;
|
d3 = (d3 >= 0) ? d3 : -d3;
|
||||||
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
|
||||||
{
|
{
|
||||||
path->push_back(ImVec2(x4, y4));
|
path->push_back(ImVec2(x4, y4));
|
||||||
}
|
}
|
||||||
else if (level < 10)
|
else if (level < 10)
|
||||||
{
|
{
|
||||||
float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
|
float x12 = (x1 + x2)*0.5f, y12 = (y1 + y2)*0.5f;
|
||||||
float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
|
float x23 = (x2 + x3)*0.5f, y23 = (y2 + y3)*0.5f;
|
||||||
float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
|
float x34 = (x3 + x4)*0.5f, y34 = (y3 + y4)*0.5f;
|
||||||
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
float x123 = (x12 + x23)*0.5f, y123 = (y12 + y23)*0.5f;
|
||||||
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
float x234 = (x23 + x34)*0.5f, y234 = (y23 + y34)*0.5f;
|
||||||
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f;
|
||||||
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
|
||||||
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
PathBezierToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1039,9 +1077,9 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.50f,0.50f), rounding, rounding_corners);
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, rounding_corners);
|
||||||
else
|
else
|
||||||
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.49f, 0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,8 +1107,8 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_ma
|
||||||
|
|
||||||
const ImVec2 uv = _Data->TexUvWhitePixel;
|
const ImVec2 uv = _Data->TexUvWhitePixel;
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2));
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 3));
|
||||||
PrimWriteVtx(p_min, uv, col_upr_left);
|
PrimWriteVtx(p_min, uv, col_upr_left);
|
||||||
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
||||||
PrimWriteVtx(p_max, uv, col_bot_right);
|
PrimWriteVtx(p_max, uv, col_bot_right);
|
||||||
|
@ -1234,9 +1272,9 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||||
if (font_size == 0.0f)
|
if (font_size == 0.0f)
|
||||||
font_size = _Data->FontSize;
|
font_size = _Data->FontSize;
|
||||||
|
|
||||||
IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
IM_ASSERT(font->ContainerAtlas->TexID == _CmdHeader.TextureId); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
|
||||||
|
|
||||||
ImVec4 clip_rect = _ClipRectStack.back();
|
ImVec4 clip_rect = _CmdHeader.ClipRect;
|
||||||
if (cpu_fine_clip_rect)
|
if (cpu_fine_clip_rect)
|
||||||
{
|
{
|
||||||
clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x);
|
clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x);
|
||||||
|
@ -1257,7 +1295,7 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, cons
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
|
const bool push_texture_id = user_texture_id != _CmdHeader.TextureId;
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
|
@ -1273,7 +1311,7 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, con
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
|
const bool push_texture_id = user_texture_id != _CmdHeader.TextureId;
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
|
@ -1356,27 +1394,20 @@ void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
|
||||||
if (_Channels[i]._CmdBuffer.Size == 0)
|
if (_Channels[i]._CmdBuffer.Size == 0)
|
||||||
{
|
{
|
||||||
ImDrawCmd draw_cmd;
|
ImDrawCmd draw_cmd;
|
||||||
draw_cmd.ClipRect = draw_list->_ClipRectStack.back();
|
ImDrawCmd_HeaderCopy(&draw_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
|
||||||
draw_cmd.TextureId = draw_list->_TextureIdStack.back();
|
|
||||||
_Channels[i]._CmdBuffer.push_back(draw_cmd);
|
_Channels[i]._CmdBuffer.push_back(draw_cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool CanMergeDrawCommands(ImDrawCmd* a, ImDrawCmd* b)
|
|
||||||
{
|
|
||||||
return memcmp(&a->ClipRect, &b->ClipRect, sizeof(a->ClipRect)) == 0 && a->TextureId == b->TextureId && a->VtxOffset == b->VtxOffset && !a->UserCallback && !b->UserCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
||||||
{
|
{
|
||||||
// Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
|
// Note that we never use or rely on _Channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
|
||||||
if (_Count <= 1)
|
if (_Count <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetCurrentChannel(draw_list, 0);
|
SetCurrentChannel(draw_list, 0);
|
||||||
if (draw_list->CmdBuffer.Size != 0 && draw_list->CmdBuffer.back().ElemCount == 0)
|
draw_list->_PopUnusedDrawCmd();
|
||||||
draw_list->CmdBuffer.pop_back();
|
|
||||||
|
|
||||||
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
|
||||||
int new_cmd_buffer_count = 0;
|
int new_cmd_buffer_count = 0;
|
||||||
|
@ -1386,15 +1417,22 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
||||||
for (int i = 1; i < _Count; i++)
|
for (int i = 1; i < _Count; i++)
|
||||||
{
|
{
|
||||||
ImDrawChannel& ch = _Channels[i];
|
ImDrawChannel& ch = _Channels[i];
|
||||||
|
|
||||||
|
// Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback.
|
||||||
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0)
|
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0)
|
||||||
ch._CmdBuffer.pop_back();
|
ch._CmdBuffer.pop_back();
|
||||||
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL && CanMergeDrawCommands(last_cmd, &ch._CmdBuffer[0]))
|
|
||||||
|
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
|
||||||
|
{
|
||||||
|
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
|
||||||
|
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
// Merge previous channel last draw command with current channel first draw command if matching.
|
// Merge previous channel last draw command with current channel first draw command if matching.
|
||||||
last_cmd->ElemCount += ch._CmdBuffer[0].ElemCount;
|
last_cmd->ElemCount += next_cmd->ElemCount;
|
||||||
idx_offset += ch._CmdBuffer[0].ElemCount;
|
idx_offset += next_cmd->ElemCount;
|
||||||
ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges.
|
ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ch._CmdBuffer.Size > 0)
|
if (ch._CmdBuffer.Size > 0)
|
||||||
last_cmd = &ch._CmdBuffer.back();
|
last_cmd = &ch._CmdBuffer.back();
|
||||||
new_cmd_buffer_count += ch._CmdBuffer.Size;
|
new_cmd_buffer_count += ch._CmdBuffer.Size;
|
||||||
|
@ -1418,8 +1456,18 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
||||||
if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; }
|
if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; }
|
||||||
}
|
}
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
draw_list->UpdateClipRect(); // We call this instead of AddDrawCmd(), so that empty channels won't produce an extra draw call.
|
|
||||||
draw_list->UpdateTextureID();
|
// Ensure there's always a non-callback draw command trailing the command-buffer
|
||||||
|
if (draw_list->CmdBuffer.Size == 0 || draw_list->CmdBuffer.back().UserCallback != NULL)
|
||||||
|
draw_list->AddDrawCmd();
|
||||||
|
|
||||||
|
// If current command is used with different settings we need to add a new command
|
||||||
|
ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
|
||||||
|
if (curr_cmd->ElemCount == 0)
|
||||||
|
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
|
||||||
|
draw_list->AddDrawCmd();
|
||||||
|
|
||||||
_Count = 1;
|
_Count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1428,6 +1476,7 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||||
IM_ASSERT(idx >= 0 && idx < _Count);
|
IM_ASSERT(idx >= 0 && idx < _Count);
|
||||||
if (_Current == idx)
|
if (_Current == idx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
|
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
|
||||||
memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer));
|
memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer));
|
||||||
memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer));
|
memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer));
|
||||||
|
@ -1435,6 +1484,13 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||||
memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer));
|
memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer));
|
||||||
memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer));
|
memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer));
|
||||||
draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size;
|
draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size;
|
||||||
|
|
||||||
|
// If current command is used with different settings we need to add a new command
|
||||||
|
ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
|
||||||
|
if (curr_cmd->ElemCount == 0)
|
||||||
|
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
|
||||||
|
draw_list->AddDrawCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1558,7 +1614,6 @@ ImFontConfig::ImFontConfig()
|
||||||
// The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
|
// The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
|
||||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
|
const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
|
||||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
||||||
const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
|
|
||||||
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
|
static 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- XX "
|
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
|
||||||
|
@ -1747,15 +1802,15 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
|
||||||
static unsigned int stb_decompress_length(const unsigned char *input);
|
static unsigned int stb_decompress_length(const unsigned char* input);
|
||||||
static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length);
|
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
|
||||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||||
{
|
{
|
||||||
while (*src)
|
while (*src)
|
||||||
{
|
{
|
||||||
unsigned int tmp = Decode85Byte(src[0]) + 85*(Decode85Byte(src[1]) + 85*(Decode85Byte(src[2]) + 85*(Decode85Byte(src[3]) + 85*Decode85Byte(src[4]))));
|
unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4]))));
|
||||||
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
||||||
src += 5;
|
src += 5;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
|
@ -1822,7 +1877,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si
|
||||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||||
{
|
{
|
||||||
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
|
||||||
unsigned char* buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size);
|
unsigned char* buf_decompressed_data = (unsigned char*)IM_ALLOC(buf_decompressed_size);
|
||||||
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||||
|
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
|
@ -1841,14 +1896,11 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
int ImFontAtlas::AddCustomRectRegular(int width, int height)
|
||||||
{
|
{
|
||||||
// Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000)
|
|
||||||
IM_ASSERT(id >= 0x110000);
|
|
||||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||||
ImFontAtlasCustomRect r;
|
ImFontAtlasCustomRect r;
|
||||||
r.ID = id;
|
|
||||||
r.Width = (unsigned short)width;
|
r.Width = (unsigned short)width;
|
||||||
r.Height = (unsigned short)height;
|
r.Height = (unsigned short)height;
|
||||||
CustomRects.push_back(r);
|
CustomRects.push_back(r);
|
||||||
|
@ -1857,13 +1909,16 @@ int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||||
|
|
||||||
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
|
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
|
||||||
{
|
{
|
||||||
|
#ifdef IMGUI_USE_WCHAR32
|
||||||
|
IM_ASSERT(id <= IM_UNICODE_CODEPOINT_MAX);
|
||||||
|
#endif
|
||||||
IM_ASSERT(font != NULL);
|
IM_ASSERT(font != NULL);
|
||||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||||
ImFontAtlasCustomRect r;
|
ImFontAtlasCustomRect r;
|
||||||
r.ID = id;
|
|
||||||
r.Width = (unsigned short)width;
|
r.Width = (unsigned short)width;
|
||||||
r.Height = (unsigned short)height;
|
r.Height = (unsigned short)height;
|
||||||
|
r.GlyphID = id;
|
||||||
r.GlyphAdvanceX = advance_x;
|
r.GlyphAdvanceX = advance_x;
|
||||||
r.GlyphOffset = offset;
|
r.GlyphOffset = offset;
|
||||||
r.Font = font;
|
r.Font = font;
|
||||||
|
@ -1888,7 +1943,6 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
||||||
|
|
||||||
IM_ASSERT(CustomRectIds[0] != -1);
|
IM_ASSERT(CustomRectIds[0] != -1);
|
||||||
ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]];
|
ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]];
|
||||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
|
||||||
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
||||||
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
||||||
*out_size = size;
|
*out_size = size;
|
||||||
|
@ -2110,7 +2164,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||||
if (atlas->TexDesiredWidth > 0)
|
if (atlas->TexDesiredWidth > 0)
|
||||||
atlas->TexWidth = atlas->TexDesiredWidth;
|
atlas->TexWidth = atlas->TexDesiredWidth;
|
||||||
else
|
else
|
||||||
atlas->TexWidth = (surface_sqrt >= 4096*0.7f) ? 4096 : (surface_sqrt >= 2048*0.7f) ? 2048 : (surface_sqrt >= 1024*0.7f) ? 1024 : 512;
|
atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512;
|
||||||
|
|
||||||
// 5. Start packing
|
// 5. Start packing
|
||||||
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
// Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
|
||||||
|
@ -2223,9 +2277,9 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||||
if (atlas->CustomRectIds[0] >= 0)
|
if (atlas->CustomRectIds[0] >= 0)
|
||||||
return;
|
return;
|
||||||
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
||||||
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);
|
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||||
else
|
else
|
||||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
|
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||||
|
@ -2274,7 +2328,6 @@ static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||||
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
||||||
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
||||||
ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
||||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
|
||||||
IM_ASSERT(r.IsPacked());
|
IM_ASSERT(r.IsPacked());
|
||||||
|
|
||||||
const int w = atlas->TexWidth;
|
const int w = atlas->TexWidth;
|
||||||
|
@ -2309,13 +2362,13 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||||
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
||||||
{
|
{
|
||||||
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
|
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
|
||||||
if (r.Font == NULL || r.ID >= 0x110000)
|
if (r.Font == NULL || r.GlyphID == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
||||||
ImVec2 uv0, uv1;
|
ImVec2 uv0, uv1;
|
||||||
atlas->CalcCustomRectUV(&r, &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);
|
r.Font->AddGlyph((ImWchar)r.GlyphID, 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
|
// Build all fonts lookup tables
|
||||||
|
@ -2325,7 +2378,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||||
|
|
||||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||||
// FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots.
|
// FIXME: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||||
for (int i = 0; i < atlas->Fonts.size(); i++)
|
for (int i = 0; i < atlas->Fonts.size(); i++)
|
||||||
{
|
{
|
||||||
ImFont* font = atlas->Fonts[i];
|
ImFont* font = atlas->Fonts[i];
|
||||||
|
@ -2358,7 +2411,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesKorean()
|
||||||
{
|
{
|
||||||
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
0x0020, 0x00FF, // Basic Latin + Latin Supplement
|
||||||
0x3131, 0x3163, // Korean alphabets
|
0x3131, 0x3163, // Korean alphabets
|
||||||
0xAC00, 0xD79D, // Korean characters
|
0xAC00, 0xD7A3, // Korean characters
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
return &ranges[0];
|
return &ranges[0];
|
||||||
|
@ -2674,7 +2727,7 @@ void ImFont::BuildLookupTable()
|
||||||
tab_glyph.Codepoint = '\t';
|
tab_glyph.Codepoint = '\t';
|
||||||
tab_glyph.AdvanceX *= IM_TABSIZE;
|
tab_glyph.AdvanceX *= IM_TABSIZE;
|
||||||
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
|
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
|
||||||
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
|
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
|
// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
|
||||||
|
@ -2865,7 +2918,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow wrapping after punctuation.
|
// Allow wrapping after punctuation.
|
||||||
inside_word = !(c == '.' || c == ',' || c == ';' || c == '!' || c == '?' || c == '\"');
|
inside_word = (c != '.' && c != ',' && c != ';' && c != '!' && c != '?' && c != '\"');
|
||||||
}
|
}
|
||||||
|
|
||||||
// We ignore blank width at the end of the line (they can be skipped)
|
// We ignore blank width at the end of the line (they can be skipped)
|
||||||
|
@ -2891,7 +2944,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||||
const float line_height = size;
|
const float line_height = size;
|
||||||
const float scale = size / FontSize;
|
const float scale = size / FontSize;
|
||||||
|
|
||||||
ImVec2 text_size = ImVec2(0,0);
|
ImVec2 text_size = ImVec2(0, 0);
|
||||||
float line_width = 0.0f;
|
float line_width = 0.0f;
|
||||||
|
|
||||||
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
||||||
|
@ -3169,7 +3222,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||||
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
|
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
|
||||||
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
|
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
|
||||||
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
|
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
|
||||||
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
|
||||||
draw_list->_VtxWritePtr = vtx_write;
|
draw_list->_VtxWritePtr = vtx_write;
|
||||||
draw_list->_IdxWritePtr = idx_write;
|
draw_list->_IdxWritePtr = idx_write;
|
||||||
draw_list->_VtxCurrentIdx = vtx_current_idx;
|
draw_list->_VtxCurrentIdx = vtx_current_idx;
|
||||||
|
@ -3255,10 +3308,10 @@ void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, Im
|
||||||
pos -= offset;
|
pos -= offset;
|
||||||
const ImTextureID tex_id = font_atlas->TexID;
|
const ImTextureID tex_id = font_atlas->TexID;
|
||||||
draw_list->PushTextureID(tex_id);
|
draw_list->PushTextureID(tex_id);
|
||||||
draw_list->AddImage(tex_id, pos + ImVec2(1,0)*scale, pos + ImVec2(1,0)*scale + size*scale, uv[2], uv[3], col_shadow);
|
draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||||
draw_list->AddImage(tex_id, pos + ImVec2(2,0)*scale, pos + ImVec2(2,0)*scale + size*scale, uv[2], uv[3], col_shadow);
|
draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||||
draw_list->AddImage(tex_id, pos, pos + size*scale, uv[2], uv[3], col_border);
|
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
|
||||||
draw_list->AddImage(tex_id, pos, pos + size*scale, uv[0], uv[1], col_fill);
|
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
|
||||||
draw_list->PopTextureID();
|
draw_list->PopTextureID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3347,7 +3400,7 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
||||||
|
|
||||||
// Helper for ColorPicker4()
|
// Helper for ColorPicker4()
|
||||||
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
||||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether.
|
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
||||||
// FIXME: uses ImGui::GetColorU32
|
// FIXME: uses ImGui::GetColorU32
|
||||||
void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
|
void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
|
||||||
{
|
{
|
||||||
|
@ -3513,7 +3566,7 @@ static unsigned int stb_decompress(unsigned char *output, const unsigned char *i
|
||||||
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding).
|
||||||
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static const char proggy_clean_ttf_compressed_data_base85[11980+1] =
|
static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] =
|
||||||
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
"7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
|
||||||
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
"2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
|
||||||
"`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
|
"`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
|
||||||
|
|
|
@ -68,7 +68,7 @@ enum GlfwClientApi
|
||||||
static GLFWwindow* g_Window = NULL; // Main window
|
static GLFWwindow* g_Window = NULL; // Main window
|
||||||
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
|
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
|
||||||
static double g_Time = 0.0;
|
static double g_Time = 0.0;
|
||||||
static bool g_MouseJustPressed[5] = { false, false, false, false, false };
|
static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
|
||||||
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||||
static bool g_InstalledCallbacks = false;
|
static bool g_InstalledCallbacks = false;
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void ImGui_ImplGlfw_NewFrame()
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
|
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
|
// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
||||||
|
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||||
|
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||||
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
||||||
|
@ -76,27 +79,7 @@
|
||||||
#else
|
#else
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
#endif
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include "TargetConditionals.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Auto-enable GLES on matching platforms
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
|
||||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
|
||||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
|
||||||
#elif defined(__EMSCRIPTEN__)
|
|
||||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3)
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
|
||||||
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// GL includes
|
// GL includes
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
@ -119,12 +102,16 @@
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||||
|
#ifndef GLFW_INCLUDE_NONE
|
||||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
|
#endif
|
||||||
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
||||||
#include <glbinding/gl/gl.h>
|
#include <glbinding/gl/gl.h>
|
||||||
using namespace gl;
|
using namespace gl;
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||||
|
#ifndef GLFW_INCLUDE_NONE
|
||||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||||
|
#endif
|
||||||
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
||||||
#include <glbinding/gl/gl.h>
|
#include <glbinding/gl/gl.h>
|
||||||
using namespace gl;
|
using namespace gl;
|
||||||
|
@ -141,32 +128,32 @@ using namespace gl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// OpenGL Data
|
// OpenGL Data
|
||||||
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries.
|
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
||||||
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
||||||
static GLuint g_FontTexture = 0;
|
static GLuint g_FontTexture = 0;
|
||||||
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||||
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
||||||
static int g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
|
static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
|
||||||
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
{
|
{
|
||||||
// Query for GL version
|
// Query for GL version (e.g. 320 for GL 3.2)
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
GLint major, minor;
|
GLint major, minor;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
g_GlVersion = major * 1000 + minor;
|
g_GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||||
#else
|
#else
|
||||||
g_GlVersion = 2000; // GLES 2
|
g_GlVersion = 200; // GLES 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Setup back-end capabilities flags
|
// Setup back-end capabilities flags
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (g_GlVersion >= 3200)
|
if (g_GlVersion >= 320)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -178,6 +165,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
if (glsl_version == NULL)
|
if (glsl_version == NULL)
|
||||||
glsl_version = "#version 300 es";
|
glsl_version = "#version 300 es";
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
if (glsl_version == NULL)
|
||||||
|
glsl_version = "#version 150";
|
||||||
#else
|
#else
|
||||||
if (glsl_version == NULL)
|
if (glsl_version == NULL)
|
||||||
glsl_version = "#version 130";
|
glsl_version = "#version 130";
|
||||||
|
@ -242,6 +232,14 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||||
|
bool clip_origin_lower_left = true;
|
||||||
|
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||||
|
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
|
||||||
|
if (current_clip_origin == GL_UPPER_LEFT)
|
||||||
|
clip_origin_lower_left = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||||
|
@ -249,6 +247,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
||||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||||
float T = draw_data->DisplayPos.y;
|
float T = draw_data->DisplayPos.y;
|
||||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||||
|
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||||
const float ortho_projection[4][4] =
|
const float ortho_projection[4][4] =
|
||||||
{
|
{
|
||||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||||
|
@ -293,14 +292,14 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
// Backup GL state
|
// Backup GL state
|
||||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||||
#ifdef GL_SAMPLER_BINDING
|
#ifdef GL_SAMPLER_BINDING
|
||||||
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
|
||||||
#endif
|
#endif
|
||||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
GLint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array_object);
|
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||||
#endif
|
#endif
|
||||||
#ifdef GL_POLYGON_MODE
|
#ifdef GL_POLYGON_MODE
|
||||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||||
|
@ -317,12 +316,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||||
bool clip_origin_lower_left = true;
|
|
||||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
|
||||||
GLenum last_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&last_clip_origin); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
|
|
||||||
if (last_clip_origin == GL_UPPER_LEFT)
|
|
||||||
clip_origin_lower_left = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Setup desired GL state
|
// Setup desired GL state
|
||||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||||
|
@ -343,8 +336,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
|
|
||||||
// Upload vertex/index buffers
|
// Upload vertex/index buffers
|
||||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
|
||||||
|
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
|
@ -370,15 +363,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||||
{
|
{
|
||||||
// Apply scissor/clipping rectangle
|
// Apply scissor/clipping rectangle
|
||||||
if (clip_origin_lower_left)
|
|
||||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||||
else
|
|
||||||
glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
if (g_GlVersion >= 3200)
|
if (g_GlVersion >= 320)
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -653,9 +643,9 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||||
|
|
||||||
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
|
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
|
||||||
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
|
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
|
||||||
g_AttribLocationVtxPos = glGetAttribLocation(g_ShaderHandle, "Position");
|
g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
|
||||||
g_AttribLocationVtxUV = glGetAttribLocation(g_ShaderHandle, "UV");
|
g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
|
||||||
g_AttribLocationVtxColor = glGetAttribLocation(g_ShaderHandle, "Color");
|
g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
|
||||||
|
|
||||||
// Create buffers
|
// Create buffers
|
||||||
glGenBuffers(1, &g_VboHandle);
|
glGenBuffers(1, &g_VboHandle);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// https://github.com/ocornut/imgui
|
// https://github.com/ocornut/imgui
|
||||||
|
|
||||||
// About Desktop OpenGL function loaders:
|
// About Desktop OpenGL function loaders:
|
||||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "imgui.h" // IMGUI_IMPL_API
|
||||||
|
|
||||||
// Backend API
|
// Backend API
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
|
||||||
|
@ -35,36 +36,49 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
|
||||||
// Specific OpenGL versions
|
// Specific OpenGL ES versions
|
||||||
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||||
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||||
|
|
||||||
// Desktop OpenGL: attempt to detect default GL loader based on available header files.
|
// Attempt to auto-detect the default Desktop GL loader based on available header files.
|
||||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||||
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
|
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
|
||||||
// You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
|
||||||
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||||
#if defined(__has_include)
|
|
||||||
#if __has_include(<GL/glew.h>)
|
// Try to detect GLES on matching platforms
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
#endif
|
||||||
|
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||||
|
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||||
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||||
|
|
||||||
|
// Otherwise try to detect supported Desktop OpenGL loaders..
|
||||||
|
#elif defined(__has_include)
|
||||||
|
#if __has_include(<GL/glew.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||||
#elif __has_include(<glad/glad.h>)
|
#elif __has_include(<glad/glad.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||||
#elif __has_include(<GL/gl3w.h>)
|
#elif __has_include(<GL/gl3w.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||||
#elif __has_include(<glbinding/glbinding.h>)
|
#elif __has_include(<glbinding/glbinding.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
||||||
#elif __has_include(<glbinding/Binding.h>)
|
#elif __has_include(<glbinding/Binding.h>)
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
||||||
#else
|
#else
|
||||||
#error "Cannot detect OpenGL loader!"
|
#error "Cannot detect OpenGL loader!"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W
|
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue