|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
// ImGui library
|
|
|
|
|
// ImGui library v1.12
|
|
|
|
|
// See .cpp file for commentary.
|
|
|
|
|
// See ImGui::ShowTestWindow() for sample code.
|
|
|
|
|
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
|
|
|
|
@ -19,18 +19,6 @@ struct ImGuiWindow;
|
|
|
|
|
#include <stdarg.h> // va_list
|
|
|
|
|
#include <stdlib.h> // NULL, malloc
|
|
|
|
|
|
|
|
|
|
#ifndef IM_MALLOC
|
|
|
|
|
#define IM_MALLOC(_SIZE) malloc((_SIZE))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef IM_FREE
|
|
|
|
|
#define IM_FREE(_PTR) free((_PTR))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef IM_REALLOC
|
|
|
|
|
#define IM_REALLOC(_PTR, _SIZE) realloc((_PTR), (_SIZE))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef IM_ASSERT
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
|
|
|
@ -67,8 +55,17 @@ struct ImVec4
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace ImGui
|
|
|
|
|
{
|
|
|
|
|
// Proxy functions to access the MemAllocFn/MemFreeFn/MemReallocFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
|
|
|
|
|
void* MemAlloc(size_t sz);
|
|
|
|
|
void MemFree(void* ptr);
|
|
|
|
|
void* MemRealloc(void* ptr, size_t sz);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
|
|
|
|
// this implementation does NOT call c++ constructors! we don't need them! also only provide the minimum functionalities we need.
|
|
|
|
|
// Use '#define ImVector std::vector' if you want to use the STL type or your own type.
|
|
|
|
|
// Our implementation does NOT call c++ constructors! because the data types we use don't need them (but that could be added as well). Only provide the minimum functionalities we need.
|
|
|
|
|
#ifndef ImVector
|
|
|
|
|
template<typename T>
|
|
|
|
|
class ImVector
|
|
|
|
@ -84,7 +81,7 @@ public:
|
|
|
|
|
typedef const value_type* const_iterator;
|
|
|
|
|
|
|
|
|
|
ImVector() { Size = Capacity = 0; Data = NULL; }
|
|
|
|
|
~ImVector() { if (Data) IM_FREE(Data); }
|
|
|
|
|
~ImVector() { if (Data) ImGui::MemFree(Data); }
|
|
|
|
|
|
|
|
|
|
inline bool empty() const { return Size == 0; }
|
|
|
|
|
inline size_t size() const { return Size; }
|
|
|
|
@ -95,7 +92,7 @@ public:
|
|
|
|
|
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
|
|
|
|
|
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
|
|
|
|
|
|
|
|
|
|
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
|
|
|
|
|
inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
|
|
|
|
|
inline iterator begin() { return Data; }
|
|
|
|
|
inline const_iterator begin() const { return Data; }
|
|
|
|
|
inline iterator end() { return Data + Size; }
|
|
|
|
@ -106,14 +103,14 @@ public:
|
|
|
|
|
inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); }
|
|
|
|
|
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
|
|
|
|
|
|
|
|
|
|
inline void reserve(size_t new_capacity) { Data = (value_type*)IM_REALLOC(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
|
|
|
|
|
inline void reserve(size_t new_capacity) { Data = (value_type*)ImGui::MemRealloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
|
|
|
|
|
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
|
|
|
|
|
|
|
|
|
|
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
|
|
|
|
|
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
|
|
|
|
|
|
|
|
|
|
inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const int off = it - begin(); memmove(Data + off, Data + off + 1, (Size - off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
|
|
|
|
inline void insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const int off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - off) * sizeof(value_type)); Data[off] = v; Size++; }
|
|
|
|
|
inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const ptrdiff_t off = it - begin(); memmove(Data + off, Data + off + 1, (Size - off - 1) * sizeof(value_type)); Size--; return Data + off; }
|
|
|
|
|
inline void insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const ptrdiff_t off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - off) * sizeof(value_type)); Data[off] = v; Size++; }
|
|
|
|
|
};
|
|
|
|
|
#endif // #ifndef ImVector
|
|
|
|
|
|
|
|
|
@ -145,16 +142,16 @@ namespace ImGui
|
|
|
|
|
void BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);
|
|
|
|
|
void EndChild();
|
|
|
|
|
bool GetWindowIsFocused();
|
|
|
|
|
float GetWindowWidth();
|
|
|
|
|
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
|
|
|
|
|
void SetWindowPos(const ImVec2& pos); // set current window pos
|
|
|
|
|
ImVec2 GetWindowSize();
|
|
|
|
|
float GetWindowWidth();
|
|
|
|
|
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
|
|
|
|
|
void SetWindowPos(const ImVec2& pos); // set current window pos.
|
|
|
|
|
ImVec2 GetWindowContentRegionMin();
|
|
|
|
|
ImVec2 GetWindowContentRegionMax();
|
|
|
|
|
ImDrawList* GetWindowDrawList();
|
|
|
|
|
void SetFontScale(float scale);
|
|
|
|
|
void SetScrollPosHere();
|
|
|
|
|
void SetTreeStateStorage(ImGuiStorage* tree);
|
|
|
|
|
ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
|
|
|
|
|
void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontBaseScale if you want to scale all windows together.
|
|
|
|
|
void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
|
|
|
|
|
void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
|
|
|
|
|
ImGuiStorage* GetTreeStateStorage();
|
|
|
|
|
void PushItemWidth(float item_width);
|
|
|
|
|
void PopItemWidth();
|
|
|
|
@ -166,7 +163,8 @@ namespace ImGui
|
|
|
|
|
|
|
|
|
|
// Tooltip
|
|
|
|
|
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
|
|
|
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
|
|
|
|
void SetTooltipV(const char* fmt, va_list args);
|
|
|
|
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
|
|
|
|
void EndTooltip();
|
|
|
|
|
|
|
|
|
|
// Layout
|
|
|
|
@ -178,12 +176,12 @@ namespace ImGui
|
|
|
|
|
float GetColumnOffset(int column_index = -1);
|
|
|
|
|
void SetColumnOffset(int column_index, float offset);
|
|
|
|
|
float GetColumnWidth(int column_index = -1);
|
|
|
|
|
ImVec2 GetCursorPos(); // cursor position relative to window position
|
|
|
|
|
ImVec2 GetCursorPos(); // cursor position is relative to window position
|
|
|
|
|
void SetCursorPos(const ImVec2& pos); // "
|
|
|
|
|
void SetCursorPosX(float x); // "
|
|
|
|
|
void SetCursorPosY(float y); // "
|
|
|
|
|
ImVec2 GetCursorScreenPos(); // cursor position in screen space
|
|
|
|
|
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
|
|
|
|
|
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
|
|
|
|
|
float GetTextLineSpacing();
|
|
|
|
|
float GetTextLineHeight();
|
|
|
|
|
|
|
|
|
@ -197,16 +195,19 @@ namespace ImGui
|
|
|
|
|
void Text(const char* fmt, ...);
|
|
|
|
|
void TextV(const char* fmt, va_list args);
|
|
|
|
|
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
|
|
|
|
void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
|
|
|
|
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
|
|
|
|
void LabelText(const char* label, const char* fmt, ...);
|
|
|
|
|
void LabelTextV(const char* label, const char* fmt, va_list args);
|
|
|
|
|
void BulletText(const char* fmt, ...);
|
|
|
|
|
void BulletTextV(const char* fmt, va_list args);
|
|
|
|
|
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
|
|
|
|
|
bool SmallButton(const char* label);
|
|
|
|
|
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
|
|
|
|
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
|
|
|
|
|
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
|
|
|
|
|
bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
|
|
|
|
|
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
|
|
|
|
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
|
|
|
@ -215,12 +216,12 @@ namespace ImGui
|
|
|
|
|
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
|
|
|
|
bool RadioButton(const char* label, bool active);
|
|
|
|
|
bool RadioButton(const char* label, int* v, int v_button);
|
|
|
|
|
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
|
|
|
|
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
|
|
|
|
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
|
|
|
|
|
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
|
|
|
|
|
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
|
|
|
|
|
bool InputFloat4(const char* label, float v[4], int decimal_precision = -1);
|
|
|
|
|
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100);
|
|
|
|
|
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
|
|
|
|
|
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
|
|
|
|
|
bool Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
|
|
|
|
|
bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7); // Separate items with \0, end item-list with \0\0
|
|
|
|
|
bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_height_items = 7);
|
|
|
|
@ -228,10 +229,12 @@ namespace ImGui
|
|
|
|
|
bool ColorEdit3(const char* label, float col[3]);
|
|
|
|
|
bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
|
|
|
|
|
void ColorEditMode(ImGuiColorEditMode mode);
|
|
|
|
|
bool TreeNode(const char* str_label_id); // if returning 'true' the user is responsible for calling TreePop
|
|
|
|
|
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
|
|
|
|
bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
|
|
|
|
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
|
|
|
|
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layout purpose
|
|
|
|
|
bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
|
|
|
|
bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
|
|
|
|
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
|
|
|
|
void TreePush(const void* ptr_id = NULL); // "
|
|
|
|
|
void TreePop();
|
|
|
|
|
void OpenNextNode(bool open); // force open/close the next TreeNode or CollapsingHeader
|
|
|
|
@ -260,8 +263,11 @@ namespace ImGui
|
|
|
|
|
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
|
|
|
|
bool IsMouseClicked(int button, bool repeat = false);
|
|
|
|
|
bool IsMouseDoubleClicked(int button);
|
|
|
|
|
bool IsMouseHoveringBox(const ImVec2& box_min, const ImVec2& box_max);
|
|
|
|
|
ImVec2 GetMousePos();
|
|
|
|
|
bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window)
|
|
|
|
|
bool IsMouseHoveringAnyWindow(); // is mouse hovering any active imgui window
|
|
|
|
|
bool IsMouseHoveringBox(const ImVec2& box_min, const ImVec2& box_max); // is mouse hovering given bounding box
|
|
|
|
|
bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
|
|
|
|
|
ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
|
|
|
|
float GetTime();
|
|
|
|
|
int GetFrameCount();
|
|
|
|
|
const char* GetStyleColorName(ImGuiCol idx);
|
|
|
|
@ -290,10 +296,11 @@ enum ImGuiWindowFlags_
|
|
|
|
|
enum ImGuiInputTextFlags_
|
|
|
|
|
{
|
|
|
|
|
// Default: 0
|
|
|
|
|
ImGuiInputTextFlags_CharsDecimal = 1 << 0,
|
|
|
|
|
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1,
|
|
|
|
|
ImGuiInputTextFlags_AutoSelectAll = 1 << 2,
|
|
|
|
|
ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
|
|
|
|
ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
|
|
|
|
|
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
|
|
|
|
|
ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus
|
|
|
|
|
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
|
|
|
|
|
//ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
|
|
|
@ -405,7 +412,8 @@ struct ImGuiIO
|
|
|
|
|
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
|
|
|
|
float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
|
|
|
|
|
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
|
|
|
|
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
|
|
|
|
float FontBaseScale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
|
|
|
|
|
bool FontAllowUserScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
|
|
|
|
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
|
|
|
|
|
|
|
|
|
// Settings - Rendering function (REQUIRED)
|
|
|
|
@ -418,6 +426,12 @@ struct ImGuiIO
|
|
|
|
|
// NB- for SetClipboardTextFn, the string is *NOT* zero-terminated at 'text_end'
|
|
|
|
|
const char* (*GetClipboardTextFn)();
|
|
|
|
|
void (*SetClipboardTextFn)(const char* text, const char* text_end);
|
|
|
|
|
|
|
|
|
|
// Settings - Memory allocation
|
|
|
|
|
// Default to posix malloc/realloc/free functions.
|
|
|
|
|
void* (*MemAllocFn)(size_t sz);
|
|
|
|
|
void* (*MemReallocFn)(void* ptr, size_t sz);
|
|
|
|
|
void (*MemFreeFn)(void* ptr);
|
|
|
|
|
|
|
|
|
|
// Input - Fill before calling NewFrame()
|
|
|
|
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
|
|
|
@ -429,8 +443,8 @@ struct ImGuiIO
|
|
|
|
|
char InputCharacters[16]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
|
|
|
|
|
|
|
|
|
// Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
|
|
|
|
|
bool WantCaptureMouse; // ImGui is using your mouse input (= window is being hovered or widget is active).
|
|
|
|
|
bool WantCaptureKeyboard; // imGui is using your keyboard input (= widget is active).
|
|
|
|
|
bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
|
|
|
|
|
bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
|
|
|
|
|
|
|
|
|
|
// Function
|
|
|
|
|
void AddInputCharacter(char c); // Helper to add a new character into InputCharacters[]
|
|
|
|
@ -467,9 +481,9 @@ private:
|
|
|
|
|
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
|
|
|
|
struct ImGuiTextFilter
|
|
|
|
|
{
|
|
|
|
|
struct TextRange
|
|
|
|
|
{
|
|
|
|
|
const char* b;
|
|
|
|
|
struct TextRange
|
|
|
|
|
{
|
|
|
|
|
const char* b;
|
|
|
|
|
const char* e;
|
|
|
|
|
|
|
|
|
|
TextRange() { b = e = NULL; }
|
|
|
|
@ -478,7 +492,7 @@ struct ImGuiTextFilter
|
|
|
|
|
const char* end() const { return e; }
|
|
|
|
|
bool empty() const { return b == e; }
|
|
|
|
|
char front() const { return *b; }
|
|
|
|
|
static bool isblank(char c) { return c == ' ' || c == '\t'; }
|
|
|
|
|
static bool isblank(char c) { return c == ' ' || c == '\t'; }
|
|
|
|
|
void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e-1))) e--; }
|
|
|
|
|
void split(char separator, ImVector<TextRange>& out);
|
|
|
|
|
};
|
|
|
|
|